Skip to content

refactor(agents): separate pure model references from runtime normalization - #203095

Merged
vincentkoc merged 2 commits into
mainfrom
refactor/model-reference-normalization-owner
Nov 21, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
refactor/model-reference-normalization-owner

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Pure model-key and formatting consumers inherit manifest and provider-runtime imports from a mixed reference module.

Fixes #203078

User Impact

No intended behavior or public contract change. Pure reference consumers lose those runtime dependency edges; no performance improvement is claimed.

Why This Change Was Made

Moves the six normalizers and private closure into the existing normalization owner, with complete caller cutover across 32 files. Preserves scalar, captured and lazy factory behavior, runtime-generation ownership, lookup semantics and SDK declaration anchors.

Moves the unchanged compaction assertion helper into its already-used owner to satisfy the existing line-cap ratchet. Every case, assertion and typed dynamic-import timing is preserved.

Evidence

  • 421 focused cases across 23 suites and four owning test type graphs passed before the three-line import type correction and are reused.
  • Corrected head: core types, scoped typed lint, two cold-import positives and two exact-denial controls, local normal build and qualified abliteration cold import passed; hosted build skipped.
  • Scoped emitted SDK declarations, type origins and export mappings inspected; signed hooks, line cap and fresh full-range source review passed.
  • Build exited 0 with seven report-only UI budget violations; attribution remains undetermined.
  • Exact-head CI and security passed after one job-only recovery from a 15-minute CI job timeout; the original overrun cause remains unknown.
  • Final native revalidation and landing remain pending.

@vincentkoc vincentkoc self-assigned this Nov 21, 2026
@clawsweeper

clawsweeper Bot commented Nov 21, 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 commands Command implementations agents Agent runtime and tooling size: M labels Nov 21, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 21, 2026
@clawsweeper

clawsweeper Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR moves model normalization into its existing normalization module so pure model-reference consumers avoid runtime imports.

Example: A fallback skip marker constructs the key openai/gpt-5.

  • Before: Importing modelKey also loads manifest-policy and provider-runtime dependencies.
  • After: The same key is constructed through a runtime-free reference module.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Execution evidence is thin despite a coherent patch and no identified source defect.
Proof confidence 🦪 silver shellfish (2/6) This internal refactor has no intended user-visible behavior change and requires no shipped-entry-point demonstration.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: No observed user-facing failure; pure model-reference consumers inherit unnecessary runtime dependencies.
Reason: The maintainer-authored direction removes a concrete dependency coupling through existing owners without adding behavior or public surface.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this maintainer-authored PR open: the focused separation is coherent, and source review found no actionable defect.

Priority: P3
Reviewed head: 5d5efaf1a357bfd9f5ccd14eb3bed0dca461631a

Before merge

  • Complete next step - PR owner: add and run the linked issue’s cold-import boundary regression with its denial control, run affected normalization and caller suites plus owning typechecks, and complete pnpm build and emitted SDK/API classification.

Findings

None.

Agent review details

How this fits together

Model-reference helpers serve fallback, catalog, onboarding, SDK, and runtime consumers; pure helpers format keys, while normalization combines provider IDs, manifest policies, and prepared runtime hooks.

flowchart TD
  A[Pure reference consumers] --> B[Model reference helpers]
  B --> C[Pure catalog primitives]
  D[Normalization consumers] --> E[Model selection normalization]
  E --> C
  E --> F[Manifest policies]
  E --> G[Prepared provider hooks]
Loading

Technical review

Best possible solution:

Keep pure reference helpers runtime-free and all normalization in the existing normalization owner while preserving results, lifecycle semantics, and SDK contracts.

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

Current-main static imports establish the dependency coupling through real pure-key consumers; no functional failure is alleged, and no target code was executed.

Is this the best way to solve the issue?

The existing normalization module can absorb the implementations without another module, forwarder, cache, or public API, and the inspected cutover preserves their logic.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit cdb8d32 adds src/agents/model-ref-shared.ts:162 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cdb8d32bccf6; files: src/agents/model-ref-shared.ts)
  • Vincent Koc: Raw commit d13869a adds src/agents/model-selection-normalize.ts:85 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d13869aab94d; files: src/agents/model-selection-normalize.ts)

PR surface

Source -5, Tests +2. Total -3 across 32 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 25 170 175 -5
Tests 7 15 13 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 32 185 188 -3

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.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #203078
Summary: This PR implements the precise ownership separation requested by the linked issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P3: Internal dependency cleanup has no reported user-facing failure or measured resource benefit.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: Internal dependency cleanup has no reported user-facing failure or measured resource benefit.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed November 21, 2026, 8:26 AM ET / 13:26 UTC.

@vincentkoc
vincentkoc marked this pull request as ready for review November 21, 2026 14:14
@vincentkoc
vincentkoc merged commit 423ae09 into main Nov 21, 2026
310 of 312 checks passed
@vincentkoc
vincentkoc deleted the refactor/model-reference-normalization-owner branch November 21, 2026 14:57
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
…zation (openclaw#203095)

* refactor(agents): separate pure model references from runtime normalization

* refactor(agents): erase type-only model reference imports
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
* perf(agents): prepare fallback rate-limit routes with model snapshots

Reuse configured fallback models within the admitted config snapshot and share provider handles across configured normalization hooks. Preserve cold resolution for standalone or mismatched snapshots and reload route facts with their owning snapshot.

* fix(agents): preserve static model selection during fallback preparation

Skip projection for agents without configured fallbacks. Match the production plugin-runtime scope in fallback benchmarks and regressions so both variants use the same retained registry.

(cherry picked from commit 2b58c8e)

Companion audit: #201632 is selected to preserve registry and metadata ownership for the fallback hot path. #200605, #203901, #203095 and #202618 make independent TUI, custody, module separation and model listing changes; none is required by this port.

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

Labels

agents Agent runtime and tooling commands Command implementations P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(agents): separate pure model references from runtime normalization

1 participant