Skip to content

fix(catalog): gate released v3 readers and row loss; strict publisher guards - #197189

Merged
obviyus merged 8 commits into
mainfrom
openclaw/catalog-v3-publisher-guard-o
Nov 11, 2026
Merged

obviyus merged 8 commits into
mainfrom
openclaw/catalog-v3-publisher-guard-o

Conversation

@obviyus

@obviyus obviyus commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The catalog v3 pre-flip audit found six publisher and guard gaps:

  • B2: the publish guard (scripts/released-readers.mjs in openclaw/catalog) checks v1/v2 only and passes any updated|unchanged|fresh status. 2026.11.5-beta.1 read a v2 file with one unknown pricing.status as updated, keeping 1243 of 1244 models. Every v3 reader salvages rows this way, so a status-only v3 guard would pass files that silently lose models.
  • S2: a media row without inference publishes, and every reader treats it as chat (audit fixture 61).
  • S3: the publisher silently strips unknown keys under inference (fixtures 16, 17, 18, 29, 60).
  • S4: v1 is at 92.3% of the 4 MiB cap. The only warning fires at 2 MiB, so it shows on every run. A v1 overflow also blocks v2 and v3.
  • S5: scheduled publishes fail with released reader failed … (exit 0) and no parser error (Actions runs 42933322733, 42755763377, 42519989192, 42499756640). Each reader copied the worker module to one shared path just before spawning; the readers spawn in the same tick, so on Linux a sibling could load the truncated file, run an empty module and exit 0 without run.json.
  • Shrink: nothing stops a publish that is missing a provider or many rows.

Fix

pnpm catalog:compare-released --check is the new publish gate. It sits next to the released-reader sandbox it drives.

  • The feed comes from the candidate's schemaVersion.
  • A release is checked only if its dist declares validateAndSanitizeRemoteModelCatalogBundleV<N>; all releases read v1. A test pins those names in remote-catalog-bundle.ts.
  • Today v3 prints no v3 reader, skipped for each release. The first release that ships a v3 reader is checked on every publish, with no list to update.
  • Reads are refresh-only. Each checked release reads the candidate and, if given, --baseline (the last published file).
  • It fails on a rejection, or when a release keeps fewer rows than the publisher wrote, beyond the loss that release already had on the baseline.
    • Threshold: any new loss. The audit case lost 1 row in 1244 (0.08%), so any percentage threshold would pass it.
    • A loss already live from an earlier publish does not fail again.
    • --allow-row-loss <n> accepts one intended loss.
    • Accepted edge case: the gate compares counts, not ids.
  • Report mode's default baseline now follows the candidate's feed instead of always v2.
  • S5: the worker is copied once, right after the run directory is created, before any reader spawns. The --dump format (<release>-baseline.json / -candidate.json) is unchanged.

Publisher (scripts/publish-model-catalog.mts):

  • S3: inference declarations fail on any key Zod would strip, at any depth, and the error names the path. Runtime and reader schemas are unchanged.
  • S2: auth-choice onboardingScopes default to text-inference.
    • If every auth choice for a provider names only other scopes (image or music generation), that provider's rows must set inference.chat: false.
    • Fixture 61's row on a chat provider looks exactly like a minimal chat row, so the owning surface is the only signal the publisher has.
    • Decision rows must already state chat (the schema requires it).
    • No current manifest trips this rule.
  • S4: each feed warns above 90% of the cap, about two weeks of growth at the current rate (~60 rows/week, ~3 KiB per v1 row).
    • --skip-oversized-v1 leaves an oversized v1 unwritten and keeps the previous v1; v2/v3 still publish.
    • Every versioned output goes through the temp-file and recovery publisher, including a single v2 or v3 left after v1 is skipped. An interrupted or out-of-space write keeps the previous file.
    • A v1-only run keeps the direct writer, as fix(models): prepare catalog pairs before replacing outputs #160157 intended. That path is unchanged.
    • Tradeoff: v1 goes stale instead of being truncated, which would drop rows. Without the flag, an overflow still fails all feeds.
  • Shrink guard: --previous, --previous-v2 and --previous-v3 name the last published files.
    • A feed that loses more than 5% of rows, or any provider, fails unless --allow-shrink is given.
    • The largest drop in the last 400 publishes was 3.94%. Each of the four largest providers holds more than 5% of rows.
    • A missing previous file is reported, not compared.

