Skip to content

fix(gateway): retain continuation authority for every child run - #178693

Merged
steipete merged 1 commit into
mainfrom
steipete/child-continuation-authority
Oct 20, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/child-continuation-authority

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

#178186 fixed children newly spawned by a restart-recovered parent turn, but only through a caller-passed special case (agentRunTracking === "native_subagent" → independentContinuation). Children that were already running when the Gateway died take a different path. Restart recovery resumes them through sessions_send/nested:<child>, which still retained the parent's run-scoped recovery claim. When the recovered parent turn ended, every resumed child failed:

Restart recovery operator run is no longer active.

Live, on latest main with #178186 (Codex app-server parent, Gateway kill -9 while the parent was still in its first turn): 2 of 2 runs lost all 8 children, with 16 authority-lost failures and nothing merged.

User Impact

Children resumed after a Gateway restart retain continuation authority when the recovered parent turn finishes. Explicit parent Stop and operator revocation still cancel child work. No migration or user action is required.

Why This Change Was Made

The decision is now structural, made at the shared run-retention boundary. retainGatewayOperatorRun chooses the independent continuation authority from the admitted session's persisted spawnedBy lineage, so callers can no longer pass independentContinuation.

  • The native_subagent special case is removed. One rule covers native spawns, restart-resumed children, nested-lane continuations, follow-ups and steers to a child, and collector children.
  • Agent, chat-send and Talk admission all supply the lineage.
  • Original authority validation, scope intersection, the model-policy ceiling, live source checks, revocation and parent Stop cancellation are unchanged.
  • The choice is only between the operator's already-registered continuation authority and the inherited one, so no new authority can be minted.

Evidence

  • subagent-spawn.production-boundary.test.ts "resumed child": red on base (admitted run operator authority is no longer active at admitted-run-context.ts:384) and green with the fix. 18 focused recovery, resume, cancellation and Talk files pass, including operator-run-recovery*, server.startup-recovery-*, subagent-registry-restart-recovery, server.sessions-send-resume, session-subagent-resume, in-process-subagent-resume, subagent-parent-recovery.restart-integration, chat-send-subagent-custody and the Talk authority suites. The full spawn file passed 64/64. One later repeat hit an existing sandbox-fixture model-entry wait under heavy local load; it is unrelated to authority (no authority error or abort in its diagnostics).
  • Live Crabbox A/B, identical first-turn kill, Codex parent, same moment:
    • main: 16 authority-lost failures and nothing merged.
    • this branch: 0 authority-lost failures, and the fleet recovered to 8/8 merged (35/35 tests) about 3 minutes after the kill.

Choose continuation authority from persisted spawnedBy lineage at the shared
run-retention boundary. Remove the native-subagent admission exception and
carry child lineage through agent, chat, and Talk admission.

Cover an interrupted child's sessions_send continuation after its recovered
parent finishes. Preserve source validation, scope and model ceilings,
revocation, and parent Stop cancellation.

Focused recovery, resume, cancellation, and Talk suites pass. The full spawn
file passed all 64 cases. A later repeat hit the existing model-entry wait
and a subsequent fixture timeout; the five-case recovery/native subset
passes, but the repeat-only failure remains unresolved.
@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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling labels Oct 20, 2026
@steipete
steipete marked this pull request as ready for review October 20, 2026 19:03
@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-20T19:14:39.292419Z 4259b46 Draft marked ready
ℹ️ 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.

@github-actions

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: 4259b46a0fc6471d3d3ed2b0b8bb146886e9d023
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/talk/client-run-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. labels Oct 20, 2026
@steipete
steipete enabled auto-merge (squash) October 20, 2026 19:19
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR uses persisted child-session lineage to retain continuation authority across agent, chat, and Talk admission.

Example: A recovered parent resumes eight interrupted children and finishes before them.

  • Before: The resumed children lose the parent's recovery authority and abort.
  • After: The agent admission path retains independent continuation authority so the children can finish.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful shared-owner repair with meaningful recovery coverage, one ineffective Talk handoff, and incomplete final-effect authority evidence.
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: Interrupted children resumed after a Gateway crash abort when their recovered parent finishes.
Reason: The maintainer-authored direction restores documented continuation lifetime using existing authority owners without new configuration or persisted formats.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this maintainer-authored PR addresses a current recovery bug, but the Talk lineage handoff is overwritten before retention.

Priority: P1
Reviewed head: 4259b46a0fc6471d3d3ed2b0b8bb146886e9d023

Before merge

  • Add real behavior proof - Authority-chain proof required: the body reports real Gateway/model crash recovery with eight completed children, and the regression exercises sessions_send after parent retirement, but neither demonstrates the nearest forbidden principal—a revoked operator or device—being rejected before final I/O through the changed retention route; provide a sanitized trace with credentials, IPs, 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.
  • Apply persisted Talk lineage after the authority overlays (P2) - For an existing child session with spawnedBy set, the Gateway Talk runner calls consultRealtimeVoiceAgent without a spawnedBy argument. buildRealtimeVoiceAgentToolAuthorityOverlay therefore creates an own spawnedBy property containing undefined, and its spread at line 525 overwrites this new persisted value. createTalkClientAgentRuntime then passes undefined to retainRun, so the new shared retention rule treats that child as a non-child and retains inherited claim-bound authority. Place the canonical lineage assignment after the overlays, including prepareToolContext, and cover an existing child whose consult arguments omit lineage.
  • Resolve security concern: Verify revoked authority through resumed-child retention - The existing write-tool regression verifies the shared continuation authority through a different capture route; the supplied evidence does not show a revoked resumed child rejected at final I/O through this PR's admission route.
  • Resolve merge risk - Before merge, establish that the extended resumed-child authority rejects effects after operator or device revocation.

Findings

  • [P2] Apply persisted Talk lineage after the authority overlays — src/talk/agent-consult-runtime.ts:522-525
  • [medium] Verify revoked authority through resumed-child retention — src/gateway/operator-run-cancellation.ts:49

Tests

  • Missing end-to-end proof: Supply sanitized final-effect evidence through resumed-child admission showing an allowed effect after parent completion and rejection before I/O after operator or device revocation.
Agent review details

How this fits together

Gateway admission turns authenticated requests and session lineage into retained run authority, which governs execution, cancellation, and privileged effects.

flowchart TD
 A[Authenticated request] --> B[Session admission]
 B --> C[Persisted child lineage]
 C --> D[Shared authority retention]
 D --> E[Child execution]
 F[Live operator revocation] --> D
 D --> G[Cancellation and effect checks]
Loading

Technical review

Best possible solution:

Keep continuation selection in the shared retention owner and ensure Talk passes persisted lineage after every overlay.

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

Current-main admission shows the native-only exception, and the PR reports a red-on-base resumed-child regression plus live crash recovery failures; no target code was executed during this read-only review.

Is this the best way to solve the issue?

Centralizing the decision in the existing retention owner is the smallest coherent repair, but Talk's later overlays currently defeat its persisted-lineage assignment.

Full review comments:

  • [P2] Apply persisted Talk lineage after the authority overlays — src/talk/agent-consult-runtime.ts:522-525
    For an existing child session with spawnedBy set, the Gateway Talk runner calls consultRealtimeVoiceAgent without a spawnedBy argument. buildRealtimeVoiceAgentToolAuthorityOverlay therefore creates an own spawnedBy property containing undefined, and its spread at line 525 overwrites this new persisted value. createTalkClientAgentRuntime then passes undefined to retainRun, so the new shared retention rule treats that child as a non-child and retains inherited claim-bound authority. Place the canonical lineage assignment after the overlays, including prepareToolContext, and cover an existing child whose consult arguments omit lineage.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Verify resumed-child revocation at final I/O (recommended)
    Exercise recovery dispatch and sessions_send through the changed retention route, allow a child effect after parent completion, then revoke its operator or device during awaited preparation and show that the next effect is rejected before I/O.

Provenance checked

  • Native-child admission exception changes intended behavior with a stated reason (a34835d: Allow newly spawned children to survive recovered-parent completion while retaining Stop and revocation.)
  • Independent continuation policy keeps the original intent (31c93ec: Separate accepted-child policy custody from the parent's exact recovery claim while preserving current authorization.)
  • Operator cancellation keeps the original intent (552b54b: End accepted and queued work when its original access grant expires or is revoked.)
  • Talk retained execution authority keeps the original intent (f4f4868: Use ordinary authenticated execution permissions for voice while retaining source revocation and accepted-work lifetime.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was found, but extended child authority needs final-effect revocation verification.

Evidence

Security concerns:

  • [medium] Verify revoked authority through resumed-child retention — src/gateway/operator-run-cancellation.ts:49
    The existing write-tool regression verifies the shared continuation authority through a different capture route; the supplied evidence does not show a revoked resumed child rejected at final I/O through this PR's admission route.
    Confidence: 0.96

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a34835d adds src/agents/subagents/spawn/subagent-spawn.recovery.test-support.ts:95 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a34835d75c56; files: src/agents/subagents/spawn/subagent-spawn.recovery.test-support.ts)

PR surface

Source +11, Tests +56, Docs +1. Total +68 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 20 9 +11
Tests 1 77 21 +56
Docs 1 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 99 31 +68

Review metrics

Metric Value Why it matters
Production versus test changes Production +20/-9; tests +77/-21 The production change reuses existing authority machinery; test growth adds a distinct resumed-child lifecycle case to the shared fixture.

Labels

Label changes:

  • add P1: The reported current-main restart workflow aborts entire accepted child fleets after their recovered parent finishes.
  • add merge-risk: 🚨 security-boundary: Child authority now outlives more inherited recovery claims, and final-effect revocation through the changed route remains unverified.
  • 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 current-main restart workflow aborts entire accepted child fleets after their recovered parent finishes.
  • merge-risk: 🚨 security-boundary: Child authority now outlives more inherited recovery claims, and final-effect revocation through the changed route remains unverified.
  • 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.

  • Show that a resumed child can perform an effect after parent completion but cannot perform it after operator or device revocation.

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:20 PM ET / 19:20 UTC.

@steipete
steipete merged commit 76cf9fe into main Oct 20, 2026
203 of 207 checks passed
@steipete
steipete deleted the steipete/child-continuation-authority branch October 20, 2026 22:06
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…claw#178693)

Choose continuation authority from persisted spawnedBy lineage at the shared
run-retention boundary. Remove the native-subagent admission exception and
carry child lineage through agent, chat, and Talk admission.

Cover an interrupted child's sessions_send continuation after its recovered
parent finishes. Preserve source validation, scope and model ceilings,
revocation, and parent Stop cancellation.

Focused recovery, resume, cancellation, and Talk suites pass. The full spawn
file passed all 64 cases. A later repeat hit the existing model-entry wait
and a subsequent fixture timeout; the five-case recovery/native subset
passes, but the repeat-only failure remains unresolved.
jalehman added a commit that referenced this pull request Nov 9, 2026
…194798)

* fix(gateway): accepted turns keep their authority after the sender's run ends

A turn admitted by sessions_send (or chat/Talk) from a scheduled or recovered run inherited that run's occurrence-bound operator authority. When the occurrence ended, the receiving session's in-flight turn failed with 'Cron occurrence source authority is no longer active'. #178693 moved only child targets to the retained continuation; every accepted turn now uses it. The continuation still revalidates device, profile, role and access grant.

* fix(gateway): sender session cleanup no longer revokes handed-off turns

Restored scheduled authority revoked its shared policy signal when the claimed sender session was replaced or removed, so an isolated run's normal exact-run session cleanup still aborted turns it had handed to other sessions. Claim lifecycle now ends only the run-bound authority; the retained continuation keeps device, profile, role and grant revocation.

* test: allocate test lines for receiver continuation authority regressions
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
…penclaw#194798)

* fix(gateway): accepted turns keep their authority after the sender's run ends

A turn admitted by sessions_send (or chat/Talk) from a scheduled or recovered run inherited that run's occurrence-bound operator authority. When the occurrence ended, the receiving session's in-flight turn failed with 'Cron occurrence source authority is no longer active'. openclaw#178693 moved only child targets to the retained continuation; every accepted turn now uses it. The continuation still revalidates device, profile, role and access grant.

* fix(gateway): sender session cleanup no longer revokes handed-off turns

Restored scheduled authority revoked its shared policy signal when the claimed sender session was replaced or removed, so an isolated run's normal exact-run session cleanup still aborted turns it had handed to other sessions. Claim lifecycle now ends only the run-bound authority; the retained continuation keeps device, profile, role and grant revocation.

* test: allocate test lines for receiver continuation authority regressions
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. docs Improvements or additions to documentation gateway Gateway runtime security-sensitive-changed size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant