Skip to content

fix(agents): retain operator authority for recovery-spawned children - #178186

Merged
steipete merged 2 commits into
mainfrom
steipete/recovery-run-child-authority
Oct 20, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/recovery-run-child-authority

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

If the Gateway crashes while a parent is still in its first turn (spawning children, not yet yielded), main-session restart recovery resumes that turn as a restart-recovery operator run. Any child the resumed parent spawns inherits the recovery run's run-scoped authority. When the parent's recovered turn ends, the recovery assertion revokes that authority, and every child dies about 10 s into its work:

admitted run authority is no longer active | Restart recovery operator run is no longer active.

Live, a crash before the parent's yield wiped out the whole fleet:

  • Codex app-server parent, openai/gpt-6-astra, killed mid-first-turn: 16 authority-lost failures and nothing merged.
  • Embedded Opus parent, killed while preparing managed worktrees: all replacements failed the same way or on retained names.
  • Parents that had already yielded before the crash recovered fine, because they take the durable owner-evidence path from fix(subagents): restore owner-started fleets after Gateway restarts #176861.

User Impact

Recovery-spawned children can finish their accepted work after the recovered parent finishes. Explicitly stopping the parent still cancels its children. No migration or operator action is required.

Why This Change Was Made

Native child admission (agent-run-admission-phase.ts) now asks retainGatewayOperatorRun for independentContinuation when the caller is a native subagent. The child then retains the existing independent continuation authority, the same mechanism docs/gateway/restart-recovery.md already promises for accepted child continuations, instead of the parent's run-scoped recovery claim.

Original authority validation, scope intersection, the model-policy ceiling and live source-policy checks still apply. Revoking the operator, replacing the source session or stopping the Gateway still invalidates the child. Explicitly stopping the parent still cancels it. No new token, store or grant path is added. The docs now name sessions_spawn children explicitly.

Evidence

  • subagent-spawn.production-boundary.test.ts: "recovered requester finish before its spawned child: complete" is red on base (admitted run operator authority is no longer active at admitted-run-context.ts:355) and green with the fix. A Stop regression confirms parent Stop still persists the child as killed. The admitted-run-context, operator-run-recovery(.requester), server-instance-runtime.operator-recovery, server.startup-recovery-boundary/-webchat, subagent-registry-restart-recovery and operator-run-cancellation suites pass.
  • Live Crabbox, same harness, Gateway kill -9 while both parents were still in their first turn (neither yielded):
    • main: the Codex fleet lost every child (16 authority-lost failures) and merged nothing.
    • this branch: both parents were resumed by restart recovery, with 0 authority-lost failures. Codex and Opus fleets both merged 8/8 (35/35 tests) about 4 minutes after the kill. The Codex parent reported "all recovered in their retained sessions without replacements".

The first head's CI failed a nested-plugin case with "Session event origin is missing". The cause was the new recovery fixture: it assigned a nonexistent agent:main:main parent whose delayed notice could fail during a later test (session-event-handoff.ts:499, reproduced with a controlled timer probe). The second commit makes those cases explicitly parentless and asserts that no notice leaks. The full spawn file then passed 3/3 consecutive runs (63/63), with production code unchanged.

Native child admission now retains the existing independent continuation authority, so children survive completion of a restart-recovered requester. The original scope and model ceilings, live source-policy checks, and parent Stop cancellation still apply.

Add production-boundary regressions for child completion and parent Stop, and clarify the restart-recovery documentation. The completion regression fails on the base with inactive admitted operator authority. Focused recovery, authority, registry, and cancellation tests pass. One collector-origin failure in the full spawn file did not reproduce in the focused replay.
@clawsweeper

clawsweeper Bot commented Oct 20, 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 20, 2026 06:58
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 20, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-20T07:59:05.747844Z f307ea7 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.

@steipete
steipete enabled auto-merge (squash) October 20, 2026 07:01
@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 20, 2026
@steipete
steipete disabled auto-merge October 20, 2026 07:15
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Native children spawned by a recovered parent retain independent operator policy authority after the parent finishes.

Example: A restart-recovered parent spawns eight native children and finishes before them.

  • Before: The children lose admitted operator authority when the recovered parent finishes.
  • After: The children can finish their accepted work while current authorization and explicit Stop remain effective.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused patch with meaningful lifecycle regressions; final-effect authority verification and CI attribution remain open.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Children spawned during restart recovery abort when their recovered parent finishes, preventing accepted delegated work from completing.
Reason: The maintainer-authored direction restores the documented child lifetime without adding configuration, persisted formats, or another authority owner.

Merge readiness

⛔ Blocked before merge - 4 items remain

This PR addresses a concrete recovery lifetime defect with a focused change to the existing authority owner; no introduced code defect was found.

Priority: P1
Reviewed head: 6493f5addfe70e9579ac7c167d9fb5da3a4eb273

Before merge

  • Add real behavior proof - Authority-chain proof required: the body reports successful real Gateway/model restart recovery, and the added harness exercises native spawning, parent retirement, and Stop; neither shows a revoked native child rejected at final I/O through the changed admission route. The older continuation write-tool regression supports the shared owner but exercises a different capture path. Supply a sanitized production-path trace of an allowed child effect after parent completion and a denied effect after revocation or source-session replacement, with credentials and non-public endpoints redacted. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security review attention item - No concrete authorization bypass was found, but the extended native-child lifetime needs final-effect revocation evidence.
  • Resolve merge risk - Before merge, establish that independently retained native-child authority cannot authorize effects after operator revocation or source-session replacement.
  • Complete next step - Have the CI owner attribute the checks-node-changed-4 session-origin failure against the pinned base; request a branch repair only if this PR caused it.

Findings

None.

Tests

  • Missing end-to-end proof: Supply native-spawn final-effect evidence showing an allowed write after parent completion and rejection before I/O after operator revocation or source-session replacement.
Agent review details

How this fits together

Gateway admission transfers the authenticated requester's authority into an accepted agent run; native spawning uses that admission path to establish each child's execution lifetime.

flowchart TD
A[Interrupted parent] --> B[Recovery authority owner]
B --> C[Recovered parent turn]
C --> D[Native child admission]
B --> E[Current operator policy]
E --> D
D --> F[Child execution and effects]
Loading

Technical review

Best possible solution:

Keep the focused admission change and verify its retained authority through a native child's final effect.

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

Current main selects inherited claim-bound authority at native child admission, and the PR reports a matching base failure and live restart reproduction; no target code was executed during this review.

Is this the best way to solve the issue?

Selecting the existing independent continuation authority at child admission is the smallest complete production fix and preserves the shared scope, model-policy, revocation, and cancellation owners.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Verify native-child revocation before I/O (recommended)
    Through recovery dispatch and sessions_spawn, allow a child write after parent completion, then revoke its operator or replace the source session during awaited preparation and verify that the next write never reaches I/O.

Provenance checked

  • Recovery continuation lifetime keeps the original intent (31c93ec: Separate accepted continuation policy from the recovered parent's exact claim while preserving current authorization checks.)
  • Native admission authority retention keeps the original intent (cbc53ac: Retain the exact authenticated caller through admission while moving session facts and authority preparation through existing workers.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was found, but the extended native-child lifetime needs final-effect revocation evidence.

Evidence

What I checked:

PR surface

Source +4, Tests +236, Docs +2. Total +242 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 4 0 +4
Tests 2 236 0 +236
Docs 1 6 4 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 246 4 +242

Review metrics

Metric Value Why it matters
Production versus test growth Production +4 lines; tests +236 lines The production change reuses existing authority machinery; the test growth exercises distinct recovered-parent completion and Stop lifetimes through the existing Gateway fixture.

Labels

Label changes:

  • add P1: The reported crash-recovery workflow loses entire accepted child fleets when the recovered parent finishes.
  • add merge-risk: 🚨 security-boundary: The change deliberately extends child authority beyond the parent's recovery claim, requiring final-effect evidence that revoked authority remains ineffective.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P1: The reported crash-recovery workflow loses entire accepted child fleets when the recovered parent finishes.
  • merge-risk: 🚨 security-boundary: The change deliberately extends child authority beyond the parent's recovery claim, requiring final-effect evidence that revoked authority remains ineffective.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof that a native child remains functional after parent completion but cannot write after operator revocation or source-session replacement.

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.

Reviewed October 20, 2026, 3:15 AM ET / 07:15 UTC.

Let top-level recovery scenarios opt out of the default grouping parent. Otherwise their human-message event queues a delayed notice to a missing main session and fails later boundary tests.

Assert that the recovery cases leave no such notices. Preserve grouped fixture defaults and production authority behavior. Verified three full spawn-boundary runs, focused recovery and admitted-context tests, owning typechecks, lint, format, and independent review.
@steipete
steipete merged commit a34835d into main Oct 20, 2026
123 of 125 checks passed
@steipete
steipete deleted the steipete/recovery-run-child-authority branch October 20, 2026 08:15
@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 21, 2026
…penclaw#178186)

* fix(agents): retain operator authority for recovery-spawned children

Native child admission now retains the existing independent continuation authority, so children survive completion of a restart-recovered requester. The original scope and model ceilings, live source-policy checks, and parent Stop cancellation still apply.

Add production-boundary regressions for child completion and parent Stop, and clarify the restart-recovery documentation. The completion regression fails on the base with inactive admitted operator authority. Focused recovery, authority, registry, and cancellation tests pass. One collector-origin failure in the full spawn file did not reproduce in the focused replay.

* test(agents): isolate recovery spawn fixture notices

Let top-level recovery scenarios opt out of the default grouping parent. Otherwise their human-message event queues a delayed notice to a missing main session and fails later boundary tests.

Assert that the recovery cases leave no such notices. Preserve grouped fixture defaults and production authority behavior. Verified three full spawn-boundary runs, focused recovery and admitted-context tests, owning typechecks, lint, format, and independent review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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 size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant