From 97f97d7a4ee7c4eb76331947b9a9d8ac192779be Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 13 Nov 2026 15:46:31 -0800 Subject: [PATCH 1/2] chore(quest): claim quest/m0/host-independent-tests.md Quest-Claim: 1950d7707f24f52a From e39cbf6d93262d0299a0124987bd4bd553fb438f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 13 Nov 2026 15:47:41 -0800 Subject: [PATCH 2/2] test: isolate the usage and review tests from the host's /work and OPENAI_BASE_URL Co-Authored-By: Claude Opus 5.5 --- quest/m0/host-independent-tests.md | 12 ------------ test/review.test.ts | 9 ++++++++- test/usage.test.ts | 22 +++++++++++++++++----- 3 files changed, 25 insertions(+), 18 deletions(-) delete mode 100644 quest/m0/host-independent-tests.md diff --git a/quest/m0/host-independent-tests.md b/quest/m0/host-independent-tests.md deleted file mode 100644 index 7fe7f72d..00000000 --- a/quest/m0/host-independent-tests.md +++ /dev/null @@ -1,12 +0,0 @@ -# [S] Make the usage and review tests host-independent - -## Goal - -`just test` passes on any host, independent of its filesystem and environment, with each test isolating what it reads rather than skipping it. - -## Plan - -Two tests pass in CI but failed on the land fixer's host, on main alone (2026-11-13): - -- `test/usage.test.ts`, "ties each session to its PR and role": its fixture sessions use `cwd: "/work"` and treat it as a deleted checkout, so a host with a real `/work` attributes sessions differently. [#704](https://github.com/moq-dev/quest/pull/704) rewrites this file but its `exported` fixture still uses `/work`. Root it in a temporary directory the test controls (one created, one removed), whichever PR lands second. -- `test/review.test.ts`, "Codex reaches a gateway at OPENAI_BASE_URL": the direct run expected exit 1 and got 3, which suggests ambient provider variables (`OPENAI_BASE_URL` and the like) from the host reach the fake Codex. Confirm the cause, then have the review test setup clear every variable the gateway detection reads. diff --git a/test/review.test.ts b/test/review.test.ts index 096de062..29f97256 100644 --- a/test/review.test.ts +++ b/test/review.test.ts @@ -257,7 +257,14 @@ function setup(host: "CLAUDECODE" | "CODEX_THREAD_ID" | null = "CLAUDECODE"): Se vi.stubEnv("PATH", `${bin}:${process.env.PATH}`); vi.stubEnv("FAKE_LOG", log); // The session's own profile would change the logged-out errors. - const unset = [...HOST_CREDENTIALS, "CLAUDECODE", "CODEX_THREAD_ID", "CLAUDE_CONFIG_DIR", "CODEX_HOME"]; + const unset = [ + ...HOST_CREDENTIALS, + "CLAUDECODE", + "CODEX_THREAD_ID", + "CLAUDE_CONFIG_DIR", + "CODEX_HOME", + "OPENAI_BASE_URL", + ]; for (const name of [ ...unset, "FAKE_LOGGED_OUT", diff --git a/test/usage.test.ts b/test/usage.test.ts index 0a8ee569..966d9928 100644 --- a/test/usage.test.ts +++ b/test/usage.test.ts @@ -1,5 +1,5 @@ import { execFileSync } from "node:child_process"; -import { mkdirSync, writeFileSync } from "node:fs"; +import { mkdirSync, rmSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { describe, expect, test } from "vitest"; @@ -18,6 +18,15 @@ const OWNED = "f1913a12-44c4-438c-a9d9-06e5b1192c04"; const GONE = "83a08f0e-6ef1-4b41-ad0c-58b37fc993f8"; const BOTH = "5d2c7f3e-8a41-4b6e-9f0d-2c6a1e7b4d93"; +// Checkouts since deleted: directories the test created and removed, so no host path of the same name is read. +const removed = () => { + const path = tempDir(); + rmSync(path, { recursive: true }); + return path; +}; +const WORK = removed(); +const OTHER_WORK = removed(); + const lines = (...records: unknown[]) => `${records.map((r) => JSON.stringify(r)).join("\n")}\n`; /** A Claude Code log line; the message stands in for a prompt the report must never read out. */ @@ -41,7 +50,7 @@ const codexLog = ( payload: { id: THREAD, timestamp, - cwd: extra.cwd ?? "/work", + cwd: extra.cwd ?? WORK, source: extra.source ?? "exec", git: branch ? { branch, repository_url: extra.url ?? "https://github.com/acme/proj.git" } : undefined, }, @@ -415,11 +424,11 @@ describe("usage", () => { // below it, which may be another repository's and so is not charged to this one. writeFileSync( join(claudeHome, "projects", "-work", `${OWNED}.jsonl`), - lines(claude("2026-11-06T14:00:00Z", "quest/m0/a", { cwd: "/work" })), + lines(claude("2026-11-06T14:00:00Z", "quest/m0/a", { cwd: WORK })), ); writeFileSync( join(claudeHome, "projects", "-work", `${GONE}.jsonl`), - lines(claude("2026-11-06T14:00:00Z", "quest/m0/a", { cwd: "/work/nested" })), + lines(claude("2026-11-06T14:00:00Z", "quest/m0/a", { cwd: join(WORK, "nested") })), ); const codexHome = join(dir, "codex"); const day = join(codexHome, "sessions", "2026", "11", "06"); @@ -432,7 +441,10 @@ describe("usage", () => { ); writeFileSync( join(day, "rollout-c-22222222-2222-2222-2222-222222222222.jsonl"), - codexLog("2026-11-06T13:00:00Z", "quest/m0/a", { url: "https://github.com/other/repo.git", cwd: "/other" }), + codexLog("2026-11-06T13:00:00Z", "quest/m0/a", { + url: "https://github.com/other/repo.git", + cwd: OTHER_WORK, + }), ); const body10 = [