Skip to content

fix: resume interrupted peer work after gateway restarts - #176697

Merged
roboclaw-bot merged 20 commits into
mainfrom
openclaw/delta-krill-2
Oct 19, 2026
Merged

roboclaw-bot merged 20 commits into
mainfrom
openclaw/delta-krill-2

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: admitted peer follow-ups and returned results can remain interrupted after a Gateway restart, even though their original session and unfinished work still exist.

User Impact

Peer work resumes automatically in the original session after restart without requiring a manual Resume action or repeating a completed command. Requested replies still arrive when reverse-direction sends are disabled. Stop, cancellation, access revocation, and replaced-session boundaries remain enforced. No configuration or database-schema migration is required.

Why This Change Was Made

Preserve the admitted operator recovery source, route automatic peer results through the existing durable communication owner, and retain their optional-reply context. Requested replies use authority captured from the accepted request rather than a new reverse-direction send permission. Exact endpoint and current cancellation/access checks still apply.

Make concurrent history reconciliation return consistent interrupted state, and revisit startup orphans after a temporary controller owner releases them. Recovery keeps the original startup cutoff and live ownership checks. Explicitly stopped claims and operations retain cleanup custody but cannot be captured or revalidated as recoverable work.

This does not fabricate receipts for historical deliveries already missing evidence or modify the running Team Gateway.

Evidence

Validated tree: 3dad52e17a34de685e32ddae3b04842549bc2111, integrating main 1f7b2f1c6f0075fb90946615d6bab6b96e02f593 and its canonical cleanup repair #176912.

  • 8/8 real-process controls pass: managed restart, SIGTERM, SIGKILL, repeated SIGKILL, automatic peer continuation, restrictions before recovery and permission changes during inference, returned-result recovery, and terminal Stop. Completed effects remain exactly once. Test time: 156 seconds (375 seconds including the clean rebuild); subprocess crashes require this release-tier proof.
  • Real-model Chromium proof passes on the integrated tree: UI send → peer work → completed command → SIGKILL → same-disk restart → automatic final response. No recovery RPC or new post-crash message; original effect remains exactly once. Wall time: 72 seconds (live, opt-in).
  • Integrated ownership/lifecycle tests pass: execution cleanup 34, Gateway authority 20 including teardown, native recovery 13, successor recovery 6.
  • Fresh Gateway test type graph, focused type-aware lint, formatting and diff checks pass. Earlier focused communication/history regressions and selected failed CI cases also passed. Independent P0–P2 review found no additional working-tree defects; its index-only stale test findings were fixed by staging the tested replacement before commit.

The process controls now prove automatic recovery under current shared-secret owner authorization, rather than requiring a new manual turn. This PR does not modify the live Team Gateway.

  • Fixed the final CI integration defect: newer main wrapped backend attachments, but Talk still compared the old shape. The exact CI-base regression reproduced no_active_run; comparing the actual backend handle restores queued-to-running steering without weakening ownership checks. Relevant Talk tests, all 8 process controls and the live browser proof pass on the integrated source.
  • Corrected the input-custody test teardown: successful cleanup is allowed; unexpected errors still fail, and the exact publication-denial regression remains covered separately. Original eight-file authority shard: 110 tests pass.
  • Final full-candidate P0–P2 independent review is clean. Final-head hosted CI passed: run 39206373527, head 3dad52e17a34de685e32ddae3b04842549bc2111.

Requested by Peter Steinberger; co-author credit is preserved in the implementation commits.

Worked on by

Work sessions

roboclaw-bot and others added 2 commits October 19, 2026 00:33
Preserve admitted operator recovery sources for peer follow-ups while keeping internal delivery boundaries. Route automatic peer results through durable communication admission and retain optional-reply semantics.

Keep concurrent history reconciliation consistent and revisit startup orphans after temporary controller owners release, without taking over live, completed, stopped, or replaced work.

Verified with focused regressions, restart and Stop process controls, two real-model Chromium SIGKILL/restart runs, type checks, lint, and independent review.

Co-authored-by: steipete <[email protected]>
Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 5aee73d0-1bd6-44e3-a024-fe4d4af4a30a
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: XL labels Oct 19, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 19, 2026 00:42
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR resumes interrupted peer requests and returned results through existing session recovery owners while preserving Stop and authority checks.

Example: agent:main:peer-restart-target completes a command before the Gateway receives SIGKILL.

  • Before: The peer task can remain interrupted despite its saved session and completed command.
  • After: The task resumes automatically in the same session without repeating the completed command.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Strong recorded behavior proof supports the repair, but two attributable current-head test failures remain.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Recorded final-composition Gateway process controls exercise peer continuation, durable returned-result delivery with reverse sends disabled, Stop across process death, and permission revocation preventing a real filesystem effect; earlier real-model browser runs provide additional qualified evidence.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Accepted peer tasks and their requested results can remain interrupted after a Gateway restart.
Reason: The maintainer-authored direction restores useful continuity through existing owners while preserving terminal cancellation and current execution authority.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open: this PR provides a useful recovery repair, but two diff-caused test failures block merge; the earlier findings are resolved.

Priority: P1
Reviewed head: dfccd3da41775e2c20402f81978640e940417e59

Before merge

  • Supply authenticated requester origin in the peer recovery fixture (P2) - The new peer-follow-up case passes inter_session provenance into createRestartRecoveryOperatorSource without requesterOrigin. The integrated admission owner accepts that provenance only when requesterOrigin.operatorProfileId matches the captured authority, apart from the separate requester-settle exception. Consequently the fixture returns undefined and fails before exercising recovery or the automation write. Exact-head check checks-node-changed-compact-small-10-1 confirms this failure. Pass the authenticated source session and matching operator profile through the fixture; keep the production identity check intact.
  • Preserve the successor ownership-loss regression (P2) - When sourceTurnId is absent, this change stops invoking resolveDeliveryContext. The existing Control UI ownership-loss case in restart-recovery-claim.successor.test.ts schedules its replacement claim through that callback, so replacement never occurs and admission succeeds instead of reporting the changed claim. Exact-head check checks-node-changed-compact-small-23 fails at line 105. Move the test’s replacement to an exercised admission boundary while retaining its refusal assertions, or remove this unrelated callback-evaluation change.

Findings

  • [P2] Supply authenticated requester origin in the peer recovery fixture — src/gateway/operator-run-recovery.test-support.ts:132
  • [P2] Preserve the successor ownership-loss regression — src/auto-reply/reply/restart-recovery-claim.ts:427-429
Agent review details

How this fits together

Session tools admit peer messages into the Gateway’s pending-input owner, which persists recovery facts and dispatches unfinished work after restart.

flowchart TD
  A[Requesting session] --> B[Communication admission]
  B --> C[Durable pending input]
  C --> D[Peer execution]
  D --> E[Accepted result]
  E --> C
  C --> F[Gateway restart recovery]
  F --> G[Current authority and session checks]
  G --> D
Loading

Technical review

Best possible solution:

Retain the existing recovery owners and repair the authenticated peer fixture and ownership-loss regression without weakening authorization or cancellation assertions.

Do we have a high-confidence way to reproduce the issue?

Current-main source shows returned results bypassing durable communication admission, and the PR records restart controls for the repaired behavior; exact-head CI independently reproduces two validation failures.

Is this the best way to solve the issue?

The repair appropriately reuses communication admission, pending-input persistence, and session-controller recovery; its remaining defects are focused test integration problems.

Full review comments:

  • [P2] Supply authenticated requester origin in the peer recovery fixture — src/gateway/operator-run-recovery.test-support.ts:132
    The new peer-follow-up case passes inter_session provenance into createRestartRecoveryOperatorSource without requesterOrigin. The integrated admission owner accepts that provenance only when requesterOrigin.operatorProfileId matches the captured authority, apart from the separate requester-settle exception. Consequently the fixture returns undefined and fails before exercising recovery or the automation write. Exact-head check checks-node-changed-compact-small-10-1 confirms this failure. Pass the authenticated source session and matching operator profile through the fixture; keep the production identity check intact.
    Confidence: 1
  • [P2] Preserve the successor ownership-loss regression — src/auto-reply/reply/restart-recovery-claim.ts:427-429
    When sourceTurnId is absent, this change stops invoking resolveDeliveryContext. The existing Control UI ownership-loss case in restart-recovery-claim.successor.test.ts schedules its replacement claim through that callback, so replacement never occurs and admission succeeds instead of reporting the changed claim. Exact-head check checks-node-changed-compact-small-23 fails at line 105. Move the test’s replacement to an exercised admission boundary while retaining its refusal assertions, or remove this unrelated callback-evaluation change.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6e4883fca44e.

Provenance checked

  • Durable peer delivery keeps the original intent (0d4037e: Recover accepted peer updates through the pending-input owner without replaying sender tasks.)
  • Requested-result communication authority keeps the original intent (550fc18: Communication preferences govern new peer admissions while already accepted work retains its completion contract.)
  • Optional returned-result replies keeps the original intent (b00ea8b: Optional completion processing must not demand another acknowledgment or repeat an already delivered answer.)
  • Session-controller Stop ownership keeps the original intent (36e277d: One session controller owns turns, queues, cancellation, and cleanup custody.)
  • Requester recovery identity keeps the original intent (fd2a6ca: Preserve authenticated requester identity at execution admission instead of reconstructing authority from attribution.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/gateway/server-instance-runtime.native-restart-recovery.test.ts --maxWorkers=1
  • pnpm test src/auto-reply/reply/restart-recovery-claim.successor.test.ts --maxWorkers=1
  • git diff --check

What I checked:

  • Exact-head peer recovery test failure: The current-head check reports that the added peer-follow-up scenario fails during fixture construction: createRestartRecoveryOperatorSource returns undefined before recovery or automation execution is exercised. (src/gateway/operator-run-recovery.test-support.ts:132, dfccd3da4177)
  • Exact-head successor regression failure: The current-head check reports the ownership-lost Control UI case failing at its claim-changed assertion; the PR skips the callback that this existing test uses to replace ownership. (src/auto-reply/reply/restart-recovery-claim.ts:427, dfccd3da4177)
  • Requester identity contract: Current main permits an inter-session operator recovery source only with a matching requester operator profile, except for its separately recognized requester-settle path; the new peer fixture supplies provenance without requesterOrigin. (src/agents/operator-run-recovery-source.ts:54, 6e4883fca44e)
  • Recorded production-process proof: The PR supplies passing output for eight isolated Gateway process controls; their source checks automatic recovery, completed-effect uniqueness, permission revocation before filesystem I/O, returned-result recovery with reverse sends disabled, and terminal Stop. (test/gateway-session-resume-restart.e2e.test.ts:663, dfccd3da4177)
  • Previous documentation finding resolved: The recovery documentation now explicitly distinguishes accepted requested results from fresh reverse-direction sends and retains cancellation, exact-session, and live-authority requirements. Public docs: docs/gateway/restart-recovery.md. (docs/gateway/restart-recovery.md:1375, dfccd3da4177)
  • Compatible optional persistence extension: returnedResult is optional within the existing version-1 delivery representation; records without it retain the existing request path, with no schema installation, migration, or rewrite of existing rows. (src/gateway/session-send-delivery.ts:82, 6e4883fca44e)

Likely related people:

  • Peter Steinberger: Raw commit 1dcb35b adds src/agents/main-session-restart-recovery-runtime.ts:317 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1dcb35b204d6; files: src/agents/main-session-restart-recovery-runtime.ts)

PR surface

Source +282, Tests +1778, Docs +26. Total +2086 across 35 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 16 372 90 +282
Tests 18 1861 83 +1778
Docs 1 27 1 +26
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 35 2260 174 +2086

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish. Replaced prior rating: 🦐 gold shrimp.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P1: The central repair prevents admitted agent work and requested results from remaining interrupted after Gateway restart.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish. Replaced prior rating: 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-19T01:00:54.186Z sha cb49f09 :: needs real behavior proof before merge. :: [P1] Preserve the existing authority for requested peer results | [P2] Complete the new browser scenario's suite registration | [P2] Use test cancellation instead of new timeout-race helpers
  • reviewed 2026-10-19T02:28:44.110Z sha 08b5e7a :: blocked before merge. :: [P2] Update the existing send fixture to return an acceptance receipt | [P3] Document the accepted-result exception to communication preferences
  • reviewed 2026-10-19T02:47:04.414Z sha fd26dcf :: blocked before merge. :: [P3] Document the accepted-result exception to communication preferences

Reviewed October 18, 2026, 11:50 PM ET / October 19, 2026, 03:50 UTC (Revision 4).

roboclaw-bot and others added 3 commits October 19, 2026 01:14
Preserve cancellation while controller cleanup is retained, recheck captured owners, and align restart proof fixtures with CI ownership and timeout contracts.

Co-authored-by: steipete <[email protected]>
Keep requested replies bound to their accepted request instead of requiring new reverse-direction communication grants. Preserve exact endpoint and live continuation checks, including retained result recovery. Cover receive-only and send-only peers and automatic recovery revocation.

Co-authored-by: steipete <[email protected]>
Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 9a2eea6f-d0ab-4df7-9022-bf01a687e625
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Oct 19, 2026
roboclaw-bot and others added 2 commits October 19, 2026 02:02
Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: b46863ce-7762-493b-9213-10d76d1ef610
@openclaw-barnacle openclaw-barnacle Bot removed the cli CLI command changes label Oct 19, 2026
roboclaw-bot and others added 2 commits October 19, 2026 02:18
Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: db018862-f35f-4237-849a-7a732db4185a
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@roboclaw-bot
roboclaw-bot enabled auto-merge (squash) October 19, 2026 03:45
@roboclaw-bot
roboclaw-bot disabled auto-merge October 19, 2026 04:15
roboclaw-bot and others added 5 commits October 19, 2026 04:42
Keep final-response authority checks and publication ordering while distinguishing a denied response from unfinished runtime disposal. Verify rejection and cleanup explicitly, preserve recovery callback invocation, and align requester and UI proof fixtures.

Co-authored-by: steipete <[email protected]>
Merge main's canonical execution-cleanup repair and update the real-process controls to prove automatic authenticated recovery, terminal cancellation, and live permission checks.

Co-authored-by: steipete <[email protected]>
The input-custody proof must reject unexpected cleanup failures, but final publication can already have settled. Keep the exact allowed denial and retain the dedicated execution-cleanup regressions.

Co-authored-by: steipete <[email protected]>
Integrate the CI base and compare the captured backend handle, not its attachment wrapper. Preserve exact-owner checks across queued-to-running publication. The existing real-reply regression is red on the integrated base and green with this fix.

Co-authored-by: steipete <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. label Oct 19, 2026
@roboclaw-bot
roboclaw-bot merged commit bf76b0c into main Oct 19, 2026
173 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/delta-krill-2 branch October 19, 2026 06:10
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
…6697)

* fix(sessions): resume admitted peer work after gateway restarts

Preserve admitted operator recovery sources for peer follow-ups while keeping internal delivery boundaries. Route automatic peer results through durable communication admission and retain optional-reply semantics.

Keep concurrent history reconciliation consistent and revisit startup orphans after temporary controller owners release, without taking over live, completed, stopped, or replaced work.

Verified with focused regressions, restart and Stop process controls, two real-model Chromium SIGKILL/restart runs, type checks, lint, and independent review.

Co-authored-by: steipete <[email protected]>

* fix: resume interrupted peer work after gateway restarts

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 5aee73d0-1bd6-44e3-a024-fe4d4af4a30a

* fix(sessions): keep stopped work out of restart recovery

Preserve cancellation while controller cleanup is retained, recheck captured owners, and align restart proof fixtures with CI ownership and timeout contracts.

Co-authored-by: steipete <[email protected]>

* fix(sessions): preserve accepted peer reply authority

Keep requested replies bound to their accepted request instead of requiring new reverse-direction communication grants. Preserve exact endpoint and live continuation checks, including retained result recovery. Cover receive-only and send-only peers and automatic recovery revocation.

Co-authored-by: steipete <[email protected]>

* Publish openclaw/delta-krill-2

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 9a2eea6f-d0ab-4df7-9022-bf01a687e625

* Publish openclaw/delta-krill-2

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: b46863ce-7762-493b-9213-10d76d1ef610

* Publish openclaw/delta-krill-2

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: db018862-f35f-4237-849a-7a732db4185a

* test: exercise session key precedence with accepted dispatch

Co-authored-by: steipete <[email protected]>

* Publish openclaw/delta-krill-2

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 7921627c-e41a-4397-b3b0-7314ebf1e3df

* Publish openclaw/delta-krill-2

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 80568c1f-17da-4d70-afc1-4c69a6a5ff44

* Publish openclaw/delta-krill-2

Worked on by:
- @steipete

Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 82344178-4568-4f6b-b557-aec5587ac138

* fix(gateway): release completed custody after response denial

Keep final-response authority checks and publication ordering while distinguishing a denied response from unfinished runtime disposal. Verify rejection and cleanup explicitly, preserve recovery callback invocation, and align requester and UI proof fixtures.

Co-authored-by: steipete <[email protected]>

* test: include task PR fixture in UI ownership expectations

Co-authored-by: steipete <[email protected]>

* test: allow completed custody cleanup after caller revocation

The input-custody proof must reject unexpected cleanup failures, but final publication can already have settled. Keep the exact allowed denial and retain the dedicated execution-cleanup regressions.

Co-authored-by: steipete <[email protected]>

---------

Co-authored-by: steipete <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant