Repository navigation
Description
Three sequant run invocations were killed by an external SIGTERM mid-run. Investigation identified the trigger; the timer's owner is still unidentified.
Finding
A nested phase claude that hangs after finishing its turn is terminated at ~106s (±1s) from spawn, and the termination takes down the entire process tree — including the parent sequant run.
A nested claude that exits cleanly is never killed, at any lifetime.
Evidence
mDNSResponder stamps every claude process by PID, giving exact lifetimes (/usr/bin/log show --predicate 'process == "mDNSResponder" AND eventMessage CONTAINS "claude"'):
| PID | lifetime | outcome |
|---|---|---|
| 21762 | 107.08s | KILLED (parent died 01:21:57) |
| 33738 | 106.23s | KILLED (parent died 01:36:05) |
| 40181 | 105.41s | KILLED (parent died 01:39:36) |
| 17241 | 316s | exited normally — no blanket cap |
| outside-session phase | 131.7s | clean exit — longer than 106s, survived |
Spread across the three deaths: 1.7s.
The discriminator is not lifetime, session, repo, or -Q. It is whether the agent hangs on exit. From .entire/logs/entire.log, the Stop-hook to SessionEnd gap:
- healthy phase: 0.36s
- the three killed phases: 96.3s / 58.0s / 92.7s
One killed phase did ~9s of actual work, then sat idle ~93s with all ~12 MCP servers still up. At each death every MCP server quit inside a 60ms window — simultaneous teardown, not a cascade.
Ruled out (each by direct measurement)
- Idle-output timeout. A background task that printed one line then stayed silent 300s completed normally. Independently, one victim survived a 107s intra-run silence and died after a 108s one — a threshold cannot sit in a 1s window crossed in both directions.
- Lifetime cap. Two runs survived 26m54s and 22m49s.
CLAUDE_STREAM_IDLE_TIMEOUT_MS. Governs the model API response stream and aborts/retries a request; it does not SIGTERM a child.- sequant signalling itself. Five signal-capable sites; the only cross-process SIGTERM requires both
--forceand--signal-other(CLI-only, unreachable from settings or env) and is self/parent-guarded at the syscall. No timeout constant between 100-300s exists anywhere in the source. - Hooks. Zero
kill/pkill/killall/trapacross all four hook scripts and both mirrors. Verified the hooks did fire inside the nested agent. entireCLI. Logged "no files modified during session, skipping checkpoint" on every turn; no git operations.git reflogis empty at all three death timestamps.- launchd. Only
com.admarble.pm-orchestratorcan kill; wrong schedule, and it only signals the PID in its own lockfile. - jetsam / memory pressure / sandbox denials / TMOUT / ulimit — all checked, all negative.
- Concurrent process-group kill from the test suite. The successful outside-session run began 6 minutes AFTER the last death; no overlap.
- Stale PID / lock reuse, and the MCP group-kill at
src/mcp/tools/run.ts:893(detached: trueis set at:750, sokill(-pid)targets a genuine group leader).
Not reproducible on demand
A later in-session run with the identical -Q flags cleared spec and ran 8m53s into exec before being stopped manually. The hang is intermittent, which is why an outside-session run of the same command succeeded — nothing about being outside the session was protective.
Acceptance Criteria
- AC-1: The owner of the ~106s timer is identified, by tracing signal delivery during a reproduction (
sudo dtrace -n 'proc:::signal-send /args[2] == 15/') or equivalent. - AC-2: The cause of the post-turn hang is identified; the first hypothesis to test is MCP server shutdown, since every hung session had ~12 servers up including
npm exec sequant@latest serve(a registry fetch per phase). - AC-3: A phase run with
--no-mcpis compared against the 0.36s healthy Stop-hook-to-SessionEnd baseline, establishing whether MCP shutdown causes the hang. - AC-4: When a run is terminated by an external signal, the failure is surfaced to the user as an abort with its cause rather than silently truncating.
Related defects found during this investigation
- A SIGTERM'd run is logged as a success.
run-2026-07-29T06-37-48-*.jsonrecordsissues[0].status: "success"andsummary.passed: 1for a run with zero completed phases andtotalDurationSeconds: 0. Aborted phases leave nophases[]entry and noerrorContext, so nostdoutTailsurvives for diagnosis. - Truncated teardown leaks locks. When the shutdown is escalated to SIGKILL mid-cleanup, "Release issue locks" does not complete and
.sequant/locks/*.lockplus.sequant/pids/*.pidare left behind. One run left the worktree corrupted with every tracked file showing as deleted. - Stale locks with recycled PIDs read as fresh.
.sequant/locks/505.lock(pid 28809, 2026-05-14),708.lock(pid 97866, 2026-06-03) and803.lock(pid 58609, 2026-07-25) all hold long-dead PIDs.classifyStalenesstreats a same-hostname live PID as fresh, so a recycled PID silently blocks those issues from ever running.
Environment note
log is shadowed by a zsh function on the affected machine — log show ... fails with (eval):log:1: too many arguments. Use /usr/bin/log.
Activity
admarble commentedon Jul 29, 2026
#856 — Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run
Open
────────────────────────────────────────────────────────────────
→ PARK — AC-1/2/3 are diagnostic measurements that need a live reproduction; the body states the hang is intermittent and not reproducible on demand
Resume after: a hang is captured live under
sudo dtrace -n 'proc:::signal-send /args[2] == 15/', or AC-4 and the three related defects are split into their own issues────────────────────────────────────────────────────────────────
⚠ AC-1/2/3 need a live reproduction under sudo dtrace; the body states the hang is not reproducible on demand
⚠ AC-4 plus the three related defects (SIGTERM'd run logged as success, leaked locks, recycled-PID stale locks) are independently automatable — splitting them unblocks work the diagnosis ACs hold up
────────────────────────────────────────────────────────────────
admarble commentedon Jul 29, 2026
Investigation: the ~106s killer is Claude Code's bg-pty watchdog (group SIGKILL), not anything in sequant
Follow-up investigation, 2026-07-29. The original sweep covered sequant's source, hooks, launchd, and the OS — everything except Anthropic's own code. That's where the killer is.
AC-1 candidate answer:
[bg-pty]host-dead watchdog in Claude Code 2.1.220The installed
claudebinary (2.1.220, Mach-O; the same code ships inside@anthropic-ai/claude-agent-sdk's CLI) contains a background-task PTY subsystem, "bg-pty". Background Bash tasks run under a detached helper (claude --bg-pty-host <sock> <cols> <rows> -- <cmd>,detached: true,argv0: "claude bg-pty-host"); a claude session is the client that connects to the sock. Extracted from the binary (minified, reformatted):Constants:
xhp=30(attempt cap), connect backoff ladder[50,100,250,500,1000,2000]ms. The same subsystem has a teardown path that does groupSIGTERM→ 5s grace → groupSIGKILL, and an adopt-mode short-circuit (ENOENT on adopt — sock file externally deleted; respawning) that jumps the counter straight to 30. Telemetry names for upstream searchability:tengu_bg_ptyhost_crash,tengu_bg_adopt_sock_unlinked,tengu_bg_revival_guard.Why this matches every measurement:
process.kill(t,0)throw → graceful branch → never killed, at any lifetime. This is the only mechanism found anywhere on the machine that keys on exactly that state.claude, all its MCP servers, and the parentsequant runshare one pgid (specimen:sequant run 771pid 9403 = pgid of itself, the nested claude 12659, and bothsequant serveprocesses). One group signal produces the whole observed death pattern.Victims identified by transcript — all three, to the second
2b7de5d978565ed5a5d0bda3Last-entry timestamps equal the three parent-death times (01:21:57 / 01:36:05 / 01:39:36 local) exactly.
Two structural facts fall out:
tail -f <tasks>/b6byn5iih.output(started 01:34, mid-death-window) is still running, orphaned, parented to the still-alive interactive claude (pid 70335). So each victim tree lived under a bg-pty host's process group — a group the interactive session's client machinery holds a kill switch for.The post-turn hang and the kill are then one defect, not two: the same client machinery that can't connect is what blocks SessionEnd (the ~12 MCP servers still being up is a downstream symptom of never reaching teardown, not the cause). This redirects AC-2's first hypothesis away from MCP shutdown.
Corrections to the ACs
args[2] == 15captures only SIGTERM; the primary kill here is a group SIGKILL (a SIGTERM→SIGKILL path exists in the same subsystem, so capture both:args[2] == 15 || args[2] == 9). "External SIGTERM" in the original finding was inferred, not captured — a 15-only capture may record nothing and falsely exonerate.--no-mcpcontrol is still worth running, but the sharper repro matrix is: {backgrounded vs foreground launch} × {concurrent same-cwd interactive session vs none}. Prediction: foreground launches from a plain shell never die (confirmed by the surviving specimens — the 131.7s and 316s clean runs, and today's terminal-launched run 771); backgrounded launches with a same-project interactive session are the vulnerable configuration.Upstream
If a live capture confirms, this is a Claude Code bug to file upstream: the "treating host as dead" heuristic group-SIGKILLs a process tree whose host is alive-but-busy, and the process group it kills can contain the caller's own ancestors. Reference the extracted strings and telemetry names above; version 2.1.220.
Workaround available today
Until confirmed/fixed upstream: launch long
sequant runs from a plain terminal (or via the MCPsequant_runtool), not as a backgrounded Bash task inside an interactive Claude session. Every observed death was a backgrounded launch; no foreground launch has ever died.admarble commentedon Jul 29, 2026
#856 — Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run
Open
────────────────────────────────────────────────────────────────
Supersedes prior assess from 2026-07-29 (PARK)
→ PARK — The ~106s killer is now identified as Claude Code 2.1.220's [bg-pty] host-dead watchdog issuing a group SIGKILL — an upstream defect, not a sequant one. AC-1/2/3 remain diagnostic measurements needing a live reproduction, and the body states the hang is intermittent and not reproducible on demand.
Resume after: a live capture confirms the bg-pty group SIGKILL, or AC-4 and the three related defects are split into their own issues
────────────────────────────────────────────────────────────────
Cleanup:
gh issue edit 856 --add-label bug # unlabeled
────────────────────────────────────────────────────────────────
⚠ New 17:01 investigation redirects AC-2 away from MCP shutdown — the post-turn hang and the kill are one upstream defect, not two, with the ~12 MCP servers a downstream symptom of never reaching teardown
⚠ AC-1's dtrace predicate is wrong as written: the primary kill is a group SIGKILL, so capture args[2] == 15 || args[2] == 9 — a 15-only capture may record nothing and falsely exonerate
⚠ AC-4 and the three related defects (SIGTERM'd run logged as success, leaked locks, recycled-PID stale locks) are independently automatable — splitting them unblocks work the diagnostic ACs hold up
⚠ Workaround available today: launch long sequant runs from a plain terminal or via the MCP sequant_run tool, never as a backgrounded Bash task inside an interactive Claude session
────────────────────────────────────────────────────────────────
admarble commentedon Jul 30, 2026
Plan (/spec) — scoped to AC-4 + the three related defects
Complexity: Standard (4 ACs, 1 directory) · Scope decision: AC-1/AC-2/AC-3 are diagnostic measurements requiring a live reproduction of an intermittent hang under
sudo dtrace. They are not automatable and stay unchecked. This run implements AC-4 and the three related defects from the issue body, and lands the AC-1/AC-2 investigation findings into the repo so they survive outside a GitHub comment.AC Quality Check
Linter: ✅ all 4 ACs clear and testable. But the linter does not model feasibility — AC-1/2/3 each require capturing a non-deterministic event that the issue body itself states is "not reproducible on demand". That is a scoping problem, not a wording problem.
Scope Assessment
Non-Goals: not present in the issue body. Declared here:
[bg-pty]watchdog — that is Anthropic's defect (v2.1.220), tracked for upstream filing..sequant/pids/*cleanup — those belong to the relay subsystem, which is dead code (Interactive relay: bidirectional communication with headless runs #383).Verdict:⚠️ SCOPE_WARNING (missing Non-Goals — supplied above). Quality loop auto-enabled.
Root causes located
Each related defect traced to a specific line. All three are variants of one pattern: absence of evidence is being read as evidence of success.
src/lib/workflow/log-writer.ts:125—startIssue()seedsstatus: "success"optimistically. If no phase ever completes,logPhase()never runs, soderiveIssueLogStatus()never overwrites it. TheFinalize run logsshutdown task then callscompleteIssue()for every in-flight issue and persistssuccesswithphases: [],totalDurationSeconds: 0. Reinforced byrun-log-schema.ts:457—deriveIssueLogStatus([])also returns"success"for zero phases.src/lib/workflow/run-orchestrator.ts:961-971registersRelease issue locksplus a syncprocess.on("exit")net. Neither can run underSIGKILL— uncatchable by construction. The only available fix is recovery on next start, which defect 3's fix provides.src/lib/locks/lock-manager.ts:137-140— the same-host branch returnsnull(fresh) wheneverisPidAlive(pid)is true, with no age bound at all. A 2026-05-14 lock whose PID 28809 has since been recycled reads as fresh forever, permanently blocking #505. Confirmed live:505.lock,708.lock,803.lockare 76 / 56 / 4 days old.src/lib/shutdown.ts:219-221—gracefulShutdown()prints"Interrupted. Cleanup complete."and callsthis.exit(0). A run killed by an externalSIGTERMtherefore exits 0 with no cause named, andrunCommand()never reachesdisplaySummary(), so the existingabortReasonrendering path (run-display.ts:119) is never reached.Acceptance Criteria
AC-1: Owner of the ~106s timer identified
Verification: Manual (live capture) — NOT MET, out of scope this run
Candidate answer already recorded: Claude Code 2.1.220's
[bg-pty]host-dead watchdog (xhp=30failed connects →process.kill(-pid, "SIGKILL")). Confirming it requires catching an intermittent hang undersudo dtrace -n 'proc:::signal-send /args[2] == 15 || args[2] == 9/'. This run persists the evidence todocs/incidents/856/and leaves the box unchecked.AC-2: Cause of the post-turn hang identified
Verification: Manual (live capture) — NOT MET, out of scope this run
The 17:01 investigation redirects this away from MCP shutdown: hang and kill are one upstream defect, with ~12 live MCP servers a downstream symptom of never reaching teardown. Recorded, not proven.
AC-3:
--no-mcpcompared against the 0.36s baselineVerification: Manual measurement — NOT MET, out of scope this run
Deliberately excluded: per AC-2's redirect, MCP shutdown is no longer the leading hypothesis, so this control now tests the wrong variable. The sharper matrix (
{backgrounded vs foreground} × {concurrent same-cwd session vs none}) is recorded in the incident doc.AC-4: External termination surfaced as an abort with its cause
Verification: Unit Test + Integration Test
Scenario: Given a
sequant runwith an in-flight issue → When the process receivesSIGTERMfrom outside → Then the CLI prints an abort banner naming the signal and its likely cause, exits128+signum(143), and the run log records the issue as a failure marked aborted carrying the signal — notsuccess.Assumptions:
SIGKILLis uncatchable; AC-4 is satisfiable only for catchable signals. TheSIGKILLcase is covered indirectly by defect 2/3's recovery-on-next-start.Related defect 1: aborted run must not log as success
Verification: Unit Test —
LogWriter.finalize({ aborted })marks in-flight issues aborted;finalizeRunLogexcludes them fromsummary.passed.Related defect 2: leaked locks recoverable after truncated teardown
Verification: Integration Test — a lock left behind by a killed process is cleared on the next
acquirerather than blocking it forever.Related defect 3: recycled PID must not read as fresh
Verification: Unit Test —
classifyStalenesswith a same-host, PID-alive, 76-day-old lock returns a stale reason instead ofnull.Implementation Plan
Phase 1 — Lock staleness ceiling (defects 2 + 3)
src/lib/locks/types.ts: addDEFAULT_MAX_LOCK_AGE_MS(24h) and a"max-age-exceeded"staleness reason onAcquireResult/LockListing.src/lib/locks/lock-manager.ts: inclassifyStaleness, apply the absolute ceiling before the same-host PID branch, so it binds regardless of host, PID liveness, orskipPidCheck. 24h is ~48× the 30-min run timeout and 4× the 6h skill TTL — no false positives against any real run, while every leaked lock becomes self-clearing. AddmaxLockAgeMsconstructor option +SEQUANT_MAX_LOCK_AGE_MSenv override (mirrors the existingresolveSkillLockTtlMsseam).sequant locks listoutput.Phase 2 — Abort-aware run logging (defect 1)
src/lib/workflow/run-log-schema.ts: add additive optionalaborted?: boolean+abortReason?: stringtoIssueLogSchema, andabortedBy?: stringtoRunLogSchema. Deliberately not a newIssueStatusenum value — follows thecappedprecedent atrun-log-schema.ts:164-170, which reuses"failure"plus a boolean specifically to keep the persisted-log schema stable atversion: 1.deriveIssueLogStatus([])stop returning"success"for zero phases (an issue that ran no phase did not pass).src/lib/workflow/log-writer.ts:finalize(options?: { aborted?: { signal: string; reason: string } })— when set, every still-active issue is completed asstatus: "failure",aborted: true,abortReason: <cause>.Phase 3 — Surface the abort (AC-4)
src/lib/shutdown.ts:gracefulShutdown(signal)exits128 + signum(SIGINT→130, SIGTERM→143) instead of0, and prints an abort banner naming the signal. ForSIGTERMspecifically, include the known-cause pointer (external termination; seedocs/incidents/856/), since no interactive user sends SIGTERM by hand.src/lib/workflow/run-orchestrator.ts:750: theFinalize run logscleanup passes the abort context through towriter.finalize()so the persisted log and the console banner agree on one cause.Phase 4 — Persist the investigation (AC-1/AC-2 evidence)
docs/incidents/856/— the bg-pty watchdog findings, the three victim transcripts, the corrected dtrace predicate (args[2] == 15 || args[2] == 9), the repro matrix, and the standing workaround. GitHub comments are not durable evidence;.sequant/rotates at 100 files.Rule Touchpoints
No AC triggers the behavior-rule heuristic (<2 keywords from
default|always|never|rule|behavior|skip, noalways X unless Ypattern). Section omitted per the short-circuit.Sibling-site scan
Three co-located instances of "absence reads as success" — all in scope, all in the fix above:
log-writer.ts:125(optimistic seed),run-log-schema.ts:466(empty-phases derive),shutdown.ts:221(exit(0)after interruption). Not widening scope beyond these; they are the same root cause in three places.Design Review
classifyStaleness) — the ceiling belongs there, not in callers. Abort semantics belong inLogWriter/ShutdownManager; the orchestrator only wires the two together.pssubprocess calls and per-platform parsing; a 24h ceiling clears every observed stale lock with zero risk to a 30-minute run, as a pure function with no I/O.capped(feat(orchestrator): preserve partial output for turn-capped phases in phase-executor #739) for the additive-boolean-over-new-enum choice;resolveSkillLockTtlMsfor the env-override seam;abortReasononIssueResultfor abort vocabulary thatrun-display.tsalready renders.shutdown.test.tswill be updated deliberately, not loosened.Feature Quality Planning
SIGKILLremains unfixable in-process — AC-4 is honest only about catchable signals. This will be stated in the PR, not papered over.version: 1unchanged; existing logs still parse.Open Questions
deriveIssueLogStatus([])change globally, or only on the abort path? — Recommendation: change globally; zero phases is never a pass. Impact if wrong: a caller relying on empty-means-success flips. Will be checked against all call sites during exec.Recommended Workflow
Phases: spec → exec → qa · Quality loop: enabled (SCOPE_WARNING) · Testgen: skipped — every touched module already has a test file (
lock-manager.test.ts,log-writer.test.ts,shutdown.test.ts,run-log-schema.test.ts); stubs would be untracked noise. Browser test: skipped (no UI).Label Review
Current: none · Recommended:
bug→gh issue edit 856 --add-label bugadmarble commentedon Jul 30, 2026
/fullsolve Complete — PR #877
Scope: AC-4 + the three related defects. AC-1/AC-2/AC-3 deliberately not attempted (see below).
AC Coverage
[bg-pty]host-dead watchdog, group SIGKILL) is now preserved indocs/incidents/856/with the corrected dtrace predicate. Closing it needs a live capture of an intermittent hang undersudo.--no-mcpvs the 0.36s baseline128+signum, abort banner naming the cause, SIGTERM pointer to the incident doc,sequant logsrendersABORTED.completeIssuederives from phases; abort forcesfailure;deriveIssueLogStatus([])is no longer a pass; additiveaborted/abortReason/abortedBy+summary.aborted.SIGKILLis uncatchable, so no in-process release can fire. Leaked locks now self-clear via the 24h ceiling on next acquire.classifyStaleness, checked before the same-host PID branch. Clears505.lock/708.lock/803.lock.Quality Metrics
tsc --noEmitclean;eslint --max-warnings 0clean; prettier cleanRisk Assessment
SEQUANT_MAX_LOCK_AGE_MS, but the constant would need revisiting rather than the env var being the answer.SIGKILLpath — untestable in-process by definition. The abort surfacing is verified for catchable signals only (SIGINT/SIGTERM); the real bg-pty kill is SIGKILL, where only the lock-recovery half applies.sequant runwrites an aborted log. The wiring (registerCleanup→finalize({aborted})) is unit-tested at both ends but not exercised through a live run.Progress
Verdict: AC_MET_BUT_NOT_A_PLUS — everything in the agreed scope is met and verified, but three of the issue's four ACs remain open by design.
Recommended follow-up
Split AC-1/AC-2/AC-3 into a dedicated diagnostic issue (both prior
/assessruns recommended this), so #856 can close on the work that is actually done. Reopening the diagnosis needs a live capture, not another implementation pass.Separately: a test in this suite writes to the shared
${TMPDIR}/claude-parallel-*.markernamespace that the livepre-tool.shhook reads, and during this run it transiently hijacked the session's worktree enforcement. Worth its own issue.test(#856): close the untested gaps; answer AC-3 by measurement
admarble commentedon Jul 30, 2026
Gap-fix pass — AC-3 now met, untested paths covered
Follow-up to the previous comment. Everything it listed as unmet-but-fixable or untested is now closed, and one statement in it was wrong.
AC-3 is met — and the answer is "no"
Ran the comparison rather than arguing it away. Flipped exactly the variable
--no-mcpflips (the Agent SDK'smcpServersoption,drivers/claude-code.ts:118), 3 reps per arm, alternating, everything else constant:MCP shutdown does not cause the hang. Both arms sit ~50× below the 58–96s victim band and in the same order as the 0.36s healthy baseline; the MCP-off arm was marginally slower. MCP costs ~5s of startup, not teardown. This is AC-2's redirect confirmed by measurement instead of by reasoning.
The method is validated against this incident — it reproduces the published victim gaps at their exact death timestamps:
One correction to the original investigation's method: the metric is
TurnEnd→SessionEnd, notSessionStop→SessionEnd.entirerecordsSessionStopas a session phase transition (idle/active→ended); it pairs withSessionEndfor only 10 of 555 sessions and yields multi-day gaps. The Claude Code Stop hook fires at end-of-turn, whichentirelogs asTurnEnd.Limits, stated plainly: n=3 per arm on a trivial prompt, and no hang occurred in any run. This establishes that MCP presence alone does not produce a 58–96s gap; it cannot prove MCP is irrelevant during a hang, because no hang was reproduced. These were direct SDK queries, not full
sequant runphases.Both scripts are preserved in
docs/incidents/856/tools/so this is reproducible — including the trap that cost two runs: reading MCP servers from~/.claude.jsoninstead of the desktop config silently yields zero servers and turns the treatment arm into a second control, producing a convincing null result.New evidence for AC-1/AC-2
On the incident day, 8 sessions had a 30–120s teardown gap. Two are the known victims. The other 6 survived. So the post-turn hang is necessary but not sufficient for the kill — consistent with the bg-pty trigger depending on contended socket/adoption state rather than on hang duration. Recorded in the incident doc; AC-1/AC-2 still need the live capture.
Untested paths now covered
finalize()called with no argument. Newabort-logging.integration.test.tssends a real SIGTERM/SIGINT to a real process wiring LogWriter + ShutdownManager as the orchestrator does, then reads the log off disk: exit 143/130,aborted: true,abortedBy,summary.passed: 0.run-orchestrator.tsregressed. A third test asserts the realregisterCleanup("Finalize run logs", …)block forwards its abort argument — scoped to that block, not the file. Mutation-verified by reverting the orchestrator to a barefinalize().kill(1,0)throws EPERM → reads as alive), so only the age ceiling can free it — plus a negative control proving a recent lock on a live PID is still respected.8 mutations total now, each killing exactly its intended tests.
Correction
My previous comment said a test in the suite writes the shared
claude-parallel-*.marker. That was wrong./exec's parallel-group protocol creates/tmp/claude-parallel-group-1.markerunder a hardcoded, globally-shared name, andpre-tool.shglobs that namespace and takes the first hit with no project scoping. So a parallel group in any project redirects worktree enforcement for every concurrent session on the machine — and the session that loses the race gets its guard silently pointed at an unrelated directory, which is worse than the blocked edit that made it visible. Filed as #881.Remaining
AC-1 and AC-2 only, both requiring a live capture of an intermittent hang under
sudo dtracewith the corrected predicate (args[2] == 15 || args[2] == 9— the original captures only SIGTERM and would falsely exonerate). Everything else in this issue is done.Verdict: READY_FOR_MERGE for the implementable scope. PR #877.
docs(#856): downgrade the bg-pty attribution; add a runnable test plan
docs(#856): make the summary consistent with the downgraded attribution
admarble commentedon Jul 30, 2026
How to test AC-1/AC-2 — plus a correction to the bg-pty attribution
Went looking for a way to actually test the ~106s kill instead of waiting for it. Two things came out of that: the previous attribution was overstated, and there's a much better lead.
Correction: the bg-pty conclusion was overstated
My earlier comment (and the incident doc) called the
[bg-pty]host-dead watchdog the cause with "high confidence." That rested entirely on strings extracted from the binary, never on observed runtime behaviour. Watching the runtime changes it:CLAUDE_BG_BACKENDis"daemon". Background tasks are managed by a transient daemon, which spawns bg-pty hosts as a spare pool (~/.claude/daemon.log:bg spare spawned host pid=33010).origin=transientand exitsidle 5s with no clients. With no daemon up, a backgrounded task is just a child of the interactiveclaudein its own pgid — no host, no socket. So a naive "is there a bg-pty host?" check returns nothing and looks like a refutation when it's really "not testable right now."sequant runtree while leaving the interactive session alive — which is exactly what happened (the spawning session, pid 70335, is still running).The bg-pty watchdog is still a live candidate. It is no longer the only one.
Stronger lead: the daemon lost its auth token 17 minutes before the first death
All three victims started inside the unauthenticated window, and no run has died outside it. An unauthenticated supervising daemon would explain both halves at once: an agent blocking on an auth-dependent teardown step, and a supervisor that eventually tears the tree down.
Three samples is correlation, not cause. Stating it because it is the strongest untested lead and — unlike the intermittent hang — it is inducible on demand. Caveat: the daemon log has no entry at any of the three death timestamps, so whatever killed them didn't log it there.
Recovered: the killed run's own stdout, still on disk
tasks/b6byn5iih.outputfrom the incident session survived (its orphanedtail -fis still running, 22h later):Then nothing — no cleanup task ever reported. Two consequences:
Received SIGTERMwas captured, not inferred. The first signal is catchable, so much of this is observable without dtrace at all.The test plan — three tiers, cheapest first
Tier 1 — induce the auth window (no sudo, best lead). The only condition separating every victim from every survivor. Start the daemon, invalidate its token, confirm
auth: no token found, then launchsequant runbackgrounded from inside an interactive session withtools/watch-signals.sh --no-dtracerecording. Positive → AC-1 and AC-2 both collapse to "unauthenticated daemon tears down its background tree." Negative → the correlation is coincidence, worth knowing before anyone builds on it.Tier 2 — induce a wedged host (deterministic).
tools/induce-bgpty-hang.sh. The watchdog's condition is "pid alive but socket won't accept", andkill -STOPproduces exactly that — so the mechanism is testable without waiting for the intermittent trigger. Requires a running daemon first.Tier 3 — name the sender (sudo; SIP may block).
sudo tools/watch-signals.sh. Only dtrace identifies the sender directly. SIP is enabled here, so the script preflights the probe — an empty capture under SIP means unknown, never nothing was sent. Captures signal 9 and 15.All three scripts are in
docs/incidents/856/tools/in PR #877.One harness bug worth recording, found by dry-running it: a loose
grep bg-ptymatched the script's own command line and SIGSTOPped the parent shell. Target selection is now strict and refuses self/parent, mirroringLockManager.signalOther's guard.fix(#856): refuse to signal a lock holder past the age ceiling; docum…
docs(#856): add a positive-control verifier for the capture rig; fix …
docs(#856): fix stale 'both are Node scripts' line in the tools README
22 remaining items
test(#856): close the untested gaps; answer AC-3 by measurement
docs(#856): downgrade the bg-pty attribution; add a runnable test plan
docs(#856): make the summary consistent with the downgraded attribution
fix(#856): refuse to signal a lock holder past the age ceiling; docum…
docs(#856): add a positive-control verifier for the capture rig; fix …
docs(#856): fix stale 'both are Node scripts' line in the tools README
docs(#856): make the verifier distinguish a missing probe from a brok…
feat(#856): identify the signal sender without dtrace — SIP withholds…
docs(#856): every death falls inside the daemon's auth-broken window
docs(#856): record the daemon-down baseline — backgrounding alone is …
docs(#856): correct the risk check — daemon-auth-status.json is stale…
docs(#856): draft the upstream report; ship it with the incident dossier
test(#1222): #856 abort-forwarding guard follows the finalizer into r…
admarble commentedon Oct 6, 2026
Upstream fixes to re-test against before more work here: v2.1.288 (#1334) "Fixed headless (
-p/ SDK) sessions occasionally ignoring SIGTERM when a supervisor such astimeoutor systemd sends SIGCONT alongside it", and v2.1.285 (#1328) "Fixed synchronous hooks hanging Claude Code while a background process the hook started kept its output open".templates/hooks/post-tool.sh:377backgrounds a subshell( … ) &without detaching its stdout/stderr, so it is one such process. Reproduce on ≥ 2.1.288 first. If the hang is gone, record that here and close, or narrow the issue to what remains.admarble commentedon Oct 9, 2026
Correction to my 2026-10-06 comment. The two upstream fixes I pointed at do not touch this bug's mechanism, so a re-test against them would prove nothing.
Status as of 2026-10-09 (Claude Code 2.1.295, sequant 2.19.0):
sequant runbackgrounded through Claude Code's Bash tool in an interactive session (run_in_background), with the bg-pty daemon alive.sequant_runtool or from a plain foreground terminal. Three more MCP runs on 2.1.295 (fix(skills): Claude Code ≥2.1.286 tells Claude to run any project skill namedverifybefore every commit — Sequant's verify expects an issue number and posts to GitHub #1345, fix(worktree): npm ci runs at the worktree root even when the package lives in a subdirectory — EUSAGE on every provision #1243, fix(run): parallel mode drops per-issue warnings, not just progress — spec-parse failure, PR-after-exec failure and checkpoint-commit failure are silent on every MCP run #1342, 6–13 minutes each, three phases each) finished with no kill.No new evidence suggests a code change in Sequant. Closing, narrowing to the upstream tracker, or keeping this open as the recurrence tracker is the owner's call.