Commit 96ea1a3
fix(pipeline): PR#9 slice D -- upsert call_sites by identity instead of delete-all/insert-all (fixes proof churn root cause)
This is the fix ddbc6a0's commit message flagged as still missing: v3's
position-independent identity (slices A-C) alone could never reduce
external_proofs/evidence_conflicts/ambiguity_group_candidates churn,
because driver::remove_file_rows unconditionally deleted every call_sites
row for a changed file before persist_file re-inserted fresh ones --
AUTOINCREMENT never reuses a deleted id, so every reindex of a file
churned every durable proof/conflict/ambiguity row FK'd to call_sites.id
ON DELETE CASCADE, regardless of identity_version.
- driver::remove_file_rows no longer touches call_sites at all (doc
comment rewritten to explain why). Two new/reused cleanup paths take
over its old responsibility:
- driver::delete_call_sites_for_path: the explicit, unconditional
call_sites DELETE for a path that's genuinely gone (no re-extraction
follows) -- called from both "file deleted" branches in
reindex_changed_cancellable/reindex_paths, and from both "file
changed but language unrecognized" (data=None) branches where
persist_file never runs.
- extraction::reconcile_call_sites: the real fix. Loads existing
call_sites for the path, matches each freshly extracted call site
against them by IDENTITY (version-aware: byte-absolute key for v1/v2,
relative-to-enclosing-symbol key for v3+, mirroring db::schema's
idx_call_sites_v2_identity/idx_call_sites_v3_identity exactly). A
match keeps its id, UPDATEd in place only if something actually
changed (including call_line/callee_start_byte/callee_end_byte/
callee_start_rel/callee_end_rel -- a matched v3 row's RELATIVE
identity can stay stable while its ABSOLUTE position legitimately
shifts, e.g. an edit earlier in the same enclosing symbol; a first
version of this fix missed refreshing those columns, caught live by
golden_graph_equivalence's own RenameFn mutation round producing a
real continued-vs-fresh divergence -- fixed in the same slice before
landing). An unmatched fresh call site is INSERTed (still `OR
IGNORE`: two call sites within the SAME extraction batch can
legitimately collide on identity, same pre-existing case
persist_file_ignores_a_call_site_that_collides_on_the_full_identity_
tuple covers). An unmatched existing row is DELETEd -- the call
really is gone, so CASCADE cleanup for it is correct, not churn.
persist_file now calls this instead of a plain INSERT loop.
Also updates persist_file_ignores_a_call_site_that_collides_on_the_full_
identity_tuple: its own setup (write a.rs, run a real indexing pass first)
is incompatible with persist_file's new contract -- a real pre-existing
call site not present in this test's hand-built (partial, synthetic)
call_sites list would now be correctly treated as removed. Stripped the
now-unnecessary real-indexing setup; the test still verifies exactly what
its own doc comment says (in-batch duplicate-identity dedup), just
without unrelated pre-existing state in the way.
Verified: cargo build/clippy -p calm-core --all-targets clean, cargo test
-p calm-core 1248 passed/0 failed/12 ignored including both
golden_equivalence_{continued,incremental}_vs_fresh_across_mutation_rounds
(the real oracle for this change -- exercises exactly the kind of
same-file, position-shifting edits this fix is about), cargo fmt clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent 759928b commit 96ea1a3
3 files changed
Lines changed: 327 additions & 55 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5097 | 5097 | | |
5098 | 5098 | | |
5099 | 5099 | | |
5100 | | - | |
5101 | | - | |
5102 | | - | |
5103 | | - | |
5104 | | - | |
5105 | | - | |
5106 | | - | |
5107 | | - | |
5108 | | - | |
| 5100 | + | |
| 5101 | + | |
| 5102 | + | |
| 5103 | + | |
| 5104 | + | |
| 5105 | + | |
| 5106 | + | |
| 5107 | + | |
| 5108 | + | |
| 5109 | + | |
| 5110 | + | |
| 5111 | + | |
5109 | 5112 | | |
5110 | 5113 | | |
5111 | | - | |
5112 | 5114 | | |
5113 | 5115 | | |
5114 | 5116 | | |
| |||
5154 | 5156 | | |
5155 | 5157 | | |
5156 | 5158 | | |
5157 | | - | |
5158 | | - | |
5159 | 5159 | | |
5160 | 5160 | | |
5161 | 5161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
52 | 71 | | |
53 | 72 | | |
54 | 73 | | |
55 | | - | |
56 | 74 | | |
57 | 75 | | |
58 | 76 | | |
| |||
61 | 79 | | |
62 | 80 | | |
63 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
64 | 94 | | |
65 | 95 | | |
66 | 96 | | |
| |||
404 | 434 | | |
405 | 435 | | |
406 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
407 | 443 | | |
408 | 444 | | |
409 | 445 | | |
| |||
423 | 459 | | |
424 | 460 | | |
425 | 461 | | |
| 462 | + | |
426 | 463 | | |
427 | 464 | | |
428 | 465 | | |
| |||
535 | 572 | | |
536 | 573 | | |
537 | 574 | | |
| 575 | + | |
538 | 576 | | |
539 | 577 | | |
540 | 578 | | |
| |||
573 | 611 | | |
574 | 612 | | |
575 | 613 | | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
576 | 619 | | |
577 | 620 | | |
578 | 621 | | |
| |||
0 commit comments