Skip to content

fleet: bound claim acquisition settle window - #5127

Merged
jakildev merged 3 commits into
masterfrom
codex/5126-claim-acquire-settle
Nov 21, 2026
Merged

jakildev merged 3 commits into
masterfrom
codex/5126-claim-acquire-settle

Conversation

@jakildev

@jakildev jakildev commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fleet claim acquisition waits through a bounded settle window when a losing
label is slow to disappear, while keeping the independent two-GET admission
contract. The race fixtures use atomic per-label state, with shared helpers and
an exact per-pass POST bound.

Acceptance evidence

Criterion Check run Observed
Census every hosted failure since 2455e3240 gh run view <run> --attempt 1 --log-failed for seven historical runs All failures classified as retry/yield, POST/mutex, or the older POST-only diagnostic gap.
Slow-release positive control fails meaningfully on origin/master fleet-positive-control scripts/fleet/tests/test_fleet_claim_acquire_race.sh origin/master MEANINGFUL: 7 of 82 assertions fail; the slow-release schedule admits no owner and leaves no label.
50 consecutive targeted passes 50 serial bash scripts/fleet/tests/run_all.sh --only fleet_claim_acquire_race runs Every invocation reported 1 passed, 0 failed, 0 skipped.
Preserve two independent GETs and mutation control bash scripts/fleet/tests/run_all.sh --only fleet_claim_acquire_race; first-decision mutation Fixed tree passes; mutation caused four assertion failures, including one-GET success paths.
Bound POST attempts per pass bash scripts/fleet/tests/run_all.sh --only fleet_claim_acquire T7 asserts the real bound: no more than FLEET_CLAIM_ACQUIRE_RETRIES + 1 POSTs per pass.
Diagnose and fix lost removal or stop after six attempts Hosted runs 44005462018, 44006355087, 44006364550, 44006377125, 44006387871, 44006402415 The six-attempt diagnostic found a slow-release retry window and a vanished fixture mutex; bounded settling plus atomic per-label state fixes both.
Hosted full fleet suite has zero failures Hosted PR run 44654347558 Hosted run succeeded: 305 suite(s) — 304 passed, 0 failed, 1 skipped; the engine-only runner skipped cross-repo parity.
Feedback follow-up validation bash scripts/fleet/tests/run_all.sh --only fleet_claim_acquire and bash scripts/fleet/tests/run_all.sh --only fleet_claim_cross_lane Acquire, acquire-race, and cross-lane suites passed after the shared-helper cleanup.
Changed-area static validation bash -n; python3 scripts/lint_comment_refs.py; python3 scripts/light-verify.py --if-changed Syntax and comment lint passed; light verification was not required for these seven non-visual paths.
Reviewer notes

Notes for reviewer

  • Historical hosted census, slow-release trace, and local full-suite evidence
    remain in the issue and review thread. The current head replaces the
    duplicate label helpers, removes the unused race mutex, escapes fixture
    filenames for native Windows, and rejects a non-integer settle window.
  • The local supervised suite on this macOS Codex host had two documented
    sandbox-denial failures outside the changed area; the focused claim suites
    above pass.

Refs #5126

Authored with OpenAI Codex.

@jakildev jakildev added fleet:wip Work in progress — not ready for review fleet:author-codex Implementation last authored by Codex; route review to Claude fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend labels Nov 17, 2026
@jakildev
jakildev force-pushed the codex/5126-claim-acquire-settle branch from 083f6a1 to a97697c Compare November 17, 2026 06:32
@jakildev jakildev added the fleet:awaiting-infra Complete-but-unverifiable PR parked until an infra blocker lands; body carries Parked-until: #N label Nov 17, 2026
@jakildev jakildev changed the title test: expose fleet claim removal races fleet: bound claim acquisition settle window Nov 17, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Parking this WIP under the completion contract: the hosted full-suite gate remains blocked by #5129.

Overlap check:

  • #5122 scripts/fleet/fleet-claim clean
  • #5122 scripts/fleet/tests/test_fleet_claim_cross_lane.sh conflicts
  • VERDICT: block

PR #5122 is already parked until #5126, so this chain head is not parked behind that descendant. The body carries the complete evidence and the independent #5129 park marker.

— worker (OpenAI Codex)

@evin-mac-claude-app evin-mac-claude-app Bot added fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file and removed fleet:awaiting-infra Complete-but-unverifiable PR parked until an infra blocker lands; body carries Parked-until: #N labels Nov 17, 2026
@jakildev jakildev removed the fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file label Nov 17, 2026
@jakildev
jakildev force-pushed the codex/5126-claim-acquire-settle branch from a97697c to bdd6842 Compare November 17, 2026 22:59
@evin-desktop-claude-app evin-desktop-claude-app Bot added the fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file label Nov 17, 2026
@jakildev jakildev added the fleet:awaiting-infra Complete-but-unverifiable PR parked until an infra blocker lands; body carries Parked-until: #N label Nov 17, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Rebased this branch onto current origin/master, which includes the former #5129 identity-routing fix, and pushed/stamped head bdd684243 as Codex.

Changed-area validation remains green: hosted test_fleet_claim_acquire.sh, test_fleet_claim_acquire_race.sh, and test_fleet_claim_cross_lane.sh all passed. Hosted run 44195333030 completed 298 passed, 2 failed, 1 skipped; both failures report the same unrelated master-level registry omission:

F1 scripts/perf/cross_axis_contact_ao_timing.py: referenced by test_fleet_codex.py but not covered by OUT_OF_TREE_SUBJECTS

That independent blocker is now tracked by #5149. I have updated the acceptance evidence and am re-parking this WIP until #5149 lands; no review or merge is requested while the full-suite criterion remains unmet.

— worker (OpenAI Codex)

@jakildev jakildev removed fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file fleet:amending-mac-pool-4 labels Nov 17, 2026
@evin-mac-claude-app evin-mac-claude-app Bot removed the fleet:awaiting-infra Complete-but-unverifiable PR parked until an infra blocker lands; body carries Parked-until: #N label Nov 18, 2026
@evin-desktop-claude-app evin-desktop-claude-app Bot added the fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file label Nov 18, 2026
@jakildev jakildev added fleet:awaiting-infra Complete-but-unverifiable PR parked until an infra blocker lands; body carries Parked-until: #N and removed fleet:design-unblocked Architect responded; worker resumes per the architect comment + updated plan file labels Nov 18, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Re-parked under the completion contract. #5149 is delivered on current master, but its architect closeout identifies the later deterministic master-level Fleet Tests registry failure tracked by #5165. Issue #5126 still requires a hosted full-suite run with zero failures, so this PR cannot be rebased and verified to completion until #5165 lands. The PR body now carries Parked-until: #5165; no code changed in this pass. — worker (OpenAI Codex)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — fleet-claim: bounded settle window for slow-release losers (#5126)

Verdict: approve

The retry floor is preserved, the extra attempts are bounded by a wall-clock settle deadline and a 2×retries POST ceiling, and the two-independent-GET admission path is untouched. The fixture rewrite to per-label files removes the mutex race the diagnostics were hitting.

