✅ test(dvara): two supervisor tests no longer fail under load

Merged
AT
15d ago
+33-6

Slice: #148

Two dvara supervisor tests stop depending on how fast git and ps start, so a local pnpm check on a loaded machine no longer fails in dvara. dvara's behaviour does not change, and nothing is released. Proposal approved on #148 (page).

The change

  • "stops waiting on output a leftover process holds open" no longer times the whole supervise run against 2500 ms. Its leftover job holds the hook's output open until the test releases it, and the test checks that supervise returned before the job wrote its marker, which is what the drain limit is for. A 30 s fallback in the job turns a supervisor that waits for it into a red assertion, not a hang. The memory sampler's ps is stubbed in this test.
  • "records a passing run with its stages and leaves no listener behind" no longer reads its invocation from the real ps, whose 5 s timeout gives "unknown" under load. Options takes an optional parentTable, passed straight to invocationContext (which already took one), and the test gives it a fixed chain ending at init, with pids no real process has, so a supervise that ignored the option would get "unknown" from the real table. The other supervise tests, and context.test.ts's "reads the real process table by default", still run the real ps, with no timing riding on it.

Proof

PATH shims that sleep before exec-ing the real binary (docs/lessons/testing.md, "Budget flakes come from stalls, not load"):

git +1.5 sps +6 s
test 1, before✖ Date.now() - started < 2500 (26.1 s)
test 2, before✖ 'unknown' !== 'manual'
both, after✔✔

Each test still goes red when what it guards is broken (both breaks reverted):

  • Drain limit removed from the race in drained(): test 1 fails at the marker check, after the job's fallback (57 s).
  • supervise ignoring parentTable: test 2 fails with 'unknown', with no shim.

pnpm -C packages/dvara check passes (328 tests, coverage thresholds met). The full local pnpm check (provenance, every package's check, test:scripts, lint, guards) passes on a loaded Mac, after merging main with #159, the fix for veda-hq/veda#147. Before that merge it failed only in kavach's run-child test, #147's.

🤖 Generated with Claude Code


Summary by cubic

Fixes two dvara supervisor tests so a local pnpm check no longer fails on a loaded machine; dvara's behavior doesn't change.

  • The leftover-process test no longer times the whole supervise run against 2500 ms. It now checks that supervise returned before the job wrote its marker, with a 30 s fallback in the test's job that turns a hung supervisor into a red assertion rather than a hang.
  • The passing-run test no longer reads its invocation from the real ps, which gives "unknown" under load. Options now accepts an optional parentTable passed straight to invocationContext, and the test uses a fixed chain with pids no real process has, so ignoring the option fails via the real table.