Skip to content

fix(models): keep v3 catalog rows when newer publishers add fields - #190187

Merged
obviyus merged 1 commit into
mainfrom
obviyus/catalog-schema-adr
Nov 1, 2026
Merged

obviyus merged 1 commit into
mainfrom
obviyus/catalog-schema-adr

Conversation

@obviyus

@obviyus obviyus commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #189678

What Problem This Solves

The opt-in v3 model catalog repeats the problem that forced v2 and v3: its reader rejects unknown fields. Any field a newer publisher adds would drop rows on every install that reads v3, so the next additive change would need a v4.

User Impact

Installs that read a v3 catalog keep every model when the hosted feed gains new fields. Unknown fields are ignored at any depth. Released clients are unaffected: they read only v1/v2, which are unchanged.

Why This Change Was Made

  • Reader: the v3 reader now parses with the existing strict schemas and drops only the keys zod reports as unrecognized, then parses again. The publisher keeps the same strict schemas, so typos in rows, providers and pricing still fail before publication. The v1/v2 readers are unchanged.
  • Cache slot: v3 is cached in the existing modelCatalog.remote.v3 slot again, and the modelCatalog.remote.v4 slot added in feat(models): preserve inference capabilities in opt-in catalog v3 #189678 is removed.
    • No release or beta reads modelCatalog.remote.v3: stable 2026.10.9, extended-stable 2026.9.36 and beta 2026.10.10-beta.5 all read modelCatalog.remote.v2, which this client never writes.
    • So the extra slot protected no shipped downgrade.

Production +70/−20: the reader helper is the growth; the fourth cache slot and its fallback branch are gone. Tests +33/−8.

This follows the catalog schema decision: v3 is the last version for additive change. New capability kinds go inside inference with chat: false, and v1/v2 stay frozen. The doc is updated with these rules.

Peer catalogs reached the same rule:

  • models.dev v2 tells clients to accept extra keys.
  • LiteLLM's cost map has had no version in three years.
  • OpenRouter and Codex readers drop unknown keys.

Evidence

  • Real refresh, before vs after. Ran pnpm openclaw models refresh (built from this branch) against a loopback mirror, with isolated state.
    • Feed: the hosted v3 catalog plus one unknown field on one row.
      • Before: 1,243 models and skipped invalid row models.4 (claude-fable-5).
      • After: 1,244 models, no warning.
    • Hosted v3, v3 with an unknown kind inside inference, and v3 with two fal image/music rows: 1,244 / 1,244 / 1,246 models, no warnings.
    • All v2 feeds behave exactly as before.
    • The stored row is modelCatalog.remote.v3 with schemaVersion: 3 and 1,244 models; no .v4 row.
  • Upgrade from stable 2026.10.9 on one state dir:
    • The standard doctor --fix migration ran first.
    • This head adopted stable's cached catalog (unchanged, 1,230 models) and then read hosted v3 (1,244 models).
    • It cached v3 in modelCatalog.remote.v3 and never rewrote the released modelCatalog.remote.v2 row, which stays byte-identical.
    • agents.defaults.model.primary was preserved.
    • Details are in the PR comment.
  • Released readers. pnpm catalog:compare-released with 2026.10.9 and 2026.9.36: both reject any v2 feed with an extra field, as expected. This is why v1/v2 stay frozen and new fields go to v3 only.
  • Focused tests. model-catalog-normalize.test.ts (41) and remote-refresh.test.ts (19) pass. The new test fails without the reader change (1 failed / 40 passed) and passes with it.
  • Checks. oxfmt, oxlint and git diff --check are clean on the changed files. pnpm build passes.
  • Not run locally. Full typecheck and broad suites are left to CI.

Merge danger: a two-way door. A revert restores strict v3 parsing and the .v4 slot. Only installs built from main since #189678 that already cached v3 in .v4 refetch once. Blast radius is limited to opt-in v3 mirror users on unreleased builds.

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Nov 1, 2026
@obviyus
obviyus marked this pull request as ready for review November 1, 2026 09:13
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes v3 catalog readers tolerate unknown fields while keeping publisher validation strict and reusing the unreleased v3 cache slot.

Example: A v3 mirror adds an unknown field to claude-fable-5.

  • Before: The refresh skips that row and reports 1,243 models.
  • After: The refresh retains the row and reports 1,244 models without a warning.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused, correct repair with shipped-CLI results, stable-upgrade evidence, and a passing current-head CI gate; runtime evidence is summarized in the maintainer's report.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The maintainer reports real models refresh runs through a loopback mirror and isolated SQLite, retaining the formerly skipped row and exercising nested inference additions; the current-head upgrade table additionally demonstrates stable cache adoption and settings preservation.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An additive field from a newer v3 publisher can remove otherwise usable models from an older client's refreshed catalog.
Reason: Reader tolerance follows recorded catalog direction, and the maintainer-authored change keeps released formats and settings intact.

Merge readiness

✅ Ready for maintainer review

This PR is useful and ready for normal landing consideration: no actionable defects were found, and the new upgrade evidence resolves the prior blocker.

Priority: P2
Reviewed head: a9ac97cf409cb92090a6133820524dad682f3009

Before merge

None.

Findings

None.

Agent review details

How this fits together

Remote catalog downloads enter the shared schema validator, which sanitizes model metadata before SQLite persistence and publication to model and pricing consumers.

flowchart LR
  A[Catalog mirror] --> B[Remote refresh]
  B --> C[Shared catalog validator]
  C --> D[SQLite cache worker]
  D --> E[Catalog projection]
  E --> F[Model and pricing consumers]
Loading

Technical review

Best possible solution:

Land the focused v3 reader repair with strict authoring validation and the released cache slots preserved.

Do we have a high-confidence way to reproduce the issue?

Current main passes v3 rows through strict schemas that reject unknown row keys; the author reports the matching real CLI failure and successful refresh after the repair.

Is this the best way to solve the issue?

The patch uses the existing validation and storage owners, removes only reported unknown keys, retains validation of known fields, and preserves strict publisher parsing without another wire version.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2a49211f59ef.

Provenance checked

  • Independent row ingestion keeps the original intent (bf8da00: Salvage usable rows while rejecting malformed known metadata and preserving strict publisher validation.)
  • Strict v3 reader changes intended behavior with a stated reason (177fe32: Restore opt-in inference-capability transport using canonical schemas; this PR explains why additive reader fields must be tolerated.)
  • Fourth cache slot and fallback changes intended behavior with a stated reason (177fe32: Protect older readers during downgrade; this PR verifies that released readers use .v2, preserves that slot, and accepts a refetch for unreleased .v4 caches.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 177fe32 adds packages/model-catalog-core/src/remote-catalog-bundle.ts:492 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 177fe32dfdd7; files: packages/model-catalog-core/src/remote-catalog-bundle.ts)
  • Peter Steinberger: Raw commit bf8da00 adds packages/model-catalog-core/src/remote-catalog-bundle.ts:98 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bf8da001d61c; files: packages/model-catalog-core/src/remote-catalog-bundle.ts)

PR surface

Source +50, Tests +25, Docs +6. Total +81 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 70 20 +50
Tests 2 33 8 +25
Docs 1 8 2 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 111 30 +81

Review metrics

Metric Value Why it matters
Production versus test changes Production +70/-20; tests +33/-8 The reader helper reuses existing schemas instead of maintaining parallel tolerant schemas, while removal of the unreleased cache generation reduces storage branches.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Forward compatibility affects opt-in v3 mirror users; the default feed and released v1/v2 readers remain unchanged.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-01T09:29:03.887Z sha a9ac97c :: blocked before merge. :: none

Reviewed November 1, 2026, 4:41 AM ET / 09:41 UTC (Revision 2).

@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

Upgrade proof: stable 2026.10.9 → this head (a9ac97c) on one isolated state dir, with a loopback catalog mirror and real SQLite.

Step Refresh result modelCatalog.remote.v2 modelCatalog.remote.v3
1. Stable (npm [email protected]): config set agents.defaults.model.primary, models refresh on hosted v2 updated, 1,230 models written, sha3 49B5A0FFF7FA, schema 2 —
2. This head: doctor --fix --non-interactive --client-credentials (the standard update migration), models refresh on v2 unchanged, 1,230 models (stable's cache adopted) unchanged 49B5A0FFF7FA written, schema 2
3. This head: switch the mirror to hosted v3, then to v3 with an unknown row field, and refresh each time unchanged, 1,244 models both times unchanged 49B5A0FFF7FA schema 3
  • agents.defaults.model.primary still reads anthropic/claude-fable-5 after step 3.
  • This head never writes the released .v2 row; its bytes stay exactly what stable wrote.
  • Running stable again on the same state dir is refused by the existing global database gate (uses newer schema version 38; this build supports 20). Every main build hits this, since it predates this PR, and feat(models): preserve inference capabilities in opt-in catalog v3 #189678 reported the same. This PR changes no database schema. The released .v2 slot stays byte-identical for a restore from a pre-update backup.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 1, 2026
@obviyus
obviyus merged commit 8ef2c73 into main Nov 1, 2026
241 of 242 checks passed
@obviyus
obviyus deleted the obviyus/catalog-schema-adr branch November 1, 2026 09:42
@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 8ef2c73.

  • Bug: the opt-in v3 catalog reader rejected unknown fields, so any field a newer publisher added would drop models on every v3 reader. feat(models): preserve inference capabilities in opt-in catalog v3 #189678 also moved the cache to a new .v4 slot that no release needed.
  • Fix: v3 readers drop only the fields the strict schema reports as unknown, at any depth. The publisher stays strict. v3 is cached in modelCatalog.remote.v3 again.
  • Proof:
    • A real models refresh keeps all 1,244 models when a v3 row has an unknown field (1,243 plus a warning before the fix).
    • An upgrade from stable 2026.10.9 adopts the cached catalog, keeps settings and leaves the released .v2 row byte-identical.
    • Hosted review ready; CI green on the exact head.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
…penclaw#190187)

Related: openclaw#189678

## What Problem This Solves

The opt-in v3 model catalog repeats the problem that forced v2 and v3: its reader rejects unknown fields. Any field a newer publisher adds would drop rows on every install that reads v3, so the next additive change would need a v4.

## User Impact

Installs that read a v3 catalog keep every model when the hosted feed gains new fields. Unknown fields are ignored at any depth. Released clients are unaffected: they read only v1/v2, which are unchanged.

## Why This Change Was Made

- **Reader:** the v3 reader now parses with the existing strict schemas and drops only the keys zod reports as unrecognized, then parses again. The publisher keeps the same strict schemas, so typos in rows, providers and pricing still fail before publication. The v1/v2 readers are unchanged.
- **Cache slot:** v3 is cached in the existing `modelCatalog.remote.v3` slot again, and the `modelCatalog.remote.v4` slot added in openclaw#189678 is removed.
  - No release or beta reads `modelCatalog.remote.v3`: stable `2026.10.9`, extended-stable `2026.9.36` and beta `2026.10.10-beta.5` all read `modelCatalog.remote.v2`, which this client never writes.
  - So the extra slot protected no shipped downgrade.

Production +70/−20: the reader helper is the growth; the fourth cache slot and its fallback branch are gone. Tests +33/−8.

This follows the catalog schema decision: v3 is the last version for additive change. New capability kinds go inside `inference` with `chat: false`, and v1/v2 stay frozen. The doc is updated with these rules.

Peer catalogs reached the same rule:
- models.dev v2 tells clients to accept extra keys.
- LiteLLM's cost map has had no version in three years.
- OpenRouter and Codex readers drop unknown keys.

## Evidence

- **Real refresh, before vs after.** Ran `pnpm openclaw models refresh` (built from this branch) against a loopback mirror, with isolated state.
  - Feed: the hosted v3 catalog plus one unknown field on one row.
    - Before: 1,243 models and `skipped invalid row models.4 (claude-fable-5)`.
    - After: 1,244 models, no warning.
  - Hosted v3, v3 with an unknown kind inside `inference`, and v3 with two fal image/music rows: 1,244 / 1,244 / 1,246 models, no warnings.
  - All v2 feeds behave exactly as before.
  - The stored row is `modelCatalog.remote.v3` with `schemaVersion: 3` and 1,244 models; no `.v4` row.
- **Upgrade from stable `2026.10.9`** on one state dir:
  - The standard `doctor --fix` migration ran first.
  - This head adopted stable's cached catalog (`unchanged`, 1,230 models) and then read hosted v3 (1,244 models).
  - It cached v3 in `modelCatalog.remote.v3` and never rewrote the released `modelCatalog.remote.v2` row, which stays byte-identical.
  - `agents.defaults.model.primary` was preserved.
  - Details are in the PR comment.
- **Released readers.** `pnpm catalog:compare-released` with `2026.10.9` and `2026.9.36`: both reject any v2 feed with an extra field, as expected. This is why v1/v2 stay frozen and new fields go to v3 only.
- **Focused tests.** `model-catalog-normalize.test.ts` (41) and `remote-refresh.test.ts` (19) pass. The new test fails without the reader change (1 failed / 40 passed) and passes with it.
- **Checks.** `oxfmt`, `oxlint` and `git diff --check` are clean on the changed files. `pnpm build` passes.
- **Not run locally.** Full typecheck and broad suites are left to CI.

Merge danger: a two-way door. A revert restores strict v3 parsing and the `.v4` slot. Only installs built from `main` since openclaw#189678 that already cached v3 in `.v4` refetch once. Blast radius is limited to opt-in v3 mirror users on unreleased builds.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant