Skip to content

test(codex-processes): Codex fixtures say READY from the process after its exec - #3900

Merged
devswha merged 1 commit into
mainfrom
test/codex-processes-slow-runner
Nov 15, 2026
Merged

devswha merged 1 commit into
mainfrom
test/codex-processes-slow-runner

Conversation

@devswha

@devswha devswha commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

server/codex-processes.test.ts failed twice in one evening in Fast checks on GitHub-hosted ubuntu-24.04 runners: run 43710397061 (job 132800776012) and run 43714835800 (job 132814318485, PR #3808). Both times the failing test was "shows no conversation of the store an earlier read's Codex keeps once another Codex runs there", at line 186, and nothing else in the file failed. It got no_session_path where it expects { source: "codex-transcript", path }, and the test took about 27 ms. A rerun passed it, and main's own runs never failed it.

Three tests started their Codex stand-in as bash -c "echo READY; exec -a codex sleep 600". That means READY came from bash before the exec. While an exec runs, the kernel has already switched the process to its new memory but has not laid out the environment yet, so /proc/<pid>/environ reads empty. processCodexHome caches that read (no CODEX_HOME) for 30 s. A lookup that read Codex A during A's exec therefore placed A in the default store. The test's second lookup, which expects A's own store, then found nothing there. A runner slow enough that A is still in its exec after Codex B has started (B is started right after A's READY) fails the test.

The three tests now start the stand-in with the file's runningCodex. Its node process prints READY itself, after its exec, the way the file's other process fixtures already signal from the state they promise. What the tests prove is unchanged. The two tests that expect no_session_path now see each stand-in's real store, so they test the earlier-read guard rather than a store read that might have come back empty.

Every other process fixture in the file already signals from its final state: the Bun child after opening its files, cat echoing after Python's execv, the Python lock holders after flock, and runningCodex/codexHolding after node's exec. On this PC, the only other failures of the file are 5 s timeouts in tests that start no process at all. Their cause is CPU time under heavy load, which this change does not address (see Validation).

Validation

Forcing (scratch, not committed): a FUSE mount serves /usr/bin/sleep (and, for the fixed fixture, node) and holds the read of the page the ELF loader faults in after the point of no return (the zeroed tail of the last file-backed segment) for 1-2 s. That stretches each exec of the stand-in the way a slow runner does, with the test file and product code unchanged; PATH puts the mount first.

  • Under the hold, a probe that starts A, then B, read A's /proc/<pid>/environ as empty after B was ready in 5 of 5 rounds.
  • On unmodified main (9782b4a), the test failed in 3 of 6 forced runs, each at codex-processes.test.ts:186 with ConversationUnavailable: no_session_path, the same as the hosted failure.
  • With this change, all three tests passed in 13 of 13 forced runs with both sleep and node held (--timeout 30000, since FUSE also slows node's start), and in 5 of 5 with sleep held.
  • CPU starvation of the stand-ins alone (taskset on one CPU at nice 19 or SCHED_IDLE beside a busy loop) did not reproduce it here: the exec finished within one time slice before B was ready.
  • A real fault still fails: with the earlier-read store guard removed from codexTranscriptPath (scratch, reverted), both "once another Codex runs there" tests fail.

Unforced:

  • bun test --rerun-each 20 ./server/codex-processes.test.ts: the three changed tests passed 20 of 20. On a quiet PC (load average about 40 on 80 cores), the whole file passed all 20 passes: 5520 pass, 0 fail, 720 s. An earlier 20x run, made while bun run check fast and the forced runs ran beside it (load average up to 124), had 5 timeouts in its first three passes. They were in tests that start no process at all ("still takes short answers below the prompts they answered", "takes no answer the screen shows with more at either end", two of "the thread id a Codex pane's terminal title shows", and "claims nothing for a long answer another pane shows under some other prompt"). Those tests are CPU-bound: this PC runs the file in about 58 s, against 11 s on the hosted runner. This change does not touch them.
  • bun run check fast passes.

Skipped: Integration and browser, Native Windows install, macOS (no product code or other test changed). No changelog fragment, because the change is test-only.

…r its exec

Three tests started their Codex stand-in as `echo READY; exec -a codex sleep 600`:
READY came from bash before the exec. While an exec runs, /proc/<pid>/environ
reads empty, and processCodexHome caches that read (no CODEX_HOME) for 30 s, so
a lookup on a slow runner placed Codex A in the default store and the test that
expects A's store to resolve failed with no_session_path (Fast checks on a
GitHub-hosted runner, run 43710397061). They now start it with runningCodex,
whose node process prints READY itself, after its exec.
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated Linux process tests to use a shared Codex fixture and clarified notes about process readiness and environment reads.

Three Linux tests now use the shared runningCodex fixture with CODEX_HOME configured. The fixture comment clarifies when it emits READY and notes that reading /proc/<pid>/environ during exec may return an empty result.

Changes: Codex process test fixtures

Layer / File(s) Summary
Use the shared Codex process fixture
server/codex-processes.test.ts
Three tests replace Bash processes renamed to codex with runningCodex and a configured CODEX_HOME. The fixture comment documents the READY signal timing and a possible empty environment read during exec.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Other

Suggested reviewers: cheol-95, wouldu-pres

Merge Risk: Minimal · up to 8d4f6

This only changes test fixtures to remove an intermittent failure on slow runners. It has no production impact and no remaining merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the test-only change to the Codex fixtures and the READY signal timing after exec, which matches the raw summary and objectives. It is specific, concise, and conveys the primary change…
Description check Passed The description covers the problem (Fast checks failures on ubuntu-24.04 with run and job references), the root cause (READY before exec, empty /proc environ, 30 s cache), the change, and detailed val…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the test-only change to the Codex fixtures and the READY signal timing after exec, which matches the raw summary and objectives. It is specific, concise, and conveys the primary change. The word 'Codex' is used as a fixture name, which is accurate for this file.

Full details: Description check

Explanation

The description covers the problem (Fast checks failures on ubuntu-24.04 with run and job references), the root cause (READY before exec, empty /proc environ, 30 s cache), the change, and detailed validation with forced and unforced runs, plus skipped checks. It follows the template's Change and Validation sections, though it does not reference CONTRIBUTING.md or a changelog decision beyond stating none was added (it does explain why). The template asks for the validation commands run, which are given (bun run check fast, bun test reruns). Mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e2349be and 8d4f683.

Files selected for processing: 1

  • server/codex-processes.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

@devswha
devswha merged commit 65f8d48 into main Nov 15, 2026
24 checks passed
@devswha
devswha deleted the test/codex-processes-slow-runner branch November 15, 2026 14:07
@devswha

devswha commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head 8d4f6834cd94 as 65f8d4895437 on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
codex CLEAR

One reviewer: test-only.

The fixture said READY before its exec, so a lookup could read an empty /proc/<pid>/environ, which processCodexHome caches for 30 s. Shown by its author with the exec held open: main failed 3 of 6 at that line, this change passed 13 of 13.

Not closed here, a product follow-up: processCodexHome should not cache an empty environ read.

Review reports: ~/.cache/ovis-tmp/reports/

devswha added a commit that referenced this pull request Nov 15, 2026
… claims it as it is released never fails the run that let it go (#3905)

## What

Fast checks on a GitHub-hosted runner (run 43717080636, attempt 2, PR
#3738) failed `scripts/install-binary.test.ts` "lets one waiter at a
time break a stale lock, with a mkdir that never refuses" with `rm:
cannot remove '.../.install.lock': Directory not empty`. This is the
race install.sh's `install_lock` comment had left as "a follow-up". The
fault is in the script, not the test.

**Mechanism.** `install_lock` claims the lock by creating
`.install.lock/pid` only where none exists (noclobber), whatever `mkdir`
answered. The lock was already exclusive before this PR.
`install_unlock` released it with `rm -rf "$lock"`, which unlinks the
pid a moment before it removes the folder. A waiter could claim the lock
in that moment, with any `mkdir` (GNU, busybox, macOS, uutils). The
holder's removal then failed with `Directory not empty`, and under `set
-e` the install that had just finished exited 1. The waiter did hold the
lock correctly. The stale-lock breaker's `rm -rf "$lock" || true` had
the same interleaving, but its error was swallowed.

**Fix.**
- `install_unlock` and the breaker both call `install_lock_drop`. It
moves the folder to `.install.lock.gone-<pid>` in one `rename(2)`
(`mv`), while the holder's pid is still inside, and removes it there. A
waiter never finds the folder without its holder's pid. One that
resolved the folder before the rename fails to write its pid and tries
again; one after it makes a fresh lock.
- A run cut off between that rename and the removal (kill -9, or a
signal during the `rm`) leaves its `.install.lock.gone-<pid>`. The
lock's holder now removes every `.install.lock.gone-*` as soon as it
holds the lock, right after the traps in `install_lock`. That cleans the
leftover, and it clears an older leftover with this run's own pid before
its rename needs the name. It sits in `install_lock` rather than beside
the `.stage-*` sweep, because a run that waited and then finds the
version installed releases the lock before reaching that sweep.
- install.sh's comment, INSTALL.md and docs/development.md no longer say
a race remains.

**install.ps1** carries the same lock, but `Exit-InstallLock` and the
breaker remove it with `Remove-Item ... -ErrorAction SilentlyContinue`.
In the same interleaving the folder removal fails quietly, the waiter
keeps a valid lock, and no install fails, so it is left as it is.

**Tests** (scripts/install-binary.test.ts):
- "leaves the lock to a waiter that claims it while the holder removes
it, and both succeed" forces the interleaving with the system's own
`mkdir` (no stand-in: the claim never depended on `mkdir`'s answer).
- An `rm` stand-in makes the first removal of a lock folder pause where
`rm -rf` does, between unlinking the pid and removing the folder, until
another run holds the lock. Like `rm -f`, it takes a folder that is
already gone as removed.
- The second run starts once the first leaves a mark while holding the
lock. The mark stays, so it cannot be missed. The wait is bounded at 30
s and exits 3 with "the first run never held the lock: no
.../first-holds after 30 s", which fails the test instead of hanging it.
- The test asserts the claim happened during the pause, both installs
exit 0, bin holds the second's release, and no `.install.lock*` is left.
- "removes the lock folder a run cut off while it released the lock
left, and fails no run whose pid it names": a leftover
`.install.lock.gone-1` from a dead run, plus `.install.lock.gone-<this
run's pid>/.install.lock/pid`. The install exits 0 and no
`.install.lock*` is left.

## Validation

All on this commit, main (with #3900) merged in.

| Run | Before | After |
|---|---|---|
| Release race, forced: `bun test --rerun-each 5
./scripts/install-binary.test.ts -t 'claims it while the holder removes
it'` | origin/main's install.sh: **5/5 fail**, holder exits 1, `rmdir:
failed to remove '.../.install.lock': Directory not empty` | **5/5
pass** |
| Leftover, `-t 'cut off while it released'` | 79bf6b7's install.sh
(this PR's first head): **5/5 fail**, `mv: cannot overwrite
'.../.install.lock.gone-<pid>/.install.lock': Directory not empty` |
**5/5 pass** |
| `bun test --rerun-each 30 ./scripts/install-binary.test.ts` | | **1020
pass, 0 fail** (34 tests x 30; the two new tests and the stale-lock test
that failed in CI 30/30 each) |
| `bun run check fast` | | **exit 0**: unit 17416 pass, 0 fail, 54 skip;
typecheck, build, generated files, workflow syntax |

- Waiters that must not get the lock still do not; these existing tests
pass in every run: "leaves a fresh holder's lock to it when a slow
breaker judged the lock before it stale", "takes over the lock of an
install that died, and waits out a live one's, then says who holds it",
"lets a second install in only after the first has swapped bin, not into
its window" (both mkdir variants), "lets six waiters take a dead
holder's lock one at a time" (its overlap marker), and "lets one waiter
at a time break a stale lock".
- `scripts/conventions.test.ts` and `scripts/changelog-fold.test.ts`
pass; `sh -n install.sh` passes.
- Skipped: `bun run check full`, the integration and browser suites (no
`server/`/`src/` change), and the Windows install (install.ps1
unchanged).

This PR touches `install.*`, so it waits for GitHub's own checks,
including the real installer runs, not only a local merge gate.
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