/**
 * MemoryStore — project memory substrate.
 *
 * Durable, provenance-rich memory for decisions, constraints, incidents, and
 * patterns. Backed by SQLite via SQLiteStore. Survives process restarts and is
 * queryable by runtime/panel/context enrichment consumers.
 *
 * Provenance links can reference: session, turn, task, event, or file.
 */
import { type MemoryVectorStats } from './memory-vector-store.js';
import { MemoryEmbeddingProviderRegistry, type MemoryEmbeddingDoctorReport } from './memory-embeddings.js';
export type MemoryClass = 'decision' | 'constraint' | 'incident' | 'pattern' | 'fact' | 'risk' | 'runbook' | 'architecture' | 'ownership';
export type MemoryScope = 'session' | 'project' | 'team';
export type MemoryReviewState = 'fresh' | 'reviewed' | 'stale' | 'contradicted';
export type ProvenanceLinkKind = 'session' | 'turn' | 'task' | 'event' | 'file';
export interface ProvenanceLink {
    kind: ProvenanceLinkKind;
    /** The referenced identifier (session ID, turn number, task ID, event ID, or file path). */
    ref: string;
    /** Optional human-readable label. */
    label?: string;
}
export interface MemoryRecord {
    /** Auto-assigned, unique within the store. */
    id: string;
    /** Scope of the record for retrieval and sharing workflows. */
    scope: MemoryScope;
    /** Memory class — governs retrieval priority and display grouping. */
    cls: MemoryClass;
    /** Brief summary (one sentence). */
    summary: string;
    /** Optional expanded detail. */
    detail?: string;
    /** Tags for search and grouping. */
    tags: string[];
    /** Provenance links back to the source context. */
    provenance: ProvenanceLink[];
    /** Operator/state review signal. */
    reviewState: MemoryReviewState;
    /** Confidence score from 0-100. Higher means the record is more trusted for retrieval. */
    confidence: number;
    /** Last explicit review timestamp, if any. */
    reviewedAt?: number;
    /** Reviewer identity, if recorded. */
    reviewedBy?: string;
    /** If stale/contradicted, why. */
    staleReason?: string;
    /** Creation timestamp (epoch ms). */
    createdAt: number;
    /** Last updated timestamp (epoch ms). */
    updatedAt: number;
}
export interface MemoryLink {
    /** ID of the source record. */
    fromId: string;
    /** ID of the target record. */
    toId: string;
    /** Human-readable relationship label, e.g. "caused", "supersedes". */
    relation: string;
    /** Creation timestamp (epoch ms). */
    createdAt: number;
}
export interface MemorySearchFilter {
    scope?: MemoryScope;
    cls?: MemoryClass;
    tags?: string[];
    /** Full-text substring match on summary and detail. */
    query?: string;
    /** Use the sqlite-vec semantic index for query ranking when available. */
    semantic?: boolean;
    /** Return records created after this timestamp. */
    since?: number;
    /** Match a specific review state or a small set of states. */
    reviewState?: MemoryReviewState | MemoryReviewState[];
    /** Minimum confidence threshold, 0-100. */
    minConfidence?: number;
    /** Restrict to records with at least one matching provenance kind. */
    provenanceKinds?: ProvenanceLinkKind[];
    /** Convenience flag for review queue retrieval. */
    staleOnly?: boolean;
    limit?: number;
}
export interface MemoryAddOptions {
    scope?: MemoryScope;
    cls: MemoryClass;
    summary: string;
    detail?: string;
    tags?: string[];
    provenance?: ProvenanceLink[];
    review?: {
        state?: MemoryReviewState;
        confidence?: number;
        reviewedAt?: number;
        reviewedBy?: string;
        staleReason?: string;
    };
}
export interface MemoryReviewPatch {
    state?: MemoryReviewState;
    confidence?: number;
    reviewedBy?: string;
    staleReason?: string;
}
export interface MemoryBundle {
    schemaVersion: 'v1';
    exportedAt: number;
    scope: MemoryScope | 'all';
    recordCount: number;
    linkCount: number;
    records: MemoryRecord[];
    links: MemoryLink[];
}
export interface MemoryImportResult {
    importedRecords: number;
    skippedRecords: number;
    importedLinks: number;
}
export interface MemorySemanticSearchResult {
    record: MemoryRecord;
    distance: number;
    similarity: number;
    score: number;
}
export interface MemoryStoreOptions {
    embeddingRegistry: MemoryEmbeddingProviderRegistry;
    enableVectorIndex?: boolean;
    vectorDbPath?: string;
}
export interface MemoryDoctorReport {
    readonly vector: MemoryVectorStats;
    readonly embeddings: MemoryEmbeddingDoctorReport;
    readonly checkedAt: number;
}
export { MemoryRegistry } from './memory-registry.js';
export declare class MemoryStore {
    private sqlite;
    private vectorIndex;
    private ready;
    private rebuildVectorIndexPromise;
    private readonly embeddingRegistry;
    constructor(dbPath: string | undefined, options: MemoryStoreOptions);
    init(): Promise<void>;
    get isReady(): boolean;
    /** Add a new memory record. Returns the created record. */
    add(opts: MemoryAddOptions): Promise<MemoryRecord>;
    /** Retrieve a single record by ID. */
    get(id: string): MemoryRecord | null;
    /** Search records with an optional filter. */
    search(filter?: MemorySearchFilter): MemoryRecord[];
    searchSemantic(filter?: MemorySearchFilter): MemorySemanticSearchResult[];
    reviewQueue(limit?: number): MemoryRecord[];
    exportBundle(filter?: MemorySearchFilter): MemoryBundle;
    importBundle(bundle: MemoryBundle): Promise<MemoryImportResult>;
    /** Create a directed link between two records. */
    link(fromId: string, toId: string, relation: string): Promise<MemoryLink | null>;
    /** Get all links where this record is either source or target. */
    linksFor(id: string): MemoryLink[];
    /** Update mutable fields of an existing record. */
    update(id: string, patch: {
        scope?: MemoryScope;
        summary?: string;
        detail?: string;
        tags?: string[];
    }): MemoryRecord | null;
    review(id: string, patch: MemoryReviewPatch): MemoryRecord | null;
    /** Delete a record and all its links. */
    delete(id: string): boolean;
    rebuildVectorIndex(): MemoryVectorStats;
    rebuildVectorIndexAsync(): Promise<MemoryVectorStats>;
    vectorStats(): MemoryVectorStats;
    doctor(): Promise<MemoryDoctorReport>;
    save(): Promise<boolean>;
    close(): void;
    private persist;
}
//# sourceMappingURL=memory-store.d.ts.map