Repository navigation
fix(subagents): restore requester authority after Gateway restarts - #173873
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e70dce05a9
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs real behavior proof before merge. What this changesPersist original operator source evidence and revalidate it before continuing a subagent’s requester after a Gateway restart. Example: An operator with operator.write starts a child, then the Gateway restarts.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 10 items remain Keep this PR open: it addresses a real restart-recovery defect, but introduced recovery regressions and incomplete migration cutover block merging. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe subagent registry persists child execution and completion state; Gateway recovery reloads those records, restores caller custody, and dispatches retained results to the requester. flowchart TD
A[Admitted requester] --> B[Subagent registry]
B --> C[Shared state database]
C --> D[Gateway restart recovery]
D --> E[Current operator policy]
E --> F[Requester settlement]
F --> G[Delivery and tool effects]
Technical reviewBest possible solution: Restore caller-specific custody through the existing registry and policy owners while preserving legitimate channel recovery, retryability, worker isolation, and complete migration consumers. Do we have a high-confidence way to reproduce the issue? Current main retains completion custody tied to the closed Gateway; the corrected warm-restart regression documents the exact authority error, and source inspection confirms the path without executing it. Is this the best way to solve the issue? Sharing operator restoration and replacing registry custody are appropriate, but applying operator-only evidence requirements to every restored caller breaks existing channel recovery. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against da455704bd46. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: No concrete authorization bypass was found, but restored authority lacks proof at the final effect boundary. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +285, Tests +560, Docs +40, Config 0, Other +7. Total +892 across 29 files. Added test files: 0. View PR surface stats
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 October 16, 2026, 2:17 AM ET / 06:17 UTC. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cfc606c061
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
0453c45 to
0b257cd
Compare
|
Merged as CI run 38872939453 completed: 162 passed, 17 skipped, seven failed root jobs and their aggregate. Each remaining root failure reproduces on the exact tested main parent
Baseline commands were serial single-file The native merge command refused before dispatch because its PR review worktree was absent. The explicitly authorized exact-head API fallback merged successfully. No production deployment or restart was performed. |
…penclaw#173873) * fix(subagents): restore requester authority after Gateway restarts * test(subagents): align restart fixtures with restored operator custody * fix(subagents): retry overload-deferred authority restoration * fix(gateway): preserve retention updates across placement changes * fix(gateway): refresh retention facts before strict dispatch * fix(gateway): retry stale retention preparation before dispatch
Same-conversation scheduled agent turns (at + agentTurn + session:<key>) created from an authenticated operator turn now retain that operator source privately and re-admit it under current policy at each occurrence. Explicit one-shot session continuations may call next_check to rearm the same job. Release adaptations for 2026.10.6: - Restore the occurrence-bound operator source in run.ts and pass it to run-executor.ts admission (run-prompt-executor.ts does not exist here). - Extract restoreGatewayOperatorSource from restoreGatewayOperatorRecovery, matching only the operator-run-recovery.ts split from #173873. - Reconcile the source in ops-mutations.ts add/upsert/update (release has no job-mutations worker); captureCronCreatorSession stays synchronous. - Omit the github-publish-tool description change (no inspect/merge on this line); adapt cron-tool and docs wording to release text. - Regression tests observe the restored Gateway operator selection and a guarded sessions continuation instead of GitHub inspect/merge; port createCronServiceWithStateForTest and the OpenAI Responses model fixture; adapt one-shot expectations to release startup staggering and A->B->A schedule-edit semantics. - Regenerate prompt snapshots. (cherry picked from commit d74a4ae)
What Problem This Solves
A Gateway restart could leave interrupted subagents with completion authority bound to the previous Gateway, producing
operator source authority is no longer activeinstead of returning interrupted work to the requester. The registry owns child recovery; the main-session recovery exclusion is intentional.Interrupted children now keep their clean interrupted result, and their requester can continue under a freshly validated operator grant with the original scope ceiling. The requester can inspect uncertain effects and decide whether to resume child history or assign replacement work. Children are not automatically relaunched.
Ownership and security
Gateway custody transfers through the registry's acknowledged replacement operation instead of rebinding the old runtime owner. Restoration uses the same policy owner as main-session recovery, which retains its exact reservation checks. Recovery validates the current profile, role, authentication policy, device/token identity, access grant, requester incarnation, registry owner, and Gateway. Stale callbacks remain invalid, and sibling batches must share their original admitted source and narrowed scopes. Completed follow-up tasks discard old source evidence when they acquire fresh caller custody.
Stored-shape change: one optional
operatorRecoverySourcein the existing registry payload/codec, captured once at admission and bounded to 65,536 bytes. It contains non-secret evidence, never executable authority or transport credentials. No new table, index, sidecar, backfill, or bulk rewrite.Format 25 is necessary: the previous binary accepts the optional field but can ignore it during cold recovery and dispatch as system. The existing version guard therefore refuses older binaries instead of silently dropping the restriction. SQLite 24→25 publishes version metadata without reading or rewriting subagent payloads. PostgreSQL updates its version markers through the existing transactional migration owner with an unchanged catalog. Rollback requires a compatible binary or the verified pre-upgrade backup, through the normal update owner.
Missing, malformed, or revoked evidence preserves the interrupted result and refuses automatic dispatch; it never substitutes system authority. This also means source-less system-originated children do not automatically wake their requester: missing evidence cannot prove system authority. A fresh authorized turn can inspect the result and start new work; automatic adoption of that restricted old completion is not provided. The review suggestion to add a system fallback was declined under this approved contract.
An overload-only restoration deferral retries through the existing sweeper. Success or permanent refusal clears the runtime marker; later grant revocation never re-arms it. Requester retirement stays sticky across awaited restoration. No new timer, persisted state, or configuration.
Evidence
PR CI owns broad validation. No Testbox/Crabbox leases were allocated. A subprocess-test wrapper began full-build preparation locally; it was stopped to respect host limits, and subprocess proof remains with PR CI. No production restart or live-state mutation was performed.
Measurement and size
Synthetic storage measurement on an isolated Linux rig: Node 26.8.1, 6,000 retained rows, two alternating pairs, sequential writes below 100 MB. Source JSON: 617 bytes; payload: +643 bytes/row. Serialization median: 5.92 → 10.93 µs/row. SQLite write median: 11.66 → 17.50 µs/row (+5.84 µs, +50.1%); ranges 11.60–11.71 versus 17.33–17.66 µs/row. Database: 7.99 → 14.15 MB. This is a correctness fix with measured storage overhead, not a performance optimization. The measurement uses the actual table/index schema, WAL/NORMAL, and checkpoint; it excludes codec normalization, worker IPC, and grant restoration. Remote scratch was removed.
Production delta: +353 lines (545 added, 192 removed; excluding tests/support/docs, including generated SQL). Test/support delta: +1,047 (1,295 added, 248 removed). Durable bounded evidence, fresh custody, and the downgrade fence require growth to preserve the approved security contract. The old resolver-rebinding path is removed; policy validation stays with one owner.
CI repairs and review
CI exposed a decoder import cycle and remaining schema-version consumers. Capture stays private to admission, the durable decoder remains independent of Gateway runtime policy, and migration previews/native ceilings/Doctor descriptions track format 25. The SQL guard permits only the exact reviewed content-version transition. PostgreSQL's state-port fixture now derives its expected version from the canonical constant.
A paired-node retention failure exposed stale prepared placement observations. The coordinator retries complete preparation once for typed stale-read failures, covering both initial-read and inventory-read invalidation. Retired, released, or indeterminate authority still refuses. A dispatch flag prevents retry after any invocation or partially applied pruning. Strict placement validation remains immediately before dispatch, including null-to-null transitions. All 32 coordinator cases and 12 placement-projection worker cases pass. This replaces the incomplete intermediate per-fact refresh repair. Streaming proof now waits for the first observed delta instead of assuming 20 ms timing, retaining ordering/terminal/persistence assertions.
Review: independent subagent review (autoreview route unavailable). No review configuration was changed. Reviews are clean after the completed-follow-up, failed-rebind, overload-retry, schema-fence, and retention corrections; the final five-file repair also has a clean independent review. Main was integrated only after GitHub reported a merge conflict; generated PostgreSQL output was regenerated to preserve main's agent-deletion migration.
CI attribution
Final-head CI run 38872939453 tests head
88b29015f147565490795ae492df0ce3c18ae33ethrough merge984323177a142515126f13bf7db94be7ec4b0d98, whose main parent is6ea0cbc94c7ce6f642c49b5c4633becd99a38122. Seven failed jobs are inherited; each reproduces on that exact unchanged main parent with serial single-filepnpm test <file> --maxWorkers=1runs:session-binding.test.tsretains three undefined old import names; source is unchanged in the tested merge.attempt-startup-lifetime.test.ts: 2 pass, missing replacement binding;attempt-startup-retry.test.ts: 8 pass, missing recovered binding.run-attempt-thread-cleanup.test.ts: 7 pass, eight matching incognito binding/cleanup failures.registration-imports.test.ts: 2 pass, one forbidden import through provider-auth-aliases → current-plugin-metadata-snapshot → manifest-registry-installed.bot-message-dispatch.progress-card.test.ts: 4 pass, the same five reasoning-delivery failures.apply-deadline-real-transport.test.ts: the same 630000 ms versus 30000 ms deadline assertion.The full app-server source tree is identical between the baseline and tested merge. The named import, migration, and Telegram production paths and all seven test files are also unchanged. No production edits were made for attribution; the clean lane checkout was restored afterward. The aggregate CI gate remains red downstream of these failures; this is an inherited-failure exception, not a claim of green CI. No CI rerun was requested to chase green.
Current-head paired-node lifecycle passes both cases, including reconnect retention after bundle loss; required-native same-session passes; Telegram model-button identity passes. PostgreSQL conformance, iOS screenshots, production types, lint, and security-fast pass. The latter two E2E failures on the previous head remain unexplained transient observations; passing replay is not claimed as a product fix. The native fixture now reports failed synthetic node RPC results and workspace.skills invocation IDs without changing assertions or retries.
Earlier CI also exposed unrelated debug-overlay lint, reasoning timer, directive-delivery, and database concurrent-opener failures. Those were independently attributed to their exact main parent and are green on this head. Database attribution required an identical temporary fixture barrier on main and head after ordinary main repetitions did not reproduce; the barrier preserved the production entry point and original two-winner assertion, and was removed byte-for-byte afterward. No database ownership repair is included. An earlier iOS runner lacked the requested watchOS runtime; current-head iOS proof passes.