Tests and proof

  • test/scripts/publish-model-catalog-guards.test.ts holds the publisher regressions:
    • strict inference fields: all four audit mutations, in one row;
    • chat: false for media-only providers;
    • the 90% warning;
    • v1 overflow with and without --skip-oversized-v1;
    • the lone-v3 partial write;
    • the shrink guard.
  • Each publisher regression fails against the code it guards:
    • All six fail on the base.
    • The lone-v3 partial write also fails on the previous head: the v3 write lands half its bytes, then hits ENOSPC, and the old v3 file was destroyed. With the fix it is intact.
  • The former publish-model-catalog-decisions suite is merged into this file on one shared fixture.
  • catalog-compare-released.test.ts covers:
    • table-driven gate verdicts (beta row loss, known loss, allowed loss, rejected baseline, rejection);
    • row counting and the source-name pin;
    • --check skipping v3 by name.
  • The S5 staging regression counts copies of the staged worker. It sees exactly one copy; the pre-fix code made four.
  • All catalog script suites pass (75 tests). Tooling tsgo, tsgo:scripts, oxlint, format and the test-lines ratchet also pass.
  • Test-line budget:
    • After consolidation the net growth is +297, down from +517.
    • That is allocated in config/test-lines-allocations/197189-catalog-v3-publisher-guards.txt.
  • Real publish on the repo's manifests with live sources: v2 has 1244 rows, v3 1261, v1 1244.
    • shrink guard v1/v2/v3: 0.0% each.
    • Warning shown: v1 bundle 3872069 bytes is 92.3% of the 4194304-byte client limit.
  • Real --check against the released tarballs (2026.11.3, 2026.9.37, 2026.11.5-beta.1) in a sanitized environment:
fresh v1: all three  updated, 1244/1244 rows (last published 1244/1244)   exit=0
fresh v2: all three  updated, 1244/1244 rows (last published 1244/1244)   exit=0
fresh v3: v3 on openclaw@<each>: no v3 reader, skipped
          v3: no checked release reads v3 yet                             exit=0
audit v2-20-enum-pricing-status:
v2 on [email protected]: error (last published 1244/1244)
v2 on [email protected]: error (last published 1244/1244)
v2 on [email protected]: updated, 1243/1244 rows (last published 1244/1244)
::error::v2 on [email protected]: error …: [ { "code": "invalid_union", … "path": [ "models", 4, "pricing", "status" ] …
::error::v2 on [email protected]: error …: [ { "code": "invalid_union", … ]
::error::v2 on [email protected]: updated, 1243/1244 rows (last published 1244/1244): release dropped 1 of 1244 published rows (allowed 0)
exit=1
  • The beta line above is a case the current catalog guard passes. v2-11-unknown-row fails the same way.
  • Report mode still prints no behavior change on all three releases.
  • --check takes 5–13 s per feed with cached installs.

Unverified: the v3 reader path cannot run end to end until a release ships a v3 reader. The detection rule is pinned by a test, and the verdict logic is unit-tested.

What openclaw/catalog must change

  1. In Assemble catalog, add --previous ../models/v1/catalog.json --previous-v2 ../models/v2/catalog.json --previous-v3 ../models/v3/catalog.json --skip-oversized-v1. Add --allow-shrink only through a manual dispatch input.
  2. In Check released readers, call the gate for v1 v2 v3 on every run. Skip a feed whose catalog.next.json is absent:
    for version in v1 v2 v3; do
      next=models/$version/catalog.next.json; [ -f "$next" ] || continue
      args=(--check --candidate "$PWD/$next")
      [ -f "models/$version/catalog.json" ] && args+=(--baseline "$PWD/models/$version/catalog.json")
      (cd openclaw && node scripts/catalog-compare-released.mts "${args[@]}") || failed=1
    done; exit ${failed:-0}
    
    ::error:: lines are already annotations. --allow-row-loss <n> can be a dispatch input. released-readers.mjs can be deleted.
  3. In Commit on change only, tolerate a missing models/v1/catalog.next.json: keep the current v1 and move only the feeds that were written.

Size: production about +400 lines, tests +297 net (allocated), docs +24. The noisy 2 MiB warning is removed.

obviyus and others added 2 commits November 11, 2026 16:28
… guards

- catalog:compare-released --check: run every release that ships a reader for the
  candidate's wire version (v1/v2/v3) and fail on rejection or on any row the
  publisher wrote that the release drops, beyond the loss it already had on the
  last published file. --allow-row-loss accepts an intended loss.
- publish-model-catalog: unknown keys under inference fail publish; providers
  offered only on non-chat auth scopes must mark rows inference.chat: false;
  per-feed 90% size warning; --skip-oversized-v1 keeps v2/v3 publishing;
  --previous* shrink guard (5% rows or any provider) with --allow-shrink.

Co-authored-by: obviyus <[email protected]>
… guards

OpenClaw-Publication: 7ce306ca-a43c-4826-a4bb-8facebe1b849
@clawsweeper

clawsweeper Bot commented Nov 11, 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 scripts Repository scripts size: L labels Nov 11, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds released-reader row-loss checks, strict inference validation, catalog shrink guards, and safe publication when oversized v1 output is skipped.

Example: A v2 catalog contains 1244 models, but [email protected] accepts only 1243 after encountering an unknown pricing status.

  • Before: The status-only guard accepts the reader's updated result.
  • After: The new --check gate reports the missing row and exits with failure.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, production-path-proven tooling repair with no correctness finding; one implementation-coupled test reduces patch quality.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied live publisher and comparison CLI output exercises real manifests, live sources, and released tarballs, including successful normal feeds and rejection of a one-row beta loss; v3 acceptance remains an explicitly disclosed future-release limitation, while current v3 skipping is exercised.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Published catalog changes can silently remove models from released installs or stop newer feeds from updating when v1 exceeds its size limit.
Reason: The maintainer-authored direction addresses demonstrated publication failures with explicit operator controls and preserves existing runtime schemas and defaults.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses concrete catalog publication failures, preserves the existing publication owners, and fixes the earlier write-safety finding; no introduced correctness blocker was found.

Priority: P2
Reviewed head: 0b1add69b2b96ebfad526c4aba9492135bdf179e

Before merge

None.

Findings

None.

Tests

  • Low-value test test/scripts/catalog-compare-released.test.ts: Remove the staged-worker copy-count test: both fake readers fail, and counting copyFileSync calls proves neither successful concurrent loading nor staging before spawn.
Agent review details

How this fits together

The catalog publisher turns plugin manifests and upstream metadata into versioned JSON feeds; the comparison CLI serves candidates to isolated released readers before deployment.

flowchart LR
  A[Plugin manifests] --> C[Catalog publisher]
  B[Upstream metadata] --> C
  C --> D[Versioned candidate feeds]
  D --> E[Released reader sandbox]
  E --> F[Acceptance and row loss gate]
  D --> G[Recoverable file publisher]
Loading

Technical review

Best possible solution:

Land the guards through the existing tooling owners, then adopt the documented invocation in the catalog publication workflow.

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

Current source establishes the per-reader shared worker copy and missing inference-key, shrink, and row-loss checks; the PR supplies real CLI output for the released-reader loss case, which this read-only review did not rerun.

Is this the best way to solve the issue?

The smallest complete repair strengthens the existing publisher and comparison CLI, stages their shared worker once, and reuses the existing recoverable writer instead of introducing another publication owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Released-reader comparison and worker staging keeps the original intent (409b16c: The original tool intentionally provided a non-gating report and isolated each released reader from user state.)
  • Inference declaration parsing changes intended behavior with a stated reason (cff3c30: Canonical assembly preserved native capability declarations before legacy chat projection; the new publisher-only validation explains why silently stripped authoring keys must fail.)
  • Bundle size warning and overflow changes intended behavior with a stated reason (5347285: Hosted pricing increased bundle size and needed size reporting; the new threshold restores a useful warning and explicitly makes stale-v1 continuation opt-in.)
  • Recoverable output publication keeps the original intent (d36da73: Prepare and retain recoverable catalog artifacts while preserving the v1-only direct writer.)
  • Versioned capability coverage consolidation keeps the original intent (177fe32: Keep native task facts on opt-in v3 while preserving released chat feeds and their minimum model floor.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced changes and current main: The pinned introduced diff contains the new gates and publisher guards; fetched main retains the original publisher and comparison behavior. (scripts/publish-model-catalog.mts:1714, 0b1add69b2b9)
  • Production-path evidence supplied: The full PR body records a real publisher run with live sources and CLI checks against stable, extended-stable, and beta tarballs: normal v1/v2 candidates pass, while the beta's 1243/1244-row result fails the new gate. (0b1add69b2b9)
  • Earlier finding resolved: A sole v2/v3 output remaining after v1 is skipped now uses publishModelCatalogPair; the regression injects a partial ENOSPC write and checks that previous v3 bytes survive. (scripts/publish-model-catalog.mts:1818, 0b1add69b2b9)
  • Accepted publication tradeoffs: The collaborator-authored direction explicitly accepts comparing row counts rather than identities and retaining stale v1 bytes when the operator selects --skip-oversized-v1; neither changes the default overflow behavior. (scripts/lib/catalog-compare-released-gate.mts:60, 0b1add69b2b9)
  • Downstream publication contract: The PR explicitly targets this workflow's consumption of the OpenClaw publisher and comparison CLI, establishing the dependency signal; the current workflow still invokes the status-only v1/v2 guard, so deployment adoption remains separate work as the PR documents. (.github/workflows/publish.yml:56, 1f2ffef76b04)
  • Preserved publication intent: The merged recovery repair explicitly retained the v1-only direct writer and documented single-publisher recovery; this PR preserves that path and reuses the existing recoverable writer for versioned outputs. (scripts/lib/publish-model-catalog-files.mts:62, d36da73091ce)

Likely related people:

  • Ayaan Zaidi: Raw commit 73970eb adds scripts/publish-model-catalog.mts:1238 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 73970eb84a71; files: scripts/publish-model-catalog.mts)
  • Vincent Koc: Raw commit 177fe32 adds scripts/publish-model-catalog.mts:1354 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: scripts/publish-model-catalog.mts)
  • Peter Steinberger: Raw commit d36da73 adds scripts/publish-model-catalog.mts:1209 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d36da73091ce; files: scripts/publish-model-catalog.mts)

PR surface

Tests +297, Docs +22, Other +424. Total +743 across 12 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 395 98 +297
Docs 2 24 2 +22
Config 0 0 0 0
Generated 0 0 0 0
Other 5 454 30 +424
Total 12 873 130 +743

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test growth Production +419 net lines; tests +297 net lines Growth implements distinct publication guards and released-reader checks while consolidating the former decisions suite.
New tooling flags 7 Adds --check, --allow-row-loss, --previous, --previous-v2, --previous-v3, --allow-shrink, and --skip-oversized-v1; existing invocations retain their defaults.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Prevents silent catalog row loss and publication failures through maintainer tooling without changing ordinary user setup.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • 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 (2 earlier review cycles)
  • reviewed 2026-11-11T11:16:45.013Z sha fe2b5f5 :: needs changes before merge. :: [P2] Preserve safe publication for a sole remaining versioned output
  • reviewed 2026-11-11T12:29:34.082Z sha c217fb6 :: needs maintainer review before merge. :: none

Reviewed November 11, 2026, 7:54 AM ET / 12:54 UTC (Revision 3).

obviyus and others added 2 commits November 11, 2026 17:29
Readers spawn in the same tick; copying the worker module per spawn truncates
the file a sibling is loading, which then runs an empty module and exits 0
without run.json ("released reader failed ... (exit 0)" in scheduled publishes).

Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: e1bd317c-c35d-4681-b4d3-b8634fb803e6
obviyus and others added 2 commits November 11, 2026 17:52
With an oversized v1 and --skip-oversized-v1, one versioned output can remain;
it went through the truncating direct writer, so ENOSPC or an interruption
could destroy the previous file. The v1-only direct writer is unchanged.

Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 4639135f-c808-402d-9d88-74f6f5425b50
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 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. 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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
obviyus and others added 2 commits November 11, 2026 18:16
…ests

Table-drive the gate verdicts, share one fake-release runner, fold the four
inference fixtures and the shrink cases into single regressions, and merge the
decisions suite into the guards suite on one fixture. Every regression still
fails on the code it guards. Allocate the remaining +297 test lines.

Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 150f0f2a-8400-4290-87aa-60819c94b012
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
@obviyus
obviyus merged commit 6a5ac74 into main Nov 11, 2026
113 checks passed
@obviyus
obviyus deleted the openclaw/catalog-v3-publisher-guard-o branch November 11, 2026 13:02
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. scripts Repository scripts size: L 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