Repository navigation
fix(explore): render the symbol you asked for, and charge what you spend - #223
Merged
Merged
Conversation
Four selection and budget defects, all reachable from one code path. A named symbol could vanish. Asking for a symbol by name gave back 615 bytes, no source sections at all, and no sign anything was missing — while `query` found it immediately. Two independent escapes produced that: a file whose whole section is unaffordable was rejected entire, before any windowing existed to narrow it, and a file that fell through to clustering had its first cluster accepted unconditionally and then thrown away for being oversize. Named symbols now carry a protected focus, a whole-file section that cannot be afforded is windowed around it rather than dropped, and a first cluster is bounded instead of trusted. A later cluster that did not fit was skipped whole, so a file could contribute its header and nothing else. Later clusters now shrink to what the remaining room allows, and the bound is applied to the finished section rather than to the cluster bodies alone — the admission test compares the section, so a ceiling on the bodies leaves the frame unpaid and the windowed section is discarded anyway. An ambient declaration file that nothing depends on could take the top slot on a flow query, pushing implementations down the page. Such files are now damped, combined with the generated-file signal by taking the stronger of the two, so a file that is both is penalised once rather than twice. Files whose type the query names are exempt. The budget was wrong in both directions at once: every section was charged a flat 200 characters instead of its real cost, while the epilogue was appended after the loop and charged nothing. Fixing either alone makes overflow more likely, so both land together, with the epilogue's frame reserved up front and its pointer block sized to the room that is actually left. The hard-ceiling cut consequently becomes unreachable — it sits above the budget at every tier — which is why the truncation note no longer eats the very text that says what was omitted. CG-27 is deliberately not ported: upstream measured it dropping delivered characters from 7,539 to 397 and rejected it.
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #223 +/- ##
==========================================
+ Coverage 95.31% 95.35% +0.03%
==========================================
Files 141 141
Lines 78022 78711 +689
==========================================
+ Hits 74364 75051 +687
- Misses 3658 3660 +2
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tier 5 of the post-
v1.5.0upstream sync — upstream's CG-24…CG-38 selection/budget epic, minus CG-27 which upstream measured and rejected (delivered characters 7,539 → 397, inner closures 7/11 → 0/11).A named symbol could vanish entirely
Asking for a symbol by name returned 615 bytes, 0 source sections, 0 definition lines — while
queryfound it immediately. Two independent escapes produce that, and they need separate fixes because they take different branches:Escape A is the subtle one:
whole_file_max_chars = 3 × max_chars_per_fileis not derived frommax_output_chars, so whole-file eligibility says nothing about affordability. It needs the target file not to rank first — at the cap an 11,375-byte file renders to 12,160 against a 12,780 budget, affordable as the first file by only 201 bytes, and any earlier admitted file erases that margin.Measured:
1..51+598..620A later cluster that did not fit was skipped whole
So a file could contribute its header and nothing else — 848 B with
processPayroll(function)in the header and no body. Later clusters now shrink to the remaining room: 4,138 B with both bodies.The bound applies to the finished section, not the cluster bodies: the admission test compares
section.len(), so a ceiling on bodies leaves the frame (header + lang + fences, measured 168 B) unpaid and the windowed section is discarded anyway. Hence.saturating_sub(section_frame)sits outside themin.Ambient declarations could take the top slot
A
.d.tsthat nothing depends on outranked implementations on a flow query. Now damped, combined with the generated-file signal byminso a file that is both is penalised once, not twice — verified arithmetically: generated-only and generated+ambient both weigh 3, so their order falls to the path tie-break, and non-ambient files stay order-isomorphic to today's ranking.Order became
upload.ts, env.d.ts, chunker.tswith section sizes 228 / 966 / 138 byte-identical — a pure reorder. That is why the acceptance criteria assert rank, not share: item 14 cannot move a share, and an earliershare < 0.50assertion was not just unreachable but actively wrong — a lazy "drop.d.tsfromfile_order" fix scores 0% and would have passed it, whilelen(names) == 3andsize == BASEcatch it.The budget was wrong in both directions at once
Every section was charged a flat 200 characters instead of its real cost, while the epilogue was appended after the loop and charged nothing. Fixing either alone makes overflow more likely, so both land together with the epilogue's frame reserved up front and its pointer block sized elastically:
The hard-ceiling cut consequently becomes unreachable —
hard_ceiling = min(max_output_chars × 1.5, 25000)exceeds the budget at every tier (19,500>13,000; 25,000>18,000; 25,000>24,000) — so the truncation note no longer deletes the very text saying what was omitted.One existing test had to be rerouted, and it took three attempts
ext_explore_banner_ignores_marker_collision_from_retained_sourceasserted "the hard-ceiling cut must run", a premise this change removes by construction. Its real invariant — a spoofed#### pathmarker in retained source must not cause a dropped file to be cited — is intact and now pinned through admission-drop instead.Two replacement assertions were inert before one discriminated, and I initially mis-measured this myself: my revert kept the 6-symbol pointer cap, and with the cap in place every pointer line fits regardless, so nothing could discriminate. The minimal failing set is
{cap, elastic block}— matching the plan's own "the cap bounds a line, elasticity bounds the block, both are needed". Verified independently:The docstring records the sensitivity table and names where the real-cost charge and the reserve are pinned, so nobody mistakes this test for budget coverage.
Verification
make cigreen: 133 suites / 3,426 passed / 0 failed (baseline 133 / 3,408).reference/completely clean including untracked — no extraction-golden and no MCP-fixture movement.CURRENT_EXTRACTION_VERSIONstays 9; this is a query-time surface.callsself-edges intact; no#[ignore], no deleted assertion, no dependency change.explore_tiny_tier_budget_drops_whole_methods_not_mid_methodoutput diffed against the pre-change binary: byte-identical.crates/codegraph-mcp/src/engine.rsandcrates/codegraph-mcp/tests/golden_mcp.rs.The plan cleared eight review rounds and seventeen blockers; two of those rounds corrected me rather than the plan.