Repository navigation
fix(recovery): wait for owner release before reply admission - #120935
Conversation
Punchcard-Session: amber-workshop-workshop-36
|
Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 2:45 AM ET / 06:45 UTC. ClawSweeper reviewWhat this changesThe PR makes successor replies wait for durable restart-recovery ownership release before they can enter reply admission. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep open. Current main still wakes successor reply work before durable recovery-owner release begins; this PR moves that ordering fence to the registry owner boundary and has no definite correctness finding, but it remains a draft maintainer PR needing exact-head validation and a maintainer decision on the persistent-store outage tradeoff. Priority: P1 Review scores
Verification
How this fits togetherRestart recovery coordinates an interrupted agent reply with the next inbound turn. The reply-run registry controls in-memory lane admission, while the recovery store owns the durable lease release that prevents a successor from observing stale recovery state. flowchart LR
A[Reply operation completes] --> B[Reply-run registry]
B --> C[Successor admission fence]
C --> D[Durable owner release]
D --> E[Recovery store]
E --> F[Next reply admission]
F --> G[Reply delivery]
Decision needed
Why: The implementation intentionally favors durable recovery correctness over immediate visible-reply availability during a store outage; source inspection establishes the behavior but cannot choose the product tradeoff. Before merge
Agent review detailsSecurityNone. PR surfaceSource +243, Tests +441. Total +684 across 7 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the registry-owned fence, rebase it, and prove the restart-recovery ordering through the Matrix/mock-gateway boundary before a maintainer marks the PR ready. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main wakes the reply lane before beginning durable owner release, and the linked Matrix QA report provides the observable failed ordering; no fresh run was executed in this read-only review. Is this the best way to solve the issue? Yes. Starting the fence in the reply-run registry before wake-up fixes the owner ordering directly while leaving durable CAS and retry ownership in the recovery store; narrowing downstream claim comparisons would be a less canonical mitigation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a3d2ac7dc887. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer decision and ClawSweeper Rank-up moves:
No ClawSweeper code or security finding remains. Proceeding only through the required |
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Merged via squash.
|
…20935) Punchcard-Session: amber-workshop-workshop-36
Fixes #120833
What Problem This Solves
Fixes an issue where a reply arriving immediately after restart recovery could begin before the previous reply operation had durably released its recovery ownership. In that ordering, the successor could snapshot recovery state that the old owner's delayed release then changed.
Why This Change Was Made
The reply-run registry is the lifecycle owner for operation clear and successor admission. It now installs and starts a successor-admission fence synchronously when the old operation clears, before the lane wakes a successor. The recovery-store release remains the durable CAS owner and resolves that fence only after its bounded owner-release retry completes.
Visible successors wait abortably through the release retry. Queued follow-ups remain bounded, heartbeat callers remain non-blocking, rotated session IDs propagate across registered aliases, and command-turn adoption preserves the source-keyed recovery identity.
Root Cause
runAfterReplyOperationClearpreviously began durable recovery-owner release only afterclearReplyRunStatenotified lane waiters. That allowed a successor to pass admission and read durable recovery state before the old owner's release callback ran.Architectural Owner And Canonical Fix
reply-run-registry.tsowns operation clear ordering and successor admission.reply-turn-admission.tsregisters recovery-owner release as the operation's successor fence.main-session-recovery-store.tsowns the durable release retry and completion signal.The canonical path remains the existing reply operation and durable recovery CAS flow. No duplicate execution path or downstream compensation layer was added.
Removed Or Avoided Paths
AsyncLocalStorage, QA ownership moves, or broad CLI changes.User Impact
Replies that race restart recovery no longer observe a partially released recovery owner. Normal visible replies remain cancellable, while queued and heartbeat traffic keeps its existing bounded behavior.
Evidence
Independent exact-head review approved:
4d6ed0cf84e1b88c43cdc8b128173d46a877847fFocused local proof:
reply-run-registry.test.ts: 73 passedreply-turn-admission.test.ts: 48 passedmain-session-recovery-store.test.ts: 23 passedrestart-recovery-claim.test.ts: 8 passedsession-accessor.test.ts: 94 passedgit diff --check: passedorigin/maind7133e7df6f5418810609be4827f61e2c51e7120: clean (abb54df2d66bfa806bfe88442f4b70df7bf5d4c7) with no overlap in the seven owner filesChanged-check proof passed conflict, ratchet, formatting, SDK contract, API, boundary, and package-patch gates. The remaining local typecheck gap is environment-only: this linked worktree lacks package-local
[email protected], so resolution falls back to root4.2.3. Hosted exact-head CI and repository-native prepare gates remain required before merge.Production delta:
+282/-39Test delta:
+442/-1Punchcard-Session: amber-workshop-workshop-36