Skip to content

improve(tests): make native Codex checks cancellation-safe - #141579

Merged
steipete merged 1 commit into
mainfrom
test/codex-node-fixture-owned-waits
Sep 7, 2026
Merged

steipete merged 1 commit into
mainfrom
test/codex-node-fixture-owned-waits

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

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/exited arrived after process/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.

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.ts
node scripts/check-changed.mjs -- extensions/codex/src/node-exec-server.test.ts

Dependency behavior was personally checked against pinned Codex rust-v0.153.4, commit 3d2ee51ca2d5db578f328aa75e20aa22c0197c9a: 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.

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.
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 5:29 PM ET / 21:29 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 801583eddf6862040f20c79bf48684b783730369

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused fixture repair with preserved assertions, source-matched native validation reporting, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test repair; its matching-tree report nevertheless describes real pinned-binary delay, notification-order, and timeout-cleanup controls through the production node relay.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this maintainer-authored test repair; its matching-tree report nevertheless describes real pinned-binary delay, notification-order, and timeout-cleanup controls through the production node relay.
Evidence reviewed 7 items Introduced scope and current-main necessity: The verified introduced patch changes only the native test fixture. Current main and the pinned merge base both contain blob d48e477c539496d1ebdfe457e36ae63bbf1183d8 for this file, retaining the polling waits and synchronous teardown. The verified test merge also changes only this file. The latest release has a different older blob; its contents were unavailable locally, so no release implementation claim is made.
Cancellation and assertions: Read the complete test file. Frames are recorded before waiters wake; waits observe the combined invocation/test signal; response matching distinguishes replies from reverse requests. Process checks still enforce exact notification counts and sequence order. Teardown joins pendingNodeProof before restoring plugin-root and environment state.
Production cleanup owner: The unchanged production relay observes cancellation, terminates its native transport, waits for output and pending writes, and removes its private temporary home; the command wrapper subsequently releases the managed workspace. No production authority, API, dependency, or configuration change is introduced.
Findings None None.
Security None None.

How this fits together

OpenClaw’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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +27. Total +27 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 66 39 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 66 39 +27

Review metrics

None.

Technical review

Best 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.

Labels

Label changes:

  • add P3: This improves integration-test reliability without changing shipped runtime behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This improves integration-test reliability without changing shipped runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

  • Introduced scope and current-main necessity: The verified introduced patch changes only the native test fixture. Current main and the pinned merge base both contain blob d48e477c539496d1ebdfe457e36ae63bbf1183d8 for this file, retaining the polling waits and synchronous teardown. The verified test merge also changes only this file. The latest release has a different older blob; its contents were unavailable locally, so no release implementation claim is made. (extensions/codex/src/node-exec-server.test.ts:61, fb60915a3f9f)
  • Cancellation and assertions: Read the complete test file. Frames are recorded before waiters wake; waits observe the combined invocation/test signal; response matching distinguishes replies from reverse requests. Process checks still enforce exact notification counts and sequence order. Teardown joins pendingNodeProof before restoring plugin-root and environment state. (extensions/codex/src/node-exec-server.test.ts:96, 801583eddf68)
  • Production cleanup owner: The unchanged production relay observes cancellation, terminates its native transport, waits for output and pending writes, and removes its private temporary home; the command wrapper subsequently releases the managed workspace. No production authority, API, dependency, or configuration change is introduced. (extensions/codex/src/node-exec-server.runtime.ts:337, 801583eddf68)
  • Source-bound native validation report: The captured PR body reports actual Codex 0.153.4 runs on macOS arm64: a 1,500 ms delayed loopback response fails the baseline and passes the candidate; reordered real notifications retain exact assertions; a 120,000 ms timeout control observes cancellation and cleanup before fixture restoration. It also reports 82 focused/sibling cases passing. git rev-parse confirms that HEAD's tree is the reported 8b4929d4d9d22b15ddb5f2ff309cfc8972f787f6. These are contributor-reported observations, not executions performed during this review. (extensions/codex/src/node-exec-server.test.ts:484, 801583eddf68)
  • Pinned dependency contract inspected: The test directly exercises the native Codex protocol and relies on process notification ordering, establishing the dependency gate. Personally inspected the pinned source: watch_exit records exit state before asynchronously enqueueing its notification, while finish_output_stream can independently emit closure. rpc.rs enqueues notifications asynchronously; server/transport.rs shuts down the single stdio connection. Repository ownership was verified through the dependency cache's origin, https://github.com/openai/codex.git. (codex-rs/exec-server/src/local_process.rs:1018, 3d2ee51ca2d5)
  • Related work remains separate: The captured discussion explicitly splits this test-lifetime repair from fix(nodes): reduce completion delays and clarify execution outcomes #132180, which remains open for broader node execution and completion changes. That broader PR is not a merged replacement or a basis for closing this PR.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Lehman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready on 801583eddf6862040f20c79bf48684b783730369, tree 8b4929d4d9d22b15ddb5f2ff309cfc8972f787f6.

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.ts
node scripts/check-changed.mjs -- extensions/codex/src/node-exec-server.test.ts

Fresh 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).

@steipete
steipete merged commit 33918cd into main Sep 7, 2026
167 checks passed
@steipete
steipete deleted the test/codex-node-fixture-owned-waits branch September 7, 2026 22:10
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant