Repository navigation
fix(codex): preserve native assignments across parent rotation - #160952
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: needs real behavior proof before merge. Reviewed September 29, 2026, 10:16 PM ET / September 30, 2026, 02:16 UTC (Revision 24). ClawSweeper reviewWhat this changesThe Codex plugin stages parent-thread replacement to retain native child assignments, and the branch extends lifecycle tests and the published-upgrade fixture to check their recovery. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain Keep open. Current main and v2026.9.6 retain the reported loss path, and this PR has positive recovery evidence. The remaining merge gate is proof that a retained result cannot reach a replaced or revoked requester. Priority: P2 Review scores
Verification
How this fits togetherThe Codex plugin runs OpenClaw agent turns through Codex app-server. It reads a saved parent-thread binding, starts or resumes a Codex thread, and routes recovered child results through OpenClaw's completion delivery path. flowchart LR
A[Session request] --> B[Codex thread lifecycle]
B --> C{Rotate parent?}
C --> D[Binding store replacement]
D --> E[Retained child assignments]
E --> F[Completion authority check]
F --> G[Gateway reply]
Before merge
Findings
Agent review detailsSecurityNeeds attention: No new dependency or secret-handling concern was found; final-effect denial for a retained assignment remains unproven. PR surfaceSource -16, Tests +666, Other +311. Total +961 across 17 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the binding store as the sole owner of same-connection assignment retention, and demonstrate both successful recovery and final-effect denial for a revoked or replaced requester. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source clears the predecessor before replacement, and the PR reports an original-code control failing at the intended assignment-preservation assertion. This read-only review did not execute that control. Is this the best way to solve the issue? Yes, the existing binding-store replacement is the narrowest apparent repair and avoids another persistence owner. The retained-assignment delivery boundary still needs the forbidden-requester proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ec5564bb6857. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
What 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 (23 earlier review cycles; latest 8 shown)
|
454f618 to
20c71a8
Compare
|
Landing conflict-only rebase The previous head's full CI failed only on shared, PR-lane-only test defects (see the earlier comment: Codex fixture worker-teardown guard, CI-planner owner test). After #161425 merged, this PR was rebased with conflicts resolved to keep main's cleanup plus this assignment fix. On the rebased head: both import-cycle checks report 0 and 288 focused tests passed on a Crabbox box. Its hosted CI run 36665380177 failed only at |
…law#160952) * test(upgrade): isolate native assignment fixture lifecycle * test(upgrade): use explicit fixture control flow * test(upgrade): decode native fixture websocket frames * fix(codex): preserve native assignments across parent rotation * test(codex): cancel native rotation at the commit boundary * test(codex): use fresh MCP fixture threads * test(codex): remove redundant attestation call assertion * test(codex): tighten rotation fixture types * test(codex): return a valid workspace resume response * test(codex): isolate schema lifecycle bindings * test(codex): route assignment lifecycle through the database broker * ci: refresh native assignment checks after main repairs * ci: refresh native validation after parent-audit fixture repair * ci: refresh native checks after duplicate route repair
…nt test "settles timeout at final with writer release after cutoff" hung for its full 120 s on main since 5367527 (#160952). That change makes a rotated native thread reject reuse of its persisted predecessor's thread ID, but the successor fixture still answered thread/start with "thread-1", so the product correctly refused the reuse and the test waited forever on turn/start. The fixture now returns a distinct ID for a fresh thread/start, completes the turn on the selected thread, and awaits real turn acceptance. Test-only; all assertions unchanged. The case now runs in ~0.6 s.
…nt test "settles timeout at final with writer release after cutoff" hung for its full 120 s on main since 99db35f (openclaw#160952). That change makes a rotated native thread reject reuse of its persisted predecessor's thread ID, but the successor fixture still answered thread/start with "thread-1", so the product correctly refused the reuse and the test waited forever on turn/start. The fixture now returns a distinct ID for a fresh thread/start, completes the turn on the selected thread, and awaits real turn acceptance. Test-only; all assertions unchanged. The case now runs in ~0.6 s.
Match the app-server identity contract: each thread/start creates a fresh thread, while thread/resume retains the requested identity. The auth fake introduced in #139911 returned one fixed ID, so dynamic tool catalog rotation could hit the replacement fence used by #160952 before the profile-removal proof reached its recovery assertion. Qualify start identity across independent fixture processes and preserve resume identity at the stdio boundary. Keep every existing product-proof assertion and timeout unchanged; production binding guards stay intact.
Match the app-server identity contract: each thread/start creates a fresh thread, while thread/resume retains the requested identity. The auth fake introduced in openclaw#139911 returned one fixed ID, so dynamic tool catalog rotation could hit the replacement fence used by openclaw#160952 before the profile-removal proof reached its recovery assertion. Qualify start identity across independent fixture processes and preserve resume identity at the stdio boundary. Keep every existing product-proof assertion and timeout unchanged; production binding guards stay intact.
What Problem This Solves
An upgrade can import native child assignments successfully, then lose them when the parent thread rotates. Ordinary rotation cleared the predecessor binding before starting its replacement. That clear removed pending assignments and retained completions while preserving the import marker, so recovery could neither deliver the result nor import it again.
User Impact
Pending native work and completed child results remain recoverable through parent rotation within the same session and connection. Failed replacement attempts retain the predecessor's recovery facts. Reset, retirement, connection-change filtering, native ownership and execution-authority checks remain in their existing owners; there is no new configuration or protocol.
Why This Change Was Made
The lifecycle now stages the exact predecessor and uses the existing
replace-threadtransaction. Its store owner decides whether assignments can survive the connection transition. Ordinary rotation still releases its native subscription before starting the successor, preserving the active-work refusal. Configured-MCP rotation retains its existing release after commit. A temporary turn neither replaces the stored binding nor releases the predecessor. The live authority check previously performed by the clearing mutation remains explicit before staging.The regression exercises
startOrResumeThreadwith the real binding mutator. It carries a pending child, a recorded completion and import provenance through replacement, and covers failed starts, cancellation, revoked authority, competing replacements, claimed predecessors, changed connections and temporary turns. The failed-attestation test still requires cleanup of the rejected successor and now requires the predecessor to remain intact.The upgrade fixture also needed independent thread identities and explicit seed/close prompts. Its handoff interrupts only the witnessed seed-parent turn after the published Gateway stops, joins acknowledgment with the terminal notification, and verifies unchanged children and legacy rows. These behaviors follow the inspected Codex 0.155.1 contract. Four read-only inventory captures exposed the product loss; their existing preparation owner clears them between attempts. Retained history, exactly-once completion, child reads, close confirmation, no replay and unchanged legacy rows remain required.
Evidence
The current exact-head CI 36621294557 was cancelled after a suite-teardown assertion in
run-attempt.reasoning-effort.test.ts. All 484 selected cases passed; teardown counted the intentionally process-owned native supervisor as a leaked fixture worker. The suite and worker owner are unchanged from incoming main. The actual merge was56d59e7938ef897896b9068977f83c657a063048into main99a2b25e73cccc85f2284cb697b3f4751a857173. Settled jobs: 101 successful, two cancelled, 23 skipped, and two failed (one root plus aggregate). The existing owner of #159847 is preparing the fixture correction to observe joined logical worker pools; this PR does not duplicate it. Current hosted CI is not green, and no final readiness claim is made.Current head
743fbb3b652ddd363fdbc26bf85e43f8b4324931, tree1e5615cdd5d56796bcd8996f233962153a922120, based on main snapshot59490dc752778ea6281f0b3ebfcf17130d95fecd. The production change and subsequent test corrections passed fresh isolated managed review through P2 without actionable findings. All requested native Testbox proof passed; the current hosted teardown failure is recorded above. The current commit has an empty diff from tested head56edbc3b0d78209c016b0df888db5c7a6b4200bd, preserving the complete source tree. It refreshes the merge inputs after the canonical main repairs. Previous exact-head CI 36612201003, attempt 1, failed in preflight before tests:split timing generation repeats files for core-runtime-infra-storage-state. Its merge was2740f8709b7a032ecdc9f070a09de689fcd7af6dinto maindf97da27f07f6655d5678bdbf1f6f9e460678013. Main commitb4df789c4a95f9b2b8f4290e47d7355efcc71f48removes exactly the second PDF-test registration, preserving the original route and strict duplicate guard. Canonical #161335 was closed as already fixed; this branch contains no duplicate repair. CI 36608379074 failed one incoming-main tooling case: the immutable-parent audit fixture returnedmain-treefor the newly required landed-commit parent lookup. The tested merge was3257d775906320e571a8a5dce2a875eb620b8d29into main74cbf1a117b4e9dead49402f9042f77fab48dd01; 301 sibling cases passed. Canonical main commit7cc7e521137ddfe25b02280b5f7a13fe8262ce35supplies that exact fixture parent without changing the production audit or assertions. No duplicate repair is included. Auto-merge is off. CI 36568340609 failed an existing workspace-reference test whose fake returned an invalid empty resume response, then reused the predecessor ID during fallback. The current test-only repair supplies the intended valid resume reply and reuses the canonical compaction-notification fixture. Its original six-file shard and delta changed-file gate now pass. CI 36571272391 then exposed a separate schema fixture sharing the same singleton binding store across its cases. Per-case store ownership now passes its full three-case file, the original two-group CI selection (718 cases across 46 files), typed lint and the changed-file gate; no production guard or schema assertion was relaxed. CI 36575173119 failed the eight new rotation cases during fixture setup/teardown because their run-attempt hooks require the SQLite host broker, while the new filename was routed to the ordinary Codex shard. The new file is now registered with the existing database-worker routing owner. That one-line correction passed fresh independent review, its default-wrapper test route, planner tests and changed-file gate. Its 22 other files and 469 cases passed; fail-fast cancellations are not passing evidence. The next exact-head CI run 36581058343 failed extension bundle 7 and cancelled the remaining pending jobs. The failed case expects rollback after a binding-commit rejection, but receives the guarded-rollback AggregateError. The test and helper are identical to the incoming main base. A clean-main replay at95d4489f6fb7d34fce5e08f36d04cb09db83a1dcreproduced the same failure and captured the nested host-broker admission error. The isolated one-line registration fix is merged in #161276 (5ce29782b78f80d7fc5ee3fd5a5df9cb17f13fc1), with all 12 recovery cases, 396 remaining shard cases, 160 planner cases and the changed gate passing on Testbox. Source assertions and production behavior are unchanged. The shared lint-fixture repair in #161271 is also merged (9b2da9290be3002f1a2dcae03c0bd139d8a1705a). Its existing owner repaired the related snapshot-test observation as well. This branch includes no duplicate fixture repair or allowlist expansion. The latest run passed preflight after both canonical repairs and reached the fixture-teardown failure recorded above; no successful final-CI result is claimed yet.Completed production proof at
dbd1eb0beb91402a762ef59fdd09451132b99ba7(tree40693ec1fd87aed85e4c83c51b31716a7bb7a205) used blacksmith-testbox, owned leasetbx_01m3pf230rambqz356ysvrhjkk, run 36562499837, with source carrieref3370880781cbdaf9990e0a33abbc11096a5bfcand that exact production-proof tree. Build metadata and the final clean source check match that carrier. The owned lease is stopped. The core package SHA256 iscfeb4c4d6b3bd1718d70ce3435a90a134291f7ed13b34832bf23263264833797; all 43 companion packages exactly match the canonical planner and their recorded archive hashes.pnpm test extensions/codex/src/app-server/thread-lifecycle.assignment-rotation.test.ts --maxWorkers=1node scripts/check-changed.mjs --base 59490dc752778ea6281f0b3ebfcf17130d95fecdpnpm build[email protected]manual upgradeThe manual cell proves first-hop import, retained history, exactly-once retained completion, preservation after unconfirmed closure, settlement after confirmed closure, and no replay. The wire log contains exactly one retained-result request. All four inventory captures were inspected: the pending running child survives on the rotated parent with the original physical session, connection and import marker; it disappears only after confirmed settlement. Legacy Task rows remain unchanged.
The harness exited 0. The outer proof wrapper then exited 1 because our post-verifier incorrectly looked for
sourceShaundernativeAssignments; the canonical producer puts it undernativeAssignmentEligibility. A separate read-only reconciliation checked the actual field, all six native flags, all 62 completed phases, clean source, all four captures and 23 required downloaded artifacts against remote hashes. The wrapper failure remains recorded; the successful cell was not rerun to replace it. A bulk download also reached its five-minute transport cap. One missing planning receipt was fetched separately; all 23 required artifacts hash-match their remote originals.This is Linux package/upgrade proof with a synthetic Codex WebSocket backend, not live provider execution. Rollback passed its published-driver contract. Its summary explicitly reports raw transcript restoration as
unsupported-by-published-backup; no raw-file restoration claim is made for this cell.Focused and sibling coverage
There are 379 distinct owner/sibling cases across 14 files, plus 82 fixture cases across four files. Replayed cases are counted once. Production bytes are unchanged after the owner correction in
1cb335caf5a2f02658ccd4f0d6d1ef5d93f2707d; later commits correct only tests. Reused proof retains its actual source identity:3bc8740e3bc8740eadc99910run-vitest.mjsadc99910861f9ee84cbcc6334cbcc6334cbcc633The eight-case rotation replay above validates the production-proof source; the later default-wrapper replay below also validates its corrected CI route. The three-case attestation replay is part of the 126-case binding coverage. The earlier shared sibling batch failed only in the subsequently repaired MCP file; only its eight fully passing files and 176 cases are reused. The separate 82-case fixture evidence covers unchanged fixture bytes.
Per-file costs include startup. At the production-proof head, the rotation file took 45.22s inside Vitest (83% transform, 10% tests, 6% import); the cold MCP run took 68.15s (88% transform, 4% tests), and binding took 51.85s (55% transform, 40% tests). These cases exercise the real lifecycle and binding mutator; the fixture regression drives its real WebSocket script. There are no added sleeps, retry allowances or enlarged deadlines.
Later fixture corrections
The workspace-reference correction at
4e3797714e192254857a2317440fce0a6936c7a5passed typed lint (161.59s), the original six-file / 182-case CI shard (143.65s), and its explicit changed-file gate (224.45s). An initial gate invocation lacked the raw parent in the synthetic carrier; the supported explicit-file selection used the pinned base, without rerunning the passing tests.The schema-store correction at
a2f98a4e3b9784cf507ca03eb9a3037fe5918b5dpassed on blacksmith-testbox leasetbx_01m3pnknc1pzn9n77npwkvz5db, run 36575297298, carrier57a91960e0c00a452b86573679a1c7384eada05e. Typed lint passed in 154.78s, the whole three-case file in 60.00s, the original two-group selection in 156.78s (371 + 347 cases), and the explicit changed-file gate in 265.59s. The plan retains the original group selections, but hosted CI admitted one plan while this Testbox admitted two concurrently. It is not a serially identical replay. The demonstrated leak was within the schema file, whose complete three-case sequence also passed separately. The complete wrapper exited 0, and the owned lease is stopped. These later replays are separate from the distinct owner-coverage count above.The one-line assignment routing correction at
56edbc3b0d78209c016b0df888db5c7a6b4200bdpassed on blacksmith-testbox leasetbx_01m3pr9srs0ycq81d51rnf68at, run 36581252711, carriereb930bf235cf2d9bba4aab7180cf3de486babf7a, tree1e5615cdd5d56796bcd8996f233962153a922120. The normalpnpm testroute ran all eight rotation cases inextension-database-workers(63.27s wall; 61.11s inside Vitest), all 160 cases in three canonical routing/planner suites passed (48.66s), metadata lint passed (0.57s), and the explicit changed-routing gate passed (164.00s). The wrapper exited 0, and the owned lease is stopped. Its source mirror took 618.852s to prepare one changed file and reuse 50,551 files; the command completed without a restart or lock removal.Regression and failure attribution
The original-code control restored the four production owners from
4cbcc633while running the new regression at1cb335ca. It failed normally with exit 1 at the intended predecessor-equality assertion: both assignments and the active binding were removed while the import marker remained (67.33s wall). The original production control and intended snapshot assertion are unchanged; later test edits tighten types, local naming and synchronous reads. Candidate bytes were restored and verified before positive execution.Before the owner fix, the corrected fixture's full manual cell at
4cbcc633failed with zero retained-completion deliveries despite successful import. Its four captures prove same-session, same-connection inventory loss after parent rotation. The exact initiating guard was not retained because the first-hop log was replaced and the failed container was removed. The new complete cell passes that previously failing recovery boundary.Validation also found test-fixture defects: cancellation was injected before the real client received the successor ID, and three older MCP cases reused an ID for a new thread. Cancellation now enters the actual pre-commit guard, and the MCP fake creates distinct successors and resumes the persisted ID. Cleanup, authority, fingerprint and secrecy assertions remain. The size ratchet was satisfied by removing a logically redundant no-turn assertion already guaranteed by the exact full RPC list. Six new-test lint errors were corrected without production changes, casts, suppressions or limit changes.
The earlier fixture controls also failed normally at the intended original-ID, incidental-close and stale-capture assertions; corrected fixture tests passed. Initial script/test lint errors were fixed before the accepted fixture-only gate. Retained-package transfer attempts were incomplete, so final proof uses a canonical package built directly on this lease. An obsolete three-package check in the proof recipe was replaced with exact equality against the canonical 43-package planner; no partial archive was executed and no upgrade assertion was relaxed.