Repository navigation
fix(codex): prevent stale native sessions from mutating successors - #156940
galiniliev wants to merge 8 commits into
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: blocked before merge. Reviewed September 30, 2026, 6:25 PM ET / 22:25 UTC (Revision 22). ClawSweeper reviewWhat this changesThe Codex plugin now checks current session ownership before native requests, binding mutations, and retained-thread cleanup, with regression cases for competing and superseded sessions. Merge readiness⛔ Blocked before merge - 4 items remain Keep open. Current main still permits the reported thread-wide custody check, and the linked session-ownership issue remains open. The branch has credible final-effect proof and no concrete introduced defect was found in the reviewed authority paths. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw's Codex plugin connects agent turns to a native Codex app-server thread. Session rows and process ownership determine which requests, binding updates, and subscription cleanup may reach that thread. flowchart LR
A[Agent turn] --> B[Session row authority]
B --> C[Codex attempt]
C --> D[Current lineage check]
D --> E[Native request writer]
D --> F[Thread and process custody]
E --> G[Codex app server]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfacePR surface statistics unavailable: the file list is incomplete. Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep current session-row and initiating-process custody at each native effect boundary, while preserving peer listeners, exact-claim cleanup, and existing version-1 bindings. Do we have a high-confidence way to reproduce the issue? Yes. The registered client and sandbox-process fixture rotates lineage during subscription retention and has a reported failing pre-fix peer-only control; I did not rerun it. Is this the best way to solve the issue? Yes. The patch moves the decision to current session and process owners at the final effects, while updating both official callers of the private shared session contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0016b17df26c. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (21 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Please review exact current head |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Please review exact current head |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Please review exact current head |
|
🦞👀 Re-review progress:
|
Reconcile the aggregate published repairs on current main.
91d4b9f to
2099e55
Compare
|
Consolidating this work with #143201 in #164197. The replacement preserves Galin's original commits and contributor credit, incorporates current main's authority and executor changes, and adds physical-client fencing. Validation and review are in progress; this PR will be closed after the replacement lands. |
…164197) Fence Codex native effects, binding mutations, and subscription cleanup to the initiating session lineage and exact physical client. A replaced session can no longer borrow a peer's process custody or clear a successor binding, including across worker CAS retries and delayed remote-file responses. Use the existing database workers and authority cohorts, preserve synchronous released SDK contracts and reversible deletion vetoes, and retain main's shared bounded media reader. Regression proof covers physical writes, successor recovery, compaction, cleanup, and API compatibility. Consolidates #156940 and the independently reimplemented physical-client checks from #143201. Unblocks compound PR2's native-binding authority work; executor settlement remains its required extension. Co-authored-by: Galin Iliev <[email protected]> Co-authored-by: KirDE <[email protected]>
|
Refreshed, consolidated with #143201, and landed in #164197 (283d5e6). The replacement preserves this PR's original commits and fences native effects to the initiating lineage and physical client through the existing workers. It also preserves released SDK signatures and the reversible native-binding deletion veto. Thank you @galiniliev. Your original author identity and commits are retained in the replacement branch history; the squash credits your verified GitHub identity because the native landing tool could not link the original commit email. The PR body records the superseded portions, additional repairs, and passing Testbox, compatibility, static, review, and final-head CI evidence. Closing this PR as consolidated; its source branch is preserved. |
…penclaw#164197) Fence Codex native effects, binding mutations, and subscription cleanup to the initiating session lineage and exact physical client. A replaced session can no longer borrow a peer's process custody or clear a successor binding, including across worker CAS retries and delayed remote-file responses. Use the existing database workers and authority cohorts, preserve synchronous released SDK contracts and reversible deletion vetoes, and retain main's shared bounded media reader. Regression proof covers physical writes, successor recovery, compaction, cleanup, and API compatibility. Consolidates openclaw#156940 and the independently reimplemented physical-client checks from openclaw#143201. Unblocks compound PR2's native-binding authority work; executor settlement remains its required extension. Co-authored-by: Galin Iliev <[email protected]> Co-authored-by: KirDE <[email protected]>
Related: #156938
What Problem This Solves
Fixes stale native Codex sessions that could write or retain a successor's thread subscription after session authority changed. A peer's live process could incorrectly satisfy the stale initiator's retention check.
User Impact
Current admitted native work can finish, while stale initiating sources cannot retain a reusable thread using another source's process. Peer work keeps its physical listener until its own process settles; exact old cleanup cannot evict a newer claim. Native steering rejected before enqueue remains available after cancellation instead of being reported as delivered.
No new operator configuration, stored binding format, schema version, retention policy, or permission is introduced. The complete merge-base diff against
1b31d2443e51dccc595b3e7208b8b696df26e222has no package, lockfile, plugin manifest or SQL schema delta.session-binding-codec.tspreserves the relocated normalization/encoding bytes after whitespace normalization, the stored version-1 envelope, and legacy schema-1/2 importer;migration/session-binding-sidecars.tsandsession-binding-orphans.tsstill consume that version-1 envelope. These source checks establish compatibility disposition, not full installer/updater or stable-tag upgrade execution; those were not run. Existing binding codec normalization is relocated unchanged; current worker facts add the already-stored predecessor field and compose existing source restrictions.Why This Change Was Made
The native process owner decides initiating-source custody. The existing physical subscription token/protection owner holds only required cleanup while peer work remains, and publishes no warm claim for the rejected initiator. Session row authority reaches the canonical worker transaction/commit grant and physical request writer; lease and mutation constraints both survive when they originate from distinct session rows. Definitive native ingress rejection clears the steering owner's exact dispatch receipt before retry backoff.
Published candidate:
2099e55d534a8ddba3fa58c5f415418388b049f2. The existing published repairs are reconciled on main5fe8304fd622a063c650dde26351af93496547d7, preserving current main's asynchronous plugin-state comparisons, request/catalog waiter contracts, and unrelated owner changes. The Gateway admission branch remains separate.Evidence
runCodexAppServerAttemptthrough the realCodexAppServerClientwire and task-owned sandbox processes: live initiating custody retains; settled initiating custody rejects; peer-only stale custody rejects and has no consumable warm subscription while the peer process and listener remain live. Peer settlement produces one unsubscribe. A protected competing attempt rejects at the canonical active-thread boundary, then a later successor succeeds after exact cleanup without a stale extra unsubscribe. Four cells passed in 20.57 s wrapper wall time (18.90 s Vitest duration).reject();failLocal()still preserves possible writes.2f7d89b1419bf7064346855b0acde23514b1ebc5:thread_processor.rsconfirms unsubscribe removes the connection listener rather than terminating a peer process; terminal inventory identifies concrete work. The app-server fixture is a covering protocol boundary harness, not a claim of an authenticated live Codex session.The follow-up CI repair removes the retired thread-wide inventory predicate, unused startup/error helpers and type exports, and two synthetic tests that injected custody under a different owner and expected the superseded bypass. The independent reader-release/no-replay contract remains and passed (40.56 s wrapper wall); the registered four-cell source/peer/successor effects remain the primary proof. This cleanup delta has its own fresh scoped-clean review through P2. The earlier
7666583561710730e5131268979af86b8899bae2ClawSweeper comment reported 4/6 overall, proof and patch; that rating is historical until the current cleanup head receives its own durable review. Its exact dependency CI failure identified these unused paths; no ignore or baseline was added and no job was rerun merely for green.Exact cleanup-head CI run
36770306683then required removing the obsoletecompact.tsassertion allowance (0 actual assertions versus baseline 1). This exact shrink-only ratchet maintenance adds no allowance or suppression; the owning assertion-safety ratchet passed locally. Cancelled siblings were not passing coverage, and no rerun or empty push was requested.The next exact CI attempt (
36771390993, core lint job110078863059) found a test-fixture unboundstate.withCurrentreference in the async-CAS settlement adaptation. The captured fixture method is now bound to its existing state; all three cleanup/cancellation cells and two sibling settlement cases passed (5 selected, 8 unselected, 12.05 s wrapper, 9.99 s Vitest), exact CI-config typed lint passed, and fresh correction review was scoped-clean through P2. Production behavior and the registered final-effect evidence are unchanged.Architecture CI on
7f55e678d0faf0fdb98249fe8f48d983996a53e5(36772579349, job110082974806) identified the ordered-reader/runtime type import cycle. The unchanged read scope, request and prepared-result types now live with their existing selection/result contracts insession-transcript-worker.types.ts; the ordered/runtime readers and sole Gateway question type consumer all use it directly. No SDK symbol export or runtime authority/FIFO/cleanup algorithm changes. Final production types, scoped typed lint, formatting, type-edge Madge (zero cycles) and all three Knip export scans (zero entries) passed; fresh complete repair-diff review was scoped-clean through P2 (confidence 0.94). Existing registered and ordered-reader behavioral proof remains unchanged; broad suites were not repeated for this type-only cutover.Native plugin CI on
0e260a61212560279414f3b77f644cb622ebd0c3(36774149483, bundle jobs110088213868and110088214248) exposed loss of original authority Error identity at outward auth/bounded/registered-attempt boundaries. The existingcodexPrewriteRejectionCauseowner now restores only definite pre-write causes there; physical typed rejection, possible-write uncertainty and steering ingress receipts remain unchanged. Original auth/bounded assertions failed three cases before the repair, then six selected cases passed (14.96 s wrapper). Physical request/steering 38 and registered generation 7 passed (39.44 s grouped wrapper); original initiating/settled/peer/replacement custody 4 passed (23.29 s wrapper), preserving real peer processes/listener, exact unsubscribe and successor effects.The unchanged auth requirement/handoff types and internal prepared-type exports now live with their existing
auth-types.tsowner. All internal consumers moved; the existing public shared-client export retains its name/shape. Final production types, typed lint, line-cap gate, Madge zero and all three Knip export scans zero passed. Fresh final repair/type-cutover review was scoped-clean through P2 (confidence 0.78). Historical0e260a6durable review was overall4/proof5/patch4 with no actionable findings; its failed/cancelled CI does not qualify the replacement head.Exact
45ce600extension-lint CI (36778354304, job110102357508) identified four remaining mechanical leftovers: unused settlement-test helper import, process-fixture shorthand, duplicate compact helper import and obsolete EOF lint directive. Those exact leftovers were removed/merged; exact CI-config scoped lint and diff/format checks passed. No runtime behavior, assertion, cap or ignore changes; registered proof remains unchanged. Its durable 4/5/4 review is historical after this maintenance head.The actual main conflict was reconciled on that pin, preserving recovery
refs/recovery/task_8307b20bc39b/native-pre-conflict. Main test-audit59b8097d75fretired side-question execution tests and consolidated current owner cases; the deletion/current tests remain authoritative and orphan fixture exports were removed. The removed delta included two timeout diagnostic compositions: generic tool timeout remains covered by the current consolidated case; native diagnostic timeout/finalization remains with current native notification/projector owners. Runtime timeout/finalization algorithms are unchanged; the removed duplicate full composition is not claimed as current proof.The consolidated timeout fixture originally advanced fake Date/timers before real worker admission, causing SessionSuperseded instead of Timeout. It now awaits actual turn start and tool execution and accelerates only setTimeout/clearTimeout with real Date, retaining TimeoutError/timed_out assertions. The reused pending-client fixture moved unchanged to its existing support owner to meet the existing cap. Final generation/lost-ack/stale-binding/timeout run passed four selected cases in47.52s wrapper (44.59s Vitest); production types, exact CI-config lint, line-cap gate and three Knip scans zero passed. Fresh final fixture review was scoped-clean P2 (confidence0.88). Production authority/error repair is patch-identical outside main test retirement; prior exact91d review4/5/4 is historical until this replacement receives durable review/CI.