| 1 | # Catalog refresh |
| 2 | |
| 3 | > 阅读简体中文版:[zh_hans/CATALOG_REFRESH.md](zh_hans/CATALOG_REFRESH.md)。 |
| 4 | |
| 5 | How Codewhale keeps model metadata current — what already auto-updates, what |
| 6 | is hand-maintained, and what a scheduled catalog job should (and should not) do. |
| 7 | |
| 8 | Related docs: [`MODELS_AND_PROVIDERS.md`](./MODELS_AND_PROVIDERS.md) (single |
| 9 | owner for model-ID resolution, per-provider `models` naming rules, signed |
| 10 | `registry.json` updates, and the planned Platform registry cutover), |
| 11 | [`PROVIDERS.md`](./PROVIDERS.md), RFC |
| 12 | [`rfcs/UNIFIED_PROVIDER_LOGIN.md`](./rfcs/UNIFIED_PROVIDER_LOGIN.md). |
| 13 | |
| 14 | --- |
| 15 | |
| 16 | ## Short answer |
| 17 | |
| 18 | | Question | Answer | |
| 19 | |---|---| |
| 20 | | Do users need a special model just to refresh models? | **No.** | |
| 21 | | Does Codewhale auto-update the public model catalog? | **Yes, at runtime**, from [Models.dev](https://models.dev/catalog.json), ~24 h TTL. | |
| 22 | | Is the offline bundled seed refreshed automatically? | **Yes, by pull request.** `.github/workflows/catalog-refresh.yml` runs daily, regenerates the seed and opens one PR; a maintainer reviews and merges it. Nothing is pushed to `main`. CI still fails a hand edit (`seed render --check`) and a pin nobody re-locked (`seed age --max-days 30`). | |
| 23 | | Should an LLM rewrite catalog JSON? | **No.** Ingest is deterministic public JSON. An LLM can *review* a PR, not own the source of truth. | |
| 24 | |
| 25 | --- |
| 26 | |
| 27 | ## Layers (lowest → highest priority) |
| 28 | |
| 29 | The shared catalog compiler applies these layers from lowest to highest: |
| 30 | |
| 31 | ``` |
| 32 | 0 bundled Models.dev |
| 33 | 10 live Models.dev |
| 34 | 12 Codewhale corrections (applied to layers 0 and 10 as they load) |
| 35 | 15 verified cloud facts (optional, off by default) |
| 36 | 20 exact provider-owned live roster |
| 37 | 25 Codewhale account roster |
| 38 | 30 config.toml |
| 39 | 40 user overrides |
| 40 | policy DENY (final) |
| 41 | ``` |
| 42 | |
| 43 | Codewhale corrections live in `crates/config/assets/catalog_corrections.json`. |
| 44 | They are field patches in the cloud-facts `ModelFact` shape, applied by the same |
| 45 | patch code to every Models.dev row, offline seed and live refresh alike, so a |
| 46 | correction holds on every install. Use one when an upstream fact is true but |
| 47 | misleading for a Codewhale route: `pricing_withheld` (a reason) clears the price |
| 48 | so the route reports it as unknown, for tiered rates, plan quota and billing |
| 49 | surfaces the catalog cannot tell apart; `max_output` and the other fields patch |
| 50 | limits. Every entry carries its reason. Corrections only fix rows that exist, |
| 51 | never add or hide one, and signed cloud facts can still override them. A |
| 52 | corrected row keeps its own source; a price a correction owns reports |
| 53 | `CatalogSource::CodewhaleBundled` as its price source. Do not hand-edit the offline seed |
| 54 | to hold a value back: a live refresh replaces the seed row, so the hold would |
| 55 | work only offline. |
| 56 | |
| 57 | Cloud facts use the existing compiler and provider lake, as described in |
| 58 | [`CLOUD_FACTS.md`](./CLOUD_FACTS.md). Capability provenance and price provenance |
| 59 | are separate: a capability patch cannot relabel inherited prices. Cloud price |
| 60 | patches replace the entire price block; unspecified token classes stay unknown. |
| 61 | |
| 62 | Route resolution also binds provider kind, configured identity and endpoint. |
| 63 | A fresh provider-owned roster is authoritative for its exact scope. Explicit |
| 64 | model selections remain explicit. Codex account observations/native cache and |
| 65 | Ollama endpoint tags keep their dedicated availability rules; a public catalog |
| 66 | row does not prove that an account can call that model. The installed Codex |
| 67 | `account/read` and `model/list` path is documented in |
| 68 | [`PROVIDERS.md`](./PROVIDERS.md). |
| 69 | |
| 70 | Legacy completion lists remain a last fallback where no applicable catalog |
| 71 | exists. Bundled seeds and static transport/billing rules remain release-owned; |
| 72 | refreshing catalog metadata does not introduce a new wire dialect or change |
| 73 | credential/billing ownership. |
| 74 | |
| 75 | Key code: |
| 76 | |
| 77 | | Piece | Path | Role | |
| 78 | |---|---|---| |
| 79 | | Live fetch + cache | `crates/engine/src/models_dev_live.rs` | Background refresh, TTL, atomic write, freshness status | |
| 80 | | Schema / parse | `crates/config/src/models_dev.rs` | Network-free Models.dev JSON shape | |
| 81 | | Compile + provenance | `crates/config/src/catalog.rs` | Ordered sources, independent price provenance, policy deny, id normalization | |
| 82 | | Provider lake merge | `crates/engine/src/provider_lake.rs` | Shared catalog projection with exact route-scoped provider authority | |
| 83 | | Offline seed asset | `crates/config/assets/models_dev.bundled.json` | Compact offline fallback only (`_meta.role` says so) | |
| 84 | | Codewhale corrections | `crates/config/assets/catalog_corrections.json` | Field patches applied to every Models.dev row (`crates/config/src/catalog/corrections.rs`) | |
| 85 | | Validation and generator script | `scripts/catalog/catalog_models_dev.py` | Secret-free fetch/validate, seed lock/render/age and `seed discover` (#4117) | |
| 86 | | Scheduled refresh | `.github/workflows/catalog-refresh.yml` | Daily PR that re-locks, discovers new models and regenerates the web facts | |
| 87 | | Script tests | `scripts/catalog/catalog_models_dev_test.py` | Offline shape/scrub checks | |
| 88 | |
| 89 | --- |
| 90 | |
| 91 | ## What already auto-updates (runtime) |
| 92 | |
| 93 | When the TUI/runtime starts (and is not disabled): |
| 94 | |
| 95 | 1. Seed pickers from the **on-disk cache** if present (even if stale). |
| 96 | 2. If the cache is missing or older than **24 hours**, **background-fetch** |
| 97 | Models.dev (15 s timeout, explicit Codewhale user-agent, **no credentials**). |
| 98 | 3. On success: atomic write to |
| 99 | `~/.codewhale/catalog/models-dev-catalog.json` and publish rows into |
| 100 | ProviderLake as `CatalogSource::ModelsDevLive` — layer 10, carrying no |
| 101 | endpoint fingerprint. Models.dev is a public catalog describing a model, so |
| 102 | a refreshed row is treated exactly like the layer-0 seed it supersedes and |
| 103 | stays correctable by layer 15. `CatalogSource::Live` is reserved for a |
| 104 | provider's own credential-scoped `/models` answer at layer 20. |
| 105 | 4. On failure: keep prior cache or fall back to the **bundled** seed. Model |
| 106 | selection never hard-fails because Models.dev is down. |
| 107 | 5. While the runtime remains open, recheck every 15 minutes. A successful |
| 108 | snapshot stays current for the existing 24-hour TTL; a failed network |
| 109 | attempt has a short retry backoff, and an explicit refresh bypasses both. |
| 110 | |
| 111 | ### Manual force refresh |
| 112 | |
| 113 | In the TUI: |
| 114 | |
| 115 | ```text |
| 116 | /model refresh |
| 117 | ``` |
| 118 | |
| 119 | That dispatches `AppAction::RefreshModelsDevCatalog` (async; does not block |
| 120 | the composer). When admitted cloud-facts settings are enabled, it also requests |
| 121 | a cloud refresh; hard-disable and trust-key checks still apply. Implementation lives under |
| 122 | `crates/tui/src/commands/groups/core/core.rs` and |
| 123 | `crates/engine/src/models_dev_live.rs`. |
| 124 | |
| 125 | Runtime clients use the existing route-scoped endpoint: |
| 126 | |
| 127 | ```text |
| 128 | POST /v1/providers/{id}/models/refresh?force_catalog=true |
| 129 | ``` |
| 130 | |
| 131 | Include `model_provider_id` for a named route. This refreshes public Models.dev |
| 132 | metadata and that exact provider's model list independently. Omitting |
| 133 | `force_catalog` keeps the public metadata TTL; setting it bypasses the TTL and |
| 134 | network-failure backoff. Concurrent public refreshes share one fetch owner. |
| 135 | `GET /v1/providers` exposes the existing catalog generation as `catalog_revision`. |
| 136 | It and the refresh receipt expose `public_catalog` with |
| 137 | `freshness`, `fetched_at`, `outcome`, and a bounded error category. A provider |
| 138 | listing failure and a public metadata failure remain separate results; neither |
| 139 | erases the last good public snapshot or changes the selected model. |
| 140 | |
| 141 | The desktop and shared browser model picker offer **Refresh models**. Opening |
| 142 | or focusing the picker checks stale lists; a visible open picker checks the |
| 143 | Engine's catalog revision every 30 seconds and rereads model rows when it changes. |
| 144 | This picks up background completion without repeatedly loading the full catalog. A failed |
| 145 | read keeps the previous rows for that exact route and shows retry feedback. |
| 146 | Catalog data is discarded when its workspace, account, or Engine owner changes. |
| 147 | |
| 148 | New models on an already supported route can appear without a binary update. |
| 149 | A fresh provider/account roster still owns which IDs that route exposes; public |
| 150 | metadata cannot grant access or invent a new provider protocol. |
| 151 | |
| 152 | ### Env knobs (tests / dogfood / offline) |
| 153 | |
| 154 | | Variable | Effect | |
| 155 | |---|---| |
| 156 | | `CODEWHALE_MODELS_DEV_URL` | Override base URL or full `*.json` catalog URL | |
| 157 | | `CODEWHALE_MODELS_DEV_PATH` | Load catalog from a local file; skip network | |
| 158 | | `CODEWHALE_DISABLE_MODELS_DEV_FETCH` | Truthy → never hit the network (`1` / `true` / `yes` / `on`) | |
| 159 | |
| 160 | Defaults: |
| 161 | |
| 162 | - Catalog URL: `https://models.dev/catalog.json` |
| 163 | - TTL: `24 * 60 * 60` seconds (`DEFAULT_MODELS_DEV_TTL_SECS`) |
| 164 | - Cache file name: `models-dev-catalog.json` under the Codewhale `catalog` |
| 165 | state dir |
| 166 | |
| 167 | Freshness values exposed for UI / status chips: `bundled` | `live` | `stale` | |
| 168 | `failed`. |
| 169 | |
| 170 | --- |
| 171 | |
| 172 | ## What does **not** auto-update (repo / release) |
| 173 | |
| 174 | These stay hand-maintained or release-lane work. The scheduled PR below refreshes the generated seed and adds new models, nothing else: |
| 175 | |
| 176 | | Surface | Why it drifts | |
| 177 | |---|---| |
| 178 | | `models_dev.bundled.json` | Offline seed, generated from a reviewed spec and a pinned lock (see below); refreshed by the scheduled PR or a maintainer slice, never at runtime | |
| 179 | | `provider_descriptors.json` default model IDs | Product choice, not pure catalog dump; constant projections are generated | |
| 180 | | `catalog_corrections.json` `reviewed` | Intrinsic/selector/transport compatibility facts with exact source receipts; the only reviewed-facts table, read alongside the seed | |
| 181 | | Rust pricing policy | Vendor billing windows, independent USD/CNY rates, withheld/tiered behavior; pure reference observations live in the reviewed supplement | |
| 182 | | New `ProviderKind` / wire dialect | Needs code, not only JSON | |
| 183 | |
| 184 | Runtime live refresh **does not** rewrite those files. Users on a recent |
| 185 | install with network still see new Models.dev rows; fresh clones offline, CI |
| 186 | hermetic runs, and first-boot without cache still depend on the seed. |
| 187 | |
| 188 | ### The failure this guards: a default that silently stops existing |
| 189 | |
| 190 | An account roster can rotate out from under a hand-written default. Observed |
| 191 | 2026-10-23: the ChatGPT plan roster served exactly seven ids |
| 192 | (`gpt-6.1-sol`, `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`, `gpt-5.6-sol`, |
| 193 | `gpt-5.6-terra`, `gpt-5.6-luna`) and no bare `gpt-5.6`, which is what the |
| 194 | `openai-codex` descriptor defaulted to. A fresh roster redirects the default |
| 195 | (`CodexModelRoster::preferred_model_id`), so a live account avoided it; a stale, |
| 196 | expired or missing roster fell through to `gpt-5.6` and the request failed. |
| 197 | |
| 198 | Defaults are the dangerous half of staleness because a stale *price* misreports |
| 199 | and a stale *default* breaks the request. Two mechanisms now carry the duty: |
| 200 | |
| 201 | - **Hermetic drift guard.** `seed lock` and `seed render` compare every |
| 202 | descriptor `default_model` against the seed default and refuse to write when |
| 203 | they disagree (`--descriptors` to point at another asset). A deliberate, |
| 204 | explained disagreement goes in `SEED_DEFAULT_EXCEPTIONS` in |
| 205 | `scripts/catalog/catalog_models_dev.py`; an unexplained one fails the run. |
| 206 | - **Review-time freshness report.** `seed lock --dry-run` prints which |
| 207 | providers have newer upstream ids than the seed default, plus rows in the |
| 208 | lock the spec no longer references. Nothing offline can know a model |
| 209 | shipped, so this report is the review step, not a gate. |
| 210 | |
| 211 | - **Release-time default audit.** `defaults audit` re-reads a models.dev |
| 212 | payload (the fetched snapshot, or `--snapshot PATH`) and lists each provider |
| 213 | whose default a newer stable row of its own namespace has overtaken. An |
| 214 | unrecorded one fails the run; a deliberate hold is recorded with its reason |
| 215 | in `DEFAULT_AUDIT_REASONS`, and a curated or marketplace route is advisory. |
| 216 | |
| 217 | Honest limit: the hermetic guard catches descriptor↔seed disagreement, and |
| 218 | `seed age` catches a pin nobody re-locked: it fails once `source.fetched_at` |
| 219 | is older than the limit CI enforces (30 days). Neither can tell that a vendor |
| 220 | shipped a model on the day it happened, so the report above is still the step |
| 221 | that catches a brand-new release. |
| 222 | |
| 223 | --- |
| 224 | |
| 225 | The current quote is frozen at dispatch with its exact provider identity, wire |
| 226 | ID, endpoint fingerprint, source and rates. Refreshing the catalog does not |
| 227 | reprice old turns. Live rows carry fetch and expiry clocks separately from an |
| 228 | upstream update or a declared effective date. After 24 hours a live price is |
| 229 | stale; a bundled row is a dated estimate, never proof of account access. |
| 230 | |
| 231 | The shared decimal calculator selects each request's context tier from its |
| 232 | entire input, including cache reads and writes. It prices seven published |
| 233 | classes and subtracts separately charged reasoning/audio subsets from the |
| 234 | ordinary classes. Missing rates or a required usage breakdown stay unpriced. |
| 235 | The result is an exact decimal string; display rounding does not change it. |
| 236 | CNY prices remain separate from USD. These are estimates, not reconciled bills. |
| 237 | |
| 238 | Two default wire IDs missing from the 2026-10-12 upstream snapshot remain as |
| 239 | explicitly dated curated compatibility rows in the seed spec, with their prior |
| 240 | snapshot receipts. They do not establish present account availability or a |
| 241 | renamed wire ID. Other removed non-default rows are no longer seeded. |
| 242 | |
| 243 | ## Maintainer tooling (no LLM) |
| 244 | |
| 245 | ### Validate / dry-run fetch |
| 246 | |
| 247 | ```bash |
| 248 | # Fetch Models.dev + print counts (never writes disk) |
| 249 | python3 scripts/catalog/catalog_models_dev.py refresh |
| 250 | |
| 251 | # Validate the committed offline seed still parses as Models.dev-shaped JSON |
| 252 | python3 scripts/catalog/catalog_models_dev.py snapshot --check \ |
| 253 | crates/config/assets/models_dev.bundled.json |
| 254 | |
| 255 | # OpenRouter public /models listing (no API key), dry-run only |
| 256 | python3 scripts/catalog/catalog_models_dev.py refresh --provider openrouter \ |
| 257 | --sort newest --limit 100 |
| 258 | |
| 259 | # Drift report against the committed seed: field changes, defaults that a |
| 260 | # newer upstream id has overtaken, and lock rows no longer referenced |
| 261 | python3 scripts/catalog/catalog_models_dev.py seed lock --dry-run |
| 262 | ``` |
| 263 | |
| 264 | Design constraints of the script (intentional): |
| 265 | |
| 266 | - Public endpoints only — no `Authorization` headers, no API keys. |
| 267 | - Credential-shaped keys are scrubbed if present in remote JSON. |
| 268 | - `refresh` and `snapshot` never write (`--write` / `--write-cache` fail |
| 269 | closed). The one write path is `seed lock`, which pins only the rows the |
| 270 | spec references, projected onto allowlisted fields. |
| 271 | |
| 272 | ### Regenerating the offline seed (#6396) |
| 273 | |
| 274 | `crates/config/assets/models_dev.bundled.json` is generated. Never edit it by |
| 275 | hand: CI runs `seed render --check` and fails on any difference. |
| 276 | |
| 277 | | File | Holds | Edited by | |
| 278 | |---|---|---| |
| 279 | | `scripts/catalog/models_dev_seed.toml` | Which upstream rows to carry, their Codewhale provider id, wire id, default, canonical join, and the few curated rows upstream does not list | Hand, reviewed | |
| 280 | | `scripts/catalog/models_dev_seed.lock.json` | The referenced upstream rows, allowlisted, plus the source URL, fetch time and sha256 | `seed lock` only | |
| 281 | | `crates/config/assets/catalog_corrections.json` | Deliberate holds: withheld prices, clamped limits, reasoning controls | Hand, reviewed; applies online too | |
| 282 | | `crates/config/assets/catalog_corrections.json` `reviewed` | Source-preserved intrinsic facts, completion references, public labels/source-support dates, pure route facts and reference prices (per-provider model naming rules live in `provider_descriptors.json`; see [`MODELS_AND_PROVIDERS.md`](./MODELS_AND_PROVIDERS.md)) | Hand, reviewed; source receipts retained | |
| 283 | | `crates/config/assets/models_dev.bundled.json` | The rendered seed (no reviewed facts; those stay in `catalog_corrections.json`) | `seed render` only | |
| 284 | |
| 285 | The spec selects and maps; it cannot state a value that disagrees with |
| 286 | upstream (unknown keys are refused). If an upstream value is wrong for a |
| 287 | Codewhale route, add a correction instead. Corrections apply to both the seed |
| 288 | and live rows; a hold made only by hand-editing the seed would vanish on the |
| 289 | first live refresh. |
| 290 | |
| 291 | 1. `python3 scripts/catalog/catalog_models_dev.py seed lock --dry-run` prints the |
| 292 | review report: field changes per row, corrections that upstream now |
| 293 | agrees with (delete them), upstream models not carried, a |
| 294 | **default freshness** block (providers whose default is older than a |
| 295 | newer upstream id) and a **lock rot** block (pinned rows the spec no |
| 296 | longer references). It fails when a referenced row disappeared upstream, |
| 297 | when a curated row now exists upstream (switch it to a derived row), or |
| 298 | when a descriptor default disagrees with the seed default. |
| 299 | 2. Edit the spec or the corrections as the report requires. |
| 300 | 3. `python3 scripts/catalog/catalog_models_dev.py seed lock` writes the lock. |
| 301 | 4. `python3 scripts/catalog/catalog_models_dev.py seed render` writes the seed. |
| 302 | 5. Check that default wire IDs still match `DEFAULT_*_MODEL`, run the |
| 303 | catalog checks, and land the verified slice on main with its report in the commit. |
| 304 | 6. `python3 scripts/catalog/catalog_models_dev.py seed age --max-days 30` is what turns |
| 305 | the above from a habit into a cadence: it fails, locally and in CI, when |
| 306 | `source.fetched_at` in the lock is older than the limit. It is offline and |
| 307 | reads only the lock, so it cannot excuse a stale pin either way — the fix is |
| 308 | always another re-lock. |
| 309 | |
| 310 | Optional: use a cheap model to summarize “new / removed / default-risk” in |
| 311 | the PR body — never as the author of the JSON. The scheduled job does steps 1 |
| 312 | to 4 for you; review its PR the same way. |
| 313 | |
| 314 | --- |
| 315 | |
| 316 | ## The scheduled job |
| 317 | |
| 318 | `.github/workflows/catalog-refresh.yml` runs daily at 05:17 UTC and on |
| 319 | `workflow_dispatch`. It is deterministic Python and shell; no model writes any |
| 320 | row. It never pushes to `main`. |
| 321 | |
| 322 | ```text |
| 323 | cron or dispatch |
| 324 | -> fetch https://models.dev/catalog.json once (public, no keys) |
| 325 | -> seed discover --write new text models from the vendor allowlist |
| 326 | -> seed lock, seed render re-pin the referenced rows, regenerate the seed |
| 327 | -> node web/scripts/derive-facts.mjs regenerate web/lib/facts.generated.ts |
| 328 | -> open a PR only if something material changed, or the pin on main is |
| 329 | older than 7 days |
| 330 | -> checks: seed render --check, seed age, the script unit tests, check-facts |
| 331 | -> push branch `catalog-refresh` and open or update the one PR |
| 332 | ``` |
| 333 | |
| 334 | The PR is created with a GitHub App installation token minted from |
| 335 | `vars.CODEWHALE_APP_ID` and `secrets.CODEWHALE_APP_PRIVATE_KEY`, the same |
| 336 | credentials `codewhale-review.yml` uses. The token is limited to contents and |
| 337 | pull-request write. The test suite does not run on the PR: dispatch `ci.yml` on |
| 338 | the `catalog-refresh` branch head, then fast-forward that commit to `main`. The workflow runs only from `schedule` and |
| 339 | `workflow_dispatch`, never `pull_request_target`, and does not run on forks. |
| 340 | If a check fails after the rows were generated, the PR is opened or switched to |
| 341 | a draft and the job log shows the failure; a later passing run marks it ready. |
| 342 | The checkout does not persist the token, and the push uses |
| 343 | `--force-with-lease`: commits a maintainer adds to the `catalog-refresh` branch |
| 344 | make the next run fail instead of being overwritten, so merge or close the PR |
| 345 | first. If `seed lock` itself refuses (a referenced row |
| 346 | vanished upstream, a descriptor default now disagrees with its model list) the |
| 347 | job fails and nothing is opened. |
| 348 | |
| 349 | ### `seed discover` |
| 350 | |
| 351 | ```bash |
| 352 | python3 scripts/catalog/catalog_models_dev.py seed discover # report only |
| 353 | python3 scripts/catalog/catalog_models_dev.py seed discover --write # add the rows |
| 354 | ``` |
| 355 | |
| 356 | It lists models released inside a window (`[discover].since_days` in the seed |
| 357 | spec, 45 by default, or `--since YYYY-MM-DD`) that the public list does not |
| 358 | carry. The vendor allowlist is `DISCOVER_VENDORS` in the script: anthropic, |
| 359 | openai, google, deepseek, xai, moonshotai, zai, minimax, alibaba (Qwen ids only), |
| 360 | mistral (Mistral-family ids only), meta, xiaomi and stepfun. A row qualifies |
| 361 | when it has a `release_date`, a context limit, tool calling and text-only |
| 362 | output, is not deprecated, and is not a dated snapshot, a `-latest` alias or an |
| 363 | embedding, speech, image, realtime or similar id. Ids already in |
| 364 | `reviewed.public_models`, its aliases or `reviewed.intrinsic` are never |
| 365 | proposed again, and neither are ids in `[discover].skip`, which is how a |
| 366 | maintainer declines a model for good. |
| 367 | |
| 368 | With `--write` it appends, for each new model, a `reviewed.intrinsic` entry |
| 369 | (context, output limit, reasoning, family, all from models.dev, source marked |
| 370 | `unreviewed`), a `reviewed.public_models` row whose `added_at` is the models.dev |
| 371 | `release_date`, and, when the vendor has a seed provider and the id is not yet |
| 372 | in it, the id to that provider's `models` list. A vendor without a seed provider |
| 373 | (Mistral, Qwen) gets the public row only. |
| 374 | |
| 375 | ### Known limits |
| 376 | |
| 377 | - Merging the refresh PR publishes every row it carries, including `unreviewed` |
| 378 | ones, on the public /models page; review them against the vendor docs first. |
| 379 | - Discovery only proposes models released in the last 45 days |
| 380 | (`since_days`), so a model models.dev backfills with an old `release_date` is |
| 381 | never proposed. |
| 382 | |
| 383 | - The site does not deploy itself. Landing the PR on `main` updates what the |
| 384 | 6-hourly facts-drift Worker cron reads (it needs a `GITHUB_TOKEN` in |
| 385 | production), and a deploy stays a manual `web.yml` dispatch. |
| 386 | - The workflow needs the GitHub App (`CODEWHALE_APP_ID`, `CODEWHALE_APP_PRIVATE_KEY`) |
| 387 | to be installed with contents and pull-request write on this repository. |
| 388 | Without it the first step fails and nothing is proposed. |
| 389 | - Discovery filters by id and models.dev metadata only. It cannot tell a model |
| 390 | the vendor has not opened to API users, and an upstream wrong date or limit |
| 391 | becomes our row until someone fixes it. Review each proposed row against the |
| 392 | vendor's docs; per-model facts a human knows (aliases for `/model` |
| 393 | selection, reference prices, a Rust pricing decision, a billing policy for a |
| 394 | fast mode) are not generated. |
| 395 | - A newly listed model can overtake a provider default under the same-line |
| 396 | rule. That is flagged by the existing descriptor/seed default check, which fails |
| 397 | the dispatched `ci.yml` run, to be settled by a human. |
| 398 | - It only adds. A model that models.dev removes or deprecates stays listed |
| 399 | until someone edits the spec and corrections by hand. |
| 400 | - The public list reflects the catalog on `main`, not the live picker on a |
| 401 | user's machine. |
| 402 | |
| 403 | ### In scope for automation |
| 404 | |
| 405 | - Deterministic catalog ingest from Models.dev |
| 406 | - Secret-free PR diffs |
| 407 | - Drift reports (new model ids, missing defaults, pricing presence) |
| 408 | |
| 409 | ### Out of scope for automation |
| 410 | |
| 411 | - Claude Pro/Max / subscription OAuth “model discovery” (not a supported |
| 412 | third-party path; Anthropic expects API keys for third-party tools) |
| 413 | - LLM-authored edits to `models.rs` / `provider.rs` without review |
| 414 | - Force-pushing `main` or silent asset rewrites on the default branch |
| 415 | - Treating Models.dev as the only truth for OAuth-scoped routes (Codex |
| 416 | roster remains special-cased) |
| 417 | |
| 418 | Nightly (`/.github/workflows/nightly.yml`) builds release artifacts only; it |
| 419 | does not refresh catalogs. |
| 420 | |
| 421 | --- |
| 422 | |
| 423 | ## Do we need a “model dedicated to updating models”? |
| 424 | |
| 425 | **No for the core loop.** |
| 426 | |
| 427 | | Job | Right tool | |
| 428 | |---|---| |
| 429 | | Keep known models/windows/prices from Models.dev fresh for users | Runtime live fetch (already shipped) | |
| 430 | | Keep offline seed + release assets current in git | Scheduled CI → PR (`catalog-refresh.yml`) | |
| 431 | | Decide whether to bump a product default model | Human (or agent *review* on the PR) | |
| 432 | | Wire a brand-new provider kind / dialect | Human PR + tests | |
| 433 | |
| 434 | An LLM is optional **review** of a catalog PR. It is a poor **source of |
| 435 | truth** for catalog JSON. |
| 436 | |
| 437 | --- |
| 438 | |
| 439 | ## Auth note (Claude / Anthropic) |
| 440 | |
| 441 | Anthropic model **catalog** refresh does not require Claude Pro/Max OAuth. |
| 442 | Models.dev is public. Codewhale’s Anthropic route remains **API-key-based** |
| 443 | for inference (`ANTHROPIC_API_KEY`). Do not couple catalog automation to |
| 444 | subscription OAuth or Claude Code identity headers. |
| 445 | |
| 446 | --- |
| 447 | |
| 448 | ## Quick operator checklist |
| 449 | |
| 450 | - [ ] Running install: confirm network not blocked; optional |
| 451 | `/model refresh` after a big vendor launch. |
| 452 | - [ ] Offline / CI hermetic: set `CODEWHALE_DISABLE_MODELS_DEV_FETCH=1` or |
| 453 | point `CODEWHALE_MODELS_DEV_PATH` at a fixture. |
| 454 | - [ ] Before release: `seed lock --dry-run` to see how far the offline seed |
| 455 | has drifted from Models.dev, including the default-freshness block — |
| 456 | a stale default is a broken request, not just a stale price. Re-lock |
| 457 | by PR if it matters. Skim `PROVIDERS.md` for known drift. |
| 458 | - [ ] After Models.dev adds a major family you ship by default: consider |
| 459 | seed PR + default-model decision separately. |
| 460 | - [ ] Never paste API keys into catalog assets or the automation script env |
| 461 | for Models.dev refresh. |
| 462 | |
| 463 | --- |
| 464 | |
| 465 | ## Issue / design anchors |
| 466 | |
| 467 | - Live Models.dev layer: #4187 |
| 468 | - Bundled seed demoted (not competing truth): #4188 |
| 469 | - Catalog automation script (validate / dry-run): #4117 |
| 470 | - Generated offline seed and runtime corrections: #6396 |
| 471 | - Deeper metadata inventory and drift list: the `codewhale-ops` repo |
| 472 | |
| 473 | ### Retired unscoped metadata reader |
| 474 | |
| 475 | The former models crate cache reader and its separate bundled asset, and the |
| 476 | TUI-only model registry, are retired. Existing installed legacy cache files are |
| 477 | preserved and are never imported as provider or public-label authority. |
| 478 | `config::catalog` owns the immutable compiled intrinsic projection; Engine's |
| 479 | existing provider lake and scoped catalog cache still own live/account/config |
| 480 | facts. Identical wire names at different endpoints do not create a canonical |
| 481 | join, a public label, or an unscoped price. The bundled freshness clock uses the |
| 482 | actual seed lock fetch timestamp and rechecks the current clock on each query. |
| 483 | |
| 484 | Compatibility completion lists reference the provider descriptor defaults and |
| 485 | catalog groups rather than repeating their values. Kimi's generation default |
| 486 | remains distinct from direct/membership route limits. Unknown capabilities and |
| 487 | name-suffix budgets remain explicitly unverified. Website model dates describe |
| 488 | source support, with the prior proven dates retained in the same reviewed owner; |
| 489 | they do not assert a provider release date or current API availability. |
| 490 | |
| 491 | ## PR 7368 pinned seed recovery |
| 492 | |
| 493 | The release recovery uses only the lock bytes in commit |
| 494 | `f252419bd33b8fb2bb6e1c0f00519082d61fee6a`, Git blob |
| 495 | `7ccbc152c4f080da9cb6541a1df06948fcecc274`, with the current seed spec and |
| 496 | corrections. The existing `seed render` derivation regenerates the bundled |
| 497 | asset; the PR's older corrections and generated web facts are not copied. |
| 498 | Neon's vendor review, source receipt, reference prices and provider listing |
| 499 | remain intact, as do all other routes. |
| 500 | |
| 501 | The lock records `https://models.dev/catalog.json`, fetched at |
| 502 | `2026-11-20T05:19:54Z`, and upstream SHA-256 |
| 503 | `d178146b38f5687ea10d945730a7b714c890ba85a09b45fed7a6e74c9ecea9a0`. |
| 504 | Relative to the carried 18 November lock, the only row changes are these |
| 505 | OpenRouter reference costs (USD per million tokens): |
| 506 | |
| 507 | | Model | Input | Output | Cache read | |
| 508 | |---|---:|---:|---:| |
| 509 | | `deepseek/deepseek-v4-pro` | 0.9 (unchanged) | 1.5 (unchanged) | 0.25 → 0.2 | |
| 510 | | `z-ai/glm-5.2` | 0.007 → 0.62 | 6.8 → 2.42 | 0.006 → 0.14 | |
| 511 | |
| 512 | Evidence limit: these values are substantiated by the exact pinned Git blob, |
| 513 | not by its later timestamp. That commit has no embedded signature. The full |
| 514 | upstream response bytes were not available for rehashing, so the recorded |
| 515 | upstream SHA-256 is retained provenance, not a newly verified payload digest. |
| 516 | Neither changed price row is independently substantiated here by a signed |
| 517 | catalog or provider-origin response. This local recovery makes no claim about |
| 518 | current endpoint/account billing and performs no inference or paid calls. |
| 519 |