Repository navigation
Description
Field report (founder's machine, 21k-file corpus, confirmed live): the 0.9.20 menubar never completed a single payload fetch after upgrade. Children spawned every ~50-60s, each killed at exactly 45s with ~1.2s CPU (blocked on the refresh lock, not parsing). 0.9.18/0.9.19 were fine.
Chain of causes (diagnosed with live evidence)
- Tripwire: CACHE_VERSION 5→7 in 0.9.20 (sessions: attribute PR spend per turn instead of per session #790/sessions: fold subagent runs into PR attribution #791) invalidates the whole session cache → full rehydration (>45s on large corpora).
- Fixed kill:
mac/Sources/CodeBurnMenubar/Data/DataClient.swiftspawnTimeoutSeconds = 45, SIGTERM→SIGKILL +0.5s — kills the rehydrating child mid-transaction. - Lock leak:
src/cache-refresh-lock.tshas no signal cleanup (unlike session-cache's hydrating.lock), so the killed holder leavessession-refresh.lockowned by a dead pid. - Livelock:
DEFAULT_WAIT_MS = 30_000 < DEFAULT_STALE_MS = 90_000— a waiter always gives up before it may steal an abandoned lock. Every next spawn burns 30s waiting, has ~15s left, dies; a takeover winner is killed mid-refresh, minting a fresh stale lock. Observed: lock rotating through a series of dead menubar pids.
Contributing: the resident serve child dies at its fixed 60s warm-up on large corpora and ensureStarted() has no re-entry — serve stays dead for the app's lifetime; 4 orphaned serve --stdio processes (ppid 1) found, so the stdin-close-kills-child invariant does not hold. Combined scope puts a 3s-connect/15s-per-peer device fetch on the badge path (latent; measured 47s with peer down).
Fix plan (all-users)
- A. Swift menubar watchdog (port of fix(app): no-output watchdog replaces fixed timeouts; graceful kills; cold floor everywhere; orphan serve reaping #1096): set
CODEBURN_PROGRESS=1on spawns, watch stderr keepalives, silence-window watchdog + cold floor + hard ceiling instead of fixed 45s; graceful SIGTERM→wait→SIGKILL. Same for the serve warm-up (no fixed 60s), andensureStarted()re-entry so a dead serve child can be relaunched. - B. Lock signal cleanup:
cache-refresh-lock.tsarms SIGINT/SIGTERM cleanup exactly assession-cache.tsdoes for hydrating.lock. - C. Wait/stale relationship: a waiter must be able to outlive an abandoned lock — use the heartbeat (frozen mtime) for staleness and/or wait beyond the stale gate.
- D. Serve orphan prevention: make the stdin-close invariant actually hold (and/or mac-side reaping mirroring fix(app): no-output watchdog replaces fixed timeouts; graceful kills; cold floor everywhere; orphan serve reaping #1096's electron pidfile reap).
The merged perf stack (#1097 partial saves, #1105/#1108/#1109) already shrinks the window, but without A-D the livelock recurs on any corpus where one refresh crosses the ceiling (e.g. every future cache bump).
Activity
fix(menubar): no-output watchdog, lock signal cleanup, dead-pid takeo…