Repository navigation
Conversation
…railhq#833) A burst of sessions starting together spawned dozens of concurrent _update-check and _telemetry-flush helpers. The write-then-reread guards added in trailhq#346 exclude sequential callers only: N processes that read the stale window in the same millisecond all pass, all write, all spawn. claimWindow (util/state.ts) is the cross-process mutex: the winner creates the claim file exclusively (wx), every rival loses. A crashed winner's claim expires after 10 minutes so a dead process cannot block a window forever, a corrupt claim file counts as expired, and an unwritable home claims nothing — no claim, no spawn. Wired into maybeRefreshInBackground and maybeFlushInBackground ahead of their existing write-reread belts, which stay.
🌱 graft blast radius3 areas changed → 3 areas can be affected. 4 dependent symbols, depth 2. flowchart TB
A0(("CLI Upkeep Runner<br/>2 symbols"))
A1(("Claude Hooks<br/>1 symbol"))
A2(("MCP Server<br/>1 symbol"))
classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
class A0,A1,A2 reached;
Who knows this code — 4 people across 6 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 areaCLI Upkeep Runner — 2 symbols in 2 files
Claude Hooks — 1 symbol in 1 file
MCP Server — 1 symbol in 1 file
Test signal per changed area — 3 ✓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.
21 test suites also reference this code23 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 #833.
Root cause (what is left on current main)
#346 already made both helpers verify their timestamp write before spawning, which closes the sequential hole completely. What remains is the concurrent one:
needsRefresh/needsFlushread the stale window, then writecheckedAt/flushedAt, then re-read. N processes starting in the same millisecond all read stale, all write, all pass the re-read, and all spawn — a burst of session starts becomes a burst of helpers, which is exactly the storm #833 shows.Fix
claimWindow(claimPath, staleMs, now)(util/state.ts): the winner creates the claim file exclusively (wx— an OS-level race, not a read-modify-write), every concurrent caller loses.maybeRefreshInBackgroundandmaybeFlushInBackgroundahead of their existing write-reread belts, which stay.Distinct claim files per helper (
telemetry.json.claimvsupdate-check.json.claim), so a flush claim never blocks an update check.Tests (RED→GREEN, adversarial)