Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
test: keep the suite off the developer's real contract sentinel
Jack Rudenko61032160f526
diff --git a/packages/cli/src/providers/catalog-client-contract.test.ts b/packages/cli/src/providers/catalog-client-contract.test.tsindex 410a9649..9ea5a613 100644--- a/packages/cli/src/providers/catalog-client-contract.test.ts+++ b/packages/cli/src/providers/catalog-client-contract.test.ts@@ -80,8 +80,10 @@ async function runRefreshChild(urls: {CLAUDISH_PLANS_URL: urls.plansUrl,};// Safe: the loopback CLAUDISH_CATALOG_URL override and temp HOME's isolated- // cachePath keep this hermetic.+ // cachePath keep this hermetic. The child has its own HOME, so remove an+ // inherited shared sentinel path that would leak state between children.delete env.CLAUDISH_DISABLE_CATALOG_WARM;+ delete env.CLAUDISH_CATALOG_INCOMPATIBLE_PATH;const child = Bun.spawn([process.execPath, "-e", source], {cwd: import.meta.dir,env,@@ -119,14 +121,18 @@ async function runWarmCacheChild(urls: {const after = client.getCatalogEntries();console.log(JSON.stringify({ before, after }));`;+ const env: Record<string, string | undefined> = {+ ...process.env,+ HOME: tempHome,+ CLAUDISH_CATALOG_URL: urls.catalogUrl,+ CLAUDISH_PLANS_URL: urls.plansUrl,+ };+ // The child has its own HOME, so remove an inherited shared sentinel path+ // that would leak state between children.+ delete env.CLAUDISH_CATALOG_INCOMPATIBLE_PATH;const child = Bun.spawn([process.execPath, "-e", source], {cwd: import.meta.dir,- env: {- ...process.env,- HOME: tempHome,- CLAUDISH_CATALOG_URL: urls.catalogUrl,- CLAUDISH_PLANS_URL: urls.plansUrl,- },+ env,stdout: "pipe",stderr: "pipe",});diff --git a/packages/cli/src/providers/catalog-compatibility.ts b/packages/cli/src/providers/catalog-compatibility.tsindex 193b78de..7e74b58a 100644--- a/packages/cli/src/providers/catalog-compatibility.ts+++ b/packages/cli/src/providers/catalog-compatibility.ts@@ -99,6 +99,23 @@ export interface CatalogIncompatibility {/** Where the sentinel lives. Sibling of `~/.claudish/all-models.json`. */export const CATALOG_INCOMPATIBLE_PATH = join(homedir(), ".claudish", "catalog-incompatible.json");+/**+ * The sentinel path in effect: `CLAUDISH_CATALOG_INCOMPATIBLE_PATH` when set,+ * otherwise {@link CATALOG_INCOMPATIBLE_PATH}.+ *+ * A TEST seam, set for the whole run by `scripts/guard-real-config.ts`. It is+ * read per call rather than at import, so it takes effect whenever it is set.+ * Without it, every default-path read in a test reaches the developer's real+ * file — and once a machine has run a build against a v3 catalog, that file+ * exists and says "incompatible". Measured 2026-09-18: 25 tests across+ * catalog-warm, model-catalog and the context-window suite failed on exactly+ * that, while CI, whose home directory never holds the file, stayed green.+ */+export function catalogIncompatiblePath(): string {+ const override = process.env.CLAUDISH_CATALOG_INCOMPATIBLE_PATH;+ return override !== undefined && override.length > 0 ? override : CATALOG_INCOMPATIBLE_PATH;+}+/*** The running process's own copy. Set by {@link markCatalogIncompatible} before* the write is attempted, so a failed write still protects this process.@@ -220,7 +237,7 @@ export function isIncompatibleContractVersion(version: number | null): version i*/export function markCatalogIncompatible(info: Omit<CatalogIncompatibility, "detectedAt" | "clientContractVersion">,- path: string = CATALOG_INCOMPATIBLE_PATH+ path: string = catalogIncompatiblePath()): void {const record: CatalogIncompatibility = {detectedAt: new Date().toISOString(),@@ -264,7 +281,7 @@ export function markCatalogIncompatible(* @param path Override the sentinel path. Only tests should pass this.*/export function readCatalogIncompatibility(- path: string = CATALOG_INCOMPATIBLE_PATH+ path: string = catalogIncompatiblePath()): CatalogIncompatibility | null {if (_memFlag) return _memFlag;if (_fileMemo && _fileMemo.path === path) return _fileMemo.value;@@ -391,7 +408,7 @@ function parseSentinelFile(raw: string): CatalogIncompatibility {** @param path Override the sentinel path. Only tests should pass this.*/-export function clearCatalogIncompatibility(path: string = CATALOG_INCOMPATIBLE_PATH): void {+export function clearCatalogIncompatibility(path: string = catalogIncompatiblePath()): void {_memFlag = null;_fileMemo = { path, value: null };diff --git a/scripts/guard-real-config.ts b/scripts/guard-real-config.tsindex e4653fd9..ffeb7110 100644--- a/scripts/guard-real-config.ts+++ b/scripts/guard-real-config.ts@@ -42,8 +42,16 @@* no equivalent. Until it does, this guard is the backstop.*/import { spawn } from "node:child_process";-import { copyFileSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";-import { homedir } from "node:os";+import {+ copyFileSync,+ mkdtempSync,+ readFileSync,+ renameSync,+ rmSync,+ statSync,+ writeFileSync,+} from "node:fs";+import { homedir, tmpdir } from "node:os";import { join } from "node:path";/**@@ -189,6 +197,15 @@ for (const g of GUARDED) {// it cannot put back the hermeticity. A test whose result depends on what the// hosted catalog said this morning is the failure that turned two DeepSeek// tests red mid-release.+//+// `CLAUDISH_CATALOG_INCOMPATIBLE_PATH` is the fourth, and it REDIRECTS rather+// than disables. The contract sentinel is state a real build writes on every+// launch against a newer catalog, so on a developer's machine it usually+// EXISTS — and every default-path read in the suite then sees "this catalog is+// unreadable". Measured 2026-09-18: 25 tests failed on that alone, and CI,+// whose home directory never holds the file, stayed green. A fresh directory+// per run means no run can read a sentinel an earlier run wrote either.+const sentinelDir = mkdtempSync(join(tmpdir(), "claudish-guard-sentinel-"));const child = spawn(cmd[0], cmd.slice(1), {stdio: "inherit",env: {@@ -196,6 +213,7 @@ const child = spawn(cmd[0], cmd.slice(1), {CLAUDISH_DISABLE_KEYCHAIN: "1",CLAUDISH_DISABLE_OP: "1",CLAUDISH_DISABLE_CATALOG_WARM: "1",+ CLAUDISH_CATALOG_INCOMPATIBLE_PATH: join(sentinelDir, "catalog-incompatible.json"),},});@@ -253,6 +271,7 @@ function reportAndRestore(guarded: (typeof GUARDED)[number], after: Snapshot): v}child.on("exit", (code, signal) => {+ rmSync(sentinelDir, { recursive: true, force: true });// Every guarded file is checked and restored before the first exit, so one// clobbered file cannot mask a second. Reporting only the first would send// the author to fix one test while another keeps rewriting the machine.