Repository navigation
fix(gateway): make restart recovery state authoritative - #129316
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
3abb749 to
68ce2a0
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
68ce2a0 to
1f0a51a
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 7:55 PM ET / 23:55 UTC. ClawSweeper reviewWhat this changesMoves Gateway restart recovery marking to shutdown-time exact-run handling and reports recovery starts separately from terminally settled outcomes. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for maintainer review: the recovery-owner refactor matches the current-main defect and prior cookie finding is resolved, but direct Codex-source verification required by repository policy is unavailable in this review environment. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherGateway restart first drains active work, then server shutdown decides which exact live sessions require recovery. Startup recovery dispatches those sessions, while lifecycle persistence records their eventual terminal outcome. flowchart LR
A[Gateway restart] --> B[Drain active work]
B --> C[Shutdown rechecks live runs]
C --> D[Persist recovery markers]
D --> E[Abort remaining runs]
E --> F[Startup recovery dispatch]
F --> G[Terminal session persistence]
Decision needed
Why: Repository policy requires direct inspection of that source before a final Codex verdict, while the PR body expressly relies on it as dependency evidence. Before merge
Agent review detailsSecurityNone. PR surfaceSource +5, Tests +20. Total +25 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain server close as the sole recovery-marker owner, verify the cited Codex lifecycle contract directly, then land only after exact-head CI is green. Do we have a high-confidence way to reproduce the issue? Yes: current main marks drain-start identifiers before waiting, and the branch removes that duplicate owner in favor of shutdown-time revalidation. Is this the best way to solve the issue? Yes for the OpenClaw boundary: server close already owns terminal persistence, live-run collection, marking, and abort sequencing. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b1ea61e84703. 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
HistoryReview history (3 earlier review cycles)
|
1fb1be4 to
2462e77
Compare
|
Exact-head follow-up for
Tak attribution remains in every PR commit as requested. Exact-head CI is attaching now; I will not land until the required rollup is green. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
7726553 to
68b3567
Compare
facc955 to
a6cd616
Compare
a6cd616 to
e09df55
Compare
Fixes #129285 and #129300. Co-authored-by: Tak Hoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
e09df55 to
f735922
Compare
|
Land-ready proof for
Verification:
The native review artifacts validate as |
|
Merged via squash.
|
) * fix(gateway): make restart recovery state authoritative Fixes openclaw#129285 and openclaw#129300. Co-authored-by: Tak Hoffman <[email protected]> * fix(gateway): preserve restart recovery terminal fence Co-authored-by: Tak Hoffman <[email protected]> * fix(gateway): cancel rootless work during restart Co-authored-by: Tak Hoffman <[email protected]> * fix(gateway): keep restart abort lifecycle-scoped Co-authored-by: Tak Hoffman <[email protected]> --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
Closes #129285
Closes #129300
What Problem This Solves
Fixes two failures in the same restart-recovery invariant:
Why This Change Was Made
Restart marking and abort now have one owner: server close collects exact live run identities, waits for terminal persistence, revalidates them, marks only the runs that still need recovery, then aborts.
Startup reporting remains nonblocking but distinguishes
startedfrom alreadysettled; it no longer calls execution-start “recovered.” An explicit private run-context fact carries restart-recovery provenance to the lifecycle owner, which persists the terminal session state before logging the final success, failure, timeout, or cancellation.This resolves the product decision from #129285 by separating admission/start accounting from lifecycle-owned terminal accounting. The provenance is diagnostic only, non-enumerable, generation-fenced, and never authorization. No config, protocol, Plugin SDK, dependency, or SQLite surface changes.
User Impact
Operators no longer see already-finished work replayed after a graceful restart. Startup logs no longer label an in-progress recovery as successful, and the authoritative lifecycle path records the later terminal outcome after session persistence.
Evidence
Failing-first proof
Applied the new drain-window regression to current
main(bc4ce76db350) without the production fix and ran:It failed for the intended reason:
markRestartAbortedMainSessionshad already been called once with bothsession-finishedandsession-activebefore the drain completed. On this PR head the same regression passes.The recovery regression also models accepted dispatch → execution started → never-settling terminal promise and now returns
started=1, settled=0, notrecovered=1.Focused proof on head
1fb1be422373gateway-root,config-cli) passed with incremental cache output disabled because this isolated host mounts.artifacts/tsgo-cacheread-only.git diff --check, and TruffleHog passed.The first two PR commits were rebased patch-identically onto
147e9da5d8b5;git range-diffreports both as=. Exact-head CI is https://github.com/openclaw/openclaw/actions/runs/32852265152. Earlier-head compact failures were outside this PR's changed surfaces and reproduce from the base (Claude CLI native-auth expectations plus the public Plugin SDK export budget introduced by #129052).Dependency contract
Direct sibling Codex source inspection confirmed the boundary:
codex-rs/app-server-protocol/src/protocol/v2/turn.rs:TurnStatus::InProgressis distinct from terminal statuses;TurnStartedNotificationandTurnCompletedNotificationare separate events.codex-rs/app-server/src/bespoke_event_handling.rs:turn/startedemits an in-progress snapshot;turn/completedemits the final status.codex-rs/app-server/README.md: every turn begins withturn/startedand ends withturn/completed; only the latter carriescompleted,interrupted, orfailed.Screenshots are not useful evidence for this headless lifecycle boundary; the failing/passing ordered regression, persisted terminal-state assertions, exact logs, and CI directly exercise the behavior.
Production LOC: +118/-111 (net +7). Tests: +320/-237 (net +83). The seven-line production growth is the required shutdown-owner seam: lazy runtime import, lifecycle wiring, and the post-mark cancellation call. Removing it recreates ClawSweeper's rootless-compaction P1; putting it back in the run loop recreates duplicate recovery ownership.
AI-assisted: yes. Private operational session identifiers, transcripts, and host details are omitted.
Co-authored-by: Tak Hoffman [email protected]