Repository navigation
improve(tests): make native Codex checks cancellation-safe - #141579
Conversation
Bind frame waits to invocation/test cancellation and join the pending native proof before restoring shared environment and plugin-root state. Wait for process closure and the expected notifications before retaining exact count and sequence assertions. A real delayed HTTP body within the existing request deadline fails the old poll and passes the candidate. Reordered real-frame and native-timeout controls verify notification ordering and cleanup ownership. All 82 focused and sibling cases, changed checks, and isolated P0 review pass. Related: #132180 (split node-session completion and execution follow-ups). No production behavior, permission, deadline, or dependency changes.
|
🦞👀 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 maintainer review before merge. Reviewed September 7, 2026, 5:29 PM ET / 21:29 UTC. ClawSweeper reviewWhat this changesThe PR makes native Codex test waits respond to cancellation and finishes native cleanup before restoring shared test state. Merge readiness✅ Ready for maintainer review This remains a useful, focused test-reliability repair that current main does not contain. No introduced correctness or security defect was found, and the protected maintainer-authored PR should remain open. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s Codex plugin relays execution requests to a pinned native Codex process. These integration tests exercise that relay and verify responses, process notifications, credential isolation, and cleanup. flowchart TD
A[Test requests] --> B[OpenClaw node relay]
B --> C[Pinned Codex process]
C --> D[Recorded response frames]
D --> E[Response and notification assertions]
F[Test cancellation] --> D
F --> B
B --> G[Native cleanup completes]
G --> H[Shared fixture state restored]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +27. Total +27 across 1 file. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep native test waits owned by cancellation and retain exact protocol assertions plus cleanup completion before shared fixture restoration. Do we have a high-confidence way to reproduce the issue? Yes: the reported 1,500 ms loopback-response delay exposes the baseline polling deadline while remaining inside the request’s 3,000 ms timeout. Source inspection supports that mechanism; this read-only review did not rerun it. Is this the best way to solve the issue? Yes: cancellation-owned frame waits repair the fixture boundary without increasing deadlines, weakening assertions, or changing production behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fb60915a3f9f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready on The native proof now owns frame waits through invocation/test cancellation and joins cleanup before restoring shared environment/plugin-root state. Exact notification assertions are retained after both terminal state and the expected received frames. Production behavior and all deadlines are unchanged. The real delayed-HTTP control failed the original one-second poll and passed the candidate within the existing three-second request deadline. Reordering real received notifications exposed the closed-only proposal's count race; the combined wait passed. The native 120-second timeout control failed as expected while confirming cancellation, joined cleanup, workspace release and private-home removal before shared state restoration. All temporary controls are removed. The restored candidate and siblings passed 82 tests in 24.031 seconds; required changed checks passed in 180.824 seconds: node scripts/run-vitest.mjs extensions/codex/src/node-exec-server.test.ts extensions/codex/src/node-exec-server.readiness.test.ts extensions/codex/src/app-server/sandbox-exec-server-node-relay.test.tsnode scripts/check-changed.mjs -- extensions/codex/src/node-exec-server.test.tsFresh isolated Codex autoreview returned scoped-clean at P0 across two partitions in 34.047 seconds. Exact-head CI 34162919336 passed. The pinned upstream contracts were personally inspected: stdio shutdown, notification lifecycle, and enqueueing. Production delta: 0. Tests: +66/-39, net +27. This is package-pinned native-binary proof with synthetic canaries and loopback fixtures, not operator authentication, a live-provider turn, native-app acceptance, or rollout. The remaining work stays tracked in #132180 (split node-session landing series). |
|
Merged via squash.
|
Bind frame waits to invocation/test cancellation and join the pending native proof before restoring shared environment and plugin-root state. Wait for process closure and the expected notifications before retaining exact count and sequence assertions. A real delayed HTTP body within the existing request deadline fails the old poll and passes the candidate. Reordered real-frame and native-timeout controls verify notification ordering and cleanup ownership. All 82 focused and sibling cases, changed checks, and isolated P0 review pass. Related: openclaw#132180 (split node-session completion and execution follow-ups). No production behavior, permission, deadline, or dependency changes.
Related: #132180 (split node-session completion and execution follow-ups). This is the pinned Codex test-lifetime slice only; the original remains open for other changes.
What Problem This Solves
Resolves a problem where the native Codex integration test rejects valid delayed responses using a shorter polling deadline than the operation it is testing. A timed-out test can also leave its asynchronous proof running while shared environment and plugin-root state are restored.
Why This Change Was Made
Use frame notifications and the existing test cancellation signal to own response waits, then join the native proof before restoring shared fixture state. Process notification checks require both the terminal frame and the expected received notifications before retaining the exact count and sequence assertions.
User Impact
No product runtime or permission behavior changes. The real pinned-binary test now handles valid delayed responses, cancellation, and asynchronous notification delivery without increasing a timeout or weakening assertions. Production delta: 0. One test file: +66/-39, net +27. Existing cases and all deadlines remain unchanged.
Evidence
The unchanged baseline passed all nine cases. Delaying only the loopback HTTP fixture's final response chunk by 1500 ms, within its unchanged 3000 ms request timeout, made the baseline fail at its one-second completion poll. The same actual pinned binary and delayed fixture passed with the candidate. The delay was removed.
A separate counterfactual reordered real received native frames so
process/exitedarrived afterprocess/closed. The original proposal's closed-only wait failed the exact count assertion (two instead of three); the candidate's combined wait passed with exact count/order assertions preserved. No SDK outcome or native frame was fabricated, and the reordering control was removed. This does not claim a naturally reproduced production protocol defect.A timeout control reached the existing 120000 ms test deadline and produced the expected timeout failure. Its observations confirmed that the pending response was aborted through
TestContext.signal, teardown waited while native cleanup was pending, and invocation/disconnect completion, workspace release, and private-home removal occurred before environment/plugin-root restoration. The control was removed.On final candidate tree
8b4929d4d9d22b15ddb5f2ff309cfc8972f787f6, the restored test and readiness/paired-device relay siblings passed 82 cases across three files in 24.031 seconds. Required changed checks passed in 180.824 seconds.Dependency behavior was personally checked against pinned Codex
rust-v0.153.4, commit3d2ee51ca2d5db578f328aa75e20aa22c0197c9a: stdio shutdown, process notification lifecycle, and notification enqueueing. Exit state precedes asynchronous notification, and closed process records remain retained temporarily; the tests do not infer immediate handle removal from the README wording.Proof used package-pinned Codex 0.153.4 on macOS arm64, isolated homes, synthetic credential canaries, and loopback fixtures. No operator authentication, live-provider turn, desktop binary, native-app rollout, or cross-platform proof is claimed. Fresh isolated Codex review returned scoped-clean at P0 across both partitions in 34.047 seconds, with no findings; this is not an all-severity clean verdict. Exact-head CI 34162919336 passed on
801583eddf6862040f20c79bf48684b783730369.