Skip to content

Commit ff072aa

Browse files
axisrowclaude
andcommitted
fix(tests): pin session id in the three session-filtered job-listing tests
`status` and `result` without an explicit job id filter the job list down to the current Claude session (filterJobsForCurrentSession, job-control.mjs:22). That filter is a no-op only when CODEX_COMPANION_SESSION_ID is unset. Three tests wrote fixture jobs with no `sessionId` and invoked run() with no `env`, so the child inherited whatever the host exported. In CI and a bare shell the variable is unset, the filter is a no-op, and they pass. Inside a Claude Code session the host exports a real session id, every fixture job is filtered away, and all three fail: ✖ status shows phases, hints, and the latest finished job ✖ status preserves adversarial review kind labels ✖ result returns the stored output for the latest finished job by default AssertionError: No finished Codex jobs found for this repository yet. These were previously described as pre-existing flakes. They are not flaky — they are deterministic given the ambient environment. Fix follows the pattern already used by "status without a job id only shows jobs from the current Claude session" (runtime.test.mjs:1703): pin sessionId: "sess-current" on the fixture jobs and pass a matching CODEX_COMPANION_SESSION_ID to the child. Production code is untouched. Scrubbing the variable in helpers.mjs run() was tried first and rejected: it makes the filter a no-op, so the listing then includes unrelated jobs and breaks four other tests that rely on the filtering being active (status --wait, both cancel tests, the stop-hook gate test). Full suite is now 95/95 with the variable exported, where it was 92/95 before. Refs #43 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FQBJirbWNKWhnpFUnWogB8
1 parent 3aad7f0 commit ff072aa

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

‎tests/runtime.test.mjs‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,7 @@ test("status shows phases, hints, and the latest finished job", () => {
16511651
title: "Codex Review",
16521652
jobClass: "review",
16531653
phase: "reviewing",
1654+
sessionId: "sess-current",
16541655
threadId: "thr_1",
16551656
summary: "Review working tree diff",
16561657
logFile,
@@ -1662,6 +1663,7 @@ test("status shows phases, hints, and the latest finished job", () => {
16621663
status: "completed",
16631664
title: "Codex Review",
16641665
jobClass: "review",
1666+
sessionId: "sess-current",
16651667
threadId: "thr_done",
16661668
summary: "Review main...HEAD",
16671669
createdAt: "2026-03-18T15:10:00.000Z",
@@ -1677,8 +1679,15 @@ test("status shows phases, hints, and the latest finished job", () => {
16771679
"utf8"
16781680
);
16791681

1682+
// Bare `status` filters to the current Claude session, so pin the session id on
1683+
// both the fixture jobs and the child env — otherwise the host's exported
1684+
// CODEX_COMPANION_SESSION_ID leaks in and filters these jobs away.
16801685
const result = run("node", [SCRIPT, "status"], {
1681-
cwd: workspace
1686+
cwd: workspace,
1687+
env: {
1688+
...process.env,
1689+
CODEX_COMPANION_SESSION_ID: "sess-current"
1690+
}
16821691
});
16831692

16841693
assert.equal(result.status, 0, result.stderr);
@@ -1794,6 +1803,7 @@ test("status preserves adversarial review kind labels", () => {
17941803
title: "Codex Adversarial Review",
17951804
jobClass: "review",
17961805
phase: "reviewing",
1806+
sessionId: "sess-current",
17971807
threadId: "thr_adv_live",
17981808
summary: "Adversarial review current changes",
17991809
logFile,
@@ -1806,6 +1816,7 @@ test("status preserves adversarial review kind labels", () => {
18061816
status: "completed",
18071817
title: "Codex Adversarial Review",
18081818
jobClass: "review",
1819+
sessionId: "sess-current",
18091820
threadId: "thr_adv_done",
18101821
summary: "Adversarial review working tree diff",
18111822
createdAt: "2026-03-18T15:10:00.000Z",
@@ -1821,8 +1832,14 @@ test("status preserves adversarial review kind labels", () => {
18211832
"utf8"
18221833
);
18231834

1835+
// See the note on the `status shows phases` test: bare `status` is
1836+
// session-filtered, so the session id is pinned on both sides.
18241837
const result = run("node", [SCRIPT, "status"], {
1825-
cwd: workspace
1838+
cwd: workspace,
1839+
env: {
1840+
...process.env,
1841+
CODEX_COMPANION_SESSION_ID: "sess-current"
1842+
}
18261843
});
18271844

18281845
assert.equal(result.status, 0, result.stderr);
@@ -1992,6 +2009,7 @@ test("result returns the stored output for the latest finished job by default",
19922009
status: "completed",
19932010
title: "Codex Review",
19942011
jobClass: "review",
2012+
sessionId: "sess-current",
19952013
threadId: "thr_review_finished",
19962014
summary: "Review working tree diff",
19972015
createdAt: "2026-03-18T15:00:00.000Z",
@@ -2005,8 +2023,17 @@ test("result returns the stored output for the latest finished job by default",
20052023
"utf8"
20062024
);
20072025

2026+
// `result` with no job id filters to the current Claude session
2027+
// (filterJobsForCurrentSession in job-control.mjs). That filter is a no-op only
2028+
// when CODEX_COMPANION_SESSION_ID is unset, so a bare run() inherits whatever
2029+
// the host session exports and drops this fixture job — green in CI, red inside
2030+
// a Claude Code session. Pin both sides instead of relying on the ambient value.
20082031
const result = run("node", [SCRIPT, "result"], {
2009-
cwd: workspace
2032+
cwd: workspace,
2033+
env: {
2034+
...process.env,
2035+
CODEX_COMPANION_SESSION_ID: "sess-current"
2036+
}
20102037
});
20112038

20122039
assert.equal(result.status, 0, result.stderr);

0 commit comments

Comments
 (0)