fix: work item deadlock - centralized claim mirror clearing + dispatc… - #21
fix: work item deadlock - centralized claim mirror clearing + dispatc…#21myfastcat wants to merge 1 commit into
Conversation
|
Thanks for this PR — the core fix targets the real root cause, which we have confirmed. What works (verified)The centralized mirror-clearing in
We reproduced both scenarios against a real SQLite store: on main both are permanent deadlocks (column empty, mirror stale); with this PR both become claimable again. Enforcing "clearing the column also clears the mirror" at the single write chokepoint ( Regression: ~500 related tests, zero new failures (all observed failures pre-exist on main). What is still open"Closes the whole bug class at the single write chokepoint" is not quite complete. What this PR would introduceThe four new early-returns in
Suggested changes
|
- Enforce the runtime-claim/metadata-mirror invariant in update_delegation_work_item so any path clearing the column also clears the mirror the dispatch CAS predicates on. - Clear the metadata mirror in reopen_approved_delegation_work_item_for_rework release_claim branch, closing the reopen-for-rework deadlock gap. - Add DONE_PHASES check in _rehydrate_parked_member_sessions to clear focus when work item is in terminal phase. - Add regression tests asserting that reject-release, children-approved wake, and reopen-for-rework leave both column and mirror empty and re-claimable.
|
Thank you for your feedback, this PR is updated accordingly. Please review. |
fix: work item deadlock - centralized claim mirror clearing + dispatch fixes
Summary
Fixes a deadlock where work items get stuck in
READYorREADY_FOR_REWORKphase but cannot be claimed by any session, causing the entire workflow to stall.Root Cause
When a work item's claim column (
claimed_by_role_runtime_session_id) was cleared, the metadata mirror (metadata.claimed_by_role_session_id/metadata.claimed_task_id) was not always cleared consistently.The dispatch CAS (claim_delegation_work_item_if_dispatchable) predicates on both the column and metadata mirror being empty. When only the column was cleared but the metadata mirror retained a stale value, the work item became
READYbut permanently unclaimable — a deadlock.This manifested in:
READYChanges
claimed_by_role_runtime_session_idis cleared to empty, automatically clearmetadata.claimed_by_role_session_idandmetadata.claimed_task_id. This closes the entire bug class at the single write chokepoint.synthesis_turn_started=Trueorfrontierin("resumed", "synthesis_ready")orREADY_FOR_REWORKphase bypass the dependency check — they were already validated when woken.DONE_PHASESor is_runnable(), allowing them to pick up