Skip to content

fix(build): refuse vendoring @cometix/codex older than 0.142.0 (logs_2.sqlite disk-burn fix) - #97

Open
MatrixNeoKozak wants to merge 1 commit into
Haleclipse:masterfrom
MatrixNeoKozak:fix/fix-build-refuse-vendoring-cometix-codex-older-than-0-142-0-logs-2-sqlite-disk-burn-fix-1789044977245
Open

MatrixNeoKozak wants to merge 1 commit into
Haleclipse:masterfrom
MatrixNeoKozak:fix/fix-build-refuse-vendoring-cometix-codex-older-than-0-142-0-logs-2-sqlite-disk-burn-fix-1789044977245

Conversation

@MatrixNeoKozak

@MatrixNeoKozak MatrixNeoKozak commented Sep 10, 2026

Copy link
Copy Markdown

What

Issue #89 tracks openai/codex#28224: the codex CLI wrote an unbounded logs_2.sqlite (~/.codex/logs_2.sqlite growing past 2 GB), fixed in CLI 0.142.0. This repo vendors the CLI binary at build time via npm view @cometix/codex version + npm pack in both scripts/build-from-upstream.js (mac/win) and scripts/prepare-src.js (linux). Previously nothing validated the resolved version, so a stale registry/cache response would silently ship a CLI that still has the disk-burn bug. Both vendor resolvers now enforce a MIN_CODEX_VERSION of 0.142.0 with a numeric (prerelease-aware) semver comparison and abort the build with a clear message if the resolved base version is older, so releases fail fast instead of burning users' disks. Affected users can self-check with ls -alh ~/.codex/logs_2.sqlite.

Why

This change resolves the target issue or improvement.

How to test

Verify that the project builds/runs correctly and the specific bug/improvement is addressed.

Fixes #89

Summary by Sourcery

Refuse to vendor vulnerable Codex CLI releases by enforcing version 0.142.0 or newer during builds.

Bug Fixes:

  • Prevent builds from vendoring Codex CLI versions older than 0.142.0, avoiding the unbounded logs_2.sqlite disk-growth bug.

Enhancements:

  • Add consistent minimum-version validation to platform-specific Codex vendor resolution paths with clear failure messages for unsupported versions.

@sourcery-ai

sourcery-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Both macOS/Windows and Linux vendor-resolution paths now fail fast when npm resolves @cometix/codex below 0.142.0, preventing builds from silently packaging a CLI affected by unbounded ~/.codex/logs_2.sqlite growth.

Sequence diagram for minimum Codex version validation during vendoring

sequenceDiagram
    participant Build as Build process
    participant Resolver as Vendor resolver
    participant NPM as npm registry
    participant Pack as npm pack

    Build->>Resolver: resolveCodexVendor(platform) / ensureVendorExtracted(platform)
    Resolver->>NPM: npm view @cometix/codex version
    NPM-->>Resolver: baseVer
    Resolver->>Resolver: compareVersion(baseVer, MIN_CODEX_VERSION)
    alt baseVer older than 0.142.0
        Resolver-->>Build: assertMinCodexVersion(baseVer) throws
    else baseVer is supported
        Resolver->>Pack: npm pack @cometix/codex@baseVer-platform
        Pack-->>Resolver: packaged CLI
        Resolver-->>Build: vendor CLI
    end
Loading

File-Level Changes

Change Details Files
Reject vendoring Codex CLI versions below 0.142.0 to prevent the logs_2.sqlite disk-growth bug from reaching users.
  • Define a minimum supported Codex version and compare numeric major/minor/patch components while ignoring prerelease suffixes.
  • Validate the version returned by npm before constructing the platform-specific package spec.
  • Abort with an actionable error identifying the minimum version and upstream fix.
scripts/build-from-upstream.js
scripts/prepare-src.js

Assessment against linked issues

Issue Objective Addressed Explanation
#89 Ensure the bundled @cometix/codex CLI is upgraded to version 0.142.0 or newer, which contains the fix for unbounded growth of ~/.codex/logs_2.sqlite. The PR enforces the minimum version only when resolving the CLI through npm. Both scripts return an existing local/vendor path before checking its version, so an older already-present binary could still be shipped.
#89 Prevent builds from silently vendoring a CLI version affected by the logs_2.sqlite disk-burn bug, and fail with a clear error when an old version is resolved.

Possibly linked issues

  • #28224: The PR prevents releases from bundling Codex versions below 0.142.0, which fixes logs_2.sqlite unbounded growth.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="scripts/build-from-upstream.js" line_range="71" />
<code_context>
   // 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) {
</code_context>
<issue_to_address>
**issue (broader_impact):** The minimum-version check is bypassed whenever an existing platform-specific or old-style vendor binary is found in `node_modules`, because both functions return before reaching `assertMinCodexVersion`. A stale installed package below 0.142.0 can therefore still be copied into a release.

**Triggers:** When `node_modules` contains an older @cometix/codex vendor package.

**Suggested fix:** Read and validate the installed package version before returning a local vendor path, or apply the version check to every resolved vendor source.
</issue_to_address>

### Comment 2
<location path="scripts/build-from-upstream.js" line_range="73-80" />
<code_context>
+  // 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;
+  }
+
</code_context>
<issue_to_address>
**issue (bug_risk):** `compareVersion` removes everything after the first hyphen, so prereleases such as `0.142.0-alpha` compare equal to stable `0.142.0` and pass the minimum check even though semver orders them below the stable release.

**Triggers:** When npm resolves a prerelease version at the minimum numeric version.

**Suggested fix:** Parse and compare prerelease identifiers according to semver, while treating the package-specific `-cometix` suffix according to the intended versioning contract.
</issue_to_address>

### Comment 3
<location path="scripts/build-from-upstream.js" line_range="71" />
<code_context>
   // 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) {
</code_context>
<issue_to_address>
**nitpick:** The minimum version and comparison logic are duplicated in two standalone scripts, so updating the vulnerability threshold in one resolver leaves the other resolver enforcing a different policy.

**Triggers:** When the required minimum Codex version changes in a later fix.

**Suggested fix:** Move the shared minimum version and comparison/assertion helper into a common module imported by both build scripts.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: scripts/build-from-upstream.js:71, scripts/build-from-upstream.js:80


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

// 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";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (broader_impact): The minimum-version check is bypassed whenever an existing platform-specific or old-style vendor binary is found in node_modules, because both functions return before reaching assertMinCodexVersion. A stale installed package below 0.142.0 can therefore still be copied into a release.

Triggers: When node_modules contains an older @cometix/codex vendor package.

Suggested fix: Read and validate the installed package version before returning a local vendor path, or apply the version check to every resolved vendor source.

Comment on lines +73 to +80
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): compareVersion removes everything after the first hyphen, so prereleases such as 0.142.0-alpha compare equal to stable 0.142.0 and pass the minimum check even though semver orders them below the stable release.

Triggers: When npm resolves a prerelease version at the minimum numeric version.

Suggested fix: Parse and compare prerelease identifiers according to semver, while treating the package-specific -cometix suffix according to the intended versioning contract.

// 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";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: The minimum version and comparison logic are duplicated in two standalone scripts, so updating the vulnerability threshold in one resolver leaves the other resolver enforcing a different policy.

Triggers: When the required minimum Codex version changes in a later fix.

Suggested fix: Move the shared minimum version and comparison/assertion helper into a common module imported by both build scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

有个烧盘 bug, cli 142 版本刚修复,佬儿看看什么时候升级一下

1 participant