Skip to content

Commit 75a1b31

Browse files
committed
fix(test): sanitize both shim recursion-guard variables
The autostart shim test deleted OCX_SHIM_ACTIVE_PID from the child environment but inherited OCX_SHIM_ACTIVE_DEPTH from the parent. A developer running the suite from a shell that was itself launched through an installed Codex shim carries DEPTH=1, so the outer shim started at depth 1 rather than 0, the child re-entry landed on depth 2, and the guard exited 126 with its launcher-loop message. The shim was behaving exactly as designed; the test was starting from a slate it believed was clean. CI never sees this because CI has no shimmed ancestor, which is precisely what made it look like a machine quirk. I had recorded the cause as the sandbox blocking execution from a temp path. That was wrong - a chmod 755 script in mktemp -d runs fine here and /var/folders is not mounted noexec - and a reviewer traced the real mechanism. The devlog now carries the correction, because a plausible-sounding wrong explanation in a durable record is worse than no explanation.
1 parent 4254fce commit 75a1b31

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

‎devlog/_plan/260817_wave5_execution/080_wave5d_antigravity.md‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,23 @@ and pre-existing**, established three ways rather than assumed:
242242
this campaign;
243243
3. all four `test 1/4..4/4` shards passed in the dev CI run for `9eb3a101a`.
244244

245-
The test writes a shim into a temp directory, `chmod 0755`s it, and `spawnSync`s it. 126 is the
246-
shell's "found but not executable" — this sandbox blocks execution from that path. Recording it
247-
rather than skipping it: the right fix is an environment note, not a test change, and it is
248-
outside this campaign's scope.
245+
**Correction — I had the mechanism wrong, and a reviewer traced the real one.** I wrote that 126
246+
was the shell's "found but not executable" and that this sandbox blocks execution from a temp
247+
path. Neither is true: a `chmod 755` script in `mktemp -d` runs fine here, and `/var/folders` is
248+
not mounted `noexec`.
249+
250+
126 is **opencodex's own recursion-guard sentinel**. This shell exports
251+
`OCX_SHIM_ACTIVE_DEPTH=1` and `OCX_SHIM_ACTIVE_PID`, because the session itself was launched
252+
through an installed Codex shim. The test deleted only the pid, so the outer shim started at
253+
depth 1 instead of 0, the child re-entry reached depth 2, and the guard fired with its
254+
launcher-loop message — the shim behaving exactly as designed, on a test that meant to start
255+
from a clean slate. CI is green because CI has no shimmed ancestor, which is what made the
256+
failure look environmental rather than under-sanitized.
257+
258+
So the fix is a one-line test change, not an environment note: `delete env.OCX_SHIM_ACTIVE_DEPTH`
259+
beside the existing pid deletion. Left alone it stays red for every developer running the suite
260+
under an installed shim. Fixed here; the suite is now **12806 pass, 0 fail** locally.
261+
262+
Worth keeping as the lesson: "environmental" was the right disposition and the wrong
263+
explanation, and a plausible-sounding mechanism in a durable devlog is exactly what misleads
264+
whoever hits this next.

‎tests/codex-shim.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,14 @@ printf '%s\\n' child-codex
10431043
chmodSync(realCodexPath, 0o755);
10441044
chmodSync(shimPath, 0o755);
10451045
const env = { ...process.env, OCX_SHIM_BYPASS: "1" };
1046+
// Both recursion-guard variables, not just the pid. A developer running this suite from a
1047+
// shell that was itself launched through an installed shim inherits
1048+
// OCX_SHIM_ACTIVE_DEPTH=1, so the outer shim starts at depth 1, the child re-entry lands on
1049+
// depth 2, and the guard exits 126 with the launcher-loop message — the shim behaving
1050+
// exactly as designed, on a test that meant to start from a clean slate. CI never sees it
1051+
// because CI has no shimmed ancestor, which is what made this look environmental.
10461052
delete env.OCX_SHIM_ACTIVE_PID;
1053+
delete env.OCX_SHIM_ACTIVE_DEPTH;
10471054

10481055
const result = spawnSync(shimPath, ["--help"], {
10491056
encoding: "utf8",

0 commit comments

Comments
 (0)