test(fresh-agent): deflake the b8ke handoff backoff window test - #808
Merged
Merged
Conversation
…fake timers The HANDOFF_IN_PROGRESS retry test asserted a 350ms wall-clock sleep landed mid-backoff (750ms). Under full-suite parallel load the act()-queueing gap before the sleep started could itself exceed the backoff, so the check landed after the timer legitimately fired — the base gate at origin/main hit exactly this (1 of 7,165). Advance the real timer clock deterministically instead (the file's snapshot-debounce deflake precedent), keyed on SESSION_HANDOFF_RETRY_BACKOFF_MS rather than a literal, and extend the tail: no stacked timer fires after the single re-invocation. Mutation-checked: backoff=0 fails the test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
HANDOFF_IN_PROGRESS retry waits out the backofftest (FreshAgentView.test.tsx) asserted a 350ms wall-clock sleep landed mid-backoff (750ms). Under full-suite parallel load, the act()-queueing gap before the sleep started could itself exceed the backoff, so the check landed after the timer legitimately fired.The base gate at
origin/mainhit exactly this on 2026-09-19: 1 of 7,165 tests (scripts/base-gate.sh test, exit 1). The production code honors the backoff (realsetTimeout(750)inSessionHandoffErrorBanner.tsx); only the test's wall-clock premise was unsound under load.Fix
Rewrite the test to advance the fake timer clock deterministically — the same deflake precedent this file already uses for the snapshot-debounce tests (
vi.useFakeTimers+act(advanceTimersByTimeAsync)), keyed onSESSION_HANDOFF_RETRY_BACKOFF_MSinstead of a literal, and extend the tail: assert no stacked timer fires after the single re-invocation.Evidence
SESSION_HANDOFF_RETRY_BACKOFF_MS = 0the test fails at the mid-backoff boundary — it still protects the property.npm run typecheck:clientgreen; no Rust changes (rust-gate passes trivially).