Skip to content

test(engine-spawn-cmd): publish the fake claude's argv dump atomically - #145

Merged
Lexus2016 merged 1 commit into
mainfrom
test/engine-spawn-argv-atomic
Nov 16, 2026
Merged

Lexus2016 merged 1 commit into
mainfrom
test/engine-spawn-argv-atomic

Conversation

@Lexus2016

Copy link
Copy Markdown
Owner

Problem

test/engine-spawn-cmd.test.js was flaky under load (about 1 run in 3 failed with FAIL child received the 40 KB prompt byte-identical).

The fake claude wrote its argv one argument at a time with for a in "$@"; do printf '%s\0' "$a"; done > dump. The shell creates dump when it opens the redirect, before any byte is written, while the test polls only for the file to exist and then reads it immediately. A slow writer therefore hands the test a truncated argv.

Fix (test only)

The fake writes to <dump>.tmp in the same directory and mvs it to <dump> once the loop finishes. A same-directory rename is atomic, so the dump exists only when complete. No assertion changed, and no production file is touched.

Proof

A throwaway local edit (not committed) added sleep 0.2 after each printf plus a log of what was read:

  • old fake: PROOF read 1 args, 12 B of argv at read time, then 4 FAILs including the 40 KB prompt check (17 passed, 4 failed)
  • new tmp+mv fake, same slowness: PROOF read 9 args, 40182 B of argv at read time (21 passed, 0 failed)

Unmodified test with the fix, 5 serial runs on tmux 3.8: 21 passed, 0 failed each time.

The fake claude wrote its argv with `> dump`, which creates the file
before the first byte lands, while the test polled only for the file to
exist and then read it. Under load that read a truncated 40 KB argument
and failed 'child received the 40 KB prompt byte-identical'.

Write to <dump>.tmp in the same directory and mv it into place, so the
dump exists only once it is complete. No assertion changed.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T08:19:51.672192Z eb90b5a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Lexus2016
Lexus2016 merged commit 53e8f22 into main Nov 16, 2026
3 checks passed
@Lexus2016
Lexus2016 deleted the test/engine-spawn-argv-atomic branch November 16, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant