/** * @module memory/brain-reconciler * * T1147 Wave 7: Reconciler core module. * * Extends `runConsolidation` from brain-lifecycle with a supersession pass that * automatically invalidates older BRAIN entries when a newer entry contradicts * them with high confidence (edge weight > 0.8 on the `contradicts` graph edge). * * This module absorbs the T1139 scope (decision/learning/pattern supersession) * and adds a scheduled `reconciler` trigger type to `brain_consolidation_events`. * * @task T1147 * @epic T1075 */ import { runConsolidation } from './brain-lifecycle.js'; /** Options for the reconciler pass. */ export interface ReconcilerOptions { /** Edge weight threshold above which a `contradicts` relationship triggers supersession. Default: 0.8 */ contradictionThreshold?: number; /** Session ID to associate with consolidation events. */ sessionId?: string | null; /** Dry-run mode: detect supersession candidates without writing `invalid_at`. */ dryRun?: boolean; } /** Result returned by `runReconciler`. */ export interface ReconcilerResult { /** Number of entries superseded (invalid_at set) during the reconciler pass. */ superseded: number; /** IDs of entries that were superseded, keyed by source table. */ supersededIds: { observations: string[]; learnings: string[]; decisions: string[]; patterns: string[]; }; /** Number of dedup/quality/promotion steps from the base consolidation pass. */ consolidationResult: Awaited>; /** Whether this was a dry run (no writes performed on supersession pass). */ dryRun: boolean; } /** * Runs the full reconciler pass for the given project. * * This is an extension of `runConsolidation` that adds a T1139 supersession * pass: entries whose `contradicts` edge weight exceeds `contradictionThreshold` * are marked `invalid_at = now()` in their respective brain tables. * * After the supersession pass, the result is logged to `brain_consolidation_events` * with `trigger = 'reconciler'`. * * @param projectRoot - Absolute path to the project root (used for DB location). * @param options - Optional configuration overrides. * @returns Combined result from consolidation + supersession passes. * * @example * ```typescript * const result = await runReconciler('/mnt/projects/myapp'); * console.log(`Superseded: ${result.superseded}, DryRun: ${result.dryRun}`); * ``` */ export declare function runReconciler(projectRoot: string, options?: ReconcilerOptions): Promise; /** * Counts supersession candidates without applying any changes. * * Equivalent to `runReconciler(projectRoot, { dryRun: true })` but does NOT * run the full consolidation pass — faster for pre-flight checks. * * @param projectRoot - Absolute path to the project root. * @param contradictionThreshold - Edge weight threshold (default 0.8). */ export declare function countSupersessionCandidates(projectRoot: string, contradictionThreshold?: number): Promise; /** * Fire-and-forget wrapper that triggers a reconciler sweep asynchronously. * * Used by the dispatch-time brain health reflex (T1148 W8-8 / T1151) to * schedule a sweep when the corpus is detected as unhealthy during a Tier-2 * propose tick. Returns immediately without waiting for completion. * * Errors are swallowed silently — the proposer must not be disrupted by * maintenance tasks. * * @param projectRoot - Absolute path to the project root. */ export declare function triggerReconcilerSweep(projectRoot: string): Promise; //# sourceMappingURL=brain-reconciler.d.ts.map