Skip to content

fix: recovered child sessions fail after their parent finishes - #180728

Merged
jalehman merged 2 commits into
openclaw:mainfrom
enki:fix/recovered-child-dispatch-source-20261022
Oct 23, 2026
Merged

jalehman merged 2 commits into
openclaw:mainfrom
enki:fix/recovered-child-dispatch-source-20261022

Conversation

@enki

@enki enki commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes running child sessions failing after their recovered parent finishes when the child was started through an in-process agent request, including sessions_send continuations.

User Impact

A child that has retained its own admitted operator authority can continue after the parent replies. Revoking the operator still blocks child effects, and an expired caller cannot authorize a new execution.

Why This Change Was Made

The child admission already selected the independent policy authority introduced in #176769 and generalized in #178693. However, the in-process agent facade also retained the incoming parent's work assertion as its Gateway-context assertion. Execution checked that redundant assertion before the child's valid authority, so a completed parent could still stop its child.

Separate the existing Gateway-instance assertion from source authorization. Check the incoming source during admission; let accepted execution use the authority retained by its admission owner. Scope intersection, canonical child-lineage selection, revocation, session ownership, and cancellation remain with their existing owners. No new policy, configuration, or stored format is introduced.

This is a narrow follow-up to the merged authority fixes #176769, #178186, and #178693, within the lifecycle ownership consolidated in #177698. Those changes correctly retain child execution authority; this closes the separate in-process facade assertion that still checked parent work after admission.

Related #180704 fixes a different restart symptom: obsolete child-completion reservations parking later input before execution starts. Neither PR depends on the other, and neither replaces the merged consolidation or the outstanding policy proposals. This PR does not change model timeouts, peer-message delivery policy, selected-requester policy, or reply obligations.

Evidence

Real Gateway authority controls

The missing authority controls now pass through the real built Gateway, with an added positive control under the same role-governed synthetic authentication:

Case Actual owner boundary Result
Allowed Real sessions_spawn → fixture restart → recovered-parent sessions_send; parent finishes before child release Exact child terminal ok; one real exec HTTP receiver request after parent done; child final persisted
Role revoked Same role/tool configuration; canonical users.setRole sets the identified operator's role to denied after child admission, before its queued exec response is released Exact child terminal error / rpc; zero receiver I/O
Parent expired before admission Actual sessions_send enters a real pending communication approval; canonical chat.abort ends the recovered parent while approval is awaited Late canonical approval rejected as cancelled; zero new child model requests, no forbidden child input in canonical transcript, zero receiver I/O

Each case used isolated state and a scripted loopback provider on Node 24.22.1, started/joined two owned Gateway processes, and closed both clients and provider. No turn service or authority owner was mocked. No live operator state, external inference or native Codex behavior is claimed.

SAME-AUTH ALLOWED: parent done -> child release -> receiver=1 -> child final persisted; terminal=ok
ROLE REVOKED: child admitted -> parent done -> users.setRole denied -> receiver=0; terminal=error/rpc
PARENT EXPIRED: sessions_send approval pending -> chat.abort -> late approval cancelled; child requests=0 receiver=0
CLEANUP EACH: Gateway started=2 joined=2; clients closed; provider closed

Existing build metadata identifies 271329fd32df15f9347099872d1c35e756597cad; the working-tree build contains the production patch unchanged at reviewed head b9bf4f98121f226906990933610568c7a69ae403. Captured source hashes match that head, and compiled dispatch retains the source assertion at admission while using the Gateway lifetime assertion during execution. This is source-qualified reuse of that built candidate, not a new clean-head build.

The negative captures used driver SHA-256 0cdc9d0dbf7ee8d5685e5d5f9238d007de0cee3366d1d88db23c42fd100f183d. Adding only the allowed case/branch produced driver SHA-256 bd4cef65d6cac8dd210c2a88d788e0293dbb9710b99bfe2faf5d1795e5d4efc0; its common authentication, provider, tool preparation and negative paths are unchanged. Both driver revisions, their exact diff, full sanitized terminal captures and source/compiled hashes are retained for inspection. Earlier authentication setup failures remain qualified as setup failures with joined cleanup.

Original regression and allowed-path evidence

  • Regression on upstream base 271329fd32df: 1 failed, 15 passed. The child retains valid independent authority, but the real in-process facade rejects its synthetic effect with Recovery claim retired after the parent's work claim closes. The retirement-before-acceptance control passes.
  • Fixed candidate: 102 focused tests pass: 15 continuation tests plus 87 adjacent tests covering requester continuation, authorization, commit guards, compaction, recovered operator admission, and cancellation.
  • Changed test file (maintainer remeasure, --maxWorkers=1, warm cache): 15 tests, about 7.7 seconds of test time; the two new cases take about 2.1 and 0.8 seconds.
  • Production build, targeted Gateway typechecking, lint, and formatting pass. Independent Codex review found no actionable P0–P2 findings.
  • Built-Gateway recovery flow passes: a fresh authenticated operator creates a canonical child through actual sessions_spawn; its next parent turn is interrupted by deliberately killing only the isolated fixture Gateway. The same private profile restarts and recovers the parent. Actual sessions_send admits the existing child; the child's model response is held until public history contains the parent's final reply and public status is done. Releasing the child then produces exactly one real exec effect against the synthetic fixture receiver and a persisted child final, with both session incarnations unchanged. Both Gateway processes and the fixture server are joined afterward.
Sanitized process-proof sequence and limits
canonical sessions_spawn -> retained child incarnation and spawnedBy verified
parent model request held -> fixture Gateway SIGKILL -> same-profile restart
actual recovered-parent prompt -> sessions_send -> child model request held
parent final persisted + status done + no active run; child effect count 0
release child -> exec receiver count 1 after parent done -> child final persisted
cleanup: 2 Gateway processes started, 2 joined; client and receiver closed

This is the real built Gateway and agent/tool path, using Node 24 and a scripted loopback Chat Completions provider, synthetic inputs, and a fresh private state/config/credential directory. It is not evidence of live-provider transport behavior or native Codex behavior. The build contains the reviewed patch on 271329fd32df; source hashes were recorded and the patch is unchanged in head b9bf4f98121f. Earlier collector attempts failed fixture setup, request classification, or tool-parameter assertions and are not credited as product proof. Raw requests, configuration, and logs remain private; no production conversation data is included here. That original allowed-path process trace did not exercise revocation or pre-admission rejection. The additional real-Gateway controls above now cover both boundaries; the committed regression controls remain supporting evidence.

All committed fixtures are synthetic. The live report included both a model-idle timeout and a later recovery-authority failure; the regression proves this reachable authority defect, but does not establish that it caused every observed delay. The later human-started model turn completed, so no transport-timeout change is claimed.

Maintainer follow-up commit

  • Dropped the committed operator role revoked case. Its mocked turn service enforced revocation itself, so it would still pass if execution stopped checking prepared.operatorAuthority. The built-Gateway users.setRole control above is the real revocation proof.
  • Renamed the execution-side slot from assertContextCurrent to assertGatewayLifetimeCurrent (createAgentTurnService, StartAgentRunExecutionParams) and documented on the facade option that agent dispatch carries it into accepted execution, so it must not carry caller authority.
  • captureOperatorToolGatewayContinuationContext now reuses resolved.assertGatewayCurrent instead of an inlined copy of the Gateway-binding check.

Local integration qualification

The patch cherry-picks cleanly onto the existing customized local build. Its continuation suite reports 15 passing cases, including all three new authority cases, and one existing failure in preserves GitHub identity access after subagent_announce admits a write-only continuation: expected [operator.write], observed [operator.read, operator.write]. A determining-owner rollback of the three changed production files to the incumbent local commit 7281cfa5c56b reproduces the same assertion failure; the candidate files were restored afterward. The local completion path explicitly retains its source scope ceiling. This local integration difference is not introduced or repaired by this PR; the upstream-based PR candidate still passes all 103 focused tests.

The unchanged production patch is now deployed locally as 583f9cf88fb6 on the existing customized build. The native service was stopped, the production build passed in 2m 20.2s, and the same Node 24 service started successfully. Authenticated health, core readiness, remote UI access, active plugin registrations, and both affected conversation incarnations were verified. Service definition, configuration, and private environment bytes are unchanged. This verifies activation and preservation, not a claim that every previously observed model delay has been resolved.

@clawsweeper

clawsweeper Bot commented Oct 22, 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.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

✅ Maintainer security changes approved

A maintainer approved this revision with an explicit security approval comment.

A later push requires a fresh approval comment for an external contributor's PR.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug 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. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR checks parent authority during admission and lets accepted child execution use its own retained authority.

Example: After Gateway restart recovery, a parent uses sessions_send to resume its child and finishes before the child executes.

  • Before: The child fails with “Recovery claim retired” despite retaining valid operator authority.
  • After: The accepted child finishes independently, while revoked operators and expired admission sources remain blocked.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-level repair with shipped Gateway proof, meaningful negative controls, and no actionable findings; enforced security approval remains separate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied built-Gateway terminal evidence exercises actual restart recovery and sessions_send under the same identified synthetic operator: an allowed child performs one exec receiver request after parent completion, role revocation prevents receiver I/O, and parent cancellation during approval prevents child admission; source-qualified build reuse and scripted inference limits are explicit.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An admitted child can stop when its recovered parent finishes even though the child's operator authority remains valid.
Reason: The change restores the independent child lifetime already established by merged authority fixes without adding policy, configuration, or persistence.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR fixes a remaining child-execution authority defect on current main with a focused patch and adequate Gateway proof; no actionable code findings remain.

Priority: P1
Reviewed head: b9bf4f98121f226906990933610568c7a69ae403

Before merge

  • Await maintainer action - A maintainer must review head b9bf4f9 and post /allow-security-sensitive-change to satisfy the enforced security approval gate.

Findings

None.

Agent review details

How this fits together

The in-process Gateway adapter turns agent requests into admitted executions, passing caller authorization into admission and Gateway lifetime checks into execution.

flowchart TD
  A[Recovered parent] --> B[In-process agent adapter]
  B --> C[Source authorization at admission]
  C --> D[Child retains operator authority]
  D --> E[Execution checks Gateway and child authority]
  E --> F[Tool effect and terminal result]
Loading

Technical review

Best possible solution:

Keep admission bound to its source and accepted execution bound to the existing child authority and Gateway owners.

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

Current-main source retains the parent source assertion in child execution, and the supplied base regression fails after parent retirement; this review ran no target code.

Is this the best way to solve the issue?

The patch fixes the redundant facade check at its owner while preserving admission validation and the child's existing live authority checks.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Gateway binding and source assertion composition keeps the original intent (48c022a: Preserve prepared source facts and revalidate live authority around asynchronous session persistence.)
  • Accepted in-process agent facade authority changes intended behavior with a stated reason (57d4719: Allow accepted sessions_send replies to outlive the requester turn while retaining operator revocation checks.)
  • Selected requester and scope authority keeps the original intent (d0dcc9d: Run session tools and children under the selected person's permissions, retaining revocation after turn completion.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned patch and current-main defect: The introduced patch moves source validation into assertAdmissionCurrent and supplies assertGatewayCurrent to accepted execution; fetched main still supplies assertSourceCurrent to the execution facade. (src/gateway/server-plugin-in-process-dispatch.ts:416, b9bf4f98121f)
  • Existing authority owner remains authoritative: Admission derives continuation retention from canonical spawnedBy lineage; execution separately checks retained operator authority, requester currency, cancellation, lifecycle generation, and run ownership. (src/gateway/agent-turn/agent-run-execution-phase.ts:163, b9bf4f98121f)
  • Real Gateway final-effect controls: The PR body and enki’s follow-up provide terminal results for restart recovery through sessions_spawn and sessions_send: allowed child produces one receiver request after parent completion; users.setRole revocation produces zero receiver I/O; chat.abort during pending approval prevents child admission and receiver I/O. The reused working-tree build is explicitly qualified against the reviewed production source. (b9bf4f98121f)
  • Distinct regression boundaries: The added table covers parent settlement, operator-role revocation, and retirement before acceptance using real recovery and authority owners behind the mocked turn service; the body reports the parent-settlement case failing on base and passing on the candidate. (src/gateway/server-plugin-in-process-dispatch.continuation.test.ts:72, b9bf4f98121f)
  • Prior fixes establish intended lifetime: fix: recovered subagents abort after their parent finishes #176769 separates recovery claims from continuation policy, and fix(gateway): retain continuation authority for every child run #178693 makes child continuation retention structural; this PR repairs the remaining facade assertion rather than replacing those owners. (src/gateway/operator-run-cancellation.ts:51, 76cf9fe14c35)
  • Enforced current-head security approval: The guard comment requires a maintainer approval for the reviewed head, and supplied status contexts fail specifically for that missing approval; no such approval appears in the inspected discussion. A later check-refresh request was blocked by the network sandbox, so no broader fresh CI result is claimed. (b9bf4f98121f)

Likely related people:

  • Peter Steinberger: Raw commit 48c022a adds src/gateway/server-plugin-in-process-authority.ts:502 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 48c022a42c13; files: src/gateway/server-plugin-in-process-authority.ts)

PR surface

Source +5, Tests +131. Total +136 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 18 13 +5
Tests 1 131 0 +131
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 149 13 +136

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +18/-13; tests +131/-0 The small authority-lifetime split uses existing owners; the shared test table protects three distinct admission and execution boundaries.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Recovered child executions can fail after their parent completes, interrupting an otherwise admitted agent workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • 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 (2 earlier review cycles)
  • reviewed 2026-10-22T16:04:24.879Z sha b9bf4f9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-22T20:00:43.590Z sha b9bf4f9 :: blocked before merge. :: none

Reviewed October 22, 2026, 4:07 PM ET / 20:07 UTC (Revision 3).

@enki

enki commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body's Evidence section now contains the requested real-Gateway negative controls and a positive control using the same identified, role-governed synthetic operator:

  • Allowed child: after actual restart recovery and sessions_send, the parent finishes; the accepted child then performs exactly one real exec receiver request and persists its final.
  • Revoked child: canonical users.setRole changes the accepted child's operator to a denied role before releasing its model response; the exact child terminates with error and receiver I/O remains zero.
  • Expired parent: real sessions_send reaches a pending communication approval; canonical chat.abort ends that exact parent, late approval is refused as cancelled, and there are zero new child model requests, no forbidden child transcript input and zero receiver I/O.

Each case joins both fixture Gateways and closes clients/provider. Source and compiled pins were independently checked. Production is unchanged at b9bf4f9; the body explicitly qualifies reuse of the working-tree build labelled 271329, scripted inference, earlier failed setup attempts and the two driver revisions. No clean-head rebuild, native Codex proof, live deployment or security-owner approval is claimed.

Please reassess the proof and associated merge-risk item. Enforced maintainer security approval remains a separate requirement.

@clawsweeper

clawsweeper Bot commented Oct 22, 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. 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. labels Oct 22, 2026
Drop the mock-enforced revocation case, name the execution-side slot assertGatewayLifetimeCurrent, and reuse the resolved Gateway binding check for continuations.
@jalehman

Copy link
Copy Markdown
Contributor

/allow-security-sensitive-change

@jalehman
jalehman enabled auto-merge (squash) October 23, 2026 00:55
@jalehman
jalehman merged commit 714e95d into openclaw:main Oct 23, 2026
133 of 135 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
…law#180728)

* fix: recovered child sessions fail after their parent finishes

* refactor(gateway): name execution Gateway lifetime check

Drop the mock-enforced revocation case, name the execution-side slot assertGatewayLifetimeCurrent, and reuse the resolved Gateway binding check for continuations.

---------

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

Labels

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: S status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants