fix(test): kill the four worst fixed sleeps (300s/30s/30s/20s)

- watchdog.test: the 20s blind wait for one production parent-watchdog
  tick becomes BROWSE_PARENT_WATCHDOG_INTERVAL_MS=250 (new env knob in
  server.ts, NaN-safe, production default unchanged) + polls for the
  boot line and the tick's stay-alive log — strictly stronger (the old
  form never proved a tick observed the parent death). 24s → 3.6s.
- stop-dead-daemon / terminal-agent-owner-watchdog: the 300s/30s
  stand-in child lifetimes become stdin-EOF-bound — the child can never
  self-exit mid-test on a slow runner (spurious-failure class) and
  self-reaps instantly if the test dies (no 300s orphans). Node-compat
  stdin APIs (owner-watchdog runs on the Windows lane).
- browser-skill-commands: the sleeper fixture's 30s self-time becomes
  8s (no stdin pipe exists in runToFiles) — far above the 1s product
  timeout it must outlive, below the test ceiling, so a timeout-kill
  regression fails on clean assertions instead of an opaque bun
  timeout; added: stdout must NOT contain 'done'.

45/45 green across the four files + server tripwires.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-29 05:31:02 +00:00
co-authored by Claude Fable 5
parent 73fe950fbf
commit 5c081a355a
5 changed files with 70 additions and 17 deletions
+12 -2
View File
@@ -342,8 +342,15 @@ describe.skipIf(SKIP_SPAWN)('spawnSkill: lifecycle', () => {
it('timeout fires, exit code 124, token revoked', async () => {
const dir = makeSkillDir(tiers.bundled, 'sleeper',
'name: sleeper\nhost: x.com\ntrusted: true',
// Sleep longer than the test timeout; the spawn should kill us.
`await new Promise(r => setTimeout(r, 30000)); console.log("done");`,
// The child's self-lifetime is a bound, not a wait — the test blocks
// only for the 1s spawn timeout that kills it. 8s is sized to be far
// above that 1s (the kill always lands first) but below this test's
// 10s ceiling: if the timeout-kill ever regresses, the child completes,
// prints "done", and the assertions below fail cleanly in-budget
// instead of the test opaquely timing out while the child lingers.
// (runToFiles gives skill children no stdin pipe, so a parent-death
// EOF lifetime isn't available here — self-timing is required.)
`await new Promise(r => setTimeout(r, 8000)); console.log("done");`,
);
const skill = readBrowserSkill('sleeper', tiers)!;
const result = await spawnSkill({
@@ -351,6 +358,9 @@ describe.skipIf(SKIP_SPAWN)('spawnSkill: lifecycle', () => {
});
expect(result.timedOut).toBe(true);
expect(result.exitCode).toBe(124);
// The kill must land before the script completes — "done" ever appearing
// means the child outlived its timeout.
expect(result.stdout).not.toContain('done');
expect(listTokens().filter(t => t.clientId.startsWith('skill:sleeper:'))).toEqual([]);
}, 10_000);