test(cli): the codex temp-dir cleanup test watches the dir the adapter built, not the whole of $TMPDIR (TASK-073) - #1769
Merged
Conversation
…r made (TASK-073)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One test in the cli suite is red on roughly one full-suite run in five — inside the only
required check on
main. It is not a bug in the adapter. It is an assertion that measuresthe whole machine.
cli/__tests__/adapters.codex.test.mjs›cleans up the per-spawn temp dir even when spawn rejectscountedcommonly-codex-*entries inos.tmpdir()before and after one failingspawn, and required the two counts to be equal. That number is process-global:
cli/src/lib/adapters/codex.js:442ismkdtemp(join(tmpdir(), 'commonly-codex-'))— aspawn in any parallel jest worker adds one between the two reads;
commonly-codex-operator-home-*/-public-home-*dirs match the sameprefix;
rminfinally.Measured
main@e77b1b47The rate is the same on
mainand on a branch that touches neither this test nor thespawn path, so it is pre-existing. Alone, the file never flakes — the trigger is another
suite's spawn, not this test's own logic. I never captured which direction the count moved
(one extra dir vs one fewer), because the fix does not need to know.
This is a required-check defect, not local noise.
Run CLI testsis a step inside thetestjob of.github/workflows/tests.yml(step at:147, job declared at:41, job bodyends
:165) whose display name isTest & Coverage— the single required check onmain,with
strict: true. A 1-in-5 flake there is a 1-in-5 spurious red on the merge gate.The change
The test now asserts on the path the adapter itself built, taken from the argv it handed
the
_spawnImplseam (-o <dir>/last-message.txt), instead of counting names in$TMPDIR:path parsed out of the adapter's own argv — so the test cannot pass by watching a path it
invented, and cannot pass on an adapter that creates nothing;
lstat(...)→null), which is thefinallythe test exists to guard.No polling, no retry, no
--runInBand, no env mutation: the dir is private to the spawn, sonothing concurrent can move the answer. Test file only — no
cli/srcchange, so no versionbump is required and this takes no slot on the release ladder.
Both assertions are load-bearing — mutations, not reruns
A fix for a flake has to be proven by making the defect it guards reproducible, so each
mutation was run and the result asserted, twice:
cli/src/lib/adapters/codex.jsfinallyrmremoved (the defect this test guards)mkdtempprefix changed to something elseThe first row is the point: before this change, dropping the adapter's cleanup was caught
only when the global count happened to be stable. Now it is caught every time.
Limits
~20% pre-fix rate but is not proof of absence — the proof is the second mutation row:
the assertion is now a private fact, so concurrency cannot move it.
commonly-codex-prefix match is deliberately retained (expect(spawnDir).toMatch(...))so a future rename of the adapter's temp root is a visible test failure rather than a
silent one.
TASK-073. Filed from Vera's carry note on #1764 (69971), which recorded the unexplained red
without holding on it.