From 4547a677ab84b18a3e1110810a7c01b8dbde477e Mon Sep 17 00:00:00 2001 From: ScreenTinker Date: Tue, 30 Jun 2026 22:14:17 -0500 Subject: [PATCH] =?UTF-8?q?test(#146)=20P3.9:=20de-flake=20storm=20harness?= =?UTF-8?q?=20=E2=80=94=20keep=20max-gap=20invariant,=20drop=20tick-count?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The storm harness asserted a tick COUNT (environment-timing-sensitive) that could flake in CI. Kept the real invariant (max event-loop gap < 300ms) and loosened the tick assertion to >=2 (enough to have measured a real gap), which cannot flake. Co-Authored-By: Claude Opus 4.8 (1M context) --- server/test/storm-harness.test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/test/storm-harness.test.js b/server/test/storm-harness.test.js index 76c4eed..ce9855c 100644 --- a/server/test/storm-harness.test.js +++ b/server/test/storm-harness.test.js @@ -63,10 +63,12 @@ test('storm: bloated-table sweep + flapper + OTA flood — loop stays responsive const [deleted] = await Promise.all([prunePromise, stormPromise]); clearInterval(ticker); - // 1) NO multi-second freeze — the old whole-table sort would freeze the ticker for - // tens of seconds here. + // 1) THE REAL INVARIANT — NO multi-second freeze. The old whole-table sort would + // freeze the ticker for tens of seconds here. assert.ok(maxGap < 300, `loop never froze — max event-loop gap ${maxGap}ms (was 40-48s pre-fix)`); - assert.ok(ticks >= 10, `ticker kept firing through the storm (${ticks} ticks)`); + // #146 P3.9: the exact tick count is environment-timing-sensitive; assert only that + // the ticker sampled enough to have MEASURED a real gap (>=2), not a brittle count. + assert.ok(ticks >= 2, `ticker sampled the run (${ticks} ticks) — max-gap measurement is meaningful`); // 2) The sweep actually drained the backlog to the cap. assert.ok(deleted >= 298000, `sweep trimmed the backlog (${deleted} deleted)`); assert.equal(db.prepare('SELECT COUNT(*) c FROM device_status_log').get().c, 1500, '3 devices x 500 cap');