Skip to content

fix(codex): preserve child replies during binding updates - #184604

Merged
vincentkoc merged 4 commits into
mainfrom
fix/native-completion-publication-authority-20261026
Oct 26, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
fix/native-completion-publication-authority-20261026

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Related: #183790

What Problem This Solves

Fixes native child replies and accepted follow-up receipts being lost when their parent binding is concurrently updating metadata.

User Impact

Native child work can finish and admit its reply while ownership-preserving binding updates are pending. Ownership replacement, deletion, expired entries, retired sources and uncertain write outcomes still block native admission. After admission, the exact durable requester receipt owns delivery and recovery. No configuration or migration is required.

Why This Change Was Made

The completion owner used a prepared row read that rejects every pending publication. That read fence is appropriate for data reads, but it can permanently retire completion custody during the owner's own metadata updates.

A private prepared authorization guard now validates committed ownership and every overlapping pending effect derived from the serialized state command. Codex supplies its existing binding-ownership predicate. Ordinary row reads keep their stricter pending-publication fence; queue and worker holds both participate in the guard.

Non-test production changes add 198 and remove 48 lines (net +150): the private ownership boundary and Codex integration account for +149, and one benchmark-adapter line preserves its existing unsupported-operation refusal. Tests add 820 and remove 23 lines; documentation adds 11 lines. No new public SDK subpath, dependency, schema or configuration surface is introduced.

Evidence

  • 76 focused tests passed across eight files, covering real SQLite publication, source-qualified binding checks, native completion, follow-up receipts, parent retention, subscription and assignment siblings. All three new completion regressions fail with the original pending-publication fence restored, then pass with this repair. This fixture uses an admitted host and real state workers with a credential-free Codex protocol client; outbound delivery is stubbed.
  • The 17-case completion-ownership suite passed. Four added cases run the real completion capture and session checkpoint path. A foreign writer keeps metadata/replacement CAS publication pending through the actual checkpoint predicate. Allowed metadata persists the exact claim, source run and internal ingress. Binding replacement, source revocation and requester reassignment leave no completion checkpoint and preserve the exact requester row. The accepted durable receipt remains recoverable after original native authority closes.
  • The 19-case delivery-custody integration suite passed through the real delivery queue, hooks and recording adapter. It covers physical-session, lifecycle and input invalidation plus owner-bound composition.
  • Six selected restart/final-delivery cases passed: valid recovery at both adapter handoffs, principal demotion before handoff, demotion before retained recovery, and demotion inside each recovered handoff. Unauthorized cases record zero sends; valid recovery sends exactly once.
  • The hosted compaction failure exposed an unchanged fixture reporting an old owner as unloaded while separately refusing its successor until process exit. The fixture now reports the actual loaded/idle state and observes the passive-read barrier. All eight cases pass; restoring only the old unloaded response reproduces the pre-exit ownership failure. Production compaction and assertions are unchanged.
  • Independent source review and pre-commit review found no scoped correctness issue. The final test-only fixture normalization correction was independently reviewed.
  • Targeted lint, core and state/logging test types, focused test types, the canonical Codex package-boundary compile and pnpm build passed. Final changed-test lint and types passed.
  • The hosted assertion-safety ratchet found the existing invariant comment two lines above its cast. The comment now sits directly above the assertion. The canonical targeted checker reports old count 1, new count 0 against allowance 0; removing only that comment leaves identical file bytes. No executable or type change was made.
  • The first hosted script-type check found a benchmark fixture missing the new required guard member. The fixture now uses its existing refusal handler; targeted lint and canonical pnpm tsgo:scripts pass.
  • pnpm plugin-sdk:surface:check reports three existing public-budget failures: 160 entrypoints > 158, 3827 exports > 3816, and 2219 callable exports > 2212. A same-environment comparison against the exact base source tree proves identical public entry identifiers, totals and failures. Shipped-surface removals and forbidden-subpath checks pass. Budgets are unchanged.

The checkpoint predicate proves planning/admission ordering, not arbitrary native revocation after planning or at the worker's final commit. Downstream delivery consumes requester/receipt and principal authority; this PR does not make accepted receipts depend on the original native binding forever. The admission and final-adapter tests are compositional proof, not one end-to-end native-to-channel run.

This proves a source-level race. It does not establish the root cause of the linked production incident; no live provider, Telegram delivery or full mock-gateway QA run is claimed. Codex dependency behavior was checked directly in codex-rs/core/src/agent/control.rs:418–510, codex-rs/app-server/src/bespoke_event_handling.rs:810–850, codex-rs/app-server/src/thread_status.rs:429–450 and codex-rs/app-server/src/request_processors/thread_processor.rs:2153–2245 at 414782450952a196bbb64b1605a458c2531c47b6. Exact-head hosted CI remains the landing gate.

@vincentkoc vincentkoc self-assigned this Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex plugin: file-transfer size: L labels Oct 26, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review October 26, 2026 12:15
@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 Oct 26, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 26, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review current head b6e3f39c7df300e9af18e4950a70c57a8d663d0b. The previous exact review was superseded before publication. The only follow-up change adds the existing unsupported-operation refusal to the read-only benchmark fixture; targeted lint and canonical scripts typecheck pass.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserves native child completion admission during binding metadata updates that keep the same owner.

Example: A child finishes with “Result” while its parent binding updates rolloutPath to /workspace/rollout.jsonl.

  • Before: The pending publication rejects the binding read and can retire completion custody.
  • After: Admission continues when committed ownership and every pending postimage preserve the parent owner.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused repair with no identified defect and source-verified authority coverage; proof remains compositional rather than a shipped-entry-point run.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (none): For this maintainer-authored PR, source-verified compositional authority proof covers real SQLite publication, actual completion checkpoint persistence, and production delivery owners with recording adapters: metadata is admitted, replacement/revocation/reassignment rejects, accepted receipts survive original-source retirement, and unauthorized recovered handoffs record zero sends. Reported results remain applicable after the comment-only follow-up; no live provider or native-to-channel run is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Native child results and accepted follow-up receipts can lose admission while their unchanged parent owner publishes metadata.
Reason: The maintainer-authored direction repairs a concrete source failure while preserving replacement, revocation, expiry, and uncertain-outcome protection; the broader linked incident remains explicitly separate.

Merge readiness

✅ Ready for maintainer review

This PR addresses a current native-completion admission defect; no actionable correctness finding remains on the reviewed head, and exact-head CI is still pending.

Priority: P2
Reviewed head: 1a7cb560f4a3344f29e75e047cdc7c4bab5f1df6

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Codex plugin consumes native child events, checks binding and session ownership through plugin-state publication, and transfers accepted completions to durable requester receipts for delivery and recovery.

flowchart LR
  A[Native child completion] --> B[Codex completion monitor]
  B --> C[Plugin state ownership guard]
  D[Committed binding and pending effects] --> C
  C --> E[Requester receipt admission]
  E --> F[Delivery and recovery owner]
  F --> G[Channel adapter]
Loading

Technical review

Best possible solution:

Keep ownership-preserving admission in the existing publication owner and let accepted durable requester receipts own subsequent delivery.

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

Current main exposes the pending-publication rejection path, and the maintainer reports three completion regressions failing with the original fence restored; no target code was executed during this review.

Is this the best way to solve the issue?

The repair uses existing publication, binding-codec, and requester-custody owners, preserves stricter ordinary reads, and avoids a competing persistence or recovery mechanism.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit d4820c4 adds extensions/codex/src/app-server/native-subagent-assignment-store.ts:96 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-store.ts)
  • Paul Bohm: Raw commit c853069 adds extensions/codex/src/app-server/run-attempt-resources.ts:87 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: c85306952ac7; files: extensions/codex/src/app-server/run-attempt-resources.ts)

PR surface

Source +149, Tests +797, Docs +11, Other +1. Total +958 across 26 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 11 197 48 +149
Tests 13 820 23 +797
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 26 1029 71 +958

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +198/-48; tests and test support +820/-23 Production growth classifies pending effects within the existing owner; tests cover distinct queue, worker, completion, receipt, revocation, and requester-transfer boundaries.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A bounded concurrency defect can discard native child completion admission, without evidence of a broader outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (3 earlier review cycles)
  • reviewed 2026-10-26T12:43:32.842Z sha b6e3f39 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-26T13:55:06.813Z sha a65117b :: needs maintainer review before merge. :: none
  • reviewed 2026-10-26T14:01:31.044Z sha a65117b :: needs maintainer review before merge. :: none

Reviewed October 26, 2026, 10:12 AM ET / 14:12 UTC (Revision 4).

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL and removed size: L labels Oct 26, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head a65117b8de5bdb4189ee2b185572471cb82302b1. This head adds only the reviewed test proof and a compaction fixture correction; runtime is unchanged from the prior reviewed head.

The requested authority evidence is now split at the actual production ownership transfer:

  • Native admission and durable outcome: src/agents/agent-harness-completion-ownership.test.ts:162 uses the real completion recovery capture, real plugin-state CAS and real persistAgentSession. A foreign SQLite writer keeps publication pending while the actual checkpoint predicate runs. Metadata succeeds with the exact durable claim/source run/internal ingress. Binding replacement, source revocation and requester reassignment deny admission, leave no checkpoint, and preserve the exact unrelated requester row. The 17-case file passes. This proves the planning/admission boundary, not arbitrary revocation after planning or at final worker commit.
  • Final adapter and requester custody: the existing 19-case src/agents/command/delivery.custody.integration.test.ts passes through the real queue/hooks/recording adapter, covering physical-session, lifecycle and input invalidation and owner-bound composition.
  • Nearest unauthorized principal and retained recovery: six selected cases in src/agents/command/delivery.restart-final.integration.test.ts pass. They cover valid recovery at both handoffs, admin-to-member demotion before handoff, demotion before retained recovery, and demotion inside each recovered adapter handoff. Unauthorized cases assert zero sends; valid recovery sends each payload once. The two long interpolated test names required a separate prefix filter: four passed first, then exactly the remaining two passed (21 skipped).

One stronger interpretation of the prior request is deliberately not implemented: an original native binding does not remain the final-I/O authority after the durable requester receipt is accepted. server-plugin-in-process-dispatch.ts:438 supplies the native source to admission; internal-facade.ts:344 and agent-run-execution-phase.ts:456 pass explicit execution authority separately. agent-harness-completion-recovery.ts:208–253 accepts the exact durable receipt for subsequent recovery. Coupling final I/O to the original native binding would contradict this existing ownership contract and cancel valid accepted work. The new positive test explicitly proves that receipt survives original-source revocation; the downstream tests prove requester/principal invalidation at their actual effect boundary. These are compositional tests, not a claimed full native-to-channel run.

The exact-head compaction CI failure is also addressed. Its unchanged fixture reported the old thread as notLoaded while requiring its process exit before a successor could resume. The actual Codex contract reports a loaded nonrunning thread as idle. The fixture now does so and observes the passive read before the pre-exit assertion. Eight cases pass; restoring only the old unloaded response fails the original ownership assertion. Production compaction and assertions are unchanged.

Final changed-test lint and types pass; independent source review and pre-commit review are clean. The PR body now records these results, the unchanged baseline SDK-budget failures, and the absence of live Telegram/provider or full mock-gateway proof. Direct Codex source inspection used revision 414782450952a196bbb64b1605a458c2531c47b6, including thread_status.rs:429–450 and request_processors/thread_processor.rs:2153–2245. Exact-head CI is pending; merge remains held for the current-head verdict and required gates.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Oct 26, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. 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 26, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) October 26, 2026 13:59
@vincentkoc
vincentkoc disabled auto-merge October 26, 2026 14:03
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 1a7cb560f4a3344f29e75e047cdc7c4bab5f1df6. The only change since your clean a65117 review is moving the existing SAFETY comment immediately above its cast to satisfy the canonical assertion-safety ratchet. Targeted canonical checker: before 1, after 0, allowance 0; all non-comment bytes are identical. Normal hooks and formatting passed. Runtime, tests and types are unchanged; the existing compositional admission/receipt/final-adapter proof and its stated limits remain unchanged. Exact-head CI is running.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot 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 26, 2026
@vincentkoc
vincentkoc merged commit 5ac1ab1 into main Oct 26, 2026
154 of 155 checks passed
@vincentkoc
vincentkoc deleted the fix/native-completion-publication-authority-20261026 branch October 26, 2026 14:37
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…84604)

* fix(codex): preserve child replies during binding updates

* fix(test): align adoption fixture with binding guard contract

* test(codex): prove completion receipt admission and owner handoff

* fix(sdk): attach guard assertion invariant to cast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex P2 Normal backlog priority with limited blast radius. plugin: file-transfer proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant