Repository navigation
fix(workflows): fence fresh hold mints on claim_epoch to prevent stale-claim parks (#769) - #781
Merged
Merged
Conversation
…'s row Prevents a step body whose lock lease lapsed before its first wait from parking a newer claim's running node, or committing a hold row that no node stands on: - Requires the executing claim's positive `claim_epoch` on the fresh hold mint and drops the nullable bypass in the park's SQL fence, so only the claim that holds the running row can park it; a non-positive epoch is refused before any write. - Parks the node before inserting the signal row and raises a dedicated fenced-mint error when the park matches nothing, so the signal insert and the create broadcast roll back with the park instead of leaving an orphan hold behind. - Threads the epoch through the three fresh-mint wait doors (signal, timer, child join) and unwinds a fenced mint as `"fenced"` in the plain-step and loop tails, fencing the stale claim's own ledger rows instead of reporting it as held. - Adds Postgres integration pins for the stale-claim races across all three wait surfaces, the loop node, and the production fleet execution door, and realigns the hold-staging pins to the closed orphan window.
… and map-sibling wake lookup (#769) - Return bool from reassert_hold and raise HoldMintFencedError on missed re-parks across signal, timer, and child-join wait doors so stale re-entries unwind fenced instead of held. - Fence _HOLD_HOLD_NODE_SQL against cooperatively cancelled nodes (cancel_phase = 0 AND NOT metadata ? 'cancel_phase') and type HoldMintFencedError.node_id as JobId. - Narrow _defer_loop_step / _drive_loop / _run_loop_node return types to Literal outcomes and propagate cancelled/laddered/fenced verdicts through FlowRunner._execute_claimed_tail. - Remove the = 0 default on claim_epoch across the six tail/loop forwarding parameters and switch sweep_due_timers and sweep_child_joins to exact hold-id lookup (_HELD_NODE_BY_HOLD_SQL). - Log wf-hold-mint-park-missed at INFO with attempted_hold_id, add seed_running_claim to tests/_wf_fixtures.py, pin fenced non-consumption in test_worker_execution_seam.py, and add regression pins.
rcbevans
force-pushed
the
fix/769-hold-mint-epoch-fence
branch
from
November 26, 2026 08:59
295fbfb to
bfcc16d
Compare
…old-mint fencing (#769) - Thread claim_epoch into _flow_job in tests/test_wf_flow_rate_limit_pins.py so the synthetic JobRow matches the Postgres row's claim_epoch=1 when testing hold-slot release. - Reclaim the node row to status='running' at claim_epoch=2 before re-waiting on the standing hold in tests/probes_coverage_closers.py::test_the_re_wait_while_a_hold_stands_raises_node_held.
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 changed
Fences fresh hold mints in
register_holdon the executing claim's positiveclaim_epochso a step body whose lock lease lapsed before its first wait cannot park a newer claim's running node or commit an orphanwf_signalshold row.src/taskq/workflows/api/_hitl.py):claim_epochon fresh hold mints and drops the nullable bypass from_HOLD_HOLD_NODE_SQL(status = 'running' AND claim_epoch =).wf_signalsrow and raisesHoldMintFencedErrorwhen the park matches zero rows so the transaction rolls back cleanly with no orphan hold or create notification._ctx_wait.py,_ctx_timer.py,_childflow.py,_runner.py,_runner_loop.py,_worker_execution.py):claim_epochthrough signal, timer, and child-join fresh hold mint paths.HoldMintFencedErrorbefore generic body-failure boundaries in both plain-step and loop execution tails, fences only the stale claim's ledger rows, and propagates"fenced"throughexecute_flow_job.tests/test_wf_hold_mint_epoch_fence.py): Covers stale-claim races with live successors and re-pended rows across signal, timer, child-join, loop, and fleet execution door paths, plus notification silence on fenced mints.Verification
.venv/bin/pytest tests/test_wf_hold_mint_epoch_fence.py -q: passing.venv/bin/ruff check,.venv/bin/ruff format --check,.venv/bin/pyrighton changed files: 0 errors, 0 warningsCloses #769