/** * PURE deterministic reconcile-on-write for semantic facts. * * PURE — never reads the clock (now is injected), never calls createClient, * no network access, no Date.now(), no side effects beyond the injected store. * The injected FactJudge is the ONLY async/LLM surface and is consulted ONLY * on a deterministic normalized-key collision (the ambiguity branch). * Exact-match NOOP/UPDATE/ADD never touch the judge or the network. */ import type { FactStore, FactInput } from "../../state/facts.js"; import type { FactJudge } from "./fact-judge.js"; export type ReconcileAction = "add" | "update" | "delete" | "noop"; /** * Reconcile an incoming fact against the active state in the store. * * Algorithm: * 1. Query getActiveFacts(scope, subject, predicate) — exact key, active-only. * 2. Exact match with SAME value → NOOP. * 3. Exact match with DIFFERENT value → UPDATE: * supersedeFact(old.id, now, incoming.tValid) then insertFact(incoming). * 4. No exact match → AMBIGUITY check via normalizeKey over all active facts in scope. * a. Collision AND judge provided → judge.resolve(incoming, candidate) → apply. * b. Collision but NO judge → deterministic ADD fallback. * c. No collision → ADD. * 5. DELETE = supersedeFact(candidate.id, now, incoming.tValid) without inserting incoming. * * @param store - The FactStore to read from and write to. * @param incoming - The incoming fact input (validated by insertFact on the ADD path). * @param opts.judge - Optional LLM-backed judge for ambiguity resolution. * @param opts.now - ISO 8601 wall-clock timestamp (record-time); NEVER read inside. */ export declare function reconcileFact(store: FactStore, incoming: FactInput, { judge, now }: { judge?: FactJudge; now: string; }): Promise; /** * Reconcile-then-write a fact. Wall-clock `now` is injected by the caller — * this function never reads the clock (mirrors the store's purity contract). * * The `judge` is optional; when absent the exact-match UPDATE/NOOP paths run * deterministically and ambiguous collisions fall back to ADD. */ export declare function writeFact(store: FactStore, incoming: FactInput, opts: { judge?: FactJudge; now: string; }): Promise; //# sourceMappingURL=reconcile.d.ts.map