Repository navigation
fix: give a subagent result's restart wake the requester's original access - #203479
Conversation
…iginal scopes Save the spawning requester's recovery source on the subagent run. After a Gateway restart, completion recovery re-admits that source, so the woken parent turn keeps the requester's scopes (an owner keeps admin, a writer gets write). Rows without the field keep the session principal or System write baseline. Co-authored-by: obviyus <[email protected]>
|
🦞👀 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. |
…er is refused Each restored child re-admits its own saved requester, so one refused source no longer stops its siblings or drops already-bound children from the resume list. Shutdown and a changed requester chat still stop every child. Co-authored-by: obviyus <[email protected]>
|
Codex review: blocked before merge. What this changesThis PR saves each subagent requester's recovery source and re-admits it when restoring parent completion delivery after a Gateway restart. Example: A device-authenticated writer spawns a child from agent:main:dashboard:settled-requester, then the Gateway restarts.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this maintainer-authored PR addresses a current-main restart recovery defect, and no discrete introduced code bug was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe subagent registry retains child-result obligations in SQLite; Gateway startup restores their requester custody before completion delivery starts a parent turn. flowchart TD
A[Requester spawns child] --> B[Registry captures recovery source]
B --> C[SQLite subagent run]
C --> D[Gateway restart recovery]
D --> E[Current operator admission]
E --> F[Restored completion custody]
F --> G[Parent turn admission and delivery]
Technical reviewBest possible solution: Retain the existing registry and operator-admission owners, saving bounded requester facts and restoring each child's custody independently while preserving legacy fallback behavior. Do we have a high-confidence way to reproduce the issue? Current main re-admits only the session principal or uses the write baseline, losing the spawning requester's device-backed authority; the PR reports base-red/head-green owner and writer regressions, which were inspected but not executed during this read-only review. Is this the best way to solve the issue? The patch is a focused owner-level repair: one optional registry field uses the existing bounded codec and admission path, and per-child failure handling prevents a refused requester from blocking siblings. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b8a55ae92072. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +33, Tests +198, Docs +12. Total +243 across 6 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel 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 Reviewed November 22, 2026, 7:04 AM ET / 12:04 UTC. |
|
Landed in 450441b. Subagent spawn now saves the requester's recovery source. After a Gateway restart, the woken parent turn re-admits that source: an owner keeps admin, a writer gets write and never admin, and the child result is delivered. Older runs keep the session owner, else the System write baseline. One refused source no longer blocks its siblings. Proof: the saved-source restart tests are red on base (recovery refused, result undelivered) and green on head; CI is green; review round 2 is clean; the one-admission E2E checks R and S pass. |
…ccess (openclaw#203479) Related: openclaw#203466, openclaw#198905 ## What Problem This Solves When the Gateway restarts while a parent chat still owes a subagent result, restart recovery rebinds the result so that the parent chat is woken to receive it. Since openclaw#203466, a parent chat with no recorded owner wakes with the System write baseline, so an admin requester can lose admin after a restart. A parent chat whose owner profile has no current role-based grant (for example, someone who connected with a device token) fails recovery completely: the log shows "Session principal has no current run authority", and the child result is not delivered. ## User Impact After a restart, the woken settlement turn has the access of the person who spawned the subagent, checked against current policy: an owner keeps admin, a writer gets write and never admin. The child result is delivered. Subagent runs started before this change keep the earlier behavior (the session owner's access, else the System write baseline, never admin). ## Why This Change Was Made Subagent spawn now saves the requester's operator recovery source (`requesterOperatorSource`) on the subagent run. This is the same bounded codec and the same capture (`captureQueuedOperatorRecoverySource`) that queued inputs use. Unavailable sources are not stored. At restart, `recoverRequesterCompletionCustody` re-admits that source through `restoreGatewayQueuedOperatorRecovery`, the one admission that queued work also uses. The woken turn's own admission still checks session access when it starts. A refused source leaves the result unbound, as any failed recovery does. Storage (schema change approved by Ayaan): one optional property inside the existing `subagent_runs.payload_json`. No table, column, index, schema version or backfill. Older builds ignore the property and use their own fallback (`docs/reference/database-schemas/storage-changes.md` has the entry). ## Evidence - `session-restart-resume-custody.test.ts`, "wakes the parent with the saved owner/writer requester's scopes after a restart". These tests drive restart store discovery and custody recovery, then settle the interrupted child through the real lifecycle controller. - Base `7a9ad62bfc9e`: red. Recovery fails with "Session principal has no current run authority", and the result is not delivered. - Head: green. The owner wakes with `operator.admin`. The writer wakes with `operator.write` and without admin. The result is delivered (`delivery.status === "delivered"`). - Older rows: "delivers a restored ... child's owed notice after its legacy profile/unattributed requester settled" (session owner, else `[operator.write]`). - Spawn: `subagent-registry.requester-source.test.ts`. `registerSubagentRun` persists the requester's `gateway` source in the SQLite row. - Touched and importer tests: 17 files, 226 tests pass. Production code grows by about 25 lines: one capture at spawn and per-child re-admission at restart. This is the approved stored-source design. It removes the single session-principal admission that every restored child shared. Each restored child re-admits its own saved requester. A refused source (for example, a revoked device) is logged and leaves only that child unbound. Its siblings are still recovered and resumed (test: "recovers a sibling child when another child's saved requester is refused"). Shutdown or a changed requester chat still stops recovery for every child. Co-authored-by: Ayaan Zaidi <[email protected]>
…ccess (#203479) Related: #203466, #198905 When the Gateway restarts while a parent chat still owes a subagent result, restart recovery rebinds the result so that the parent chat is woken to receive it. Since #203466, a parent chat with no recorded owner wakes with the System write baseline, so an admin requester can lose admin after a restart. A parent chat whose owner profile has no current role-based grant (for example, someone who connected with a device token) fails recovery completely: the log shows "Session principal has no current run authority", and the child result is not delivered. After a restart, the woken settlement turn has the access of the person who spawned the subagent, checked against current policy: an owner keeps admin, a writer gets write and never admin. The child result is delivered. Subagent runs started before this change keep the earlier behavior (the session owner's access, else the System write baseline, never admin). Subagent spawn now saves the requester's operator recovery source (`requesterOperatorSource`) on the subagent run. This is the same bounded codec and the same capture (`captureQueuedOperatorRecoverySource`) that queued inputs use. Unavailable sources are not stored. At restart, `recoverRequesterCompletionCustody` re-admits that source through `restoreGatewayQueuedOperatorRecovery`, the one admission that queued work also uses. The woken turn's own admission still checks session access when it starts. A refused source leaves the result unbound, as any failed recovery does. Storage (schema change approved by Ayaan): one optional property inside the existing `subagent_runs.payload_json`. No table, column, index, schema version or backfill. Older builds ignore the property and use their own fallback (`docs/reference/database-schemas/storage-changes.md` has the entry). - `session-restart-resume-custody.test.ts`, "wakes the parent with the saved owner/writer requester's scopes after a restart". These tests drive restart store discovery and custody recovery, then settle the interrupted child through the real lifecycle controller. - Base `e9f29990130b`: red. Recovery fails with "Session principal has no current run authority", and the result is not delivered. - Head: green. The owner wakes with `operator.admin`. The writer wakes with `operator.write` and without admin. The result is delivered (`delivery.status === "delivered"`). - Older rows: "delivers a restored ... child's owed notice after its legacy profile/unattributed requester settled" (session owner, else `[operator.write]`). - Spawn: `subagent-registry.requester-source.test.ts`. `registerSubagentRun` persists the requester's `gateway` source in the SQLite row. - Touched and importer tests: 17 files, 226 tests pass. Production code grows by about 25 lines: one capture at spawn and per-child re-admission at restart. This is the approved stored-source design. It removes the single session-principal admission that every restored child shared. Each restored child re-admits its own saved requester. A refused source (for example, a revoked device) is logged and leaves only that child unbound. Its siblings are still recovered and resumed (test: "recovers a sibling child when another child's saved requester is refused"). Shutdown or a changed requester chat still stops recovery for every child. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 450441b) Release adaptation: restore through the stable queued-source API without the newer agentId parameter; keep stable restart-store discovery proof and omit main-only restart-scope cases because stable has no restart-scope classifier. Carry upstream least-privilege System write fallback. #203521 deliberately does not turn completion custody into a fresh chat grant check. #203222 settlement already staged; later parent-history redesign is not a prerequisite. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit b3231a69dd6ead5d34ee7cba31b58aaaea29308a)
Release adaptation for #203479: stable recovery fixture releases its live authority before returning; exercise the persisted snapshot instead of recapturing a released handle. Spawn persistence has its own owning-boundary regression. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 6f3cc9de265f8a8a0c062bf95bd67fee234a2a58)
Related: #203466, #198905
What Problem This Solves
When the Gateway restarts while a parent chat still owes a subagent result, restart recovery rebinds the result so that the parent chat is woken to receive it. Since #203466, a parent chat with no recorded owner wakes with the System write baseline, so an admin requester can lose admin after a restart. A parent chat whose owner profile has no current role-based grant (for example, someone who connected with a device token) fails recovery completely: the log shows "Session principal has no current run authority", and the child result is not delivered.
User Impact
After a restart, the woken settlement turn has the access of the person who spawned the subagent, checked against current policy: an owner keeps admin, a writer gets write and never admin. The child result is delivered. Subagent runs started before this change keep the earlier behavior (the session owner's access, else the System write baseline, never admin).
Why This Change Was Made
Subagent spawn now saves the requester's operator recovery source (
requesterOperatorSource) on the subagent run. This is the same bounded codec and the same capture (captureQueuedOperatorRecoverySource) that queued inputs use. Unavailable sources are not stored. At restart,recoverRequesterCompletionCustodyre-admits that source throughrestoreGatewayQueuedOperatorRecovery, the one admission that queued work also uses. The woken turn's own admission still checks session access when it starts. A refused source leaves the result unbound, as any failed recovery does.Storage (schema change approved by Ayaan): one optional property inside the existing
subagent_runs.payload_json. No table, column, index, schema version or backfill. Older builds ignore the property and use their own fallback (docs/reference/database-schemas/storage-changes.mdhas the entry).Evidence
session-restart-resume-custody.test.ts, "wakes the parent with the saved owner/writer requester's scopes after a restart". These tests drive restart store discovery and custody recovery, then settle the interrupted child through the real lifecycle controller.e9f29990130b: red. Recovery fails with "Session principal has no current run authority", and the result is not delivered.operator.admin. The writer wakes withoperator.writeand without admin. The result is delivered (delivery.status === "delivered").[operator.write]).subagent-registry.requester-source.test.ts.registerSubagentRunpersists the requester'sgatewaysource in the SQLite row.Production code grows by about 25 lines: one capture at spawn and per-child re-admission at restart. This is the approved stored-source design. It removes the single session-principal admission that every restored child shared.
Each restored child re-admits its own saved requester. A refused source (for example, a revoked device) is logged and leaves only that child unbound. Its siblings are still recovered and resumed (test: "recovers a sibling child when another child's saved requester is refused"). Shutdown or a changed requester chat still stops recovery for every child.