overview_payload_budget_e2e has under 1% headroom against a load-dependent disclosure, so a correctness gate turns on machine load #98
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#98
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?
What was measured
project_overview_stays_bounded_when_every_capped_list_saturates(crates/mcp-server/tests/overview_payload_budget_e2e.rs) failed during the v0.26.1 EBF work:efc53d0under the same load: 4275 — greenSo the change under test was not the cause, and the two payloads are the same payload. The ~175 extra bytes are an honest degradation disclosure the daemon adds when it has not caught up — precisely the field that exists so an answer says it may be behind.
Why this is a defect and not a flake
The ceiling has under 1% headroom against a value that legitimately grows exactly when the machine is busy. That makes a correctness gate's verdict a function of load, which this repository has already paid for once: the weekly wall-clock ceiling exists because a 3.2x cold-index regression passed ~1950 tests and CI 10/10 three times, and the standing rule from that episode is that an isolated run must be compared against an isolated run.
The failure mode here is the mirror image: not a slowdown hiding from a correctness gate, but a correctness gate firing because of load. Both are the same underlying error — a threshold measured against a quantity it does not control.
It is also, read carefully, the gate punishing the payload for being HONEST. The bytes that push it over are the disclosure saying "this answer may be stale". A budget that a truthful answer cannot satisfy under load will eventually be "fixed" by making the answer less truthful, which is the worst available outcome.
Options
Option 1 or 2. The point is that the gate should be able to state which population it is bounding.
Reproduction
Run the daemon-leg suite under concurrent load (three simultaneous
cargo test --workspaceruns was enough), then re-run the single test isolated and compare — the payloads are identical, so any difference in verdict is the instrument, not the product.overview_payload_budget_e2eis safe from the unconsulted-package-set race by luck, not by design — 25 tokens of headroom against a ~190-token block #133Triage 2026-09-06: LEFT OPEN, and materially worse than when filed — headroom went 40 → 25 tokens.
Nothing shipped
OVERVIEW_SATURATED_MAX_TOKENS = 4_300—crates/mcp-server/tests/overview_payload_budget_e2e.rs:248, unchanged.:237-240: "HEADROOM, RE-MEASURED: 25 tokens over the binding (daemon) leg, 4,275 against 4,300… It was 40, and #91'splugin_activation.package_duplicate_idsblock spent 15 of it."REPORTED_BLOCKSat:450guardsplugin_activation/symbol_blind_extensions/count_basisbeing"reported"— that catches a degraded overview being shorter, the opposite direction from this issue.4291 → 4252 of 4300figures quoted in73ef473are that commit's own local measurement; it did not touch this file (last touches:2f16e22,1aa6514,334f2c9,354f2a7,f385b4a,5364470).So the exposure has grown while the ceiling held: the margin this issue was filed about has been spent, not defended.
Relationship to #133 — near-duplicate, not proven identical
Same file, same constant, same 25-token headroom, same remedy family — but different blocks, and the arithmetic does not reconcile:
resolver_degradation,server.rs:9511-9514package_set_unconsulted_semantics,server.rs:4386-4391Two different disclosures on one thin margin, or one mechanism measured twice with an unreconciled discrepancy. Do not close either as a duplicate of the other — that discards one of the two measurements. The right move is to merge them into a single issue whose first task is reconciling the two figures, because "budget the disclosure" cannot be specified until it is known which disclosure.
Note the asymmetry in remedies: this issue's option 1 or 2 would cover both; #133's "wait for discovery" fix covers only #133. So if they are merged, merge into this one's remedy, not that one's.
Two more pressures on the same ceiling, measured today
linked_projectshas no cap and no fixture with any links, while each link adds ~106 tokens of semantics prose to this same overview payload.Three independent routes to overrunning a sub-1% margin, none currently visible to the gate — the #158 shape again.
🤖 Triage lane, 2026-09-06, master
45cf6e4code-index://docs/reason-codesis at 3,979 of its 4,000-token cap, so the next reason code this project mints cannot be documented #184FIXED, and the reconciliation with #133 is now MEASURED — neither triage's attribution was right, and the race #133 called "never observed" fires on the first attempt.
Lane worktree
/tmp/cosi-lane-budget, rebased ontoorigin/master(87a3fc8). Not pushed. The same change is reported on #133; the two are not duplicates and neither was closed as one.1. The reconciliation, taken directly off the wire
Both figures were re-measured by serialising the body with and without each key — never by differencing two whole payloads, never by substring search. Daemon leg, saturated fixture:
statestate_detailstate— a free-form daemon string with no length boundresolve_progressresolver_degradationplugin_activation.package_set_unconsulted_semanticsThe 2026-09-06 triage on this issue attributed the ~44-token load delta to
resolver_degradation. That is wrong.resolver_degradationis present in the settled state too — not load-conditional at all, a constant 62 tokens on this leg. The load-conditional pair isstate+state_detail, whose second half is an unbounded free-form string. #133's ~190–230 figure is correct and independent (measured 208).So: two different disclosures on one thin margin, plus a third (
resolve_progress) neither issue named. They do not reconcile because they were never the same measurement, and closing either as a duplicate would have discarded a real one.2. The margin was never 25 tokens — it was never a bound at all
Three runs of the unmodified test on the unmodified tree, minutes apart, on a machine carrying four other cargo lanes:
Three verdicts, one tree. The recorded basis said 4,275 with 25 tokens of headroom; that was a bound on the lucky payload. Summed against the content, a real client can be served ~4,450 tokens where this file's worst case says 4,300.
3. The fix: option 1 and option 2, together
crates/mcp-server/tests/overview_payload_budget_e2e.rs.measure_overviewnow settles before measuring. It waits out the package-discovery race (#133's fix) and the daemon's own non-ready state, then measures. The predicate for the first is "the block is gone", notpackage_set_consulted == true: on a project with no plugin package host that field is absent forever and is itself the measurement, so waiting fortruewould spin to the deadline on every ordinary project. Both deadlines expire loudly — a warning prints and the measurement runs, so the ceilings decide and nothing skips. (#131's lesson carried over: its first version polled a format that dropped the field, readfalseforever, and still reportedok.)OVERVIEW_CONTENT_MAX_TOKENS = 4_050over the payload with every state-conditional site removed;OVERVIEW_STATE_DISCLOSURE_MAX_TOKENS = 170over what a settled daemon spends saying what state it is in. Neither borrows the other's headroom. A compile-time assert holdscontent + allowance <= 4_300, so splitting a ceiling can never raise it by arithmetic nobody reviewed.Result, three consecutive runs under the same load: 4,133 / 4,133 / 4,133, content 3,989 every time, byte-identical. The instrument no longer moves. (After rebasing onto
87a3fc8and adding #149's two basis fields: 4,150 / content 4,006 / disclosures 144, stable.)4. What that bought
5. The 208-token block is bounded at its SOURCE
The cost of the wait is that the e2e can no longer see #133's block. Leaving it ungraded because the gate that used to trip over it stopped meeting it would be the #158 shape again, so
package_set_unconsulted_semantics_fits_the_overview_allowanceinserver.rsbounds the constant where it lives, with a floor under it as well as a ceiling. MUTATION (RUN): duplicate its last two sentences → RED,1031 characters (~258 est. tokens), over its 240-token allowance by 18.MUTATIONS (all RUN)
strip_pathnever strips. RED:not one of the 5 state-conditional sites was present, so the split below grades exactly what the single ceiling used to and #98 is unfixed.CONTENT is 4120 … over the 4050-token content ceiling by 70, breakdown naming the padding field.resolver_degradation.semantics). RED on the other bound only:the daemon-state disclosures cost 238 … over their 170-token allowance by 68.3 and 4 are the pair that proves the two ceilings are two: each fires on its own population and neither on the other's.
6. The same disease, found on the OTHER budget this triage named
The triage listed #160's startup payload at "16,530 of 16,555 — 25 tokens" as a third pressure. On
87a3fc8it is worse than that and worse in a new way: Windows CI measures 16,558 and fails; Linux measures 16,555 and passes. Same tree, fourteen bytes, and the verdict decided by the operating system — a threshold measured against a quantity it does not control, which is this issue's own diagnosis applied to a different variable. Fixed the same way (a platform-invariant product bound plus a separate deployment allowance summing exactly to the old total) and reported on #160 and #111.RESIDUALS, named rather than closed over
state_detailis a free-form daemon string with no length bound, on the first call an agent makes. Measured at 87 and 102 tokens. Nothing caps it.OVERVIEW_STATE_DISCLOSURE_MAX_TOKENS's doc, not gated.linked_projects(~106 tokens per link, no fixture with any links) is untouched and rides the same content ceiling, whose headroom is now 44.Gates
cargo fmt --all -- --check0 ·cargo clippy --workspace --all-targets -- -D warnings0 ·RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items0 ·cargo test --workspace --no-fail-fast0 ·COSI_E2E_LEG=daemonon this suite 0 · corpus ratchetexecuted=7, baselines untouched.🤖 Payload-budget lane, 2026-09-06
overview_payload_budget_e2eis safe from the unconsulted-package-set race by luck, not by design — 25 tokens of headroom against a ~190-token block #133CLOSING — verified on merged master
fc329a8, daemon leg RUNClose-out lane. Reconciled against #133 rather than closed as its duplicate: #133 was the package-set race, this is the load-dependent disclosure. Both are fixed, in the same file, by different mechanisms; both get their own closing evidence.
Both of your options were taken, not one.
crates/mcp-server/tests/overview_payload_budget_e2e.rs:OVERVIEW_STATE_DISCLOSURE_MAX_TOKENS = 170(:301) budgets the disclosure explicitly.OVERVIEW_CONTENT_MAX_TOKENS = 4_050(:264) bounds the payload with every state-conditional site removed, so neither bound borrows the other's headroom.:307-312) holdscontent + allowance <= OVERVIEW_SATURATED_MAX_TOKENS, so the split cannot become a raise by unreviewed arithmetic. The old total is still asserted (:1466) as the worst case.The disclosure is measured soundly, in the units it is subtracted from.
state_disclosure_chars()(:825-842) serialises the body with and without each key — never a substring search on the wire line, never a difference of two payloads. Sites that are absent are returned separately and named in the output rather than counted as zero (:1423), so "did not carry it" and "costs nothing" stay distinct.The load dependence is removed at the source, not tolerated.
measure_overview(:616-725) settles the daemon before measuring, with the reason at:681-690: content itself drifted 4,055 vs 3,994 mid-resolve, and "a ceiling cannot bound a population it keeps re-drawing". And:1436refuses to let the split silently degenerate back into one ceiling: "not one of the N state-conditional sites was present, so the split below grades exactly what the single ceiling used to and #98 is unfixed".RUN on this tree —
COSI_E2E_LEG=daemon, exit 0, 3 passed:Each gate now names the population it bounds. The verdict no longer turns on machine load.
Three residuals, recorded here so they are not lost, none of which this title still describes:
state_detailis an unbounded free-form daemon string on the first call an agent makes — measured at 87 and 102 tokens, nothing caps it.:284-292) are documented, not gated; only their largest term is bounded, at its source.OVERVIEW_SATURATED_MAX_TOKENS(:236-238) still asserts "HEADROOM, RE-MEASURED: 25 tokens, 4,275 against 4,300", which the settle-wait falsified, and:261records content headroom 61 while the run above gives 4,006 of 4,050 — 44.Those belong in a narrower issue, not under a title that says a correctness gate turns on machine load. It no longer does.
overview_payload_budget_e2eis safe from the unconsulted-package-set race by luck, not by design — 25 tokens of headroom against a ~190-token block #133