šŸ› fix(dvara): the watchdog spares a core whose member has a live child outside it

Merged
AT
2d ago
+294-69

dvara's watchdog no longer kills a hook whose quiet pair is waiting on a child of its own. On 2026-11-26 it killed a pre-push as an internal deadlock: pnpm (91855) and sh (91890) sat quiet on a pipe, while pnpm's other child (91869) polled for agnipariksha's mutation lock, which another worktree held. The waiter keeps no descriptor on the lock, so lsof showed nothing that leads out of the pair (slice #625).

The rule (findHangCore)

  • A core counts as closed only if every live (non-zombie) child of every member is also a member.
  • A parent waits on its children's exit, which lsof never shows. So a core with a live child outside it is spared.
  • Nothing names agnipariksha or any other tool.

Trade-off

  • A real deadlock with an idle sibling child of a member is now spared too. It gets only the 60-minute idle-external warning.
  • ps and lsof show an idle sibling exactly as they show a lock waiter, so no rule can tell the two apart. This is the rule #625 was approved with.
  • The deadlock the watchdog was built for still convicts and is still killed. Its fixtures are real captures from 2026-09-13 and are unchanged.

Tests (watchdog.test.ts)

  • The 2026-11-26 incident, scrubbed from the real ps and lsof output, is spared.
  • The same pair convicts once the waiter has exited or is a zombie.
  • A live child of a non-member does not spare the core.
  • The synthetic fixtures had a live non-member child next to the core, which the new rule spares:
    • The shared createWatchdog fixture's idle cat (40480) is now a zombie.
    • The shape test's pid 3 now has a parent outside the core.
    • Two decide spare tests now have their extra leaf outside the core, so each one still spares for its own reason.
  • New tests cover paths no test reached before:
    • fds with no type, device or address,
    • a pid with no classified fds,
    • an expired diagnostics entry that disappears between stat and removal,
    • a watchdog stopped without a verdict.

Rewrites in watchdog.ts (no behaviour change)
These remove the equivalent mutants that #628 and #629 left. Each states its check only once.

BeforeAfterWhy the behaviour is the same
perfLevelNames = [], supervisorFds = []both requiredThe supervisor already passes perfLevelNames, and inspect already passes supervisorFds. Tests pass []. watchdog.js is not a package export, and the README's module contract already lists perfLevels as required.
if (!line) continue in parseLsofdroppedAn empty line has no tag, so it matches no branch.
x ?? "" on an fd's name or typeString(x)"null" matches no pattern, no type table entry and no type check, just as "" didn't.
supervisor objects omit a missing devicethey include nullEvery lookup is guarded by a non-empty string.
holders.get(fd.device ?? "")holders.get(fd.device)Only present devices are stored.
/^0x0+$/i.test(peer)Number.parseInt(peer, 16) === 0Same result for every 0x[0-9a-f]+ address.
classes.get(pid) ?? []if (!fds) continue or ?.someA missing entry still yields nothing.
(cpuDelta.get(pid) ?? 1) !== 0 and === 0without ?? 1undefined compares with 0 the same way 1 does.
ipc.length === 0 || …droppedA leaf with no channel reaches no peer, which peers.length > 0 already rejects.
fd.device !== null && in coreSharedOutsidedroppedIts set never holds null.
|| classes === null in closedVerdictdroppeddecide returns internal-deadlock only when classes are present, and both callers pass the same classes.
root find + !== undefinedone tree.some(…)The root appears in the tree only once.
summary.verdict && … && verdictAt !== nullverdictAt !== null && …The two are set and cleared together.

The refactor commit's body says the supervisor passed both defaulted arguments. Only perfLevelNames comes from the supervisor; the table above has it right.

Checks

  • Mutation gate (pnpm exec agnipariksha --lane dvara --files packages/dvara/src/watchdog.ts --no-reuse): 1001 of 1001 killed, 0 blocking.
  • pnpm check passes. pnpm --filter ./packages/dvara test passes.
  • The README's watchdog section states the new rule.

Review and approval

Slice: #625

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes dvara's watchdog killing a hook whose member has a live child outside the deadlock core. A parent waits on its children's exit, which lsof never shows, so a core with such a child is now spared.

Trade-off

  • A real deadlock with an idle sibling child of a member is also spared now, getting only the 60-minute idle-external warning.
  • ps and lsof show an idle sibling exactly like a lock waiter, so no rule can tell them apart.

Refactor and tests

  • The watchdog.ts rewrites state each check once and have no behavior change.
  • New tests reproduce the 2026-11-26 incident from real ps and lsof output and cover paths no test reached before.