From 970d68a704f790ddf72da12e6005ef9d52ba0158 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 15 Aug 2026 09:19:26 -0700 Subject: [PATCH] =?UTF-8?q?fix(test):=20ring-buffer=20lease=20interplay=20?= =?UTF-8?q?=E2=80=94=20same=20TTL=20window,=20not=20same=20millisecond?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two back-to-back mintLease() calls each stamp Date.now() + TTL; when they straddle a millisecond boundary the exact-equality assertion flakes (observed in CI: expiries of ...525 vs ...526). Assert the expiries are within a 50 ms window instead — the invariant under test is that leases share a TTL policy, not that they mint in the same clock tick. Co-Authored-By: Claude Fable 5 --- browse/test/terminal-agent-ring-buffer-runtime.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/browse/test/terminal-agent-ring-buffer-runtime.test.ts b/browse/test/terminal-agent-ring-buffer-runtime.test.ts index 5cea4f9b8..fc55b3512 100644 --- a/browse/test/terminal-agent-ring-buffer-runtime.test.ts +++ b/browse/test/terminal-agent-ring-buffer-runtime.test.ts @@ -148,7 +148,10 @@ describe('lease lifecycle interplay (via pty-session-lease)', () => { const vb = validateLease(b.sessionId); expect(va.ok && vb.ok).toBe(true); if (va.ok && vb.ok) { - expect(va.expiresAt).toBe(vb.expiresAt); + // Same TTL window, not same millisecond: each mint stamps + // Date.now() + TTL, and back-to-back calls can straddle a ms boundary + // (observed in CI: ...525 vs ...526). Exact equality is a timing flake. + expect(Math.abs(va.expiresAt - vb.expiresAt)).toBeLessThanOrEqual(50); } }); });