Flaky test: facts shutdown ordering depends on a real 1 s deadline (fails on loaded Windows runners)
Summary
packages/omo-senpi/src/components/memory/wiring.test.ts:625 ("facts shutdown wiring > #given an active facts launch #when the session shuts down #then facts cancellation runs before the shutdown drain") depends on the wall clock. It passes deadlineAt: Date.now() + 1_000 with the real Date.now, so on a loaded runner the shutdown can overrun the 1-second budget. The drain evaluator is then skipped, sequence.indexOf("drain") is -1, and expect(indexOf("cancel")).toBeLessThan(indexOf("drain")) fails.
Evidence
CI run 36450362647, job 109023452703 (senpi-compatibility (windows-latest)) on PR #9118, head 6e350c29. The test took 2071.64 ms and failed with expect(received).toBeLessThan(expected); 0 other failures. The PR does not touch the memory component; the same test passed on the PR's previous head.
Expected
The test asserts ordering, not timing. It should pass on any runner load.
Proposed fix
Inject a clock: now and deadlineAt from a fixed fake time that never advances past the deadline. Alternatively, assert on the ordering events with a deadline far beyond any plausible runtime. Keep one separate test for the over-deadline path, which asserts that the drain is skipped when the deadline has passed, driven by the fake clock.
Acceptance
- No wall-clock dependence in the ordering assertion.
- Both the in-budget and over-budget paths are covered deterministically.
Source: code-yeongyu/oh-my-openagent