Skip to content

fix(agents): preserve restart-interrupted parent continuation ownership - #165496

Merged
steipete merged 1 commit into
mainfrom
steipete/restart-parent-continuation-20261005
Oct 5, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/restart-parent-continuation-20261005

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: an interrupted parent continuation loses its source identity when a Gateway restart also drains queued child announcements, allowing the original completion to run again or fail behind the recovery owner.

User Impact

Parent turns started by subagent pause notices or completion announcements retain the same recovery source across restart. Retries join the existing recovery and consume its final receipt. Unrelated child completions wait for the recovery owner; stopping, resetting, replacing, or rerouting a session still revokes pending work.

No schema, configuration, or migration changes. Existing session recovery fields and terminal receipts retain ownership; waiting yielded parents remain with the child-batch owner. Previously persisted source-less recovery rows retain the existing single-fence correlation fallback until they settle.

Why This Change Was Made

Shutdown previously saved the active and queued run fences, then cleared the active lifecycle ID. Startup could identify a source only when exactly one fence remained. Preserve the already-recorded source before releasing lifecycle ownership, and apply the existing receipt reconciliation to announcements as well as settle turns. Refuse execution if that exact source completed while waiting for recovery, without blocking a different sibling source.

Includes the announce admission wait from #161788, with credit to @Oldrich333. This complements #165335: restoring unrelated registry work after a superseded transfer does not preserve a parent continuation's own interrupted source. Recovery logs now identify skipped sessions and reasons even when other sessions start successfully.

Net production LOC: +22 (29 added, 7 removed), required to preserve the exact interrupted source, refuse execution after a matching terminal receipt, and report skipped sessions. The existing schedulers and store remain the only owners.

Evidence

  • Blacksmith Testbox tbx_01m45h4bqcf9jgpqm2rbdzg2nw, pinned base e78e965a55e2d2b121c61d0a93e571c26f6f50f8.
  • Negative control, unchanged production with new tests: both pause/announce source-correlation cases fail, and the announcement retry executes instead of joining the recovery claim (3 failures, 1 passing control; 29.92 s).
  • Restoring the candidate: 55 recovery/delivery tests pass (55.56 s). The final single-worker run passes 41 admission-owner tests (23.87 s) and 51 parent/announcement tests (30.87 s), including the new same-source admission race. Its negative controls fail both source kinds at admission and the late announcement receipt case (3 additional failures).
  • Final committed-head gate on Blacksmith Testbox tbx_01m45s0zsbpq7rnmx74vxv3apw: node scripts/check-changed.mjs --base e78e965a55e2d2b121c61d0a93e571c26f6f50f8 --head HEAD. Formatting, boundary/ratchet guards, production types, and all 27 core-test typecheck groups pass. The command exits 1 at the broad dead-export scan on two inherited exports: GoogleMeetJoinResult in extensions/google-meet/src/transports/types.ts and MeetingRuntimeOwner in src/meeting-bot/runtime-facade-types.ts. Replacing all ten changed files with their exact base bytes, verifying a zero diff against the base, and rerunning node --import ./scripts/tsx.mjs scripts/check-deadcode-exports.mts reproduces the same failures. The candidate was restored and verified clean afterward. No scanner exception or unrelated source change was added.
  • Validation recovery: the first staged gate caught a generic mock signature error in the new fixture; that was corrected. A later lease expired during typechecking, and the authorized rig fallback was cancelled after normal Testbox capacity returned. These runs are not reported as passing gates.
  • Initial lease tbx_01m45fy33h1wbhv6b1qym5ksaa passed 21 baseline tests, then hit two full-sync timeouts and was stopped. No local test suite, build, or typecheck ran.
  • Final per-file single-worker measurements on Blacksmith Testbox tbx_01m45n39k3zxc9syet3fh9cw2r: node scripts/run-vitest.mjs <file> --maxWorkers=1 — command recovery owner: 41 tests, 27.72 s wall; direct announce delivery: 32 tests, 15.41 s; parent restart integration: 19 tests, 35.00 s. All pass. The integration file exercises real SQLite/registry shutdown and startup ownership; its existing shared fixture and asynchronous persistence make this cost materially higher than the pure admission/delivery files.
  • Independent Codex autoreview: scoped-clean at P0–P2. The subsequent fixture-only type correction uses the existing Gateway function with a spy instead of passing a generic mock as that function; the corrected fixture passes. Exact-head CI run 37294130273: success, 42 passing jobs in 515 seconds, on 22c1990af349c76169cded0fb117a6f58158a20f.

