Skip to content

fix: recovered subagents abort after their parent finishes - #176769

Merged
steipete merged 3 commits into
mainfrom
steipete/team-recoveryowner-authority
Oct 19, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/team-recoveryowner-authority

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Stack: part 1; #176770 covers delivery ordering and consumed-peer recovery.

What Problem This Solves

Fixes accepted child runs aborting after their main-recovered parent finishes following a forced Gateway restart.

User Impact

Accepted children can finish after a recovered parent settles. Current operator, device, session, and Gateway revocation still stops their effects.

Why This Change Was Made

The recovery owner coupled two lifetimes: the parent's exact recovery claim and the operator's current policy. A child retained both. Normal requester settlement retired the parent claim, so a later child tool call failed with “Subagent recovery completion owner changed” or “Restart recovery admission is no longer current.”

The shared recovery owner now gives an accepting continuation independently retained policy authority. The recovered parent still checks its exact claim; the child retains current policy, its own completion owner, and its Gateway binding. This uses the existing continuation capture/release lifecycle without another recovery manager.

Current main #176861 already fixes the registry-completion origin of this symptom. This PR preserves that fix and covers the remaining main-session recovery path: restoreGatewayRunRecovery still couples child policy to the parent registration, which normal parent settlement retires.

The main integration preserves #157806's requester restoration and compaction handoff. The compaction callback stays on the claim-bound parent authority; children do not inherit a callback that advances the parent's recovery target. #176682's unavailable-authority settlement is preserved.

Accepted limits: losing the child's own completion owner, replacing the source session, revoking current access, or stopping/replacing the Gateway still invalidates the child. Shutdown-drain and blocked-session policy are unchanged.

Evidence

The affected boot followed a systemd SIGKILL at 2026-10-18 21:47:03 UTC. Nine distinct recovered sessions subsequently failed: six with completion-owner errors and three with admission errors, between 21:49 and 22:30 UTC. Sanitized examples:

2026-10-18T21:49:37.705+00:00 … lane=nested:…:d9e80e8c … error="Restart recovery operator authority changed; start a new user turn. | Subagent recovery completion owner changed"
2026-10-18T22:30:53.244+00:00 … error="Restart recovery operator authority changed; start a new user turn. | Restart recovery admission is no longer current."

The owner regression fails on the base after parent retirement and passes with the fix. It binds the real write tool through admitted harness capabilities: the child writes after parent settlement, then pauses a second write after an awaited directory operation. Device revocation rejects that second write at final I/O, preserving the original bytes. No abort signal is supplied, so cancellation cannot mask the authority check.

Prior-head integration proof (4b2d39e): 109 tests passed, wrapper exit 0. The seven selected files cover restored operator authority, accepted continuations, requester compaction, runtime admission, queued requester replay, final peer effects, and repeated process loss. The Gateway shard passed 107 cases in 1,227.45 s; the two peer-source cases passed in a 121.37 s shard. Total wrapper 1,382.37 s, dominated by cold compilation. The strengthened child regression took 8.882 s. Existing real policy/identity owners and durable state are exercised rather than mocked decisions.

The fresh isolated real-Gateway/model proof passed on the prior integrated stack 4b2d39e: the process owner reported SIGKILL, the same state restarted, the recovered parent finished first, and the child completed afterward with registry status ok and one effect (118.796 s case; 274.30 s Vitest run; wrapper exit 0). pnpm build qaRuntime passed in 6m 54.9s after a successful frozen-lockfile install. Initial runner attempts stopped during test selection and auth staging before any test ran; the successful run used the live config and a task-owned empty staging directory, leaving local Gateway state untouched.

Targeted production, Gateway, agent-session, and live-test TypeScript graphs passed. Changed-file oxlint, formatting, and git diff --check passed. Final committed-stack Codex P2 autoreview: scoped-clean, no findings. No model-facing text changed; the earlier prompt-prefix stability run passed all five cases.

Change size against the integrated main base: production +68/-21 (net +47), tests +348/-0, docs +5/-0. Growth implements the missing lifetime split; it adds no durable store, schema, or recovery manager.

Proof commands
OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs \
  src/gateway/operator-run-recovery.test.ts \
  src/gateway/operator-run-recovery.requester.test.ts \
  src/gateway/session-send-recovery.test.ts \
  src/gateway/server-plugin-in-process-dispatch.continuation.test.ts \
  src/gateway/server-instance-runtime.operator-recovery.test.ts \
  src/gateway/server.recovery-peer-authority.test.ts \
  src/agents/main-session-recovery/main-session-restart-recovery-peer-source.test.ts --maxWorkers=1
OPENCLAW_LIVE_TEST=1 OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs \
  --config test/vitest/vitest.live.config.ts \
  test/gateway-recovered-parent-continuation.live.test.ts --maxWorkers=1
pnpm build qaRuntime
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental
node scripts/run-tsgo-core-test-shards.mjs --ci-graphs-json \
  '["core-test-gateway-root","core-test-gateway-server","core-test-agents-sessions"]'

The live fixture uses isolated state and a non-main session created/read through public RPC. Credentials are supplied privately and never persisted in the fixture or proof output.

Integrated main: 7f738047bced. Final authority head: b3b75c584cc416ddffddff687c4f8ead2b5e5403. Range comparison preserves this PR's three patches unchanged. Earlier exact-head CI 39197114185 passed on d156ff4; it is prior-head evidence. Integrated-head production and three targeted test typechecks, changed-file lint, formatting, and git diff --check passed. Final committed-stack Codex P2 autoreview is scoped-clean, no findings. The final focused run passed 166 tests across six files, wrapper exit 0, in 1,231.38 s. Its Gateway shard passed 71 cases; the registry/consumed-peer shard passed 95, including current-main descendant custody, permanent refusal settlement, and two successive process losses without input replay. Final exact-head CI is green. Ready and unmerged.

Final exact-head CI run 39202896507 passed: 48 successful, 26 skipped, zero failures. All PostgreSQL conformance shards passed. The repository watcher reports GREEN; the PR rollup also contains canceled superseded runs, which do not change this exact-run result. GitHub Codex review completed on b3b75c584cc4 with no findings.

Latest integrated-head focused command (166 passed, wrapper exit 0):

pnpm test \
  src/gateway/operator-run-recovery.test.ts \
  src/gateway/operator-run-recovery.requester.test.ts \
  src/gateway/server-plugin-in-process-dispatch.continuation.test.ts \
  src/gateway/server.agent-runtime-authority-proof.test.ts \
  src/agents/subagents/registry/subagent-registry.completion-authority.test.ts \
  src/agents/main-session-recovery/main-session-restart-recovery-peer-source.test.ts \
  --maxWorkers=1

@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.

@steipete
steipete marked this pull request as ready for review October 19, 2026 01:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T05:10:42.601237Z b3b75c5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: b3b75c584cc416ddffddff687c4f8ead2b5e5403
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/operator-run-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-plugin-in-process-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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 maintainer review before merge.

What this changes

This PR lets accepted child runs retain current operator authority after their recovered parent finishes.

Example: A recovered parent accepts a child with operator.write permission and finishes before the child writes recovered-child-effect.txt.

  • Before: The child inherits the retired parent claim and its next action fails.
  • After: The child writes allowed\n; revoking its device before a subsequent write prevents forbidden\n from replacing those bytes.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused shared-owner repair with shipped Gateway recovery proof, final-effect revocation coverage, unchanged persisted formats, and successful exact-head CI.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The reported isolated real Gateway/model run kills and restarts the process using the same state, then observes parent settlement before one successful child effect; the reported passing production-tool regression separately proves allowed writing and revoked-device rejection at final I/O without cancellation masking the check.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Accepted children can abort after their recovered parent finishes, leaving delegated work incomplete following a forced Gateway restart.
Reason: The maintainer-authored repair restores the established accepted-work lifetime contract and directly addresses recorded incidents without adding configuration or changing persisted formats.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete restart-recovery failure that remains on current main; the reviewed head has no actionable findings and its exact-head CI succeeded.

Priority: P1
Reviewed head: d156ff470aa86d9f2ebc9ed66a60a59967129379

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway recovery restores authenticated operator authority from retained source evidence, and continuation capture transfers that authority into accepted child work whose tool effects still validate current permissions.

flowchart TD
  A[Interrupted parent] --> B[Gateway recovery owner]
  B --> C[Claim-bound parent authority]
  B --> D[Retained policy authority]
  D --> E[Accepted child owner]
  E --> F[Tool effect guard]
  G[Current identity and revocation] --> F
  F --> H[Filesystem effect]
Loading

Technical review

Best possible solution:

Retain child policy authority through the existing continuation lifecycle while preserving exact parent claims and current revocation checks.

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

Current-main source shows the retained child authority still depends on the parent's exact recovery claim, matching the reported failures and the author's base-failing regression; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch repairs the shared recovery owner and existing continuation capture rather than adding a recovery manager, while retaining scope intersection, model ceilings, session invalidation, and final-effect authorization.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +47, Tests +348, Docs +5. Total +400 across 6 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 68 21 +47
Tests 2 348 0 +348
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 421 21 +400

Review metrics

Metric Value Why it matters
Production versus regression proof Production +68/-21; tests +348/-0 Production growth implements the lifetime split within existing owners; the added tests cover final-effect revocation and real process-loss recovery as distinct boundaries.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Reported forced-restart incidents caused accepted child workflows to abort after their recovered parents finished.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • 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-19T02:02:09.891Z sha bacb9a1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-19T03:23:36.779Z sha 4e5bfe47c74b36506fd15f896431e61f08a832b2 :: needs changes before merge. :: none
  • reviewed 2026-10-19T04:14:09.890Z sha d156ff4 :: needs maintainer review before merge. :: none

Reviewed October 19, 2026, 12:23 AM ET / 04:23 UTC (Revision 4).

@steipete
steipete force-pushed the steipete/team-recoveryowner-authority branch from bacb9a1 to 4e5bfe4 Compare October 19, 2026 03:17
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the requested final-I/O proof on 4e5bfe47c74b36506fd15f896431e61f08a832b2. The regression binds a production write tool through real admitted harness capabilities, proves a write after normal parent settlement, then pauses a second write after awaited directory preparation. Device revocation during that pause prevents the final write, without an abort signal; original bytes remain and only one write reaches I/O. The strengthened case passed. Existing isolated Gateway/model SIGKILL proof remains applicable. Final committed-stack Codex P2 review is scoped-clean; the PR body has current proof and limits. Exact-head CI is running.

@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-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@steipete
steipete force-pushed the steipete/team-recoveryowner-authority branch from 4e5bfe4 to d156ff4 Compare October 19, 2026 03:57
@steipete

Copy link
Copy Markdown
Contributor Author

Integrated the shared requester-restoration and compaction owner from current main on d156ff470aa86d9f2ebc9ed66a60a59967129379; the previously reported conflict is resolved. The fresh isolated Gateway/model SIGKILL proof passed: the recovered parent finished first, then its child completed one effect (118.796 s case, wrapper exit 0). The 109-test focused integration run, targeted static checks, runtime build, and committed-stack Codex P2 review are clean. The body now includes the current proof and exact-head CI is still running.

@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 proof: sufficient ClawSweeper judged the real behavior proof convincing. label Oct 19, 2026
@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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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
Keep accepted continuation policy custody independent of the restored parent work claim. Preserve current operator, device, session and Gateway revocation at effects.
@steipete
steipete force-pushed the steipete/team-recoveryowner-authority branch from d156ff4 to b3b75c5 Compare October 19, 2026 05:07
@steipete
steipete merged commit 31c93ec into main Oct 19, 2026
148 of 149 checks passed
@steipete
steipete deleted the steipete/team-recoveryowner-authority branch October 19, 2026 06:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

* fix: preserve recovered child authority after parent settlement

Keep accepted continuation policy custody independent of the restored parent work claim. Preserve current operator, device, session and Gateway revocation at effects.

* test: terminate restart fixture through its process owner

* test: verify recovered child authority at final write
RomneyDa pushed a commit that referenced this pull request Nov 2, 2026
* fix: preserve recovered child authority after parent settlement

Keep accepted continuation policy custody independent of the restored parent work claim. Preserve current operator, device, session and Gateway revocation at effects.

* test: terminate restart fixture through its process owner

* test: verify recovered child authority at final write

Release adaptation: restoreGatewayOperatorSource keeps the release's
prepareCurrent hook instead of main's prepareSource/revalidate shape, and
has no compaction callback to wrap. Main's unit tests use the
restoreGatewayRunRecovery fixture the release lacks, so the regression
test uses createOperatorRecoveryFixture: an accepted continuation stays
current after the recovered requester claim retires, and device
revocation still ends it.

(cherry picked from commit 31c93ec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. security-sensitive-changed 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