Repository navigation
Conversation
…as prose The PostToolUse accumulator sweeps JSON.stringify(tool_response) for the savings footer, and the reader matched the pattern anywhere — a document that merely mentioned "[graft] tokens saved ≈ …" added its number to the session total (one session jumped +13,509 from reading such a file). The reader now keys on where the footer can legitimately sit: start of output (a stringified payload's opening quote included — payload() unwraps tool_response, so a string result serialises with no field name before it), after a newline, or right after a JSON field's `:"` — and skips a footer preceded by a quote or backslash that is not one of those. The locale-truncation half of the report is already fixed on main (trailhq#338 pinned the writer to en-US), so the reader keeps accepting only comma groups. Fixes trailhq#624
🌱 graft blast radius1 area changed → 1 area can be affected. 4 dependent symbols, depth 2. flowchart TB
A0(("Session Metrics<br/>4 symbols"))
classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
class A0 reached;
Who knows this code — 3 people across 2 areas
Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no All 4 dependent symbols, grouped by areaSession Metrics — 4 symbols in 2 files
Test signal per changed area — 1 ⚠Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.
3 test suites also reference this code4 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.
Open the interactive graph → — click an area to see its dependent symbols at file:line. |
Fixes #624 (part 2; part 1 is already fixed on main by #338/#345 — the writer is pinned to
toLocaleString('en-US'), so footers never carry decimal commas anymore).Problem
sumSavingsFootersmatched the footer pattern anywhere in the blob the PostToolUse accumulator sweeps (JSON.stringify(tool_response)). Any tool output that merely quotes a footer line — a document that discusses graft, a task description containing"[graft] tokens saved ≈ …"— was added to the session total (the report's session jumped +13,509 from reading such a file).Fix
The reader keys on where the footer can legitimately sit, via a shared, documented
SAVINGS_FOOTER_REconstant:^), after a newline, glued after content (callers …[graft] …);:"[graft] …") — how a stringified payload renders a string field;"[graft] …"—payload()unwrapstool_response, so a string result serialises with no field name in front).It skips a footer preceded by any other quote or a backslash — exactly the prose-quotation shapes (
wrote "[graft] …",\"[graft] …"inside stringified payloads). Since the writer is locale-pinned, the reader keeps accepting only comma groups.Tests
In
test/session-metrics.test.ts: the report's exact case (raw and stringified) returns 0; field-boundary, escaped-newline, bare-string, glued-after-content, and multi-footer (both brands) shapes still count. Full suite: 4550 tests, only the six failures already present on cleanmain(49d36b7) — unchanged and pre-dating this branch.Note
A document that prints the footer at a LINE START (e.g. a quoted block on its own line) is still indistinguishable from real tool output — the same limit the report's local patch had. Flagging it here rather than over-fitting the regex.