From e528b52cb4b36f7b498d35eba38763cd67d3afe2 Mon Sep 17 00:00:00 2001 From: KozakLordOfMatrix Date: Thu, 10 Sep 2026 15:56:17 +0300 Subject: [PATCH] fix(build): refuse vendoring @cometix/codex older than 0.142.0 (logs_2.sqlite disk-burn fix) --- scripts/build-from-upstream.js | 20 ++++++++++++++++++++ scripts/prepare-src.js | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/scripts/build-from-upstream.js b/scripts/build-from-upstream.js index 5e8dfa1a..586d8c76 100644 --- a/scripts/build-from-upstream.js +++ b/scripts/build-from-upstream.js @@ -66,6 +66,25 @@ function resolveCodexVendor(platform) { if (fs.existsSync(localPath)) return localPath; // npm pack fallback — fetch platform-specific package + // openai/codex#28224: CLI versions < 0.142.0 let ~/.codex/logs_2.sqlite grow + // unbounded (2 GB+ disk burn). Never vendor an older CLI. + const MIN_CODEX_VERSION = "0.142.0"; + + function compareVersion(a, b) { + const pa = a.split("-")[0].split(".").map(Number); + const pb = b.split("-")[0].split(".").map(Number); + for (let i = 0; i < 3; i++) { + const d = (pa[i] || 0) - (pb[i] || 0); + if (d !== 0) return d; + } + return 0; + } + + function assertMinCodexVersion(ver) { + if (compareVersion(ver, MIN_CODEX_VERSION) < 0) { + throw new Error(`@cometix/codex ${ver} is older than ${MIN_CODEX_VERSION}, which fixed the logs_2.sqlite disk-burn bug (openai/codex#28224). Refusing to vendor a buggy CLI; upgrade @cometix/codex first.`); + } + } // First get latest cometix base version, then append platform suffix const PLAT_SUFFIX = { "mac-arm64": "darwin-arm64", "mac-x64": "darwin-x64", @@ -80,6 +99,7 @@ function resolveCodexVendor(platform) { baseVer = execSync("npm view @cometix/codex version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim(); } catch { return null; } + assertMinCodexVersion(baseVer); // e.g. "0.128.0-cometix" → "@cometix/codex@0.128.0-cometix-darwin-x64" const platPkgSpec = `@cometix/codex@${baseVer}-${suffix}`; console.log(` [codex] fetching ${platPkgSpec} via npm pack...`); diff --git a/scripts/prepare-src.js b/scripts/prepare-src.js index 4bd50cb1..2208f2b9 100644 --- a/scripts/prepare-src.js +++ b/scripts/prepare-src.js @@ -76,6 +76,25 @@ function ensureVendorExtracted(platform) { // 2. Try old-style vendor const oldPath = path.join(PROJECT_ROOT, "node_modules", "@cometix", "codex", "vendor", triple); if (fs.existsSync(oldPath)) { _vendorRootCache = oldPath; return oldPath; } + // openai/codex#28224: CLI versions < 0.142.0 let ~/.codex/logs_2.sqlite grow + // unbounded (2 GB+ disk burn). Never vendor an older CLI. + const MIN_CODEX_VERSION = "0.142.0"; + + function compareVersion(a, b) { + const pa = a.split("-")[0].split(".").map(Number); + const pb = b.split("-")[0].split(".").map(Number); + for (let i = 0; i < 3; i++) { + const d = (pa[i] || 0) - (pb[i] || 0); + if (d !== 0) return d; + } + return 0; + } + + function assertMinCodexVersion(ver) { + if (compareVersion(ver, MIN_CODEX_VERSION) < 0) { + throw new Error(`@cometix/codex ${ver} is older than ${MIN_CODEX_VERSION}, which fixed the logs_2.sqlite disk-burn bug (openai/codex#28224). Refusing to vendor a buggy CLI; upgrade @cometix/codex first.`); + } + } // 3. npm pack platform package const PLAT_SUFFIX = { @@ -90,6 +109,7 @@ function ensureVendorExtracted(platform) { baseVer = execSync("npm view @cometix/codex version", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim(); } catch { return null; } + assertMinCodexVersion(baseVer); const spec = `@cometix/codex@${baseVer}-${suffix}`; console.log(` [vendor] fetching ${spec} via npm pack...`); const tmpDir = path.join(require("os").tmpdir(), "cometix-codex-pack");