Skip to content

fix(codex): preserve the parent tool catalog during completion delivery - #194753

Open
dubr1k wants to merge 7 commits into
openclaw:mainfrom
dubr1k:fix/codex-completion-catalog-current-main
Open

dubr1k wants to merge 7 commits into
openclaw:mainfrom
dubr1k:fix/codex-completion-catalog-current-main

Conversation

@dubr1k

@dubr1k dubr1k commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A native child releases the parent's execution pin when its final turn settles, before its result has finished delivery. The detached completion then rebuilds the parent's dynamic tool catalog. Without a live pin it loses the original declarations, which can rotate the native thread or prevent the completion from being delivered.

User Impact

Completed native subagents can deliver their result on the original parent thread after the execution pin has been released.

Why This Change Was Made

Keep the original catalog available only to the exact in-flight completion owner. The existing monitor verifies the physical parent/client, requester, child source, announcement, active delivery attempt, and current completion custody. Recheck that custody after the awaited metadata read and under the existing binding authority before consuming the fingerprinted catalog. Do not keep the execution pin or change the current executor/permission checks. The existing settled-child retention loop moves to its parent owner so the monitor can delegate without growing its oversized module.

This ports the completion-catalog portion of #188698 to current main. It depends on #194748 (the native completion receipt custody change); it does not include the broader stable-release continuation/schema compatibility patch.

Evidence

  • The new catalog regression fails on the base: a completed child's unprotected catalog resolves to undefined. With the fix, the original catalog is restored; a revoked read, changed runtime, ordinary turn, and missing custody remain rejected or unavailable.
  • Catalog tests: 14 passed. SQLite-backed native completion contention tests: 7 passed, including actual pin release, exact/wrong request lookup, receipt handoff, retirement, and captured-custody invalidation.
  • Two composed native-dispatch regressions recover declarations from the real native metadata file during actual completion custody, then invoke the native bridge. A missing current executor is denied; session reassignment during awaited execution admission revokes custody and the prepared native policy denies execution. No OS command is spawned. This is synthetic protocol evidence for the current-main head, not clearance of the historical PR head or a live-model claim.
  • Current executor tests: 52 passed. Native follow-up custody and lifecycle sibling tests: 10 passed.
  • Targeted core and full Codex production/test TypeScript checks, targeted lint, formatting, diff whitespace check, and justified test-line allocation pass.
  • Independent local review found no actionable P0–P2 defects in this delta. It was limited to the supplied change/evidence.

The native protocol is represented by the repository's app-server fixture in these checks. This exact source head has not been exercised against a live model; previous installed-release incidents and proof are background, not an exact-head production claim.

Recovered-catalog authority evidence

At 3aa8f3d4b, the composed synthetic test exercises recovered catalog capture and a controlled allowed supervisor.spawn effect, then rejects session replacement and execution-policy revocation at the barrier immediately before tool execution. A mismatched requester does not receive the recovered catalog. Ten focused cases, targeted lint, test-line ratchet and commit checks passed; scoped review found no P0-P2 issues. The wrong-requester case is a capture-stage check, not a full downstream-dispatch denial proof. The supervisor effect is controlled, not an OS process; live Gateway/model and real end-effect validation remain outstanding.

CI allocation follow-up

7e8f5eb6f separately allocates 18 previously unallocated lines of existing custody, SQLite receipt-retirement and revoked-metadata regressions. Against the exact failing CI merge/base, the ratchet reproduced 6,583,543 / 6,583,525 and passed after this change at 6,583,543 / 6,583,543. Tests and the shared baseline remain unchanged; the new exact-head CI is pending.

@clawsweeper

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

@dubr1k
dubr1k marked this pull request as ready for review November 7, 2026 19:11
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 5f3d49aeb3fb4836b38006ed72dd7b58bc5eaef3, but the PR head is now 7e8f5eb6f7dc1a82a1a181cad7f61f70f6c4f0ef. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-08T05:37:53.947Z sha 5f3d49a :: needs real behavior proof before merge. :: none

Baumus commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Additional installed-release qualification for this repair, collected on 2026-11-08. This is not an exact-head runtime claim for this PR.

We investigated OpenClaw 2026.11.1 (source base 47c405cfffa45a73f3d5212593e7b490a6825508), Linux / Node 26.13, bundled Codex app-server, after a WebChat parent spawned a native child and yielded.

Observed incident and RCA

The child had completed with a nonempty final report. The completion wake ran on a replacement native root, whose agent list no longer exposed that child. The subsequent follow-up was blocked with the generic Native hook relay unavailable. The correlated Gateway nativeHook.invoke error was:

Codex native target is not currently identified; use its exact thread ID

Thus the Gateway was reached; this incident does not establish a stale relay registration. Native metadata establishes parent-thread replacement and differing declarations. The code-supported mechanism is the lifetime gap this PR addresses: the final child releases the execution pin before result delivery finishes, while native catalog recovery still requires live execution protection.

There is also an independent completion-content boundary, tracked in #167276: the receiving turn can have only Continue the OpenClaw runtime event. when its result remains in internalEvents. Current main already folds that context in plugin-attempt-params.ts and preserves it through Codex steering (merged #175837). Losing the original native mailbox makes that separate omission visible.

Locally installed scope

We selectively backported this PR's completion-catalog portion from 5f3d49aeb3fb4836b38006ed72dd7b58bc5eaef3, plus a release-compatible Codex-only host context bridge and the steering changes. The installation already contained native continuation work corresponding to #192214 and separate Gateway execution-lifetime corrections; those were preserved. We did not port the unrelated receipt change in #194748. Consequently this qualifies the combined release backport, not every commit/dependency in this PR.

Catalog lookup remains bound to the exact physical client, parent, requester, child source and announcement, with current in-flight completion custody checked again after the awaited metadata read. No execution pin is retained, and declarations do not grant executor authority. PreToolUse remains enabled.

Live proof against the built release backport

A child-only script generated an unpredictable marker, then waited at a barrier. The parent spawned exactly one child and successfully yielded before the barrier was released. On automatic completion, the parent followed up with that same child without supplying the marker; the child returned its remembered marker. Native history and lifecycle events established:

Scenario Parent thread/client preserved Follow-up reaches original child Remembered child result Native PreToolUse
Completion after yield Yes Yes Yes Both calls completed
User message while child waits, then completion Yes Yes Yes Both calls completed

The test checks native V2 subAgentActivity/interacted against the exact child ID, the child's second answer, and the marker in the parent's model input. This differs from the legacy collabAgentToolCall projection.

Other evidence and limits

  • The actual baseline catalog loader fails the new current-custody recovery case (undefined instead of the retained declarations); repaired catalog/SQLite contention checks pass.
  • The composed missing-executor and requester-reassignment controls deny the downstream effect before an OS spawn. These denial controls are synthetic boundary tests, not live-model revocation claims.
  • 23 catalog/contention tests, 13 steering tests and two selected host-context boundary cases passed. The host baseline also fails on the missing result marker; the non-Codex control passes.
  • The supported runtime build, targeted strict production/test typechecks and changed-test type-aware lint passed. Production type-aware lint still emits nine diagnostics on unchanged utility-type unions; native compiler probes establish non-any types, but we do not claim clean production lint or a full release build/full suite.
  • Independent external code review reported no actionable P0–P2 findings in the supplied scope.
  • The generated distribution and sealed worker import closure were validated, then installed with a verified backup. The restarted Gateway passes readiness and authenticated health, with Codex loaded and no plugin errors.

No private conversation IDs, child reports, credentials, configuration, or raw production logs are included. This is additional evidence for the existing PR, rather than a duplicate fix PR.

@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. labels Nov 8, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex P2 Normal backlog priority with limited blast radius. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants