Repository navigation
Conversation
A grammar abort is a process-global, run-dependent failure, but the extraction cache stores it as a per-file entry keyed on content hash and replays it on every later build. An untouched file then stays broken forever, and a whole language can drop out of a graph that still exits 0 with a success line. Let an entry carrying an error fall through to the parse path instead of being replayed. The entry is still persisted, so the freshness probe does not report the file as new on every query; it just never stands in for a result again. Re-parsing costs only files that produced no nodes, and a run that succeeds repairs the entry. Fixes trailhq#312
🌱 graft blast radius1 area changed → 6 areas can be affected. 12 dependent symbols, depth 2. flowchart TB
A0(("Pull Request Review<br/>4 symbols"))
A1(("Graph Freshness<br/>3 symbols"))
A2(("Graph Initialization<br/>2 symbols"))
A3(("Viewer Build<br/>1 symbol"))
A4(("Tool Invocation<br/>1 symbol"))
AX(("1 smaller area<br/>1 symbol"))
classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
class A0,A1,A2,A3,A4 reached;
classDef tail fill:#EEF2F3,stroke:#9AA4A9,stroke-width:1px,color:#3A4247;
class AX tail;
Who knows this code — 3 people across 7 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 12 dependent symbols, grouped by areaPull Request Review — 4 symbols in 4 files
Graph Freshness — 3 symbols in 2 files
Graph Initialization — 2 symbols in 2 files
Viewer Build — 1 symbol in 1 file
Tool Invocation — 1 symbol in 1 file
Synchronous Execution — 1 symbol in 1 file
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.
32 test suites also reference this code40 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. |
- generic-extract.test.ts: the union merge of trailhq#196, trailhq#200 and trailhq#201 spliced their appended tests into one another and left the file unterminated. Rebuilt as trailhq#196's file plus trailhq#200's and trailhq#201's appended blocks verbatim. - The trailhq#139 test asserted that a cached parse failure is replayed without a re-parse; trailhq#317 (fixes trailhq#312) deliberately re-parses it instead and did not update the test. It now asserts the re-parse and that the error still comes back. - The trailhq#319 symlink test (trailhq#328) needed symlink privilege on Windows. Directory links are junctions there, as test/graph-root and test/ingest-fs already do, and the file-link case is skipped with a diagnostic when it cannot be created. Co-Authored-By: Claude Opus 5 <[email protected]>
* fix(init): keep machine-wide wiring when init omits a host init converges a repository by retracting every host not named in --agents, and that sweep also ran at machine-wide scope. So `graft init B --agents cursor` removed the user-level Claude hooks, shim and MCP entry and the Codex hooks that every other repository on the machine depends on. The init-time retract is now repository-only; `uninstall` still removes the machine-wide files. Ported from nishadherath/fork_Graft a241f6fb308d (MIT). Upstream issue trailhq/Trail-Code#482. Co-authored-by: Nishad Herath <[email protected]> * fix(cli-meta): start npm through the shell on Windows On Windows npm is the npm.cmd shim, which spawnSync cannot start without a shell, so `graft version` always read "unreachable", the update check stored nothing and `graft upgrade` failed with ENOENT. All npm calls now go through one helper that passes a joined command line to the shell on Windows (avoiding Node 24's DEP0190 warning) and spawns npm directly elsewhere. The tests put a fake npm first on PATH. Ported from ansidium/trail-code-se7en 4fa301e664a8 (MIT). Upstream issue trailhq/Trail-Code#487. Co-authored-by: ansidium <[email protected]> * fix: keep a --dir on another drive out of the repo's ignore files On Windows a --dir on another drive has no relative path, so relative() returns the absolute target. That passed the startsWith("..") outside-repo check and appended /C:/... to the repository's .gitignore and .ignore. Both writers now share repoRelativeDir, which rejects anything not strictly inside the root. Ported from nishadherath/fork_Graft 50122fbd500f (MIT). Upstream issue trailhq/Trail-Code#384. Co-authored-by: Nishad Herath <[email protected]> * fix(graph): re-parse a cached entry that holds a parse error A grammar abort is a process-global, run-dependent failure, but the extraction cache stores it as a per-file entry keyed on content hash and replays it on every later build. An untouched file then stays broken forever, and a whole language can drop out of a graph that still exits 0 with a success line. Let an entry carrying an error fall through to the parse path instead of being replayed. The entry is still persisted, so the freshness probe does not report the file as new on every query; it just never stands in for a result again. Re-parsing costs only files that produced no nodes, and a run that succeeds repairs the entry. Upstream issue trailhq/Trail-Code#312, PR trailhq/Trail-Code#317 (MIT). Cherry-picked from Ercaner1988/Graft 14c0bcd7d223d1cc92bcca3c5995adc236e497e8. * fix(ingest): stop spreading a child subtree into push in walkFilesystem `out.push(...walkFilesystem(full, includes))` turns the child's array into push()'s argument list, and V8 caps that at roughly 128k. A single unignored subtree with more paths than that throws "Maximum call stack size exceeded" at trivial directory depth — the message is about the argument list, not recursion. Only the git-less path reaches this: when listGitFiles returns null the walker collects every non-dot file first and filters by language later, so any large cache, browser profile or dataset directory in a repo that was never `git init`-ed is fatal. Appending in a loop removes the cap without changing what is collected or in what order. Two tests, deliberately split: - a cheap one that pins the accumulation itself (a wide, deep subtree outside Git comes back flat and complete). It runs everywhere and would catch a botched loop, but it cannot reach the argument cap. - one that actually reproduces the crash with 150k files. It fails with "Maximum call stack size exceeded" on the previous code and passes with this one. CI also runs windows-latest, where creating that many files is far slower, so it is skipped there. Measured while writing this: on Node 22 a spread of 125k elements still succeeds and 150k throws, and `--stack-size` does not move the boundary — it is an argument-count limit, not stack depth. Upstream issue trailhq/Trail-Code#314, PR trailhq/Trail-Code#315 (MIT). Cherry-picked from Ercaner1988/Graft 88a0442969adacc9353e36a85159c40fdd44a6e7. * test(ingest): run the argument-cap walker test on Windows The 150,000-file regression test for the walkFilesystem stack overflow was POSIX-only because creating the files is slow on Windows. It takes about 35 seconds there, fails with "Maximum call stack size exceeded" without the fix, and covers the platform graft is used on daily. * test(generic): expect a cached grammar failure to be re-parsed The re-parse fix for cached parse errors changes one assertion in the throwing-grammar test: an unchanged file whose last parse failed is now parsed again instead of replayed. The test's point still holds: the failure is cached as a failure, not an empty success, and the rebuild reports it again. * style(cli-meta): spawn npm with the repo's platform shell idiom Use one spawnSync call with `shell: win`, as signup.ts, cli.ts and shim-template.ts already do, and mark the PATH lookup of npm as intended for SonarCloud. Behaviour is unchanged: a joined command line through the shell on Windows, a direct spawn elsewhere. * style(cli-meta): mark the Windows npm shell spawn as reviewed for Semgrep The shell is required to start npm.cmd on Windows and every argument is a fixed token, so suppress the spawn-shell-true finding inline with that reason. --------- Co-authored-by: Ryan Duguid <[email protected]> Co-authored-by: Nishad Herath <[email protected]> Co-authored-by: ansidium <[email protected]> Co-authored-by: datrixlab <[email protected]> (cherry picked from commit 87663089946176a111f15b6c7f0e2b67b47af3bb)
Re-landed from #317 with the conflicts against main resolved; the contributor's fork couldn't take the merge commit. Co-Authored-By: Shrish Dwivedi <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
What
An extraction-cache entry that carries an
erroris no longer replayed.buildGraphre-parses it instead, so a failure that belonged to the run cannot outlive the run.Fixes #312
Why this option
@Ercaner1988 listed three. This is option 2 — persist the entry, never let it stand in for a result — and the other two both have a hole:
graft checkreports drift that a rebuild can't clear. Persisting without theerrorfield is worse still: the file would then replay as successfully parsed with zero nodes, and the error disappears instead of merely being wrong.Aborted()andRuntimeError: memory access out of boundsagainst messages that come out of wasm, which is a list to keep up to date and a silent wrong answer whenever it's out of date.Re-parsing is cheap by construction: the only entries it re-parses are the ones that produced no nodes. On a healthy repo that's zero files.
The self-healing property matters as much as the fix. A cache poisoned by a run that has since been fixed — a smaller workspace, a
--only-dir, more memory — repairs itself on the next ordinarygraft build. Today it needs someone to know that--no-reuseexists, which requires first noticing a graph that reports✓and exit 0.The docstring already promised this
ExtractEntry.errorinsrc/graph/extract-cache.tssaid:That is the invariant the whole file is built on — its header states it twice ("an incremental build must produce a byte-identical
wiring.jsonto a cold one"). A replayed abort breaks it: the cold build parseskanit.rsand gets 11 nodes, the incremental one replays a failure and gets none. The comment has been updated to say what the code now does.The same repo already gets this right one line up
A file that can't be read recovers by itself.
an unreadable file is still recorded, so it can't look new on every probechmods a file to000, builds twice, chmods it back, and asserts the next ordinary build indexes it — no--no-reuseneeded. That works because a read error is recorded withhash: "", which can never match, so the entry is retried every build.A file that can't be parsed gets a real hash, so it is never retried. Same cache, same kind of entry, opposite lifetime — and the parse case is the one that can fail for a reason that has nothing to do with the file.
Test
One test in
test/graph-incremental.test.ts, which is where that invariant lives.It builds cold, then poisons the memo the way a grammar abort does — the entry keeps the file's real content hash, so nothing about the file looks stale — and rebuilds normally. It asserts the three things the report distinguishes:
wiring.jsonis byte-identical to the cold build (the nodes come back)languagesstill contains the language (the symptom:[python]vs[python, rust])errorsis empty (the stale message is not re-reported), and the entry on disk no longer carries one, so the next build is cheap againTwo-way: reverting only
src/graph/build.tsfails it on the first assertion.Not in scope
The report also suggests warning when a language that has files in the index produces zero nodes, and surfacing it in
graft check. That's a real gap and it stays open with #312 — but it's a new signal with its own false-positive question (a language whose files are all.d.ts-shaped, say), not part of making the cache honest. Happy to follow up separately if you want it.