Skip to main content
← Back to list
01Issue
BugOpenSwamp CLIPublic
AssigneesNone

Relationships

#5036 enrollment_token_rotation_property_test flakes: advanceTokenClock leaves 1 ms of wall-clock margin

Opened by stack72 · 11/24/2026

Summary

The property test "enrollmentTokenModel.rotate: however often it runs, a default rotation never leaves more than the lifetime plus the cap" in src/domain/models/worker/enrollment_token_rotation_property_test.ts fails intermittently on a loaded host.

Failure

verify-build run 3a0cbd70-7024-41ab-90e0-b8190b94de7f (commit 77663ea4f) failed with:

Property failed after 29 tests, seed -1384042147, path 28, counterexample [[59999,32451,1]]. Got error: Enrollment token 'ci-runner-3' has expired and cannot be rotated.

Replaying the same seed and path on an idle machine passes.

Cause

advanceTokenClock (src/domain/models/worker/worker_test_helpers.ts) moves the stored createdAt and expiresAt back by the interval, while rotate compares expiresAt with the real Date.now(). Intervals are drawn from 0 to LIFETIME_MS - 1, and fast-check favours the upper bound. An interval of 59999 leaves the token 1 ms of real time before it expires, so any pause longer than 1 ms between the previous mint or rotation and the next rotate (likely under the parallel verify-build load) makes the token expire, and rotate refuses.

Expected

The test passes no matter how much real time passes between steps. For example, rotate could read an injected clock, or the generated intervals could leave a margin that does not depend on the wall clock.

02Bog Flow
◉OPEN○TRIAGED○IN PROGRESS○SHIPPED

Open

11/24/2026, 1:22:41 AM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.