Skip to content

registry: high-level ModelRouter (workload-tier routing layer)#54

Merged
senamakel merged 1 commit into
mainfrom
registry/model-router
Jul 11, 2026
Merged

registry: high-level ModelRouter (workload-tier routing layer)#54
senamakel merged 1 commit into
mainfrom
registry/model-router

Conversation

@senamakel

Copy link
Copy Markdown
Member

What

Adds registry::router — a high-level ModelRouter: the declarative
workload-tier layer over the named model registry, filling the long-declared
ComponentKind::Router.

Where CapabilityRegistry resolves a model by name and the agent loop fails
over across a FallbackPolicy, neither owns the policy that maps a host's
workload tiers (chat-v1, reasoning-v1, vision-v1, …) onto concrete
models, plus the per-tier capability gates and same-family fallback ordering.
Hosts have re-implemented that projection by hand (OpenHuman's RouterProvider

  • routes.rs). ModelRouter is the crate-owned home for it.

Surface

  • WorkloadRoute — one tier: alias → model, optional CapabilitySet
    gate, ordered sibling fallback aliases. Pure metadata (names a model, owns
    none); serde-friendly (skips empty requires/fallbacks).
  • ModelRouter — insertion-ordered route table + optional default alias.
    Answers the three questions turn assembly needs:
    • target_model(alias) → registered model name
    • fallback_policy(alias)[alias, fallbacks…] (leads with the primary so
      FallbackPolicy::next_after yields the alternate; None when no alternates)
    • required_capabilities(alias) → gate to stamp on requests (None = ungated)
    • Builders: infallible last-write-wins with_route/with_default, plus
      duplicate-rejecting register.

Holds no models, drives no I/O — cheap cloneable policy read while wiring a
registry + RunPolicy, keeping what routes where decoupled from how a model
is built
.

Why

Foundation for issue #4249 Phase 3 (RouterProvider → crate ModelRegistry
route-projection): a host declares its tier table once and hands it over, instead
of open-coding alias resolution + fallback ordering + capability gating at the
turn-assembly boundary.

Tests / checks

cargo fmt --check, cargo clippy --lib -- -D warnings, 9 unit tests + 1
doctest, full registry:: suite (30) green. No behavior change to existing
surfaces — purely additive.

https://claude.ai/code/session_01U8NDGbt9tKj443VquzycLB

Add `registry::router` — the declarative workload-tier layer over the named
model registry, and the crate-owned home for the projection hosts have
re-implemented by hand (OpenHuman's RouterProvider + routes.rs): map named tiers
(chat-v1, reasoning-v1, vision-v1, ...) onto concrete registered models with
per-tier capability gates and ordered same-family fallback chains.

- `WorkloadRoute` — one tier: alias -> model, optional CapabilitySet gate,
  ordered sibling fallback aliases. Pure metadata (names a model, owns none).
- `ModelRouter` — insertion-ordered route table + optional default. Answers the
  three questions turn assembly needs: target_model(alias), fallback_policy(alias)
  ([alias, fallbacks...] leading with the primary so FallbackPolicy::next_after
  yields the alternate), required_capabilities(alias). Infallible last-write-wins
  builder (with_route/with_default) + duplicate-rejecting register().

Holds no models and drives no I/O — cheap cloneable policy read while wiring a
registry + RunPolicy, so *what routes where* stays decoupled from *how a model is
built*. Fills the long-declared ComponentKind::Router. Foundation for issue #4249
Phase 3 (RouterProvider -> crate ModelRegistry route-projection).

Exported from registry::{ModelRouter, WorkloadRoute} + crate root. Module README
under src/registry/router/. 9 unit tests + 1 doctest; fmt + clippy clean.

Claude-Session: https://claude.ai/code/session_01U8NDGbt9tKj443VquzycLB
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 32 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f83a7a7c-107d-49f4-900a-94cc2279763e

📥 Commits

Reviewing files that changed from the base of the PR and between 993acca and 9d6026f.

📒 Files selected for processing (6)
  • src/lib.rs
  • src/registry/mod.rs
  • src/registry/router/README.md
  • src/registry/router/mod.rs
  • src/registry/router/test.rs
  • src/registry/router/types.rs

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d6026f714

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +184 to +186
let mut chain = Vec::with_capacity(route.fallbacks.len() + 1);
chain.push(route.alias.clone());
chain.extend(route.fallbacks.iter().cloned());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Build fallback chains from target model names

When a route maps an alias to a different model (for example WorkloadRoute::new("chat-v1", "gpt-4.1-mini")), callers following this API use target_model("chat-v1") for the request model, so the agent loop's fallback cursor is the resolved target model name. This policy starts with route.alias and copies fallback aliases, so FallbackPolicy::next_after(&cursor) will not find the current model and no fallback is selected. Resolve the primary and fallback aliases to their route.model values, or keep dispatch consistently on aliases, before constructing the policy.

Useful? React with 👍 / 👎.

@senamakel senamakel merged commit 4fc8cd8 into main Jul 11, 2026
3 checks passed
@senamakel senamakel deleted the registry/model-router branch July 11, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant