Skip to content

(test): run trigger-watcher timing tests serially with a load tolerance - #261

Merged
devsuitup merged 2 commits into
mainfrom
fix/trigger-watcher-clock
Sep 11, 2026
Merged

devsuitup merged 2 commits into
mainfrom
fix/trigger-watcher-clock

Conversation

@devsuitup

Copy link
Copy Markdown
Owner

Closes #260.

Why

test/trigger-watcher.test.js drives real timers and real fs.watch against fixed wall-clock budgets. Under host load it fails on a changing subset of 5–7 tests unrelated to the change being committed; on 2026-09-11 the pre-commit hook was red 5 times out of 7 on this workstation for that reason alone. Part of that load is self-inflicted: node --test runs ~150 test files in parallel, and the timing tests compete with the other workers of the same run.

What

  • scripts/run-tests.js runs the suite in two stages: every file except the trigger-watcher one with node's default concurrency, then that file alone with --test-concurrency=1 --test-timeout=60000. npm test and npm run coverage route through it (cross-platform, no shell syntax; c8 still instruments the children through the inherited env).
  • SWITCHBOARD_TEST_TIME_SCALE (default 1) scales only the upper-bound assertions and the waitForFile ceiling in that file; lower bounds that prove an ordering or a minimum wait are untouched. Three fragile schedules were widened unconditionally (shared chain busy plateau 150 → 550 ms, W7 schedule, the settle-window test constants doubled) — the wrong-vs-right margins are preserved.
  • Context doc: "timing tests and host load" in .ai/contexts/trigger-watcher.md, with what a real clock injection would take (the five wall-clock-owning functions, ~20 exact-value tests); left as a follow-up.

Proof

Reproduced first under a synthetic load of 8 CPU-saturating processes on this 8-core machine: 6 tests red (timeouts waiting for the result file, missed busy-rise, waited_ms floors). After: 3 consecutive runs under the same load, 119/119. Mutation: removing the idleSince reset in waitForBusyFall still makes the settle-window test red under the widened bounds.

task check in the worktree: main stage 1144 pass, isolated stage 119 pass, 0 fail, 8 pre-existing skips; the commit's own pre-commit hook passed.

npm test now runs trigger-watcher.test.js alone, after everything else,
removing the self-contention of ~150 sibling test-file processes. A few
tight bounds (a ceiling, two upper-bound elapsed checks, a shared auto-turn
schedule) were widened so real host load no longer flakes them; lower
bounds proving ordering/minimum-wait are untouched.
@devsuitup
devsuitup merged commit a1900e2 into main Sep 11, 2026
10 checks passed
@devsuitup
devsuitup deleted the fix/trigger-watcher-clock branch September 11, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(test): trigger-watcher timing tests fail under host load and block the pre-commit hook

1 participant