pub struct Routing {
pub aliases: Vec<(String, String)>,
pub models: Vec<(String, ModelRules)>,
pub defaults: ModelRules,
pub allowed: Vec<String>,
pub denied: Vec<String>,
pub provider: Option<String>,
pub account: Option<String>,
}Expand description
The whole resolved routing table, carried on
crate::Config::model_routing and consulted by every routing decision.
It keeps the PATTERNS rather than one pre-resolved answer on purpose: a
mid-session model switch has to re-decide effort, budget, tier and tool
bits for the NEW model, and it does that by asking this same value again
(Routing::rules_for) rather than by re-reading config elsewhere.
Fields§
§aliases: Vec<(String, String)>Alias → slug entries from the config, in precedence order: the
declared account’s scope, then the declared provider’s, then the flat
table. Consulted before DEFAULT_ALIASES. A key may be a *
pattern, in which case the value may contain {} — replaced by the
captured stem after that stem is itself alias-resolved (Claude Code’s
sonnet[1m] shape).
models: Vec<(String, ModelRules)>[capabilities.model_catalog.models.<pattern>], least specific
first, so overlaying in order leaves the most specific rule winning.
defaults: ModelRulesThe table’s own top-level rules — the baseline every model inherits.
allowed: Vec<String>allowed_models: when non-empty, a model matching NO entry is
refused outright.
denied: Vec<String>denied_models: a model matching any entry is refused outright.
provider: Option<String>The declared provider whose alias scope is in force (provider).
account: Option<String>The declared account/plan tier whose alias scope is in force
(account) — Claude Code’s account-type defaults (cc§9).
Implementations§
Source§impl Routing
impl Routing
Sourcepub fn resolve_alias(&self, model: &str) -> String
pub fn resolve_alias(&self, model: &str) -> String
Expand a friendly model name to a full slug through this table, then
DEFAULT_ALIASES, then unchanged pass-through.
Exact entries always beat patterns, and among patterns the most
specific wins. A pattern’s {} placeholder receives the captured
stem RE-RESOLVED through this same function (depth-capped), which is
what makes sonnet[1m] land on anthropic/claude-sonnet-4-6[1m]
rather than on the literal text sonnet[1m].
Sourcepub fn rules_for(&self, model: &str) -> ModelRules
pub fn rules_for(&self, model: &str) -> ModelRules
The rules in force for model: the table defaults with every
matching models.<pattern> overlaid, least specific first.
Sourcepub fn effective_effort(
&self,
model: &str,
session_effort: Option<&str>,
) -> Option<String>
pub fn effective_effort( &self, model: &str, session_effort: Option<&str>, ) -> Option<String>
The effort level to send for model, given the session’s
[core] effort: the per-model level if one is set, else the session
level, clamped by whichever effort cap applies.
Sourcepub fn refusal(&self, model: &str) -> Option<String>
pub fn refusal(&self, model: &str) -> Option<String>
Why model is refused, or None when it is allowed — the
CONFIG-layer half of the org model allowlist. A denied model can
never be selected, and with an allowlist set nothing outside it can.
Sourcepub fn restricts_models(&self) -> bool
pub fn restricts_models(&self) -> bool
Whether anything in this table restricts model choice at all.
Sourcepub fn from_capabilities(
capabilities: &BTreeMap<String, CapabilityConfig>,
) -> Routing
pub fn from_capabilities( capabilities: &BTreeMap<String, CapabilityConfig>, ) -> Routing
Build the routing table from [capabilities.model_catalog].
Consulted regardless of the module’s enabled flag, for the same
reason resolve is: these are data a caller resolves against, not
an activation switch (and the D-9 resolver check already reads
small_model unconditionally).
Trait Implementations§
impl Eq for Routing
impl StructuralPartialEq for Routing
Auto Trait Implementations§
impl Freeze for Routing
impl RefUnwindSafe for Routing
impl Send for Routing
impl Sync for Routing
impl Unpin for Routing
impl UnsafeUnpin for Routing
impl UnwindSafe for Routing
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.