Repository navigation
Conversation
…tes (trailhq#635) The host can SIGKILL a prompt hook mid-rebuild (Claude Code's own hook timeout does exactly this). The lock file survives naming a pid that no longer exists, and lockStale only consulted pid liveness after LOCK_STALE_MS — so for the next five minutes every query waited out the lock and answered from a stale graph, exactly the trailhq#635 repro. The pid check now runs first: a dead owner holds nothing, at any age. The age rules keep protecting live owners untouched — a slow first build keeps its lock past LOCK_STALE_MS, any lock past LOCK_MAX_MS yields whoever holds it (the pid may be a recycled number), and a payload with no readable pid keeps the old age-only rule. lockHeldByOther moves with it: a fresh lock naming a dead pid no longer reads as "another process is building", so the next caller takes over and rebuilds instead of waiting out a corpse. Scope note: the child-budget half of trailhq#635 (settings "timeout" units, compounding trailhq#283) is a separate surface and is not touched here.
🌱 graft blast radius1 area changed → 1 area can be affected. 2 dependent symbols, depth 2. flowchart TB
A0(("Query Freshness Gate<br/>2 symbols"))
classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
class A0 reached;
Who knows this code — 1 person 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 2 dependent symbols, grouped by areaQuery Freshness Gate — 2 symbols 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.
Open the interactive graph → — click an area to see its dependent symbols at file:line. |
Fixes #635 (the stale-lock half; see scope note at the end).
Root cause
lockStaleonly consulted pid liveness after the LOCK_STALE_MS floor (if (age < LOCK_STALE_MS) return false;came first). A SIGKILLed prompt hook leaves a seconds-old.sync.locknaming a pid that no longer exists — and for the next five minutes every query treats it as held: it waits, then answers from the stale graph, exactly the repro's "lock survived with a dead pid; next ask waited ~3.8 s".Fix
In
lockStale(util/state.ts), the pid check now runs before the age floor:lockHeldByOthermoves with it: a fresh lock naming a dead pid no longer reads as "another process is building", so the next caller takes over and rebuilds instead of waiting out a corpse. The one existing test that asserted the old behavior (dead pid's fresh lock "is still another's") moved with the change, and gained a genuinely-live-child case in its place.Tests (RED→GREEN, adversarial)
lockHeldInfalse,acquireLocktrue — reclaimed immediately (RED before);lockHeldByOther: a genuinely live child process (async spawn, killed infinally) reads as "wait"; an exited pid's fresh lock reads as "take over".Scope note
The child-budget half of #635 — the settings
"timeout": 60read as milliseconds and floored to 4000 ms (compounding #283), and the inline rebuild exceeding that budget — is a separate surface from the lock; this PR deliberately does not touch it.