Repository navigation
fix(session): stop repeated restart recovery after retry budget - #96230
Conversation
afb7fe4 to
ea5b01f
Compare
|
Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 10:32 AM ET / 14:32 UTC. Summary Reproducibility: yes. The canonical issue provides a concrete cross-boot reproduction, and the baseline Telegram run demonstrates repeated exhausted-session replay on main before the candidate suppresses it. Review metrics: 3 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the integrated durable-owner design only after exact-head gates finish and focused recovery, Plugin SDK compatibility, upgrade, and real Gateway exhaustion evidence remain green. Do we have a high-confidence way to reproduce the issue? Yes. The canonical issue provides a concrete cross-boot reproduction, and the baseline Telegram run demonstrates repeated exhausted-session replay on main before the candidate suppresses it. Is this the best way to solve the issue? Yes for the architecture: durable pre-dispatch reservation, exact rollback, atomic session-store ownership, and private recovery state address the root invariant. The current head should merge only after exact-head validation completes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b319493a529c. Label changesLabel justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (42 earlier review cycles; latest 8 shown)
|
ea5b01f to
f5c22bc
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
83e1512 to
6efe6a1
Compare
8f20ee5 to
408fb8d
Compare
|
Merged via squash.
|
Related: #95750
Follow-up: #105877
Current Status
The implementation and validation work is complete on the frozen final range:
The branch intentionally stays on that reviewed and verified baseline. It will not continue chasing later
mainmovement. GitHub currently reports the PR asCONFLICTING / DIRTYbecausemainadvanced again after the final rebase; that repository-level conflict is the only known landability blocker.What Problem This Solves
A Gateway restart could repeatedly select the same interrupted main session for automatic recovery. The existing retry loop was process-local, so supervisor backoff only delayed the next attempt: a session that never became healthy could be dispatched again after every restart without a durable ceiling.
This PR adds a durable, session-owned recovery fuse. The first three accepted or acceptance-uncertain automatic recovery attempts may dispatch. Before a fourth dispatch, OpenClaw persists an operator notice, tombstones the session, and requires recovery through inspection and
/newor reset.Why This Change Was Made
Recovery ownership
The durable state is the core-internal
InternalSessionEntry.mainRestartRecoveryaggregate, separate from the publicSessionEntrycontract. It records the recovery cycle and revision, charged attempts, the exact pre-dispatch reservation, lifecycle-generation foreground claim tokens, and an optional terminal tombstone.src/agents/main-session-recovery-state.tsowns the pure transitions.src/agents/main-session-recovery-store.tsowns atomic persistence against the canonical SQLite row. Gateway and direct agent-command ingress use the same identity, revision, reservation, lifecycle-generation, and foreground-owner rules.The policy is:
restartRecoveryRunsremains a lifecycle-generation fence rather than the durable retry budget. Subagent orphan recovery remains independently owned and retains its existing policy.Concurrency and restart safety
The final implementation includes:
Plugin SDK boundary
Recovery coordination remains internal and does not become a plugin contract.
SessionEntry.loadSessionStoreandupdateSessionStorenow also project public rows and reconcile public mutations while preserving private recovery state and deletion semantics.The broader shipped Plugin SDK testing-barrel question remains tracked separately in #105877.
User Impact
A wedged main session can no longer trigger unbounded automatic resume across Gateway restarts. After three charged accepted or acceptance-uncertain attempts, OpenClaw persists the operator notice and quarantines the session before another automatic dispatch. Healthy progress, replacement, or reset restores the full budget; waiting alone does not.
Plugins continue to see the public session contract and cannot observe or accidentally overwrite the internal recovery state through either modern or deprecated session-store APIs.
Evidence
Exact frozen range:
14recovery-state,15Gateway lifecycle,198agent tests).tsgolanes passed.oxfmt/oxlintpassed.24.15.0.APPROVED.Final end-to-end proof used a local Docker container, actual provider
local-container, leasecbx_9736f8111fa1, Ubuntu 26.04:status=failed,abortedLastRun=false, andchargedAttempts=3;Exact-head GitHub automation has passed the dependency and security guards plus one real-behavior proof run. The standard full CI workflow did not dispatch for this fork-head update. Exact-merge-result CI cannot exist while GitHub reports the later-main conflict.
Known Blocker
The code, tests, review findings, and exact-head behavior proof are complete. GitHub currently reports
mergeable=CONFLICTINGandmergeStateStatus=DIRTYaftermainadvanced again. Per the frozen-branch decision, this PR will not be rebased or merged with another movingmainbaseline.