Skip to main content

Routing

Struct Routing 

Source
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: ModelRules

The 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

Source

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].

Source

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.

Source

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.

Source

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.

Source

pub fn restricts_models(&self) -> bool

Whether anything in this table restricts model choice at all.

Source

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§

Source§

impl Clone for Routing

Source§

fn clone(&self) -> Routing

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Routing

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Routing

Source§

fn default() -> Routing

Returns the “default value” for a type. Read more
Source§

impl Eq for Routing

Source§

impl PartialEq for Routing

Source§

fn eq(&self, other: &Routing) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Routing

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more