Two gates are blind to the population they exist for: the argument registry misses a prelude closure (FIXED), and no gate sees a read-path EXECUTION-COST regression #158
Labels
No labels
code-review
correctness
dos
performance
security
severity/high
severity/low
severity/medium
tech-debt
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
h-dv/code-index#158
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two independent instances found on 2026-09-05, filed together because the pattern is the finding and it recurred four times in one day.
1. The argument registry: all six tests green over a completely ungraded parameter — FIXED
While adding the
resolutionfilter (#141), a lane's first cut wrote the reader as a closure in the dispatch prelude:the_scanner_knows_every_reader_closurematches|k: &str|closure heads, and this one takes no argument. The per-arm key scan then found the read in the prelude, not in an arm. Result: all six registry tests stayed green over a new request parameter with no row and no grading at all.The registry's population is "keys read inside a dispatch arm". A key read once, above the match, is invisible to it — and that is exactly the shape a developer reaches for when two arms need the same argument.
Closed by
argument_registry_e2e.rs::every_request_argument_is_read_inside_a_dispatch_arm, which asserts the structural fact instead of the two symptoms: the populationderived_optional_argscan ATTRIBUTE and the population that EXISTS are the same multiset, over one shared arm splitter (dispatch_arm_bodies) so two scanners cannot disagree.crates/daemon/src/server.rsnow records the gap as closed and survives as the worked example. The stated bound is thatSERVER_SRCis one file.2.
cost-baseline.jsoncannot see a read-path EXECUTION-COST regression — the honesty half landed, the coverage half did notcorpus_cold_index_cost_stays_within_the_blessed_bandmeasures a cold index and issues no daemon read. So a read-path index can only ever raise itsvm_step, never lower it. "Add the index and check the ratchet drops" is not a test that exists.cost-baseline.jsonnow carries a_populationblock declaringmeasured: "cold_index"and naming the read path as unmeasured, kept honest bycorpus_cost.rs::the_cost_gate_declares_the_population_it_measures. That is the "explicit statement in the gate's own doc" half of the repair below, and it is done.THE RESIDUAL, STATED ACCURATELY AT THE THIRD ATTEMPT. Two earlier statements of it were too strong:
"There is still no read-path cost measurement."False.crates/daemon/tests/file_health_bounded_e2e.rs::the_work_follows_the_reported_files_not_the_indexmeasures SQLitevm_stepovergraph::index_health— a read path — through an in-processsqlite3_profilecallback, as a ratio between two fixtures."There is no read-path cost RATCHET with blessed numbers over the corpus."Also false.crates/mcp-server/tests/agent_task_bench.rs(#51) is exactly that: blessed numbers intests/bench/ratchet.json, over four corpus repos, withtool_tokens,tokens_per_correct,tool_calls,ratio_vs_rg_onlyandrg_false_positivesall gated in both directions, plus a recall floor.What is actually missing is a read-path ratchet on the EXECUTION-COST dimension. The corpus read-path ratchet blesses payload size and answer quality; it records no
vm_step, andratchet.json's own_conditionsblock says "Wall clock is NOT recorded here" deliberately, because the numbers are taken under contention. So a read-path change that costs opcodes without changing the payload — which is precisely what #143'ssymbols.ref_countindex was — is invisible to every gate in the tree, and had to be decided by hand.crates/indexer/src/migrations/m0061_file_refs_rollup.rsandcrates/daemon/src/local_index.rsboth cite that blindness as the reason.Why they are one issue
Both are the pattern this repository hit four times today:
shell:only, missingdefaults.run.shell>= 10on a file with 5An anti-vacuity floor proves a scan found something. It cannot prove the scan looked at the right set, because the floor is calibrated against whatever the scan currently finds. A floor is only worth what it was measured against — and so is a scan.
A sixth entry belongs on that table now, and it is this issue's own text: the residual was blind to the gates that already existed, twice, in the direction of overstating the work left. That is the same error class as #185/#186/#187 and it was made here, in the tracker, by the people fixing it.
What a repair looks like
For (1): done — see section 1.
For (2): the "explicit statement" option is done. The remaining option is a read-path
vm_stepdimension — not wall clock, which this tree has already declined to record for a stated reason. Both halves of the mechanism exist and it is an assembly job rather than research:file_health_bounded_e2e.rs'ssqlite3_profilecallback is how to measure a read in opcodes, andcorpus_cost's bless/render machinery is how to ratchet it. What it needs that neither provides is a fixed, representative read set and its own blessed record — and creating a new protected baseline is a decision that should be taken deliberately rather than as a side effect of closing this.The #143 measurement, recorded so it is not filed a third time
At
crates/daemon/src/local_index.rs:top_referenced_symbols(read, 1× perproject_overview)recompute_ref_counts(write, every resolve pass)recompute_ref_countsruns on the scoped path — every watcher-triggered re-index — and rebuilds the whole column regardless of scope. A session saves files far more often than it callsproject_overview, so the trade is negative on exactly the axis #73's bless names as its own disqualifier ("a hot repeated write path"). 6 ms is ~2.4% ofproject_overview, whosefile_healthcore alone is 223 ms.The first version of that measurement was wrong and the lane caught it: re-running both variants against the same two files reported the indexed write as 36% faster — WAL accumulation across iterations. Fresh copy per run, alternating, inverted the result, and the corrected direction agrees with the opcode count while the contaminated one did not.
🤖 Generated with Claude Code
https://claude.ai/code/session_01K1zj5VcFJvJt3pQxe9259K
Part 1 FIXED. Part 2 PARTIALLY fixed, with the residual named.
Lane worktree:
/tmp/cosi-lane-honesty, branchwip/honesty, based onorigin/master(ea821b6). Not pushed.1. The argument registry's blind scope — FIXED
Mechanism, and why it is one clause and not two
The issue names two independent reasons the
resolutionclosure was invisible: the reader-closure gate matches|k: &str|heads and that one took no argument, and the per-arm key scan found the read in the prelude. A gate per reason would be two gates with the same blind spot one step further out — a free function inserver.rsreadingparams.get("k")is neither a closure head nor a prelude line.So the repair asserts the structural fact instead:
Every literal request-key read anywhere in
server.rs(everyopt_*/req_*reader spelling, plusreq.params.get("and whatever aliasdispatchbinds) is counted over the whole normalized file, then the per-arm counts are subtracted. A leftover is a read no(method, arg)pair can be derived from, whatever spelling it used.derived_optional_argsand the new gate now share ONE arm splitter (dispatch_arm_bodies), so two scanners cannot disagree about which reads are attributable.Bounded honestly in the test's own doc:
SERVER_SRCis one file. A helper ingraph.rshanded&req.paramsis outside the scan; nothing does that today, and the stated repair is to widenSERVER_SRCrather than to read the gate as proof.crates/daemon/src/server.rs:411's comment — which the issue cites as recording the gap as unfixed — now records it as closed and survives as the worked example.Mutations (all RUN, real output)
M1 — the historical first cut, verbatim, back in the prelude:
Note the first two lines: both pre-existing registry gates stayed GREEN. The new test is what caught it, not a different gate.
M2 — the wider clause, proved: a free function OUTSIDE the prelude and outside the match:
M3 — anti-vacuity (break the arm split so the scan attributes nothing):
2. The cost baseline's blind DIRECTION — PARTIALLY fixed
What was done
The issue offers two repairs and calls the second "nearly free". I took the second, and made it non-vacuous rather than prose:
tests/corpus/cost-baseline.jsongains a_populationblock — placed BEFORE_blessed, becauserender_baselinekeeps only what precedes it and a block on the wrong side would be silently deleted by the next bless (the failure mode that writer already carries anafter_reposrefusal for). It namesmeasured: "cold_index"and anot_measuredlist whose first entry is the read path, carrying the #143 measurement verbatim so it is not reasoned about a third time.corpus_cost.rs::the_cost_gate_declares_the_population_it_measureskeeps the declaration from ageing: it requires the block, requires it to sit before_blessed, runsrender_baselineand asserts the block survives a bless, and pins the harness to exactly ONE measured leg whose body isindex_path. Adding a read leg is RED until the declaration is updated.Both needles in the harness half are built with
concat!and never written out literally — this test's own prose and failure messages are part ofinclude_str!("corpus_cost.rs"), so a literal needle would have matched itself. (That was a real bug in my first cut: theindex_pathassertion was satisfied by the string in its own failure message.)No blessed number moved.
_blessed.reasonand everyreposrow are byte-identical.Mutations (both RUN)
M4 — delete the
_populationblock:M5 — add a second measured leg (a
measure_readsthat issues a read query):THE RESIDUAL, NAMED
There is still no read-path cost measurement. The gate now says it measures writes only; it does not measure reads. Building that dimension needs the daemon's
LocalIndex, a fixed representative read set, and its own blessed numbers — enough that bolting it onto the write-path gate would change what a failure there means. It is not in this branch and I am not claiming it is. Item (2) of this issue is therefore half done: the honesty half, not the coverage half.Gates
cargo fmt --all -- --check0 ·cargo clippy --workspace --all-targets -- -D warnings0 ·RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items0.tests/corpus/baseline.jsonunmoved at534084b856c22566c48e386bc41ed67e.🤖 Generated with Claude Code
https://claude.ai/code/session_01K1zj5VcFJvJt3pQxe9259K
Triage 2026-09-06: LEFT OPEN. Part 1 is fixed and verified; part 2's residual is real but the lane stated it too strongly — corrected below.
I re-ran both gates myself rather than taking the lane comment's word.
Part 1 — FIXED, verified
every_request_argument_is_read_inside_a_dispatch_arm—crates/daemon/tests/argument_registry_e2e.rs:1310, sharing one arm splitter (dispatch_arm_bodies,:808) withderived_optional_argsso two scanners cannot disagree about what is attributable. Anti-vacuity on both populations at:1331-1349(arms.len() > 20,file_total > 50,arm_total > 50) plus an alias-derivation floor at:788-796.crates/daemon/src/server.rs:431— the comment this issue cites as recording the gap unfixed now reads "THE GAP ITSELF IS NOW CLOSED" and survives as the worked example.The stated bound is currently accurate:
SERVER_SRCis one file, andsearch_text("params.get(")returns zero hits anywhere else undercrates/daemon/src/, so nothing outsideserver.rsreads a literal request key today.Part 2 — the honesty half landed and is gated
executed=7, not theexecuted=0 unavailable=1false green.the_cost_gate_declares_the_population_it_measures—crates/indexer/tests/corpus_cost.rs:1228— requires the_populationblock, requires it before_blessed(a block on the wrong side is silently deleted by the next bless), runsrender_baselineand asserts the block survives a bless, and pins the harness to exactly ONE measured leg. Adding a read leg is RED until the declaration is updated.THE CORRECTION — the residual as written is too strong
The lane comment says "There is still no read-path cost measurement." That is not accurate.
crates/daemon/tests/file_health_bounded_e2e.rs:317—the_work_follows_the_reported_files_not_the_index— measures SQLitevm_stepovergraph::index_health, a read path, via an in-processsqlite3_profilecallback (mod work,:198-261), as a ratio between two fixtures. Its header records16,235,136 → 7,106,933 vm_step.The accurate residual: there is no read-path cost RATCHET with blessed numbers over the corpus. One hand-built read-path opcode gate exists, for one query.
project_overview's other legs,find_callersandresolution_gapsremain unmeasured in both directions.That distinction matters for whoever picks this up: the question is not "can we measure a read path at all" (we can, and there is a working pattern to copy at
file_health_bounded_e2e.rs:198-261) but "does a read-path regression have somewhere to be caught over the corpus".Why this stays open rather than closing
This issue's own "What a repair looks like" offers, for part 2, "a read-path cost dimension, or an explicit statement in the cost gate's own doc that it measures writes only" — and the second was taken. On a literal reading of that "or", this could close.
I am leaving it open because the title is the acceptance: "Two gates are blind to the population they exist for." One gate can now see its population. The other still cannot — it merely says so. A declaration is the right first move and is worth what it cost, but the gate is still blind, and closing on the declaration would put the coverage half beyond recall.
If the preference is to close on the letter of the "or", say so and I will close it with the residual re-filed as its own issue. It should not simply be dropped:
crates/indexer/src/migrations/m0061_file_refs_rollup.rs:79andcrates/daemon/src/local_index.rs:4462both cite this blindness as the reason a real decision (#143's refusal) had to be taken by hand.🤖 Triage lane, 2026-09-06, master
45cf6e4overview_payload_budget_e2eis safe from the unconsulted-package-set race by luck, not by design — 25 tokens of headroom against a ~190-token block #133Two gates are blind to the population they exist for: the argument registry misses a prelude closure, and cost-baseline cannot see a read-path regressionto Two gates are blind to the population they exist for: the argument registry misses a prelude closure (FIXED), and no gate sees a read-path EXECUTION-COST regressionIssue text CORRECTED (body and title). Part 1 fixed and re-verified. Part 2's residual was too strong twice — the second time by the correction itself.
Doc-drift lane, worktree
/tmp/cosi-lane-docdrift, master552e3a2. No code changed for this issue; the drift was in the tracker.The correction I was asked to make, and the one I found on top of it
I was asked to correct the residual because "a read-path measurement exists at
file_health_bounded_e2e.rs:317; what is missing is a ratchet." That is right, and the previous triage comment already said it. But the corrected version is also too strong.crates/mcp-server/tests/agent_task_bench.rs(#51) is a read-path ratchet with blessed numbers over the corpus.tests/bench/ratchet.jsonholds per-repo blocks for four corpus repos, andassert_bandgatestool_tokens[0.70, 1.05],tokens_per_correct[0.70, 1.05],tool_calls[0.90, 1.10],ratio_vs_rg_only[0.85, 1.25] andrg_false_positives[0.95, 1.05] — five bands, bounded in both directions — plus a recall floor and a hard precision-vs-ripgrep direction. It is human-maintained and never self-regenerated. So "no read-path cost ratchet with blessed numbers over the corpus" is false as stated.What is actually missing is one dimension: execution cost. That ratchet blesses payload size and answer quality. It records no
vm_step, and its own_conditionsblock says so out loud:repeated in the 2026-09-06 entry: "which is why no wall clock is recorded here and none should be read out of that spread."
So the true gap is narrow and precise: a read-path change that costs opcodes without changing the payload is invisible to every gate in the tree. That is exactly what #143's
symbols.ref_countindex was, which is why it had to be decided by hand.The body and title are updated to say this, at the claim rather than in a comment — a reader who stops at the section heading was the whole failure mode of #186, and the old heading ("cost-baseline cannot see a read-path regression") was itself the stale sentence.
I also added a sixth row to this issue's own "blind to" table, because it belongs there: the residual was blind to the gates that already existed, twice, and both times in the direction of overstating the work left — the same direction as #185, #186 and #187.
Part 1 — re-verified, not taken on report
every_request_argument_is_read_inside_a_dispatch_armshares one arm splitter withderived_optional_args, so the two scanners cannot disagree about what is attributable. That is the right shape — one structural clause, not one gate per symptom.Is the ratchet worth building? — Yes, and it is an assembly job, but it should not be done as a side effect of closing this.
Yes, because the gap has already cost a real decision (#143, taken by hand) and two in-tree sites cite the blindness as the reason —
m0061_file_refs_rollup.rsandlocal_index.rs. And because this repository has already learned once, expensively, that correctness gates cannot see slowdowns: a 3.2× cold-index regression passed ~1,950 tests and CI 10/10 three times, and only a wall-clock ceiling caught it. That was the write path. Nothing analogous watches reads.On
vm_step, not wall clock. Wall clock is the dimension this tree has already declined to record, for a stated and correct reason — the numbers are taken under lane contention.vm_stepis deterministic and contention-free, which is whycorpus_costuses it, and it is the dimension on which #143 was actually decided.It is assembly, not research. Both halves exist:
file_health_bounded_e2e.rs's in-processsqlite3_profilecallback is how to count a read in opcodes, andcorpus_cost's bless/render machinery is how to ratchet it — including the_population/_blessedordering constraint that lane already discovered.Why I am not building it in this lane. It needs a fixed, representative read set and its own blessed record. Creating a new protected baseline is a deliberate decision with a maintenance tail — the tree already carries five such records that may not be blessed — and taking it as a by-product of a doc-drift pass is how a baseline ends up owned by nobody. It also is not doc-drift work, and I would rather hand over an accurately-scoped issue than a half-built ratchet with an unowned baseline.
Recommendation: keep this issue open on part 2 only, with the corrected scope, or re-file the execution-cost ratchet as its own issue and close this. Either is defensible; what should not happen is closing it against the old "or" while the text still describes a gap that is one third the size of the one it names.
🤖 Doc-drift lane, 2026-09-06, master
552e3a2overview_payload_budget_e2eis safe from the unconsulted-package-set race by luck, not by design — 25 tokens of headroom against a ~190-token block #133overview_payload_budget_e2eis safe from the unconsulted-package-set race by luck, not by design — 25 tokens of headroom against a ~190-token block #133STAYS OPEN — part 1 fixed, part 2's honesty half landed, the coverage half is genuinely missing. Proof rather than claim, and one last tightening.
Close-out lane, verified on merged master
fc329a8. The doc-drift lane corrected this issue's text and changed no code — correctly, because the tree already matched. That means the corrected text has not been re-checked against the tree until now.Part 1 — argument registry: DONE.
every_request_argument_is_read_inside_a_dispatch_armatcrates/daemon/tests/argument_registry_e2e.rs:1310, sharingdispatch_arm_bodies(:803) withderived_optional_argsso the two grade one extraction.crates/daemon/src/server.rs:431carries the worked example recording the prelude gap as closed.RUN, exit 0:
argument_registry_e2e8 passed, 0 failed.Part 2, honesty half — DONE.
tests/corpus/cost-baseline.json:48carries_populationbefore_blessed, withmeasured: "cold_index",measured_by: "exactly one measure_pass() leg per repo, whose whole body is index_path()", and anot_measuredlist whose first entry isread_pathcarrying #143's numbers verbatim. Gated bythe_cost_gate_declares_the_population_it_measures(crates/indexer/tests/corpus_cost.rs:1228).Part 2, coverage half — STILL OPEN, and here is the measurement instead of the assertion. Five corpus baselines exist;
vm_stepoccurrence counts, taken on this tree:tests/bench/ratchet.jsoncontains the stringvm_stepzero times; its_fieldsaretool_tokens, tool_calls, truth_total, correct, recall, ratio_vs_rg_only, ratio_vs_rg_windows, rg_false_positives, correct_via_fallback— payload and quality, never opcodes. No baseline anywhere blesses a read-pathvm_step.Fourth statement of this residual, tightened once more — because it has now been overstated three times in the same direction. "Invisible to every gate in the tree" is still slightly too strong.
index_healthis counted invm_stepand asserted on, atcrates/daemon/tests/file_health_bounded_e2e.rs:317andcrates/daemon/tests/overview_scale_2m_e2e.rs— as ratios, over synthetic fixtures, the latter#[ignore]d onto the nightly.The accurate gap, and where it should stop being restated:
Do not drop it:
crates/indexer/src/migrations/m0061_file_refs_rollup.rs:80andcrates/daemon/src/local_index.rs:4569both cite this blindness as the reason they cannot be graded. Either keep this issue open on part 2 alone, or re-file the execution-cost ratchet as its own issue and close this — but not silently.Re-verified on master
1d81180: part 1 closed, part 2's residual is exactly as this issue's third statement of it says. No change from me.I picked this up as a live item and re-read both halves against the tree rather than against the issue text, because the issue itself warns that its residual has been overstated twice.
Part 1 — closed, and by the structural assertion rather than the two symptoms.
argument_registry_e2e.rs::every_request_argument_is_read_inside_a_dispatch_armis in the tree, and the file has since acquired the predicate mutation it was missing when #180's audit rated it vulnerable: a//comment naming aShapeProbe's deleted cover test used to satisfysrc.contains(&format!("fn {func}(")), anddeclares_test_fnplusthe_cover_test_scan_reads_declarations_and_not_proseclosed that.Part 2 — the residual is still open and is still, precisely, a read-path EXECUTION-COST ratchet. Confirmed by reading, not inferred:
tests/corpus/cost-baseline.json's_populationblock is present and saysmeasured: "cold_index", withread_pathnamed undernot_measuredand #143's own numbers quoted inside it.corpus_cost.rs::the_cost_gate_declares_the_population_it_measureskeeps it from drifting.vm_stepappears in exactly two read-path places, and neither is a corpus ratchet:file_health_bounded_e2e.rs(a ratio between two fixtures) andoverview_scale_2m_e2e.rs.tests/corpus/holdsbaseline.json,cost-baseline.json,stage-baseline.json,tier3-baseline.json,ruby-package-cost.json. There is no read-path opcode record.So both halves of the mechanism still exist and it is still an assembly job — and I did not do it, deliberately. This issue says creating a new protected baseline "should be taken deliberately rather than as a side effect of closing this", and it needs a decision this lane is not the right place to take: which read set is the fixed, representative one. Leaving that choice to whoever owns the ratchet.
One note for that lane, from a different issue in the same family:
agent_task_bench'sratchet.jsondeliberately records no wall clock because its numbers are taken under contention. Avm_steprecord does not have that problem, which is most of why it is the right dimension here.Part 1 fixed and verified; part 2 is a genuine residual and this stays open on it.
Part 1: the argument registry now derives its prelude from
dispatch's own (argument_registry_e2e.rs:717,:766) rather than hard-coding it, so the closure it grades is the one that actually runs.Part 2 remains open, and the lane deliberately did not close it by inventing a baseline. There is no read-path
vm_stepratchet:vm_stepon a read path appears only infile_health_bounded_e2eandoverview_scale_2m_e2e, andtests/corpus/holds no read-path record at all.Creating one would mean minting a new protected baseline, and that needs a deliberately chosen representative read set — which is a judgement about what reads matter, not a mechanical step. This issue itself says the decision should be taken deliberately. Making it up to close a ticket is how a baseline stops meaning anything, and this project has spent a lot of this week's effort on baselines that recorded their own contamination as truth.
So: part 2 is owed a choice of read set first, then the record. Left open, with the residual stated precisely rather than implied.