test(recovery): bound the raced attempt count instead of pinning it (BLO-33410) - #1818
Merged
allyblockcast[bot] merged 1 commit intoSep 14, 2026
Merged
Conversation
…BLO-33410) `reuses the raced stranded recovery action when duplicate active recovery creation conflicts` asserted `attemptCount === Math.min(8, maxAttempts)` — i.e. that exactly 5 of 8 concurrent reserves land — while its own comment ten lines below documents the count as scheduling-dependent (measured 4, 6 and 7). The two were mutually inconsistent and the equality failed ~2 runs in 3 on unchanged master, reddening a merge gate for unrelated PRs. `attemptCount` was never a gate: the reserve is a read-modify-write (`existing.attemptCount + 1`), so it counts sweeps that landed, and the budget bounds wakes rather than increments. Racing sweeps can legitimately carry it past the budget; `escalated` is sticky, so the terminal state stays correct. Assert the real ceiling — one increment per concurrent caller — and drop the comment claiming the budget is not over-spendable by the race. Dedupe (`toHaveLength(1)`) and the budget/retirement pairing below are untouched. Co-Authored-By: Claude <noreply@anthropic.com>
Author
Author
There was a problem hiding this comment.
Ally — Consolidated PR Review
Lenses: pr-review-toolkit (code, tests, comments, errors, types) + gstack/review + native-codex.
Reviewed head: d337f72
Critical Issues (0)
Important Issues (0)
Suggestions (0)
Strengths
- The test now asserts the actual concurrency invariant: one recovery-action row, with a bounded persisted count across the eight racing callers.
- The existing retirement-bound pairing remains covered, including both budget-exhausted and still-active outcomes.
- The change is narrowly scoped to the flaky assertion and removes the contradictory exact-count assumption without changing production behavior.
Recommended Action
- No Critical or Important issues found; the App-authored PR is ready for the repository's remaining CI checks.
13 tasks
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.
Thinking Path
Linked Issues or Issue Description
masterand unrelated to itGeneral tests (server 3/4)shard on BLO-33657: publish the Ally comment gate as a check-run so "not evaluated" stops rendering green #1815 at61e3bbecon 2026-09-13, which is what surfaced that this fix had been pushed but never opened as a PRSearched for duplicates. No open or closed PR references BLO-33410. Five open PRs touch this same test file (#1811, #1799, #1794, #1789, #1774) — I checked each patch and none touches the
attemptCountassertion, so there is no overlap and no expected conflict.What Changed
server/src/__tests__/heartbeat-process-recovery.test.ts: replaceexpect(actions[0]?.attemptCount).toBe(Math.min(8, defaultRecoveryActionMaxAttempts))with a bound —toBeGreaterThanOrEqual(1)andtoBeLessThanOrEqual(8).Why a bound is the correct assertion, not a smaller number.
attemptCountwas never a gate. The reserve is a read-modify-write (existing.attemptCount + 1), so it counts sweeps that landed, whiledefaultRecoveryActionMaxAttemptsbounds wakes rather than increments. 8 racing sweeps can therefore legitimately carry the count past the budget —escalatedis sticky, so the terminal state stays correct either way. 8 is the real ceiling, one increment per concurrent caller, so this assertion still fails if a retry path ever double-increments.Verification
Baseline on unmodified
master, measured 2026-09-11: 1 of 3 green —expected 6 to be 5,expected 7 to be 5on separate checkouts. Independently reproduced on 2026-09-13 in CI on an unrelated PR (#1815, head61e3bbec, job103682776748):AssertionError: expected 4 to be 5, after an automaticretry x1, as the single failure in a 940-test shard (1 failed | 939 passed).The two assertions that carry the test's actual meaning are untouched:
expect(actions).toHaveLength(1)— the dedupe invariant this test exists for.if/elsepairing below — retired iff the budget was reached, withretiringBound: "attempt_budget"stamped. Note this branch was previously unreachable: the equality on the line above requiredattemptCount === 5, so theelsearm (attemptCount < budget→ stillactive) could never execute. This change is what makes the author's own branch testable.Risks
Low, and scoped to one test. No production code changes — the diff is a single test file, +10/−3.
The one thing given up is the exact-count assertion, deliberately: it could not hold, because the quantity it pinned is scheduling-dependent by the test's own documented measurements. Weakening a bound in order to go green is normally the wrong move, so it is worth being explicit that the invariants with teeth (dedupe; budget/retirement pairing) are both retained, and that the replacement bound of 8 still fails on a double-increment regression.
Not verified in this PR: I have not run the 10-consecutive-green sequence that BLO-33410's acceptance criteria ask for, nor the negative control it requires (break the dedupe path, confirm the test goes red). Both need a working checkout; this PR is opened from an already-pushed commit whose originating workspace failed git-worktree validation. Flagging rather than claiming it.
Model Used
Claude Opus 4.5 (
claude-opus-4-5, 1M context), extended thinking, with tool use via the Paperclip agent runtime.Checklist
Fixes: #/Closes #/Refs #OR (b) described the issue in-PR following the relevant issue template