import { SqliteConnection } from "./connection.js"; import { SessionScope } from "@graphorin/core"; //#region src/conflict-store.d.ts /** * Stage label written into `fact_conflicts.stage` / * `conflict_check_pending.stage`. Stable lowercase identifier so * downstream tooling can pattern-match without parsing prose. * * @stable */ type ConflictPipelineStage = 'exact-dedup' | 'embedding-three-zone' | 'heuristic-regex' | 'subject-predicate' | 'defer-to-deep'; /** * Final outcome the pipeline produced for a candidate fact write. * `'admit'` is the default no-conflict path; the other variants record * an active intervention. * * @stable */ type ConflictPipelineDecision = 'admit' | 'dedup' | 'supersede' | 'pending' /** Deep-phase judge failed repeatedly; row closed un-adjudicated. */ | 'judge-unparseable'; /** * Per-decision row written by `runConflictPipeline(...)`. One row per * `SemanticMemory.remember(...)` invocation, even when no conflict was * detected (so operators can audit pipeline coverage). * * @stable */ interface ConflictAuditInput { readonly scope: SessionScope; readonly candidateId: string; readonly existingId?: string; readonly decision: ConflictPipelineDecision; readonly stage: ConflictPipelineStage; /** `'hot' | 'near-dup' | 'conflict-check' | 'cold' | 'heuristic' | 'subject-predicate'` (Stage 2/3/4). */ readonly detectionZone?: string; /** Cosine similarity captured during Stage 2. `null` for non-embedding stages. */ readonly similarity?: number; readonly reason?: string; /** Defaults to `'sync-write'`. Future LLM judge will pass `'consolidator-deep'`. */ readonly detectedBy?: string; } /** * Row shape returned from `recordDecision(...)`. * * @stable */ interface ConflictAuditRow { readonly id: number; readonly detectedAt: number; } /** * Per-pending row enqueued for the deep-phase LLM judge. * * @stable */ interface PendingConflictInput { readonly scope: SessionScope; readonly factId: string; readonly candidateText: string; readonly stage: ConflictPipelineStage; readonly reason?: string; /** Top-K conflicting existing fact ids surfaced by Stage 2. */ readonly conflictingIds?: ReadonlyArray; } /** * Read-back shape for `listPending(...)`. Surfaces the row id so the * deep phase can claim + resolve it later. * * @stable */ interface PendingConflictRow { readonly id: number; readonly scopeUserId: string; readonly factId: string; readonly candidateText: string; readonly stage: string; readonly reason: string | null; readonly enqueuedAt: number; readonly attemptedAt: number | null; readonly resolvedAt: number | null; readonly decision: string | null; /** Top-K conflicting existing fact ids; empty when omitted at enqueue. */ readonly conflictingIds: ReadonlyArray; } /** * SQLite-backed conflict store. Constructed by `SqliteMemoryStore`; * never instantiated directly by application code. * * @stable */ declare class SqliteConflictStore { #private; constructor(conn: SqliteConnection); /** Record a single decision row. Returns the autogenerated id. */ recordDecision(input: ConflictAuditInput): Promise; /** Enqueue a candidate fact + the conflicting fact ids for the deep phase. */ enqueuePending(input: PendingConflictInput): Promise<{ readonly id: number; }>; /** List pending rows for the supplied user, oldest-first. */ listPending(scope: SessionScope, limit?: number): Promise>; /** Mark a pending row resolved (used by the deep phase in Phase 10c). */ markResolved(id: number, decision: ConflictPipelineDecision): Promise; /** * Stamp `attempted_at` on a pending row whose deep-phase judge call * failed. The deep phase closes the row as * `'judge-unparseable'` on the NEXT failure, bounding how often a * poisoned row can be re-billed. * * @stable */ markAttempted(id: number, attemptedAt?: number): Promise; /** * Read-back helper used by the audit-replay surface (Phase 14c) and * the test suite - returns up to `limit` recent rows for the scope. * * @stable */ listRecentDecisions(scope: SessionScope, limit?: number): Promise>; } //#endregion export { ConflictAuditInput, ConflictAuditRow, ConflictPipelineDecision, ConflictPipelineStage, PendingConflictInput, PendingConflictRow, SqliteConflictStore }; //# sourceMappingURL=conflict-store.d.ts.map