Skip to content

fix(ai): build from the committed model catalog instead of refetching it - #2038

Open
snimu wants to merge 2 commits into
mainfrom
fix/deterministic-model-catalog-build
Open

fix(ai): build from the committed model catalog instead of refetching it#2038
snimu wants to merge 2 commits into
mainfrom
fix/deterministic-model-catalog-build

Conversation

@snimu

@snimu snimu commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Problem

packages/ai npm run build was npm run generate-models && tsgo ...: every build (CI Build and check, every Test (*) job, and release build-binaries.yml — all run npm run build) fetched the live model catalog and rewrote src/models.generated.ts in place.

Upstream removed claude-sonnet-4.5 from the catalog sources, but the committed models.generated.ts and 28 in-repo references (including packages/ai tests) still use it. So on every CI run the Build step silently swapped in a catalog without that model, and the subsequent npm run check / Test (ai) failed with e.g.:

packages/ai/test/context-overflow.test.ts(119,46): error TS2345: Argument of type '"claude-sonnet-4.5"' is not assignable to parameter of type '"claude-fable-5" | ...'

Every PR fails Build and check, Test (ai), and build-check-test regardless of content (example: run 33854776241 on #1947).

Fix

Build compiles the committed catalog only:

  • packages/ai build is now just tsgo -p tsconfig.build.json.
  • npm run generate-models stays as the explicit, reviewed refresh step (it is the existing documented command in AGENTS.md, README, and the generated-file header; no new alias added).

src/models.generated.ts is the generator's only output and is committed (not gitignored), so clean checkouts build and test with no network fetch of the catalog. This PR deliberately does NOT regenerate the catalog — removing claude-sonnet-4.5 references is a separate reviewed refresh.

Callers audited

generate-models had exactly one caller: the packages/ai build script. Root build, prepublishOnly (npm publish), ci.yml (Build and check + all test jobs), and build-binaries.yml (release/beta binaries) all funnel through it, so all now build from the committed catalog. No other workflow, script, or hook invokes generate-models.

Verification (clean checkout in a Prime sandbox, source-only sync + npm ci)

  • npm run build: exit 0; models.generated.ts md5 identical before/after; generate-models never invoked.
  • npm run check: exit 0 (biome, root tsgo --noEmit, installer check, browser smoke).
  • packages/ai npm test: 50 files passed / 22 skipped, 341 tests passed / 720 skipped, 0 failures.

Linear: RES-1269


Note

Low Risk
Build-script-only change; generate-models remains available for intentional catalog refreshes with no auth or runtime behavior changes.

Overview
Stops implicit model-catalog refresh on every packages/ai build so CI and local builds use the committed models.generated.ts instead of rewriting it from live upstream data.

The build script no longer runs generate-models before tsgo; catalog updates stay on the explicit npm run generate-models step. A changelog note documents that workflow.

Reviewed by Cursor Bugbot for commit f6b2059. Bugbot is set up for automated code reviews on this repo. Configure here.

LOC

Total src: +0/−0 (net +0); tests: +0/−0 (net +0).

Note

Stop refetching model catalog during npm run build in packages/ai

Removes the generate-models step from the packages/ai build script so builds compile against the committed models.generated.ts. Run npm run generate-models explicitly when the catalog needs refreshing.

Macroscope summarized f6b2059.

`npm run build` in packages/ai ran `generate-models` on every build, fetching
the live model catalog and rewriting `src/models.generated.ts` in place. When
an upstream source drops a model that the repo still references (currently
claude-sonnet-4.5, 28 references), every CI run fails `Build and check` and
`Test (ai)` regardless of the PR's content, and release builds
(build-binaries.yml) ship a catalog nobody reviewed.

Build now compiles the committed catalog only. Refreshing the catalog stays an
explicit, reviewed step: `npm run generate-models`. The generated file is the
script's only output and is committed, so clean checkouts build and test
without network access to the catalog sources.

Linear: RES-1269
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.

1 participant