Limits: the standalone changed-file aggregate remains red only on the reproduced base dead-export failures; exact-head CI is green. Behavioral proof uses synthetic SQLite/registry state and mocked dispatch, not a production deployment or live provider restart. The source-loss regression proves source correlation and replay suppression; it does not claim that the historical production incident's entire lifecycle-publication ordering was reproduced. User-input preservation and transcript-conflict classification are outside this change.

Keep the active parent source when shutdown also records queued child
announcements. Join its recovery claim and final receipt on announcement
retries, and refuse execution when recovery completed that exact source
while admission waited. Other child completions wait for the recovery owner.
Report each skipped recovery candidate and keep skip reasons in mixed
startup summaries. Existing session fields and batch ownership are retained.

Co-authored-by: Oldrich333 <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 5, 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 agents Agent runtime and tooling size: M labels Oct 5, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 7:22 AM ET / 11:22 UTC (Revision 5).

ClawSweeper review

What this changes

The PR preserves interrupted parent-turn identity across Gateway restarts, prevents completion retries from replaying recovered work, and improves recovery diagnostics.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded fix absent from current main. No introduced correctness or security blocker was found, and exact-head CI passed; the related work does not supersede the full repair.

Priority: P1
Reviewed head: 22c1990af349c76169cded0fb117a6f58158a20f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful negative controls, explicit validation limits, and successful exact-head CI.
Proof confidence 🌊 off-meta tidepool Not applicable: Verified repository-admin authorship exempts ordinary contributor proof. The supplied tests exercise persistence, restart marking, admission, and reconciliation with mocked dispatch; they do not establish a live provider restart. The change preserves existing serialized fields and legacy source fallback without changing the stored-data contract.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Verified repository-admin authorship exempts ordinary contributor proof. The supplied tests exercise persistence, restart marking, admission, and reconciliation with mocked dispatch; they do not establish a live provider restart. The change preserves existing serialized fields and legacy source fallback without changing the stored-data contract.
Evidence reviewed 9 items Introduced patch and source ownership: Reviewed the pinned merge-base-to-head delta. The production changes retain source identity, extend existing announcement admission and receipt reconciliation, and add skip diagnostics; unrelated endpoint drift is not attributed to this PR.
Still necessary on main: Fetched main lacks source preservation before lifecycle identity is cleared, announcement admission waiting, and the same-source terminal-run guard. The inspected v2026.9.8 admission-owner implementation also lacks these changes.
Existing-state and authority contracts: The existing dispatcher prefers the recorded source and retains its single-fence fallback for older source-less rows. Source correlation explicitly does not create channel authority; admission, session identity, generation, cancellation, and delivery guards remain in place. No schema, serialized field format, configuration, or permission contract is introduced.
Findings None None.
Security None None.

How this fits together

Gateway restart recovery resumes interrupted agent conversations from persisted session state. Subagent completion notices pass through session admission and delivery reconciliation so parent conversations continue without duplicate execution.

flowchart TD
  A[Parent turn and child notices] --> B[Gateway restart]
  B --> C[Persist interrupted source]
  C --> D[Session recovery owner]
  E[Completion retry] --> F[Check source and receipt]
  D --> F
  F --> G[Reuse recovered result]
  F --> H[Wait or admit unrelated notice]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +22, Tests +263, Docs +5. Total +290 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 29 7 +22
Tests 4 292 29 +263
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 326 36 +290

Review metrics

Metric Value Why it matters
Production versus regression coverage production +22 net lines; tests +263 net lines Production growth has a concrete ownership, replay-suppression, and diagnostic justification; regression coverage uses the existing owners and fixtures.

Technical review

Best possible solution:

Keep source identity and receipt consumption with the existing recovery owner so each interrupted parent continues once while unrelated notices retain normal admission.

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

