Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(sync-drain): forced 80 ms loop stall at pass start stays quiet under the injected clock
time-attackf6b179600b73
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4bb6e9c78b..500d276d44 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,7 +16,7 @@ identifiers and attribution are available in the pre-removal Git revision### Itemized changes-- `test/sync-drain-no-admission.test.ts` "a pass that commits keeps the governor quiet" failed when one 25 ms timer fired late on a loaded runner and outlasted the 60 ms no-progress window. The drain now takes an injected clock (`DrainInput.clock`, test seam, default `Date.now`), and the test advances it 25 ms per committed page while the governor keeps ticking on real timers. The assertion is unchanged; a forced 85 ms real delay on the first page, which failed the old test 3/3, is now part of the test. A new control test shows the same governor still stops `no_admission` once the clock passes the window before a commit. The file's two hung-pass tests only wait for a stop, so a late timer cannot fail them.+- `test/sync-drain-no-admission.test.ts` "a pass that commits keeps the governor quiet" failed when the event loop stalled 60 ms or more at pass start (or one 25 ms timer fired late), so the governor's 10 ms interval woke first and stopped the pass before the first commit. The drain now takes an injected clock (`DrainInput.clock`, test seam, default `Date.now`), and the test advances it 25 ms per committed page while the governor keeps ticking on real timers. The assertion is unchanged. Two forced probes are now part of the test: an 80 ms synchronous loop stall at pass start (failed the old test 5/5) and an 85 ms real delay before the first page (failed it 3/3). A new control test shows the same governor still stops `no_admission` once the clock passes the window before a commit. The file's two hung-pass tests only wait for a stop, so a late timer cannot fail them.## [0.60.165.0] - 2026-10-11diff --git a/test/sync-drain-no-admission.test.ts b/test/sync-drain-no-admission.test.tsindex aba12f64b3..8a00e9a8ed 100644--- a/test/sync-drain-no-admission.test.ts+++ b/test/sync-drain-no-admission.test.ts@@ -36,11 +36,12 @@ describe('in-pass governor: a pass that admits nothing', () => {});// The drain's clock advances 25 ms per committed page against a 60 ms window, so the governor's verdict no longer depends on- // how late a real timer fires on a loaded runner. The governor still ticks on real timers between pages, and the first page's- // real wait (85 ms) outlasts the window on purpose: that wall-clock delay alone stopped the pass before the clock seam.+ // event-loop scheduling. The governor still ticks on real timers between pages; the 80 ms loop stall at pass start and the+ // first page's 85 ms real wait each outlast the window on purpose: either alone stopped the pass before the clock seam.test('a pass that commits keeps the governor quiet', async () => {let now = 0;const result = await runDrain({ governMs: 10, noProgressMs: 60, probe: empty, clock: () => now, pass: async (_signal, onProgress) => {+ const blockedUntil = performance.now() + 80; while (performance.now() < blockedUntil) { /* the event loop stalls 80 ms at pass start */ }for (let i = 1; i <= 6; i++) { now += 25; await new Promise(r => setTimeout(r, i === 1 ? 85 : 25)); onProgress({ phase: 'managed_sync.page_committed', bankedFiles: i, total: 6 }); }return { status: 'synced', fromCommit: 'a', toCommit: 'b', added: 6, modified: 0, deleted: 0, renamed: 0, chunksCreated: 0, embedded: 0, pagesAffected: [], managedCursor: { index: 6, total: 6 } };} });