Repository navigation
Exclude coordination-blocked refreshes from PRISM template failure budget - #56
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit acffce0. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: acffce0ec8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
poll_qbit_tip_template_once raises TemplateRefreshBlocked (and its _PayoutStatePublicationBlocked subclass) for benign coordination races: a tip superseded mid-refresh, a payout publication fence pending, a refresh raced by payout mutation. Since #51 the generic failure handler recorded these into the template-refresh failure budget, so sustained payout-coordination churn exhausted PRISM_TEMPLATE_REFRESH_FAILURE_EXIT_SECONDS and os._exit(1)'d a process whose qbitd RPC was perfectly healthy -- and each restart re-triggered the same churn, producing a restart loop in production. Re-raise coordination-blocked refreshes ahead of the recording handler: they still propagate so blockpoll/blockwait schedule their immediate retry, but they no longer arm the exit clock. Genuine RPC/qbitd failures still record on first failure and still exit non-zero once the budget elapses; the success-path reset is untouched. Co-Authored-By: Claude Fable 5 <[email protected]>
Review feedback (Codex P1, Bugbot high): TemplateRefreshBlocked also wraps genuine failures -- malformed template artifacts, all client job builds failing, untrusted chain views, wrapped RPC validation errors -- and a blanket exemption would let those persist forever without work issuance on a process whose top-of-poll RPCs stay healthy. Introduce TemplateRefreshSuperseded(TemplateRefreshBlocked) and raise it only at the coordination-race sites (tip advanced mid-refresh, payout generation moved, prepared refresh superseded). The failure-budget exemption now covers only that subclass plus the payout publication fence; plain TemplateRefreshBlocked records again, so persistent non-coordination failures arm the budget from a fresh process and still take the budgeted restart path. Co-Authored-By: Claude Fable 5 <[email protected]>
acffce0 to
13bb5ba
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13bb5ba3ed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex round-2 P1: blockpoll_loop's generic handler checked template_refresh_failure_expired on every exception, so a clock armed by one transient budgeted failure could still be FIRED by a coordination-blocked attempt once churn outlasted the budget -- hard-exiting a process whose qbitd RPC had already recovered. Catch (TemplateRefreshSuperseded, _PayoutStatePublicationBlocked) in blockpoll_loop ahead of the generic handler: log and retry without consulting the budget. The armed clock now waits for the next budgeted failure or clears on the next completed refresh. The pre-armed untrusted-reconciliation and all-builds-failing exits are unaffected -- those raise plain TemplateRefreshBlocked, which still takes the budgeted path. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7779bf0e66
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex round-3 P1: the sequential/collection-mode path detects superseded snapshots inside maybe_send_job's guarded build -- "tip refresh snapshot was superseded before/during client job build" and "payout state changed during client job build" -- and those still raised plain TemplateRefreshBlocked, so sustained pre-ready coordination churn could arm and exhaust the failure budget despite healthy RPC. The startup prewarm path carries the same supersession trio. Classify all six sites as TemplateRefreshSuperseded. maybe_send_job's guarded handler re-raises TemplateRefreshBlocked unwrapped, so the subclass reaches the poll's exemption intact; genuine build failures still wrap into _JobBuildFailed and stay budgeted via the no-refreshed-work raise. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Reconcile the tip publication boundary (build/validate before submit authority moves) with 1.x.x's short publication lane (#58), bounded build supersession (#57), superseded-vs-blocked budget taxonomy (#56), and delivery priorities: - keep construction outside the publication lane, then run the PR's final validation and atomic prepared publication inside it - drop the base's early tip publication before template fetch; the poll now only records a detection there - compare build-pipeline supersession gates against the newest detected tip so a replacement build for a detected-but-unpublished tip can cache and publish itself - cancel obsolete bundle/job builds at detection time - clear retained ready bundles when publication flips the tip - classify prepared-publication races as TemplateRefreshSuperseded so coordination churn cannot arm the restart budget

Problem
poll_qbit_tip_template_onceraisesTemplateRefreshBlockedfor benign coordination races — a tip superseded mid-refresh, payout state changing during fanout — and_PayoutStatePublicationBlockedwhenever a payout publication fence is pending. The genericexcept Exceptionat the end of the poll recorded all of these via_record_template_refresh_failure.Since #51 the failure budget starts at the first recorded failure. Once
PRISM_TEMPLATE_REFRESH_FAILURE_EXIT_SECONDS(deployed: 600) elapsed without a completed refresh, blockpollos._exit(1)'d. Observed in production: sustained payout-coordination churn self-terminates a process whose qbitd RPC is perfectly healthy, and each restart re-triggers the churn — a restart loop.Fix
Introduce
TemplateRefreshSuperseded(TemplateRefreshBlocked)and raise it at the coordination-race sites only: tip advanced mid-refresh (fetch, sequential, prepared fanout, queued work), payout-state generation moved (client selection, sequential, post-fanout token checks, payout-only invalidation), and prepared-refresh supersession (fanout submission/cancellation registration, pending-token loss). #58's_BundlePreparationSuperseded("newer tip superseded shared bundle preparation"), which escapesshared_job_bundleinto the poll, subclasses it.The poll re-raises
(TemplateRefreshSuperseded, _PayoutStatePublicationBlocked)ahead of the recording handler: blocked refreshes still propagate —blockpoll_loop/blockwait_loopstill schedule their immediate retry — but they no longer arm the exit clock.Everything else stays budgeted, per review feedback from Codex and Bugbot: plain
TemplateRefreshBlockedalso wraps genuine failures — malformed template artifacts, all client job builds failing, untrusted chain views, RPC validation errors — and those persistent states must still take the budgeted restart path even when top-of-poll RPCs stay healthy. Raw RPC/qbitd failures record as before, and the success-path reset is untouched.Coordination-blocked attempts can neither arm nor fire the budget:
blockpoll_loopcatches the two exempt types ahead of its generic handler and retries without consultingtemplate_refresh_failure_expired, so a clock armed by a transient budgeted failure waits for the next budgeted failure (or clears on the next completed refresh) instead of exiting mid-churn. An already-armed budget still fires on any subsequent budgeted failure — matching the existingtest_untrusted_reconciliation_exhausts_template_refresh_failure_budget/test_all_refresh_job_builds_failing_exhausts_failure_budgetsemantics, which raise plainTemplateRefreshBlocked.Acceptance
test_sustained_blocked_refresh_storm_never_exhausts_failure_budgetdrives the real poll through alternatingTemplateRefreshSuperseded/payout-fence failures spanning >2x the budget window with a healthy tip RPC — noos._exit, clock never armed.test_rpc_outage_arms_and_exhausts_failure_budgetsimulates qbitd unreachable — the budget arms on the first raw RPC failure and the loop exits non-zero once it elapses.test_persistent_blocked_template_derivation_arms_and_exhausts_failure_budgetandtest_non_coordination_blocked_refresh_still_starts_failure_budgetprove plainTemplateRefreshBlocked(malformed artifacts / failing builds) arms the budget from a fresh process and takes the restart path.test_coordination_blocked_refresh_does_not_start_failure_budgetcovers both exempt types at the poll level.test_armed_budget_is_not_fired_by_coordination_blocked_refreshpre-arms the clock, drives blocked churn past the budget window, and asserts no exit with the clock left armed.All 512 tests across the 14 coordinator-dependent test modules pass, rebased on current
1.x.x(includes #58).🤖 Generated with Claude Code
Note
Medium Risk
Touches core blockpoll shutdown logic and error taxonomy; misclassification could either mask real outages or reintroduce restart loops under churn.
Overview
Fixes a production restart loop where benign tip/payout coordination races were counted like real template failures and eventually drove
blockpoll_looptoos._exit(1)despite healthy qbitd RPC.Introduces
TemplateRefreshSuperseded(TemplateRefreshBlockedsubclass) and reclassifies coordination-race sites—tip moved during fetch/fanout/sequential refresh, payout generation drift, prepared-refresh token loss, payout-only invalidation supersession—so they raise the new type._BundlePreparationSupersedednow subclasses it as well.poll_qbit_tip_template_onceandblockpoll_loopcatch(TemplateRefreshSuperseded, _PayoutStatePublicationBlocked)before_record_template_refresh_failure/template_refresh_failure_expired, so these paths still schedule immediate retries but never arm or fire the failure clock. PlainTemplateRefreshBlocked(bad artifacts, failed job builds, RPC validation errors, etc.) and raw RPC exceptions keep the budgeted restart behavior.Adds coordinator tests for coordination storms, armed-budget + churn, RPC outage, and persistent non-coordination blocked states.
Reviewed by Cursor Bugbot for commit fa2ae52. Bugbot is set up for automated code reviews on this repo. Configure here.