Skip to content

refactor(models): consolidate prepared catalog construction - #130654

Merged
steipete merged 2 commits into
mainfrom
codex/prepared-catalog-construction
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/prepared-catalog-construction

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Related: #130600 (model-list preparation cleanup).

What Problem This Solves

Prepared model construction still repeated work already owned by its producers: full provider-static catalogs rebuilt provider request settings once per row, four consumers reparsed the same configured references, and disk-backed versus captured plugin catalogs repeated the same shard ingestion loop.

This is an AI-assisted, maintainer-requested internal cleanup. No intended user-visible behavior change.

Why This Change Was Made

Use the existing inline provider builder once per nonempty provider, carry parsed configured references from agent-fact preparation, and send both catalog-shard sources through the existing ingestion owner. Remove the private static-resolver forwarding function and unused internal cache-reset exports. The public agent-sessions SDK exports neither reset function; command-result caching itself is unchanged.

Production: +58/-134 (net -76). Tests: +152/-68 (net +84). No dependency, public SDK, config/default, protocol, storage or auth-policy change.

User Impact

Model selection and catalog output retain the same behavior. Targeted configured lookup stays lazy; only paths that already enumerate a provider batch use batch projection. Empty providers still skip request-secret resolution. Custom transport APIs, partial costs, zero/false values, and attached request/local-service/generation metadata survive projection.

Configured references keep their order and case: static/dynamic completion may deduplicate case-insensitively, while exact registry lookup must still try a later differently cased reference. Raw collection remains available to provider selection and external CLI auth hydration. Catalog root validation, generated-owner filtering, healthy sibling salvage, and warning order are unchanged.

Evidence

  • Read complete construction owners, callers, callee contracts and affected tests: static/inline catalogs, prepared facts/configured completion/catalog projection, configured-reference collection/parsing, model registry and config-value resolution, agent discovery, prepared registry, and owner-selection tests. Request metadata consumers copy before replacing attached transport values.
  • Baseline: 128 tests across eight files passed. Expanded existing tests then passed against the old production implementation: 38 tests across three files. These prove retained contracts, not a newly claimed regression fix.
  • After refactor: all 129 tests across the same eight files passed. The expanded cases cover heterogeneous rows, empty providers with unresolved unused request metadata, request/local-service/generation facts, exact-case registry fallback, provider-only discovery scope, and invalid persisted/captured sibling shards.
  • Independent Codex autoreview passed on the complete patch with no actionable findings.
  • The CLI-startup build passed all seven phases, including the import guard and 48 built plugin control-plane modules. The actual rebuilt CLI exactly matches baseline JSON for all four views: default (2 rows), all (224), local (1), and provider-filtered (1). No authenticated inference is claimed for this behavior-neutral construction refactor.
  • Full changed-file checks passed: formatting, ratchets, all unused-export scans, production/test typechecking, lint, and architecture/storage/import guards. The first run caught shadowed test callback parameters; the mechanical rename passed a focused rerun and independent review, then the full gate passed.
  • Exact-head CI run 33036768878 is green for b14bfcc9b74f37d92423468a8d393229a4d8c330, including all 65 selected plugin shards.
  • Live inspection confirms perf(gateway): skip provider catalog rewarm on rate limits #125906 addresses auth cooldown/session listing/startup surfaces, not these construction files. No related repair is being duplicated by this batch.

Focused command (checkout-local Vitest cache used):

node scripts/run-vitest.mjs \
  src/agents/embedded-agent-runner/model.static-catalog.test.ts \
  src/agents/embedded-agent-runner/model.static-catalog.prepared.test.ts \
  src/agents/prepared-model-runtime.test.ts \
  src/agents/prepared-model-runtime.startup-static.test.ts \
  src/agents/prepared-model-runtime.owner-selection.test.ts \
  src/agents/sessions/model-registry.test.ts \
  src/agents/agent-model-discovery.test.ts \
  src/agents/prepared-model-registry.test.ts

The measured suite was 62.68s/1,114,128,384-byte maximum RSS before and 101.39s/1,109,884,928-byte maximum RSS after. The after run overlapped full checks on a shared host, so these are recorded observations, not a speedup claim.

Follow-up batch: remove unreachable/repeated prepared-owner access paths while preserving replacement-gate, timeout, lease and publication semantics. A schema-only registry split was considered and rejected because it merely moves code and adds exports without addressing another demonstrated ownership problem.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete steipete self-assigned this Aug 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 03:34
@steipete
steipete merged commit 8dac217 into main Aug 27, 2026
273 checks passed
@steipete
steipete deleted the codex/prepared-catalog-construction branch August 27, 2026 03:54
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…#130654)

* refactor(models): consolidate prepared catalog construction

* test(models): avoid shadowing registry fixture identifiers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant