Repository navigation
fix(codex): deliver native child results after parent yields - #156247
Conversation
Retain accepted native child completion ownership beyond the admitting turn and through Gateway restart drain. Bind event persistence, task transitions, history recovery, and delivery to the original assignment receipt, releasing execution holds after terminal persistence and the first handoff. Keep thread-only wait snapshots from mutating successor assignments. Document the optional exact-assignment transition contract for custom detached runtimes. Release-note: Fix native Codex child completions lost after parent yield or during Gateway restart drain.
|
🦞👀 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: needs maintainer review before merge. Reviewed September 23, 2026, 3:23 AM ET / 07:23 UTC (Revision 4). ClawSweeper reviewWhat this changesPreserves authority to persist and deliver Codex child results after the parent yields, binds updates to the accepted assignment, and checks custom adapter support before admission. Merge readiness✅ Ready for maintainer review The repair remains necessary on inspected main. No blocking correctness finding remains; the supplied authority and upgrade evidence addresses the earlier concerns. Priority: P1 Review scores
Verification
How this fits togetherThe Codex plugin translates native child-agent events into OpenClaw task records and requester continuations. Gateway authority and task ownership checks determine whether a completed result may be persisted and delivered. flowchart TD
A[Parent admits child work] --> B[Retained completion authority]
C[Codex child events] --> D[Exact assignment check]
B --> D
D --> E[Persist task result]
E --> F[Recheck requester authority]
F --> G[Resume requester]
F --> H[Reject revoked or replaced owner]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +856, Tests +2399, Docs +37. Total +3292 across 51 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep completion authority scoped to the original live requester and exact assignment, with execution holds ending after persistence and the first handoff. Do we have a high-confidence way to reproduce the issue? Yes, from source: let a native child finish after its admitting parent yields; inspected main lacks independent completion custody. This review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes. The patch extends the existing authority and task-transition owners, preserves assignment identity through recovery, and avoids bypassing custom adapters. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dc063e7bc043. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
@clawsweeper re-review Please review exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Please review exact head The PR body now explicitly supplies the requested storage/upgrade compatibility proof. Both canonical schema SQL files, schema-version declarations, task SQLite reader/writer and receipt helpers have identical Git blobs against Observed upgrade proof: the native updater completed |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash auto-merge.
|
…w#156247) * fix(codex): deliver native child results after parent yields Retain accepted native child completion ownership beyond the admitting turn and through Gateway restart drain. Bind event persistence, task transitions, history recovery, and delivery to the original assignment receipt, releasing execution holds after terminal persistence and the first handoff. Keep thread-only wait snapshots from mutating successor assignments. Document the optional exact-assignment transition contract for custom detached runtimes. Release-note: Fix native Codex child completions lost after parent yield or during Gateway restart drain. * fix(tasks): keep transition contracts independent of execution * test(tasks): isolate legacy dispatch from native settlement * fix(codex): validate task settlement before native admission * test(tasks): prove native completion authority at final effects * test(tasks): pass context to completion authority scenarios * test(tasks): settle completion request owners before assertions * test(copilot): complete task runtime capability fixture * test(tasks): match completion harness runtime contracts * test(tasks): align authority harness with typed lint * test(copilot): extract native task failure fixture
…on case main made CodexNativeSubagentMonitor.registerParent async (Promise< ParentRegistrationHandle>). This branch's direct-authority cases still used the handle synchronously (TS2339 on bindTurn/unregister; 6 runtime failures on the integration tree). Await the registration and each unregister. 'evicts the oldest pending direct spawn evidence instead of refusing the newest' fails on this branch before and after this change: main reworked native admission custody (openclaw#156247), so its buffering premise no longer holds. It is it.skip'd with a pointer to openclaw-7vub rather than guessed at. Verified: tsgo:extensions:test clean; file 34 passed, 1 skipped. Co-Authored-By: Tank (claude-opus-5-5) <[email protected]>
What problem this solves
Native Codex children can finish after their parent yields, but completion callbacks still use the expired authority of the admitting turn. Results then fail to persist or resume the requester, including during Gateway restart drain. A thread-scoped wait snapshot can also overwrite a newer assignment for the same child.
User impact
Accepted native child work keeps the authority needed to record its result and resume the same requester. Revoked or replaced requesters remain blocked. Execution holds end after terminal persistence and the first handoff, so delivery retries do not keep a restart open.
Custom detached adapters must implement the documented optional
transitionTaskAssignmentoperation before accepting native exact-assignment work. Registration now checks the captured adapter, including reused runtimes, and gives an upgrade error before submitting a turn. Existing unguarded calls retain their behavior.Why this change was made
The host issues completion custody for each accepted assignment and separates requester continuation from Gateway execution ownership. Events and transitions carry an immutable task receipt; only an acknowledged commit can advance it. The canonical transition checks that receipt around asynchronous planning. Codex owns release and recovery across child events, parent turns, and cleanup.
This removes transient caller capture, thread-only wait mutation of successor assignments, and unsafe core-store fallback for guarded custom adapters. Transition contracts now live in their existing leaf type module, removing the introduced import cycle.
Net production change: +856 lines for the completion owner and exact-commit adapter boundary. Tests/fixtures: +2,399; documentation: +37. No new configuration, schema version, dependency, or concurrency limit.
Evidence
ec2f407aa79b9b9e44f04009b15fc1d6f212ef20, based onb6340c7947bd989d19e02d277ebf25949e2454a2.1230323passes typed harness lint, Gateway test types and the packaged build (324.6 seconds); clean checkout, 50-file source manifest, frozen lockfile and embedded build revision verified. Nine real Gateway authority cases pass atf23f29e, followed only by mechanical lint corrections. At identical production revisions, 378 sibling tests across 12 files, the Copilot attempt suite, core/plugin production types, affected core/plugin test graphs and SDK surface checks pass. The transition-contract cycle repair also passes the full architecture check.473a407. Tests ran in a verified detached candidate checkout, separate from the workflow bootstrap revision.473a407: native update succeeded with matching source, dist and serving build, no final doctor/plugin errors, and no remaining update lease. A native child completed 14 seconds after its parent yielded; a distinct parent turn resumed and returned its result. The task recorded delivered and the parent pending-input count returned to zero, within the five-minute probe without a resend. A later read-only observation found 13 additional delivered native tasks, no new authority/persistence errors and no Gateway restarts. This is live proof of the original custody repair; it does not claim the later source commits are deployed.4147824: completion lifecycle incodex-rs/core/src/session/mod.rs:3714-3794; active-turn child admission incodex-rs/core/src/tools/handlers/multi_agents/spawn.rs:46-148; thread-scoped wait contract incodex-rs/app-server-protocol/src/protocol/event_mapping.rs:219-249,codex-rs/app-server-protocol/src/protocol/v2/item.rs:321-340, andcodex-rs/core/src/tools/handlers/multi_agents/wait.rs:109-158.8044ef8: no actionable P0-P2 findings. Subsequent test-only corrections supply the canonical no-media JSON value, narrow optional recorder input, follow typed-lint conventions, and extract the unchanged Copilot native-failure fixture into its existing test-support module; production and assertions are unchanged.Storage and upgrade compatibility
No database migration is needed. Against the merge base, both canonical schema SQL files, schema-version declarations, task SQLite reader/writer and receipt helpers have identical Git blobs. The
TaskRecordandTaskPersistenceReceiptdeclarations are also unchanged. The existing receipt helper freezes existing identity fields; completion custody is process-owned, not a new stored record.The flagged
detached-task-runtime-contract.tschange adds an optional adapter operation and progressdetailparameter. That parameter uses the existingTaskRecord.detail/detail_jsonfield and unchanged SQLite serializer. It does not add a table, column, version, persisted enum or backfill. Custom adapter capability admission is the separately documented runtime compatibility requirement above.Upgrade proof: the native updater took the affected existing installation from
b6340c7to473a407, completed doctor with zero errors/warnings, and the pre-existing 945-task cohort remained readable. A real post-yield native child was then persisted and delivered. Later commits change admission validation, transition type placement and tests; the storage contract remains identical. This is upgrade/readability proof, not a claim that historical failed deliveries were replayed.Review follow-through
The new Gateway harness exercises the actual announcement, input writer, dispatcher and AgentSession queue injector. Nine scenarios cover live, revoked and replaced owners at direct input staging, recorder resolution and compaction retry. Positive cases prove real persistence/injection. Negative cases prove no execution/injection, pending input or transcript change, and join request cleanup before checking dedupe. No pre-seeded successful reply is used.
The custom-adapter requirement is checked before every native registration, including cached runtime owners. Tests cover supported/core adapters, unsupported and retired owners, cleanup after rejection, and unchanged generic/Copilot behavior.
Release context: fix native Codex child completions being lost after parent yield or during Gateway restart drain. Changelog is release-owned.
Follow-ups: native next-wave delivery-obligation settlement remains a separate investigation; this repair preserves the existing visible-final policy and does not count yield or child admission as delivery. Copilot native assignment projection and native updater copy/progress performance use separate paths. Historical failed deliveries are not bulk replayed by this repair.
Additional CI follow-up: stabilize the existing three-layout config audit fixture against its independently running file watcher. One CI job observed an environment-generation conflict during include reread; the write was rolled back. The affected config/reloader/operation code is unchanged by this PR. The adjacent test fixture already supports disabling independent watch notifications while retaining real managed writes and journals. This does not justify weakening the production generation guard.