Skip to content

Commit 1e3105b

Browse files
Your Nameclaude
andcommitted
feat(schema,scip): PR#10 slice 2 -- reference_verdicts + excludes dual-write (evidence ledger, read-only)
Continues the evidence-ledger work (slice 1: 47f5489). Re-verified the "3 provider writers" premise from prior-session memory against live code first (2 parallel Explore agents) and found it inaccurate: call_edges has 1 bulk static writer (already a projection per its own schema comment) plus 2 mostly-UPDATE overlay passes (SCIP: 1 INSERT + 2 UPDATE; LSP: 0 INSERT, 3 UPDATE only). Also confirmed golden_graph_equivalence's fingerprint is byte-for-byte strict on formal_source/evidence_state/ruled_out_by_scip, not just from/to symbol -- and that no "materialize evidence into a derived table" pattern exists anywhere in this codebase yet. Given that, this slice deliberately does not touch any call_edges writer and does not attempt to reproduce the static resolver's own output. 1. `record_external_proof_exclusion` (scip/ingest.rs) -- the 'excludes' counterpart to record_external_proof_for_edge's 'supports' write, wired into insert_missing_exact_edges's conflict branch under the same proof_context guard. Closes the gap slice 1's own comment named as future work. 2. `reference_verdicts` (new table) + `recompute_reference_verdicts` (new function) -- a derived, fully recomputable reconciliation of reference_evidence: for each (call_site_id, to_symbol) pair with real evidence, what call_edges should say. Pure DELETE+repopulate, not wired into any reindex/overlay pass or MCP tool. Only covers the subset of edges with real evidence (the DoD's own "every VERIFIED edge is explainable" wording), not a reproduction of the static resolver. 5 new tests, each checked against real code-produced call_edges/ evidence_conflicts state rather than hand-typed expectations. Full workspace suite green (0 failed) plus an explicit golden_graph_equivalence re-run confirming it's unaffected, since call_edges is never touched. Still not done toward PR#10's full DoD (documented, not silent): the writer cutover / "providers append evidence only" flip, wiring verdict recomputation into any automatic pipeline, and B2/resolution_precision re-runs (neither benchmark measures anything this slice touches). Details in docs/plans/2026-08-20-product-uplift-and-b7v2-roadmap.md §15-§18. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 47f5489 commit 1e3105b

3 files changed

Lines changed: 635 additions & 16 deletions

File tree

crates/calm-core/src/db/schema.rs

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,21 +288,22 @@ CREATE TABLE IF NOT EXISTS external_proofs (
288288
CREATE INDEX IF NOT EXISTS idx_external_proofs_status ON external_proofs(status, provider);
289289
290290
-- Wave 3 evidence ledger v1 (docs/plans/2026-08-19-evidence-architecture-execution-plan.md
291-
-- Part E PR#10, slice 1 of N). Generalizes external_proofs above -- additive
292-
-- schema + dual-write only in this slice; every call_edges write path is
293-
-- UNCHANGED. disposition distinguishes a provider proof FOR a target
294-
-- ('supports', the only value written so far, from record_external_proof_for_edge
295-
-- which both the SCIP and LSP overlays call) from one recording disagreement
296-
-- ('excludes' -- not written yet; migrating insert_missing_exact_edges's
297-
-- evidence_conflicts INSERT to also land here is future work, not this slice).
298-
-- authority_class names the KIND of evidence: 'external_proof' for a live
299-
-- SCIP/LSP result today, leaving room for a 'heuristic'/'static' class if the
300-
-- static resolver's own confidence tiers are ever folded in here too (this
301-
-- slice deliberately does not attempt that -- see PR#10's real write-path
302-
-- inventory: indexer/pipeline/graph.rs's rebuild_graph/incremental_graph_update
303-
-- DELETE-then-reinsert call_edges wholesale from call_sites+symbols on every
304-
-- pass, making the static tier already a projection rather than a provider in
305-
-- this sense). Same CASCADE-on-reindex lifecycle as external_proofs.
291+
-- Part E PR#10, slice 1-2). Generalizes external_proofs above -- additive
292+
-- schema + dual-write only; every call_edges write path is UNCHANGED (still
293+
-- true through slice 2). disposition distinguishes a provider proof FOR a
294+
-- target ('supports', from record_external_proof_for_edge, called by both the
295+
-- SCIP and LSP overlays) from one recording disagreement ('excludes', from
296+
-- record_external_proof_exclusion, called by insert_missing_exact_edges's
297+
-- conflict branch as of slice 2 -- mirrors evidence_conflicts' INSERT under
298+
-- the same guard rather than replacing it). authority_class names the KIND of
299+
-- evidence: 'external_proof' for a live SCIP/LSP result today, leaving room
300+
-- for a 'heuristic'/'static' class if the static resolver's own confidence
301+
-- tiers are ever folded in here too (deliberately not attempted yet -- see
302+
-- PR#10's real write-path inventory: indexer/pipeline/graph.rs's
303+
-- rebuild_graph/incremental_graph_update DELETE-then-reinsert call_edges
304+
-- wholesale from call_sites+symbols on every pass, making the static tier
305+
-- already a projection rather than a provider in this sense). Same
306+
-- CASCADE-on-reindex lifecycle as external_proofs.
306307
CREATE TABLE IF NOT EXISTS reference_evidence (
307308
id INTEGER PRIMARY KEY AUTOINCREMENT,
308309
call_site_id INTEGER NOT NULL REFERENCES call_sites(id) ON DELETE CASCADE,
@@ -326,6 +327,34 @@ CREATE TABLE IF NOT EXISTS reference_evidence (
326327
CREATE INDEX IF NOT EXISTS idx_reference_evidence_status ON reference_evidence(status, provider);
327328
CREATE INDEX IF NOT EXISTS idx_reference_evidence_call_site ON reference_evidence(call_site_id);
328329
330+
-- Wave 3 evidence ledger v1, slice 2: reference_verdicts is a DERIVED, fully
331+
-- recomputable reconciliation of reference_evidence -- for each
332+
-- (call_site_id, to_symbol) pair it has evidence about, what call_edges
333+
-- SHOULD say if reference_evidence alone is trusted. Populated exclusively by
334+
-- recompute_reference_verdicts (scip/ingest.rs), a pure DELETE+repopulate
335+
-- function, never hand-authored and never written by any overlay directly.
336+
-- Deliberately NOT wired into any reindex/overlay pass or MCP tool yet, and
337+
-- deliberately does NOT attempt to reproduce a row for every call_edges edge
338+
-- -- only the subset reference_evidence has an opinion about (the DoD's own
339+
-- 'every VERIFIED edge is explainable' wording, not 'every edge'). This is
340+
-- the first table in the whole schema that materializes evidence into a
341+
-- derived reconciliation; there is no earlier precedent to follow here.
342+
CREATE TABLE IF NOT EXISTS reference_verdicts (
343+
id INTEGER PRIMARY KEY AUTOINCREMENT,
344+
call_site_id INTEGER NOT NULL REFERENCES call_sites(id) ON DELETE CASCADE,
345+
to_symbol TEXT NOT NULL,
346+
verdict TEXT NOT NULL CHECK (verdict IN ('confirmed', 'excluded')),
347+
provider TEXT NOT NULL,
348+
authority_class TEXT NOT NULL,
349+
projected_edge_confidence TEXT,
350+
projected_formal_source TEXT,
351+
projected_evidence_state TEXT,
352+
justifying_evidence_id INTEGER NOT NULL REFERENCES reference_evidence(id) ON DELETE CASCADE,
353+
computed_at REAL NOT NULL,
354+
UNIQUE(call_site_id, to_symbol)
355+
);
356+
CREATE INDEX IF NOT EXISTS idx_reference_verdicts_call_site ON reference_verdicts(call_site_id);
357+
329358
-- WS3 (docs/plans/2026-08-18-context-intelligence-upgrade-plan.md, D3): a call
330359
-- site whose bare-name candidate set exceeded MAX_CALLEE_CANDIDATES used to be
331360
-- silently dropped to zero call_edges rows -- unknown read identically to

0 commit comments

Comments
 (0)