Repository navigation
fix: recovered subagents abort after their parent finishes - #176769
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +47, Tests +348, Docs +5. Total +400 across 6 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 19, 2026, 12:23 AM ET / 04:23 UTC (Revision 4). |
bacb9a1 to
4e5bfe4
Compare
|
Addressed the requested final-I/O proof on @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
4e5bfe4 to
d156ff4
Compare
|
Integrated the shared requester-restoration and compaction owner from current main on @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Keep accepted continuation policy custody independent of the restored parent work claim. Preserve current operator, device, session and Gateway revocation at effects.
d156ff4 to
b3b75c5
Compare
|
Merged via squash.
|
…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
* 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)
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:
restoreGatewayRunRecoverystill 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:
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 statusokand one effect (118.796 s case; 274.30 s Vitest run; wrapper exit 0).pnpm build qaRuntimepassed 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 --checkpassed. 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 ond156ff4; it is prior-head evidence. Integrated-head production and three targeted test typechecks, changed-file lint, formatting, andgit diff --checkpassed. 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
b3b75c584cc4with 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