Repository navigation
fix(codex): preserve native thread across compacted session rotation - #138184
vincentkoc wants to merge 4 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 7:23 AM ET / 11:23 UTC. ClawSweeper reviewWhat this changesThe PR stages Codex native-thread binding transitions alongside OpenClaw session compaction so an interrupted session rotation can reconcile on the next admission. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 7 items remain This PR addresses a real current-main compaction ordering gap and resolves the prior documentation finding, but it adds a documented Agent Harness API whose long-term contract needs maintainer approval before merge. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw owns durable session generations and context-engine compaction, while the Codex plugin owns the native app-server thread. This change bridges those owners so a successor session can retain and reconcile its native thread binding. flowchart LR
A[Codex native thread] --> B[Codex binding state]
C[OpenClaw session] --> D[Context-engine compaction]
D --> E[Harness lifecycle bridge]
B --> E
E --> F[Committed successor session]
F --> G[Next session admission]
G --> A
Decision needed
Why: This is documented SDK surface for plugins, not only a Codex-private repair, so its lifetime and compatibility contract require maintainer intent. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +748, Tests +1734, Docs +38. Total +2520 across 64 files. View PR surface stats
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:
Copy recommended automerge instructionTechnical reviewBest possible solution: Approve the narrow lifecycle seam only if it is the intended long-term plugin contract, then complete focused exact-head transition, restart-admission, ownership, and changed-path validation before merge. Do we have a high-confidence way to reproduce the issue? Yes for the source scenario: current main has the successor-row-before-adoption ordering, and the PR adds focused transition and restart tests. Exact-head execution evidence remains pending in the reviewed PR body. Is this the best way to solve the issue? Unclear pending maintainer direction: staging the transition at the two state owners is sound, but exposing it as a general Agent Harness API is broader than the Codex-specific repair. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c9dc71ec1626. LabelsLabel 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 (2 earlier review cycles)
|
773dcca to
69a59ab
Compare
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The lifecycle shape is defensible: stage predecessor→successor, commit the companion Codex binding in the same host transaction, expose only a read-only lineage projection during the persisted transition, then let the async Codex owner reconcile native state after restart. That is much safer than a post-commit adoption hook. But this is a very large correctness-sensitive change (+681 production lines) and the PR body still has exact-head regression/check/review results marked pending. I would not land it until those exact-head gates are populated and the interruption matrix is green, especially crash points after host commit but before native reconciliation.
|
The draft moves native-thread generation transfer to the host successor transaction and removes the best-effort NEEDS-MAINTAINER-DECISION: durable transition design. At reviewed head The related heartbeat PR #136533 records acceptance of a generic lifecycle hook. I am not treating the API-approval bot finding alone as a blocker. That note does not establish acceptance of this candidate's new durable representation, pending-sync state, older-reader behavior, and recovery protocol. Please link the accepted material-store design, or record that decision before implementation/landing continues. The alternative to evaluate is a transaction-owned transfer using the existing canonical binding representation; a runtime-only mismatch fallback or removal of supervision fences is not an adequate repair. Evidence gathered: on current main I personally inspected upstream Codex Cold loading and dynamic-tool availability are separate evidence lanes: current main supports supervised cold resume ( Fresh No candidate code was changed. No Crabbox lease, live app-server proof, candidate changed checks, autoreview, or native landing run was performed after identifying the material-store gate. The draft and issue remain open; the reviewed head is also preserved on |
…8473) Recover the same Codex native thread when compaction commits a host successor but interruption leaves the binding at its recorded predecessor. The host already persists previousSessionId atomically; synchronous native ownership and asynchronous admission now use that fact and the existing conditional binding update. Forward the admitted store and retain the verified host-generation check through ordinary attempts, lifecycle, side questions, native compaction, and manual-resume queue/lease/RPC waits. Carry the recovered generation assertion in private Codex attempt context while preserving the original host-capability object and its core-owned private registrations. Adoption rewrites only the generation fence. Preserve native ownership, catalog refusal, cancellation/reconnect behavior, and unrelated-generation policy. Use the admitted store for manual-resume auth and preserve displaced native ownership across awaited release. Remove the after-compaction adopter and duplicate recovery. Guard startup binding clears after filesystem waits and settle known compaction rejection before restoration, so revoked authority cannot clear a binding and failed restoration cannot leak its completion watcher. Fence unconfirmed remote retirement and post-agent_end coverage/cleanup against a later host generation. Settle known pre-write rejections without waiting for a nonexistent compaction turn. Inline the single-use coverage wrapper so successor messages stay visible on the next saved-thread resume. Failing-before regressions cover interruption, cold saved-ID resume, other generations/owners, and post-adoption host-only rotation. Fixes #137914. Thanks to @vincentkoc for the report and the draft in #138184. Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
…nclaw#138473) Recover the same Codex native thread when compaction commits a host successor but interruption leaves the binding at its recorded predecessor. The host already persists previousSessionId atomically; synchronous native ownership and asynchronous admission now use that fact and the existing conditional binding update. Forward the admitted store and retain the verified host-generation check through ordinary attempts, lifecycle, side questions, native compaction, and manual-resume queue/lease/RPC waits. Carry the recovered generation assertion in private Codex attempt context while preserving the original host-capability object and its core-owned private registrations. Adoption rewrites only the generation fence. Preserve native ownership, catalog refusal, cancellation/reconnect behavior, and unrelated-generation policy. Use the admitted store for manual-resume auth and preserve displaced native ownership across awaited release. Remove the after-compaction adopter and duplicate recovery. Guard startup binding clears after filesystem waits and settle known compaction rejection before restoration, so revoked authority cannot clear a binding and failed restoration cannot leak its completion watcher. Fence unconfirmed remote retirement and post-agent_end coverage/cleanup against a later host generation. Settle known pre-write rejections without waiting for a nonexistent compaction turn. Inline the single-use coverage wrapper so successor messages stay visible on the next saved-thread resume. Failing-before regressions cover interruption, cold saved-ID resume, other generations/owners, and post-adoption host-only rotation. Fixes openclaw#137914. Thanks to @vincentkoc for the report and the draft in openclaw#138184. Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
Closes #137914
What Problem This Solves
Fixes an issue where Codex users could lose native conversation continuity when host compaction rotated the OpenClaw session generation and execution stopped after the successor host row was committed but before the Codex binding was adopted.
Why This Change Was Made
Compaction now uses one generic Agent Harness lifecycle seam to stage the predecessor-to-successor transition, commit the companion Codex binding inside the same host SQLite transaction, publish the committed host fact, and complete or reconcile the native transition. A synchronous, non-mutating ownership projection preserves native routing across a persisted transition so model setup, session rows, and chat metadata can reach the asynchronous reconciliation owner after restart.
The projection and asynchronous reconciler share one host-lineage classifier. Strict ordinary binding reads still reject unresolved transitions, and state mutation, leases, waiting, and native compaction remain in Codex dispatch. The change removes the obsolete post-compaction adoption hook. It does not add config, protocol, database schema, migration, or runtime fallback surfaces.
User Impact
Codex sessions retain their native thread across host compaction and session-generation rotation. An interrupted compaction is recoverable on the next admission instead of silently clearing continuity or dead-ending the session.
Evidence
69a59abf16aba6e40cf06ad7f55643c52337af78(tree3529802e4c4a5ef429fb73fbaad3beb7f632ed15; parent532a3a3278b493dd04bf4e313213557247394a6c; basee0c97ac015d95c3c660adfaaaa0dd083b317cde4).PENDING_REMOTE_RESULT.node scripts/check-changed.mjs:PENDING_REMOTE_RESULT.PENDING_LOCAL_RESULT.PENDING_LOCAL_RESULT.openai/codex8e6a44b428e31f91b21edc97904fcdf4f0931ade:codex-rs/app-server-protocol/src/protocol/common.rs:667definesthread/compact/start.codex-rs/app-server/src/request_processors/thread_processor.rs:2353loads the thread and submitsOp::Compact.codex-rs/core/src/compact.rs:195runs native compaction with hooks.codex-rs/core/src/hook_runtime.rs:528owns hook execution.