Yes: current source clears lifecycle identity while multiple run fences defeat the single-fence source fallback, and announcement retries lack the matching recovery guards. Reported negative controls support this path; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: the patch repairs source capture at its producer and reuses existing admission and receipt reconciliation without creating a competing owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2d3a5c7bbced.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Restart-interrupted parent conversations can replay completed work or reject child completion retries, breaking an active agent workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Verified repository-admin authorship exempts ordinary contributor proof. The supplied tests exercise persistence, restart marking, admission, and reconciliation with mocked dispatch; they do not establish a live provider restart. The change preserves existing serialized fields and legacy source fallback without changing the stored-data contract.

Evidence

What I checked:

  • Introduced patch and source ownership: Reviewed the pinned merge-base-to-head delta. The production changes retain source identity, extend existing announcement admission and receipt reconciliation, and add skip diagnostics; unrelated endpoint drift is not attributed to this PR. (src/agents/main-session-recovery/main-session-recovery-state.ts:347, 22c1990af349)
  • Still necessary on main: Fetched main lacks source preservation before lifecycle identity is cleared, announcement admission waiting, and the same-source terminal-run guard. The inspected v2026.9.8 admission-owner implementation also lacks these changes. (src/agents/agent-command-recovery-owner.ts:151, 2d3a5c7bbced)
  • Existing-state and authority contracts: The existing dispatcher prefers the recorded source and retains its single-fence fallback for older source-less rows. Source correlation explicitly does not create channel authority; admission, session identity, generation, cancellation, and delivery guards remain in place. No schema, serialized field format, configuration, or permission contract is introduced. (src/agents/main-session-recovery/main-session-restart-dispatch.ts:234, 22c1990af349)
  • Regression coverage and stated proof limits: The added integration cases exercise real session persistence, shutdown marking, lifecycle rotation, and startup recovery with both pause and announcement sources plus a queued sibling. Admission tests cover same-source suppression, unrelated-source execution, cancellation, replacement, rerouting, tombstones, and generation rotation. The body reports failing negative controls and passing candidate tests, while explicitly identifying dispatch as mocked and historical lifecycle ordering as incompletely reproduced. (src/agents/subagents/registry/subagent-parent-recovery.restart-integration.test.ts:63, 22c1990af349)
  • Verified author role: GitHub's collaborator permission endpoint confirms steipete has repository admin permission. The ordinary external-contributor real-setup proof requirement therefore does not apply.
  • Exact-head CI: GitHub confirms https://github.com/openclaw/openclaw/actions/runs/37294130273 completed successfully on the reviewed head. The body's separately reported dead-export failures were reproduced on base and are not represented as passing validation. (22c1990af349)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Oldrich333: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-05T09:52:42.987Z sha 22c1990 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-05T10:09:10.586Z sha 22c1990 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-05T10:35:51.449Z sha 22c1990 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-05T11:03:46.020Z sha 22c1990 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review October 5, 2026 10:03
@steipete
steipete merged commit 78e4060 into main Oct 5, 2026
224 of 225 checks passed
@steipete
steipete deleted the steipete/restart-parent-continuation-20261005 branch October 5, 2026 11:30
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…ip (openclaw#165496)

Keep the active parent source when shutdown also records queued child
announcements. Join its recovery claim and final receipt on announcement
retries, and refuse execution when recovery completed that exact source
while admission waited. Other child completions wait for the recovery owner.
Report each skipped recovery candidate and keep skip reasons in mixed
startup summaries. Existing session fields and batch ownership are retained.

Co-authored-by: Oldrich333 <[email protected]>
steipete added a commit that referenced this pull request Oct 6, 2026
…166030)

Consolidate claim fixtures and equivalent recovery, media, and receipt cases while retaining distinct race inputs and durable-state assertions. Preserve the requester recovery regression coverage from #165496. Test-only scope: 2,567 to 2,276 lines; the target exception and Testbox proof are recorded in the PR.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…penclaw#166030)

Consolidate claim fixtures and equivalent recovery, media, and receipt cases while retaining distinct race inputs and durable-state assertions. Preserve the requester recovery regression coverage from openclaw#165496. Test-only scope: 2,567 to 2,276 lines; the target exception and Testbox proof are recorded in the PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant