Skip to content

fix(codex): completed grandchildren replay after Gateway restarts - #179050

Merged
steipete merged 4 commits into
mainfrom
fix/codex-grandchild-completion-owner
Oct 21, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/codex-grandchild-completion-owner

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #178395

What Problem This Solves

Fixes completed Codex grandchildren leaving saved assignments that are restored and rejected again after every Gateway restart.

User Impact

Nested native work settles without repeated ownership warnings, stale assignments, or an extra result sent to the root requester. Existing pending assignments recover on registration when native lineage is available. Rotated-root follow-ups and uncertain recovery remain pending; no configuration or stored-format migration is required.

Why This Change Was Made

Codex delivers a grandchild's result to its immediate native parent, while OpenClaw's saved locator belongs to the root requester. Treating those two identities as the same delivery destination rejected valid nested completions. The assignment inventory now acknowledges lineage-proven nested completion through its existing durable consumption owner, checking current child custody and requester identity at the write. Recovery reads the middle thread's metadata when that child is no longer in memory.

The simplification pass reuses cancellation acknowledgement and avoids duplicate consumption after it commits. Production growth is +60 lines (+66/-6): the added lineage recovery and authority checks have no existing equivalent to reuse safely. Tests are +133/-1 lines (net +132); documentation is +6/-0.

Evidence

  • Source and history confirm the mismatch, rejected delivery claim, retained assignment, and restore loop on main e8d8145cd62feac71d6c65636c948a74b7f799d6. Codex's native spawn and immediate-parent completion watcher were inspected directly.
  • Added acknowledges a grandchild's native completion without root delivery or restart replay and settles a restored grandchild only with native lineage and current custody (available, unavailable, and revoked cases). Extended admits a fresh follow-up after native parent rotation only with current matching custody through undelivered completion.
  • Changed-file oxfmt passed. Changed-file oxlint passed using the current core rules; only the unrelated UI JS-plugin override was omitted because its dependency is unavailable locally. Explicit file selection was verified; no changed TypeScript file was ignored. git diff --check passed.
  • Both prescribed isolated Codex branch autoreviews: scoped-clean through P2, no accepted/actionable findings, including after the CI correction.
  • PR CI is the test gate and covers the regression tests, affected Codex completion/cancellation/recovery consumers, type checks, and repository checks selected by CI. Tests and local typechecks were intentionally not run. On the initial head, the four new cases passed with 3.565 seconds of reported test time in total; their 186-test shard completed in 128.19 seconds. Local wall time was intentionally not measured.
  • Live Gateway proof was intentionally skipped per maintainer policy. No Gateway, Crabbox, or Testbox was started.

The first CI run (39549070462) passed 28 jobs, including all new grandchild and extended rotation cases. Its only failing test expected the previous cancellation-specific acknowledgement error; the sibling Stop recovery assertion now expects the shared acknowledgement diagnostic, with all recovery/retry checks preserved. Corrected head 9497bbf2600cd45a19c95e0974186d6b0f897304 includes a fresh merge of main 855b0aa7242e31c85051d20db54a853025cd4094 and passed exact-head CI 39551224201: 29 successful jobs and 28 intentional skips, including the corrected Stop consumer and the grandchild regressions.

ClawSweeper's P2 cancellation-test finding is addressed by the diagnostic expectation correction. Its remaining asks concern extra live/durable-state proof; those are intentionally declined under the explicit maintainer policy above. The review found no concrete authorization bypass.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review October 21, 2026 05:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T05:50:37.588183Z 9497bbf New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: M labels Oct 21, 2026
@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. 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 Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR retires completed native Codex grandchildren through the existing assignment owner without sending another root continuation.

Example: parent-thread spawns child-thread, which spawns grandchild; grandchild finishes grandchild-turn.

  • Before: The root/native-parent mismatch rejects completion settlement, leaving an assignment that replays after Gateway restart.
  • After: Verified native lineage permits durable retirement without another root response; unavailable lineage leaves the assignment pending.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused repair has no remaining concrete finding and passed exact-head CI, but mandatory final-effect authority and existing-state compatibility evidence remains unproven.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Completed native grandchildren leave saved assignments that are rejected and restored after every Gateway restart.
Reason: The reporter supplies a concrete owned failure, and maintainer authorship establishes direction for this focused repair without new configuration or public API.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this maintainer-authored PR addresses a confirmed recovery defect still present on main; the prior cancellation-test finding is fixed, and no new concrete code defect was found.

Priority: P2
Reviewed head: 9497bbf2600cd45a19c95e0974186d6b0f897304

Before merge

  • Add real behavior proof - Authority-chain proof required: show allowed grandchild retirement, rejection of a different/reset requester, and custody revoked during lineage lookup preventing consumption through the real durable binding owner. Supplied registered-monitor cases retain real host custody but substitute the native client and binding storage; exact-head CI does not close that boundary. Existing-state compatibility also lacks the requested latest-stable upgrade/reopen evidence preserving settings and unrelated assignments. The maintainer's explicit decision to skip these runs is recorded, but this review procedure retains those gates. Submit redacted terminal output or logs without IPs, API keys, phone numbers, or non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security concern: Verify requester-bound retirement at the persisted effect - Source retains requester identity, live custody, binding-generation, and commit guards; the supplied Map-backed cases do not demonstrate different/reset requester refusal and revoked custody through the actual durable mutation.
  • Resolve merge risk - Before merge, establish that nested retirement cannot consume another requester's assignment or remain authorized after requester reset or custody revocation.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [medium] Verify requester-bound retirement at the persisted effect — extensions/codex/src/app-server/native-subagent-assignment-inventory.ts:186

Tests

  • Missing end-to-end proof: The supplied cases do not establish allowed and forbidden nested retirement through real durable storage or latest-stable existing-state recovery, and no base-red run of the new regressions is supplied.
Agent review details

How this fits together

The Codex plugin monitor receives native completion events and recovered thread history, then settles saved assignments through the requester-bound binding store.

flowchart TD
  A[Codex native completion] --> B[Completion monitor]
  B --> C[Native lineage recovery]
  C --> D[Requester and custody checks]
  D --> E[Existing binding mutation owner]
  E --> F[Persisted assignment retirement]
Loading

Technical review

Best possible solution:

Retire only lineage-proven completed grandchildren through the existing requester-bound assignment owner, preserving rotated-root follow-ups and uncertain recovery.

Do we have a high-confidence way to reproduce the issue?

Current main shows the mismatched native parent rejecting the completion claim, settlement preserving the pending assignment, and registration restoring it; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch uses the appropriate existing owners and distinguishes native lineage from root rotation; the simplification and test-value review found no unnecessary machinery or duplicate test group.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ef6d500b5340.

Merge-risk options

Maintainer options:

  1. Verify retirement at the durable boundary (recommended)
    Exercise allowed nested retirement and different/reset requester refusal through the real persisted binding owner, including custody revoked during the awaited lineage read.

Provenance checked

  • Durable assignment acknowledgement keeps the original intent (d4820c4: Cancellation must durably acknowledge the exact assignment and preserve retry after a refused write; this PR generalizes that existing operation and updates its Stop consumer.)
  • Native ancestry versus requester delivery changes intended behavior with a stated reason (41784ac: Recovery separates native ancestry from the current controller while requiring the saved requester and current authority; this PR explains why native nested delivery needs retirement before the ordinary parent claim.)
  • Assignment retirement and recovery ordering keeps the original intent (275c611: Terminal retirement consumes exact child-turn assignments without resurrecting them; the patch retains the existing consumption owner, distinct-turn identity, and subsequent recovery-write settlement.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was found, but the new retirement admission still needs final-effect authority proof.

Evidence

Security concerns:

  • [medium] Verify requester-bound retirement at the persisted effect — extensions/codex/src/app-server/native-subagent-assignment-inventory.ts:186
    Source retains requester identity, live custody, binding-generation, and commit guards; the supplied Map-backed cases do not demonstrate different/reset requester refusal and revoked custody through the actual durable mutation.
    Confidence: 0.9

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 275c611 adds extensions/codex/src/app-server/native-subagent-assignment-inventory.ts:154 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 275c611ead7a; files: extensions/codex/src/app-server/native-subagent-assignment-inventory.ts)
  • Vincent Koc: Raw commit d4820c4 adds extensions/codex/src/app-server/native-subagent-assignment-inventory.ts:150 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d4820c404e00; files: extensions/codex/src/app-server/native-subagent-assignment-inventory.ts)
  • Jacqueline Henriksen: Raw commit 9a5b671 adds extensions/codex/src/app-server/native-subagent-assignment-inventory.ts:229 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 9a5b67132027; files: extensions/codex/src/app-server/native-subagent-assignment-inventory.ts)

PR surface

Source +60, Tests +132, Docs +6. Total +198 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 66 6 +60
Tests 2 133 1 +132
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 205 7 +198

Review metrics

Metric Value Why it matters
Production versus test LOC Production +66/-6; tests +133/-1 Production growth supplies missing lineage recovery while reusing acknowledgement; tests cover active settlement, recovery, unavailable lineage, revocation, rotation, and the affected Stop consumer.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Completed grandchildren leave stale assignments and recurring restart warnings; the report establishes that native result delivery itself succeeds.
  • merge-risk: 🚨 security-boundary: Nested retirement bypasses the ordinary completion claim and relies on requester and custody checks whose forbidden-principal behavior remains unverified at the durable effect.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof for a different or reset requester and prove custody revocation during lineage lookup prevents the durable assignment write.
  • Show latest-stable upgrade and reopen with existing assignments and settings preserved.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-21T05:38:40.884Z sha 6170be8 :: needs real behavior proof before merge. :: [P2] Update the cancellation regression for the renamed acknowledgement error

Reviewed October 21, 2026, 2:00 AM ET / 06:00 UTC (Revision 2).

@steipete

Copy link
Copy Markdown
Contributor Author

The P2 consumer regression is fixed in 6f7be88: the Stop test now expects the shared acknowledgement diagnostic, while retaining rejected-write, reopen, and successful-retry assertions. The follow-up branch autoreview is clean through P2. The first CI run passed all four new grandchild cases and the extended rotated-root case; fresh exact-head CI will verify the correction.

Per explicit maintainer policy for this repair, PR CI is the test/proof gate. Live Gateway, released-state upgrade, and production-only negative-control runs are intentionally skipped. I am declining the proof-only requests under that policy. The review found no concrete authorization bypass: the nested path verifies native lineage and rechecks child custody, requester identity, and the existing binding owner's authority before consumption. There is no schema or stored-format change; restored existing assignments are covered by the regression cases.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 Oct 21, 2026
@steipete
steipete merged commit b189a9f into main Oct 21, 2026
124 of 127 checks passed
@steipete
steipete deleted the fix/codex-grandchild-completion-owner branch October 21, 2026 06:32
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
…enclaw#179050)

* fix(codex): retire completed grandchildren without restart replay

* test(codex): align native assignment acknowledgement expectation
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…79050)

* fix(codex): retire completed grandchildren without restart replay

* test(codex): align native assignment acknowledgement expectation

Adapted for release/2026.10.10: the cancelled-child acknowledge call keeps release's assertChild guard (main passes assertChildCustody), and #173018's give-up retirement tests move from native-subagent-inventory.test.ts into native-subagent-inventory.retirement.test.ts so the combined release file stays under the max-lines limit; the grandchild tests send raw notifications because release's test client lacks the item/completeTurn helpers.
(cherry picked from commit b189a9f)
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…79050)

* fix(codex): retire completed grandchildren without restart replay

* test(codex): align native assignment acknowledgement expectation

Release adaptation: stable has no Stop-driven descendant cancellation (#169700 is main-only), so the inventory gains the generic acknowledge() owner directly instead of renaming settleCancelled, and the main-only cancellationRequested guard and withDescendantCancellation hunks were dropped. The monitor keeps its stable thread-status-revision readHistory wrapper. Tests use client.notify with existing notification builders instead of the main-only client.item/completeTurn helpers and drop listPendingChildren probes.

(cherry picked from commit b189a9f)
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…79050)

* fix(codex): retire completed grandchildren without restart replay

* test(codex): align native assignment acknowledgement expectation

(cherry picked from commit b189a9f)

Adapted for 2026.9.x: 9.x has no descendant-cancellation (Stop) path, so there is no settleCancelled to rename; acknowledge() is added as a new method and the cancellation hunks plus the Stop submission-store test expectation are dropped. 9.x CodexNativeSubagentHistoryRecovery does not hold knownChildren, so the monitor checks its own knownChildren before asking history recovery to read the middle thread. Tests use client.notify with the existing notification builders because the 9.x test client has no item/completeTurn helpers, and listPendingChildren assertions are dropped (no such 9.x API).
RomneyDa added a commit that referenced this pull request Oct 26, 2026
The #173018/#179050/#179099 ports awaited inventory and submission-store reads that are synchronous on 9.x (await-thenable), and grew native-subagent-inventory.test.ts past the 1000-line limit. Drop those awaits and move the delivery/restoration cases into native-subagent-inventory.restoration.test.ts.
RomneyDa added a commit that referenced this pull request Oct 26, 2026
FRV 40403788884 normalCi failed check-dependencies (knip: production-unused exports added by the #181056 Slack and #179050 Codex ports) and check-docs (oxfmt on a #181920 test file). Keep those helpers module-private as main does, mirror the Slack limit in its test, and format the test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex native: a grandchild's completion is dropped as "history owner contradictory" and its assignment replays on every restart

1 participant