use vyre_foundation::execution_plan::ExecutionPlan;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum RoutingDecision {
CpuSimd,
GpuPipeline,
PersistentMegakernel,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct RoutingExplanation {
pub policy: &'static str,
pub decision: RoutingDecision,
pub reason: &'static str,
}
pub trait RoutingPolicy: Send + Sync {
fn name(&self) -> &'static str;
fn route(&self, plan: &ExecutionPlan) -> RoutingDecision;
fn route_with_explanation(&self, plan: &ExecutionPlan) -> RoutingExplanation {
RoutingExplanation {
policy: self.name(),
decision: self.route(plan),
reason: "policy returned route without extended evidence",
}
}
}
pub struct RoutingEngine {
policy: Box<dyn RoutingPolicy>,
}
impl RoutingEngine {
pub fn new(policy: impl RoutingPolicy + 'static) -> Self {
Self {
policy: Box::new(policy),
}
}
pub fn route(&self, plan: &ExecutionPlan) -> RoutingDecision {
self.policy.route(plan)
}
pub fn route_with_explanation(&self, plan: &ExecutionPlan) -> RoutingExplanation {
self.policy.route_with_explanation(plan)
}
}
pub mod standard_policy;