Files
codegraph/__tests__/fixtures/tail-render-ts/README.md
T
Colby McHenry 89c53ddf24 fix(explore): guarantee an agent-named symbol renders, wherever it sits (CG-38)
`codegraph_explore` never returned `queueMessage` (L1087) or
`flushQueuedMessages` (L1102) from a 1,414-line file, on a symbol bag or a
prose question, even with that file at rank #1 holding 67% of the envelope —
the agent got a same-stem `QueuedMessage` interface at L70 and had to Read the
file for the functions it had named. Pre-existing at every build including
pre-epic (controlled bisect, index held fixed).

Two independent causes:

1. `buildFlowFromNamedSymbols` returns the Flow prose AND the set of node ids
   the agent named — and the latter is the whole guarantee, since it injects a
   named def into its file's cluster ranges at importance 9. Its bail-outs
   returned EMPTY, zeroing the identity whenever there was nothing to PRINT.
   Two sibling closures that never call each other produce no chain, no synth
   hop and no boundary, so both defs lost importance 9 and the file rendered
   from its head. `identityOnly()` now separates the two, gated on
   shape-precise tokens so a prose word that exact-matches a callable cannot
   promote itself.

2. The ceiling trim filled in SOURCE order, so an over-ceiling render always
   dropped the END of a large file first. The shrink HAD kept both symbols
   (1022-1121); the trim cut back to 839. `windowToCeiling` now takes the
   spine call site plus every importance>=9 member as focus lines, tries the
   full ceiling first, and splits the held-back reserve evenly with
   carry-forward — greedy-in-source-order reproduced the bug one level down.

The shrink's loose size estimate is left alone deliberately, and the comment
now says why: making it exact was built and measured WORSE (it stops at the
last member that fits whole and the released bytes carry forward to
lower-ranked files, costing payroll-go's `s.store.Upsert`). `bound()` clamps to
the ceiling anyway, so the slack costs no bytes; it just must not pick the
survivors, which is what the trim now handles.

The measurement gap this closes: every existing probe is aggregate — envelope
share, per-file spend, source totals, file counts — and all are green on a
response that returns 25K from the right file and omits the named function.
`probe-named-symbol.mjs` checks the definition LINE against the response's
rendered lines, per symbol.

Suite envelope byte-identical to main on all six repos; probe-allocation 4/4,
no starvation flags; 180 files / 2,997 tests green. Fixture: 7/7 fail on main,
7/7 pass here, deterministic over 4 runs per arm.
2026-08-06 21:11:51 -05:00

2.4 KiB
Raw Blame History

tail-render-ts — CG-38

An agent-named symbol sitting in the TAIL of a large file must render.

This mirrors the geometry of the reported file (a 1,414-line Svelte chat store) closely enough that the same two defects reproduce, and it is that geometry — not any individual line — that the fixture exists to hold:

line why it matters
QueuedMessage (interface) 70 the DECOY. Same stem as the query token, near the top, cheap to render — it is what the broken build returned instead of the functions.
createSessionStore (function) 1041417 the ENVELOPE. Spans ~92% of the file, and function is deliberately not in ENVELOPE_KINDS (CG-27), so every symbol inside merges into ONE cluster that must then be shrunk and trimmed.
handleStreamMessage ~554 a 290-line god-method in the middle, so the head of the file has plenty to spend the budget on.
queueMessage 1088 TARGET. Past line 1,000.
removeQueuedMessage 1096 TARGET.
flushQueuedMessages 1102 TARGET. Past line 1,000.

Two more pieces are load-bearing:

  • queueMessage never calls flushQueuedMessages (both push to / drain the same array instead). That absence is what produced no call chain, no synthesized hop and no dispatch boundary — and so made buildFlowFromNamedSymbols throw the named-symbol identity away along with the narrative it had nothing to print.
  • types/worker-configuration.d.ts — 2,500 lines of generated Wrangler ambient types, carrying the Generated by wrangler. DO NOT EDIT. banner so the ranker flags and penalises it. It is what makes the fixture able to test the issue's index-dependence lead: a penalty on this file moves maxGraph, which moves the 6% relevance gate, which moves every other file's allowance — and must still not cost the top-ranked file the definitions the agent named.

src/lib/session-store.ts is machine-generated to hit those line numbers with real, extractable TypeScript. If you need to change it, change the geometry (the target line numbers, the closure span, the decoy's position) rather than editing individual lines — the fixture-shape assertions in __tests__/explore-named-symbol-render.test.ts will tell you if it has rotted.

Gate: __tests__/explore-named-symbol-render.test.ts. Probe: node scripts/agent-eval/probe-named-symbol.mjs. Numbers: docs/benchmarks/explore-tail-render-cg38.md.