pub enum CompiledRoutingPolicy {
FallbackChain {
name: String,
cheap: Box<RouteTarget>,
escalate_to: Box<RouteTarget>,
classifier_url: String,
classifier_model: String,
threshold: f64,
timeout_ms: u64,
api_key: Option<String>,
},
LatencyCost {
name: String,
candidates: Vec<RouteTarget>,
candidate_models: Vec<String>,
candidate_costs: Vec<u32>,
candidate_latencies: Vec<u32>,
preference: AiLatencyPreference,
live_tracker: Option<Arc<LiveLatencyTracker>>,
},
}Expand description
A compiled routing policy (DW-085). Built at AiRuntime compile
time from the config block; immutable once built. The
evaluate method returns the candidate list to
walk (the same shape as AiRuntime::route)
plus a PolicyDecision the dataplane records as a metric.
Variants§
FallbackChain
Cheap-first with complexity-signal escalation. The
evaluate call POSTs the prompt to the external classifier
service and picks the cheap or escalate-to target by the
returned score.
Fields
cheap: Box<RouteTarget>The primary target of the cheap alias.
escalate_to: Box<RouteTarget>The primary target of the escalate_to alias.
LatencyCost
Latency-vs-cost static selection. Candidates are pre-sorted at
compile time by the configured preference; evaluate returns
the best one (no I/O).
Fields
candidates: Vec<RouteTarget>Candidates sorted best-first by the preference (the first is the pick).
candidate_models: Vec<String>AI-15 (#203): the model alias for each candidate (for
live latency tracking). Parallel to candidates.
preference: AiLatencyPreferenceAI-15 (#203): the selection preference.
live_tracker: Option<Arc<LiveLatencyTracker>>AI-15 (#203): live latency tracker. None when live is
false (static selection).
Implementations§
Source§impl CompiledRoutingPolicy
impl CompiledRoutingPolicy
Sourcepub fn compile(
name: &str,
policy: &AiRoutingPolicy,
models: &BTreeMap<String, CompiledModel>,
) -> Option<Self>
pub fn compile( name: &str, policy: &AiRoutingPolicy, models: &BTreeMap<String, CompiledModel>, ) -> Option<Self>
Compile from config. Resolves each named alias to its primary
RouteTarget against the first-pass compiled model map
(plain chain/canary aliases only — a policy alias cannot
reference another policy alias, so nested policies are
rejected by returning None). Returns None when a referenced
alias is missing or is itself a policy alias (a
validate-vs-build race or an authoring error validation
missed).
Sourcepub async fn evaluate(
&self,
prompt_text: &str,
) -> (Vec<RouteTarget>, PolicyDecision)
pub async fn evaluate( &self, prompt_text: &str, ) -> (Vec<RouteTarget>, PolicyDecision)
Evaluate the policy for one request. Returns the candidate
list to walk (the same shape as
AiRuntime::route) plus a
PolicyDecision the dataplane records as a metric. For
FallbackChain, this calls the external classifier service
(async). For LatencyCost, the candidates are pre-sorted at
compile time, so this is effectively synchronous.
Sourcepub fn live_tracker(&self) -> Option<&Arc<LiveLatencyTracker>>
pub fn live_tracker(&self) -> Option<&Arc<LiveLatencyTracker>>
AI-15 (#203): Get the live latency tracker for this policy. Returns None when live tracking is not enabled.
Trait Implementations§
Source§impl Clone for CompiledRoutingPolicy
impl Clone for CompiledRoutingPolicy
Source§fn clone(&self) -> CompiledRoutingPolicy
fn clone(&self) -> CompiledRoutingPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CompiledRoutingPolicy
impl RefUnwindSafe for CompiledRoutingPolicy
impl Send for CompiledRoutingPolicy
impl Sync for CompiledRoutingPolicy
impl Unpin for CompiledRoutingPolicy
impl UnwindSafe for CompiledRoutingPolicy
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more