Skip to content

refactor(models): share model metadata primitives - #140883

Merged
steipete merged 1 commit into
mainfrom
steipete/dedup-model-data-primitives-0906
Sep 7, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/dedup-model-data-primitives-0906

Conversation

@steipete

@steipete steipete commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Runtime models, catalog metadata, and model configuration independently declared the same reasoning values, media limits, pricing buckets, and nested routing shapes. Maintaining these copies makes metadata contracts easier to drift apart.

Why This Change Was Made

One dependency-free data leaf in packages/llm-core/src/model-data.ts now owns those shared primitives. Existing public names stay in their original modules. The leaf is bundled from source by the existing package builds; no package dependency or public subpath was added.

Routing interfaces keep their own top-level members. Replacing those members with inheritance rejects a previously valid only?: string[] | undefined augmentation under exact optional properties. Sharing only nested routing objects preserves that contract. The two-field Vercel shapes and API-specific compatibility bags remain local.

User Impact

No user-visible change. Existing public type contracts are preserved. Runtime API/modality differences, optional catalog rates, normalized pricing, and complete model shapes remain intact. Exported arrays retain their order, readonly tuple types, mutability, and separate identities. Production delta: -33 lines; tests unchanged.

Config compatibility and upgrade review is complete: accepted schema values and defaults are unchanged, confirmed by the unchanged config documentation baseline and old/new type/value probes. No normalizer or config writer changed, no existing config is invalidated, and no migration is required.

Evidence

  • node scripts/run-vitest.mjs packages/model-catalog-core/src/model-catalog-normalize.test.ts packages/model-catalog-core/src/model-catalog-pricing.test.ts src/config/zod-schema.models.test.ts: 3 files / 124 tests passed.

  • pnpm config:docs:check passed without generated-file changes.

  • Actual-source type probes preserve all 113 existing exports and 53 type pairs with exact optional properties enabled and disabled. All 37 valid augmentation cases remain valid; 11 invalid cases keep the same diagnostics. Five tuple values and their owner identities/guards also pass. The inherited-interface negative control produces the expected two TS2430 errors.

  • Independent Codex autoreview: no actionable P0–P2 findings. Rebase verified patch-identical, with all four source hashes unchanged.

  • Clean build, built catalog smoke, declaration scan, and the complete changed-file gate passed on Blacksmith Testbox tbx_01m1x5wna4xtejtdrd52hr0pjv: https://github.com/openclaw/openclaw/actions/runs/34087460914. Command elapsed 20m18.7s, exit 0; the lease stopped automatically. All four source hashes matched, and 454 declarations contained zero private LLM package specifiers. No live-provider contract changed.

  • Exact-head CI passed for d77aaf1e341543dc3d773186ceb030ce073dd7fd: https://github.com/openclaw/openclaw/actions/runs/34087729644. Native prepare completed without changing the head.

Exact Testbox command
'node' 'scripts/crabbox-wrapper.mjs' 'run' '--timing-json' '--' 'bash' '-lc' 'pnpm build && node --input-type=module -e '\''import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { execFileSync } from "node:child_process";

const sources = [
  "packages/llm-core/src/model-data.ts",
  "packages/llm-core/src/types.ts",
  "packages/model-catalog-core/src/model-catalog-types.ts",
  "src/config/types.models.ts",
];
const expected = [
  "dce338cd34e280221a513e01ba945ab1c6b4bab7",
  "4c685d66f58914dc1b891a859fce1b2de9165b8f",
  "bdd6fe31ff2fe77adbe592ddb51396e2f18bf661",
  "0debf71c3a0339c644d20a6faa05fe279f803564",
];
assert.deepEqual(execFileSync("git", ["hash-object", ...sources], { encoding: "utf8" }).trim().split("\n"), expected);
const walk = (root) => fs.readdirSync(root, { withFileTypes: true }).flatMap((entry) => {
  const file = path.join(root, entry.name);
  return entry.isDirectory() ? walk(file) : [file];
});
const declarations = walk("dist").filter((file) => /\.d\.[cm]?ts$/.test(file));
assert(declarations.some((file) => file.startsWith("dist/plugin-sdk/")));
assert.deepEqual(declarations.filter((file) => fs.readFileSync(file, "utf8").includes("@openclaw/llm-core")), []);
const catalog = await import("./packages/model-catalog-core/dist/model-catalog-types.mjs");
assert.equal(catalog.MODEL_CATALOG_APIS.length, 10);
assert.equal(catalog.isModelCatalogThinkingFormat("qwen-chat-template"), true);
assert.equal(catalog.isModelCatalogThinkingFormat("unknown"), false);
assert.equal(Object.keys(catalog).some((key) => key.startsWith("MODEL_DATA_")), false);
console.log(JSON.stringify({ sourceFiles: sources.length, declarations: declarations.length, privateLlmSpecifiers: 0, builtCatalog: "passed" }));
'\'' && OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs'

Share data-only API and thinking values, media limits, raw pricing and nested routing shapes. Preserve all public exports, own routing members, optional catalog rates, and separate exported array identities.

Proof: catalog normalization/pricing and model schema suites (124 passed), config docs check, exact type/augmentation probes, and independent autoreview clean. Clean Testbox build/check in progress.
@clawsweeper

clawsweeper Bot commented Sep 7, 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 size: M maintainer Maintainer-authored PR labels Sep 7, 2026
@steipete
steipete marked this pull request as ready for review September 7, 2026 05:40
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 7, 2026, 1:46 AM ET / 05:46 UTC.

ClawSweeper review

What this changes

The PR shares model metadata definitions across runtime models, catalogs, and configuration while preserving existing exports and accepted values.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open. This is a focused, useful consolidation that is absent from the fetched main revision, and no actionable correctness defect was found. The maintainer-authored, protected PR is not eligible for cleanup closure.

Priority: P3
Reviewed head: d77aaf1e341543dc3d773186ceb030ce073dd7fd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused consolidation with preserved contracts, relevant reported validation, and no actionable review findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this internal refactor from external-contributor proof requirements. Reported type and schema checks address the changed contracts; the built-catalog smoke remains unverified, and no authority-chain exception applies.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this internal refactor from external-contributor proof requirements. Reported type and schema checks address the changed contracts; the built-catalog smoke remains unverified, and no authority-chain exception applies.
Evidence reviewed 7 items Verified introduced patch: The local merge-base-to-head diff matches the supplied introduction evidence. It extracts identical primitive shapes, preserves optional catalog pricing, retains routing interface members, and copies arrays to preserve separate identities.
Current-main necessity: The three existing consumer files are unchanged between the pinned merge base and fetched main; main still contains the duplicated definitions.
Latest release check: The shared metadata leaf is absent from the supplied latest release, v2026.9.2. No verified merged replacement was established.
Findings None None.
Security None None.

How this fits together

Model metadata describes supported APIs, reasoning settings, pricing, and media limits. Configuration validation and catalog normalization consume these definitions before models reach provider request handling.

flowchart LR
  A[Provider metadata] --> B[Catalog normalization]
  C[User configuration] --> D[Configuration validation]
  E[Shared metadata definitions] --> B
  E --> D
  E --> F[Runtime model types]
  B --> F
  D --> F
  F --> G[Provider request handling]
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
Agent review details

Security

None.

PR surface

Source -33. Total -33 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 4 155 188 -33
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 155 188 -33

Review metrics

None.

Technical review

Best possible solution:

Keep shared metadata in the dependency-free leaf while preserving public names, array identities, optionality, and owner-specific model contracts.

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

Not applicable: this PR consolidates existing definitions rather than reporting a runtime defect; the duplicated definitions are visible in current main.

Is this the best way to solve the issue?

Yes. Sharing primitive shapes while retaining separate public arrays and routing interface members is a narrow approach that preserves the inspected contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is internal metadata deduplication with no intended user-visible behavior or configuration change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER association exempts this internal refactor from external-contributor proof requirements. Reported type and schema checks address the changed contracts; the built-catalog smoke remains unverified, and no authority-chain exception applies.

Label justifications:

  • P3: This is internal metadata deduplication with no intended user-visible behavior or configuration change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER association exempts this internal refactor from external-contributor proof requirements. Reported type and schema checks address the changed contracts; the built-catalog smoke remains unverified, and no authority-chain exception applies.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 7e8cffd into main Sep 7, 2026
252 checks passed
@steipete
steipete deleted the steipete/dedup-model-data-primitives-0906 branch September 7, 2026 06:00
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
Share data-only API and thinking values, media limits, raw pricing and nested routing shapes. Preserve all public exports, own routing members, optional catalog rates, and separate exported array identities.

Proof: catalog normalization/pricing and model schema suites (124 passed), config docs check, exact type/augmentation probes, and independent autoreview clean. Clean Testbox build/check in progress.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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