/**
 * Graph Memory Engine — Core CRUD
 *
 * Provides entity, relation, and fact version management on top of SQLite.
 * Implements IMemoryStore for backward compatibility with MemoryEngine.
 *
 * Phase: 8D (Graph Knowledge Engine)
 * Constraint: < 500 LOC — traversal logic is in graph-traversal.ts
 */
import Database from 'better-sqlite3';
export interface Entity {
    id: string;
    name: string;
    type: string;
    properties: Record<string, unknown>;
    createdAt: number;
    updatedAt: number;
}
export interface Relation {
    id: string;
    fromEntity: string;
    toEntity: string;
    type: string;
    weight: number;
    validFrom: number;
    validUntil: number | null;
}
export interface FactVersion {
    id: string;
    entityId: string;
    content: string;
    version: number;
    validFrom: number;
    validUntil: number | null;
    supersededBy: string | null;
}
/** IMemoryStore — backward compatibility interface */
export interface IMemoryStore {
    store(content: string, priority: number, tags: string[]): string;
    recall(query: string, k: number): Promise<string[]>;
    getStats(): {
        prefrontal: number;
        hippocampus: number;
        cortex: number;
        totalLinks: number;
        oldestEntry: number | null;
        topTags: string[];
    };
}
export declare class GraphMemoryEngine implements IMemoryStore {
    private db;
    private extractor;
    private ngramIndex;
    constructor(dbPath?: string);
    private initSchema;
    private inlineSchema;
    /** Create or update an entity */
    upsertEntity(name: string, type: string, properties?: Record<string, unknown>): Entity;
    /** Get entity by ID */
    getEntity(id: string): Entity | null;
    /** Find entities by name (partial match) */
    findEntities(query: string, limit?: number): Entity[];
    /** Find entities by type */
    findByType(type: string, limit?: number): Entity[];
    /** Delete entity (cascades to relations and facts) */
    deleteEntity(id: string): boolean;
    /** Create a relation between two entities */
    addRelation(fromEntityId: string, toEntityId: string, type: string, weight?: number): Relation;
    /** Get relations for an entity (outgoing) */
    getRelationsFrom(entityId: string): Relation[];
    /** Get relations to an entity (incoming) */
    getRelationsTo(entityId: string): Relation[];
    /** Expire a relation (soft delete) */
    expireRelation(id: string): void;
    /** Add a new fact version for an entity */
    addFact(entityId: string, content: string): FactVersion;
    /** Get current fact for an entity */
    getCurrentFact(entityId: string): FactVersion | null;
    /** Get fact history for an entity */
    getFactHistory(entityId: string): FactVersion[];
    /** Extract entities and relations from text and ingest them */
    ingestFromText(text: string, tags?: string[]): {
        entities: Entity[];
        relations: Relation[];
    };
    /** Store: creates entity + fact, extracts sub-entities */
    store(content: string, priority?: number, tags?: string[]): string;
    /** Recall: search entities + facts by keyword */
    recall(query: string, k?: number): Promise<string[]>;
    /** Get stats compatible with MemoryEngine.getStats() */
    getStats(): {
        prefrontal: number;
        hippocampus: number;
        cortex: number;
        totalLinks: number;
        oldestEntry: number | null;
        topTags: string[];
    };
    /** Get graph-specific statistics */
    getGraphStats(): {
        entities: number;
        relations: number;
        facts: number;
        types: Record<string, number>;
    };
    /** Get the underlying database (for graph-traversal.ts) */
    getDb(): Database.Database;
    /**
     * Temporal query: return facts/relations that were valid at a given point in time.
     * Answers "what was true about <query> at timestamp <atMs>?"
     *
     * @param query  Keyword search string
     * @param atMs   Unix timestamp (ms) to evaluate the knowledge graph at. Defaults to now.
     * @param k      Max results to return (default 10)
     */
    temporalQuery(query: string, atMs?: number, k?: number): Array<{
        content: string;
        entityName: string;
        validFrom: number;
        validUntil: number | null;
    }>;
    /** Flush / close database */
    close(): void;
    private rowToEntity;
    private rowToRelation;
    private rowToFact;
}
