/** * Persistence for the FEAT-551 evidence-gated sweeper's guard-drop counters * (migration 053). Mirrors `src/storage/triage-guard-log.ts`'s two-table * split (FEAT-533) for the same reason: a reason+count-only table * (`evidence_gate_drops`) can say a drop happened, but never how often it * happened relative to how many passB atoms were even attempted — exactly * the "canary must measure rate, not existence" discipline this repo already * learned the hard way (entity extraction ran 87% broken for weeks behind a * green existence-only check). `evidence_gate_run_log` carries the * denominator (`atoms_attempted`) so a future doctor canary — or, nearer * term, FEAT-551's own AC-5 LoCoMo A/B measurement lane — can compute * `dropped / attempted` instead of reading `evidence_gate_drops` alone. * * FEAT-552 sub-scope C (AC-C2): `evidence_gate_drops`'s `reason` column is * plain TEXT (no CHECK enum) -- reused here for a THIRD, non-drop reason, * 'evidence-fuzzy-matched', so a passB atom admitted via the new fuzzy * token-window tier (src/distill/evidence-verify.ts) is DB-row observable * distinctly from an exact-match admission, with no new migration/table. * `recordEvidenceGateRunLog`'s atomsDropped is computed ONLY from the two * real drop reasons (see src/distill/stages/08-embed-index.ts) -- a fuzzy * admission is a PASS, never counted as dropped. */ import type { DB } from './db.js'; import type { EvidenceGateDropReason } from '../distill/evidence-gate.js'; /** FEAT-552 sub-scope C (AC-C2): a PASS-tier row this table also carries -- * see this file's module doc comment for why a "drops" table has a * non-drop reason value. */ export declare const EVIDENCE_FUZZY_MATCHED_REASON: "evidence-fuzzy-matched"; export interface EvidenceGateDropRow { reason: EvidenceGateDropReason | typeof EVIDENCE_FUZZY_MATCHED_REASON; count: number; } /** Write one `evidence_gate_drops` row per entry with `count > 0`. No-op * when `drops` is empty or every entry is zero — same guard every sibling * guard-drop table (relation/entity/validity/evidence) uses. */ export declare function recordEvidenceGateDrops(db: DB, drops: EvidenceGateDropRow[], sessionId: string | null): void; /** Record one run-log row for a completed embedAndIndex call where the gate * actually evaluated at least one passB atom. Mirrors * `recordTriageRunLog`'s "only write when the tier actually ran" posture — * a job with zero attempted atoms is a real, meaningful zero (the gate was * on, but this run had no passB atoms), not a phantom row to pollute a * future rate canary's denominator with every ordinary off-gate call. */ export declare function recordEvidenceGateRunLog(db: DB, row: { sessionId: string | null; atomsAttempted: number; atomsDropped: number; }): void; /** Total passB atoms the gate evaluated since `sinceMs`. */ export declare function totalEvidenceGateAttempted(db: DB, sinceMs?: number): number; /** Total passB atoms the gate dropped since `sinceMs`. */ export declare function totalEvidenceGateDropped(db: DB, sinceMs?: number): number; /** Fraction (0..1) of attempted passB atoms dropped since `sinceMs`. `null` * when zero atoms have been attempted in the window — rate is undefined, * not 0 (same convention as `triageDropRate`/extraction-yield's * `zeroYieldRate`). */ export declare function evidenceGateDropRate(db: DB, sinceMs?: number): number | null;