✨ feat(dvara): a built-in watchdog and dvara slot (#376)

Closed
AT
4d ago
+5872-12

Slice: #376

Under work item #43.

W-63 moves athya_mono's hook watchdog and its per-machine test slot into dvara, so
athya_mono can drop its own copies once this is released.

  • "watchdog": "dvara" attaches the built-in watchdog (src/watchdog.ts,
    src/liveness.ts). It stops only a hook that is provably deadlocked: exit 124, with the
    last stage marked timed_out. A hook that is just slow keeps running. It is opt-in;
    any other string is still read as a module path. DVARA_WATCHDOG* variables set it.
  • dvara slot (src/slot.ts) runs a command, with its --set variables, only while it
    holds a machine-wide slot, and it never waits for one. Its lock file and record match
    the old wrapper byte for byte, so runs from before and after the move share one slot.
  • The tests are ported to node:test case for case. The captured lsof/ps fixtures
    under fixtures/watchdog/ name a neutral working directory.

No version bump and no tag. The release is cut separately after this merges.

Evidence: pnpm check at the PR head

pnpm check (provenance, then pnpm -r check, test:scripts, eslint . and
scripts/guards.sh) exited 0:

PackageTestsPassFailSkippedLines / branches / funcs
dvara5695690099.73 / 96.85 / 99.50
agnipariksha1171170099.43 / 98.99 / 98.77
eslint-plugin-shuddhi291529150099.98 / 97.56 / 100.00
pariksha400640060099.97 / 99.14 / 99.94
kavach (node)7677670099.89 / 97.44 / 99.68
kavach (python)917OK———
sarathi58558203 (live-service cases, opt-in via SARATHI_LIVE_SERVICES)99.58 / 97.77 / 99.79
scripts18418400100.00 / 98.61 / 100.00

Coverage of dvara's new files: slot.ts 100 / 97.99 / 100, watchdog.ts
98.52 / 92.38 / 97.50, supervisor.fixture.ts 100 / 100 / 100. The dvara build and smoke
run (node dist/cli.js --version && node dist/cli.js shell stages) both passed. The
guards passed too: pariksha boundary found no denied word in 579 files, the required
settings are present, and .claude/sarathi.json is valid.

🤖 Generated with Claude Code


Summary by cubic

Moves athya_mono's hook watchdog and its per-machine test slot into dvara, so athya_mono can drop its own copies once this is released.

New Features

  • "watchdog": "dvara" attaches the built-in watchdog, which stops only a provably deadlocked hook (exit 124, last stage timed_out) and never a slow one.
  • It is opt-in: any other string is still read as a module path, and DVARA_WATCHDOG* variables configure it.
  • dvara slot runs a command with its --set variables only while holding a machine-wide slot, and it never waits for one.
  • Its lock file and record match the old wrapper byte for byte, so runs on either side of the move share one slot.

No version bump or tag; the release is cut separately.