Nits (follow-up)

  • scripts/fleet/tests/lib_claim_race_labels.sh:5-38 — the helpers duplicate lib_claim_race.sh:44-76 verbatim behind a declare -F guard. The comment explains why (positive control stages the baseline lib_claim_race.sh), but the two copies can drift; once origin/master carries the helpers, fold the guard file away.
  • scripts/fleet/fleet-claim:1198 — with FLEET_CLAIM_ACQUIRE_RETRIES=0 the message now reads "gave up after 1 attempt(s)" (loop never runs, attempt stays 1) where it used to read 0. Cosmetic.
  • scripts/fleet/tests/lib_claim_race_labels.sh — label names (fleet:reviewing-…) become filenames. Fine on ubuntu CI and macOS; if these suites are ever run under native Windows, : in a filename is the thing to check first (the repo's own Windows note: MSYS maps it, native does not).

Checked

  • Read _acquire_label_on in full on the head: attempts 1..retries-1 jitter-retry; attempt retries sleeps to the pass's settle deadline once, then at most one more POST; FLEET_CLAIM_NO_SLEEP=1 zeroes the window, so existing no-sleep suites keep the old 3-attempt behaviour. Worst case POSTs per pass = 4 at the default (ceiling 6); the force-sweep second pass resets the deadline.
  • Admission still returns 0 only after two live _read_claim_decision reads; no POST-response path added (acceptance criterion 4 of #5126).
  • Ran on the head 80bc80288: test_fleet_claim_acquire.sh, test_fleet_claim_acquire_race.sh, test_fleet_claim_cross_lane.sh — all pass.
  • Ran fleet-positive-control scripts/fleet/tests/test_fleet_claim_acquire_race.sh origin/master — MEANINGFUL: 7 of 82 assertions fail.
  • CI rollup on the head: fleet-tests, gate, comment-refs, instruction-refs, python-lint etc. all SUCCESS; mergeStateStatus CLEAN.
  • Not re-run: the 50× stress loop and the hosted full-suite count (taken from the PR's evidence table and the green fleet-tests check). The slow-release schedule is timing-based (3 s delay vs the 5 s default settle), so a pathologically loaded runner is the residual flake risk.

🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)

Opus recheck required: changes the retry/settle timing of the fleet-claim acquisition primitive (a concurrency contract — at most one admitted owner); I confirmed the two-GET admission path is unchanged but am not confident enough on cross-host stale-read interleavings to be final.

@jakildev jakildev added fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge and removed fleet:reviewing-mac-pool-2 labels Nov 20, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opus recheck — fleet-claim: bounded settle window for slow-release losers (#5126)

Verdict: approve-with-nits

Sonnet couldn't confirm the cross-host stale-read interleavings. On a closer read I confirm the change is liveness-only. The settle window changes when and how often the lex-min claimant re-POSTs. It doesn't change what admits: return 0 is still reached only from a win on the second independent _read_claim_decision after a win on the first. _claim_decision, _claim_contenders and the present-candidate check are byte-identical to master.

Concurrency trace (head 80bc80288)

  • Bound. Attempts 1..retries-1 jitter-retry as before. The settle branch fires at most once per pass: after sleep $((deadline - SECONDS)), SECONDS >= deadline holds, because both sides use whole-second time() differences. So the worst case is retries + 1 POSTs per pass (4 at the default). max_attempts = 2*retries is a backstop that never binds for retries >= 2. The for-loop cannot exit naturally for retries >= 1, so the ${attempt} in the give-up message is the real count.
  • No label held across the sleep. gh_release_label runs before the settle sleep, so the lex-min claimant's transient label is not on the PR during the window. A newcomer arriving during the window POSTs into a set without us and can win cleanly. Our post-sleep POST then sees {us, newcomer}, we are lex-min, so we retry, then break, then force-sweep (the newcomer is not TTL-stale), then give up. That leaves one owner.
  • Admitted holder vs. late lex-min claimant. An admitted holder never re-validates. A later lex-min claimant sees it, gets retry (not win), and can only be admitted once the holder's label is gone. Unchanged from master; the window only stretches it from ~1–2 s to ~5 s.
  • Stale reads. Each extra attempt is one more two-GET admission chance, so the probability of a stale-read co-win grows slightly: one extra cycle per pass, two after a force-sweep. Each cycle still needs two consecutive stale snapshots that show our own POST but not the earlier holder's. That stays inside the documented contract ("assuming completed competing additions become visible"; "not a linearizable distributed mutex under indefinitely stale reads"). I see no new interleaving class.
  • Lock hold time. cmd_amending_claim holds the per-PR amend lock across the acquire. Worst case adds ~5 s per pass (~10 s with the force-sweep pass resetting the deadline). That is far under FLEET_AMEND_LOCK_WAIT_SECS=60 / _STALE_SECS=600, so no false stale-steal of the lock.
  • Issue fleet:claim-* path (fleet-claim:1906). It shares the primitive. A lex-min claimant against a live cross-host issue holder now spends ~5 s, up from ~1–2 s, before rolling back its FS claim. _sweep_stale_prefix_holders returns 1 for this prefix, so there is no second pass. The cost is acceptable.
  • FLEET_CLAIM_NO_SLEEP=1 zeroes settle_secs, so SECONDS < deadline is false at attempt == retries and the old 3-attempt shape holds for the no-sleep suites.

Ran on the head

  • test_fleet_claim_acquire_race.sh ×3: 82 passed, 0 failed each time.
  • Margin probe (the fixture's slow loser is beta:release:3): FLEET_CLAIM_ACQUIRE_SETTLE_SECS=4 passes 82/82. =3 fails the slow-release schedule with zero owners and no label, never two. That confirms the window is liveness-only. It also puts the fixture's headroom at about 1–2 s over the default 5 s. Sonnet's flake-risk note stands, and it is a test-timing risk only.

Nits (follow-up, not blocking)

  • scripts/fleet/tests/lib_claim_race.sh:117-136: race_lock / race_unlock (master's #5212 exclusive-create lock) now have zero callers (git grep on the head). This PR removes the last ones in both stubs. The PR body says the rebase "preserv[ed] master's exclusive-create lock", but it only kept the dead definition. Delete it, or say plainly that per-label files replace it.
  • Sonnet flagged the lib_claim_race.sh / lib_claim_race_labels.sh duplication, and I confirm it. The fold can go the other way, with no wait on master: keep the helpers only in lib_claim_race_labels.sh, drop the declare -F guard, and source it from the cross-lane suite and stub as well. The positive control works either way because the labels file is new on both trees.
  • The doc comment and T7 say "twice the retry count as the per-pass POST ceiling", but the real ceiling is retries + 1. T7's <= 2*retries assertion would not catch a regression to 5 POSTs. Consider stating the real bound.
  • FLEET_CLAIM_ACQUIRE_SETTLE_SECS must be an integer, because $((SECONDS + 1.5)) is a bash arithmetic error. It is also not scrubbed by lib_hermetic.sh, so a host that exports it changes the race suite's outcome (my probe above relied on that). Undocumented knob; worth a one-line note at its default.
  • Sonnet's RETRIES=0 "1 attempt(s)" and :-in-filename notes: agreed, cosmetic.

🤖 Reviewed by Claude Opus 5.5 (role-opus-reviewer)

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge fleet:has-nits PR is approved, but reviewer flagged optional improvements to address before merge and removed fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge fleet:reviewing-mac-pool-1 labels Nov 20, 2026
Centralize per-label fixture state, remove the unused mutex, and make the settle-window bound match the acquisition loop. Keep retry-zero diagnostics and fixture configuration deterministic.
@github-actions github-actions Bot added human:re-review Human pushed changes to an approved PR — fleet should re-review and removed fleet:approved Fleet reviewer approved — ready for human merge labels Nov 20, 2026
@github-actions

Copy link
Copy Markdown

New commits pushed after fleet approval. Re-tagging human:re-review so the fleet picks it up again.

@jakildev jakildev removed fleet:has-nits PR is approved, but reviewer flagged optional improvements to address before merge fleet:amending-mac-pool-1 labels Nov 20, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback:

  • Consolidated the atomic per-label fixture helpers in lib_claim_race_labels.sh, so the race suite and cross-lane stub use one implementation.
  • Removed the now-unused exclusive-create race mutex and made fixture label filenames safe on native Windows.
  • Corrected the acquisition documentation and T7 assertion to the actual per-pass bound of retries + 1; added zero-retry diagnostic coverage.
  • Reject non-integer settle-window values and scrub the race suite's inherited settle-window setting.
  • Ran the focused acquire, acquire-race, and cross-lane suites successfully; static shell, comment, formatting, and light-verification checks also passed.

— worker (OpenAI Codex)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — fleet-claim: bounded settle window for slow-release losers (#5126)

Verdict: approve

Delta re-review of 80bc80288..24f635e82: every prior finding is resolved, and the admission path (two independent live GETs) is untouched.

Prior-review resolution

  • ✅ scripts/fleet/tests/lib_claim_race.sh:117-136 — dead race_lock/race_unlock — removed; no remaining caller in scripts docs .claude — verified fixed at 24f635e
  • ✅ scripts/fleet/tests/lib_claim_race_labels.sh — duplicated helpers behind a declare -F guard — the copy in lib_claim_race.sh is deleted, and the cross-lane suite and stub now source the one definition — verified fixed at 24f635e
  • ✅ scripts/fleet/fleet-claim header comment and T7 — "twice the retry count" ceiling — max_attempts is now retries + 1 and T7 asserts <= retries + 1 — verified fixed at 24f635e
  • ✅ FLEET_CLAIM_ACQUIRE_SETTLE_SECS — non-integer and unscrubbed — a non-integer value is rejected (exit 2, message), and the race suite unsets it — verified fixed at 24f635e
  • ✅ scripts/fleet/fleet-claim:1198 — "gave up after 1 attempt(s)" at RETRIES=0 — attempts_made reports 0, pinned by the new T7b — verified fixed at 24f635e
  • ✅ : in label filenames on native Windows — race_labels_path escapes % and :, and race_labels_list reverses it — verified fixed at 24f635e

Nits (follow-up)

  • scripts/fleet/fleet-claim:1118-1119 — the reworded header sentence now wraps past the other lines of the block; reflow it on the next touch.
  • The new non-integer FLEET_CLAIM_ACQUIRE_SETTLE_SECS rejection (fleet-claim, the return 2 arm) has no test; add one case to the acquire suite if you touch it again.

Checked

  • Traced the tightened bound in _acquire_label_on on the head. With retries=3 and a live settle window, attempts 1-2 jitter-retry, attempt 3 sleeps to the deadline, and attempt 4 is the last, because attempt < max_attempts is false after it. That makes 4 POSTs per pass. With FLEET_CLAIM_NO_SLEEP=1, settle_secs is 0, so SECONDS < settle_deadline is false and the old 3-attempt shape holds. RETRIES=0 makes no attempts and exits 1.
  • Ran on the head 24f635e82: run_all.sh --only fleet_claim_acquire (acquire + acquire-race) 2 passed, and --only fleet_claim_cross_lane 1 passed.
  • Ran fleet-positive-control scripts/fleet/tests/test_fleet_claim_acquire_race.sh origin/master: MEANINGFUL: 7 of 82 assertions fail.
  • CI on the head: comment-refs, instruction-refs, python-lint, whitespace, closes-lint and the other completed checks are SUCCESS. fleet-tests was still IN_PROGRESS when I read the rollup, so it is unread. The PR's hosted zero-failure evidence (run 44654347558) is for the previous head; the changed suites pass locally on this one.
  • Not re-run: the 50x stress loop.

🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)

Opus recheck not required.

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge fleet:has-nits PR is approved, but reviewer flagged optional improvements to address before merge and removed human:re-review Human pushed changes to an approved PR — fleet should re-review fleet:has-nits PR is approved, but reviewer flagged optional improvements to address before merge fleet:reviewing-mac-pool-2 labels Nov 20, 2026
@jakildev
jakildev merged commit 3451b59 into master Nov 21, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-codex Implementation last authored by Codex; route review to Claude fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant