Skip to main content

lean_ctx/core/
model_router.rs

1//! Thompson Sampling model router (OSS stub).
2//!
3//! Enterprise selects the optimal LLM per task class using multi-armed bandits.
4//! OSS: no-op (pass-through to configured model).
5
6/// Global model router accessor (OSS: no-op mutex).
7pub fn global_model_router() -> &'static std::sync::Mutex<ModelRouter> {
8    use std::sync::Mutex;
9    static ROUTER: std::sync::LazyLock<Mutex<ModelRouter>> =
10        std::sync::LazyLock::new(|| Mutex::new(ModelRouter));
11    &ROUTER
12}
13
14/// Model router (OSS: no-op).
15pub struct ModelRouter;
16
17impl ModelRouter {
18    /// Selects a model from candidates (OSS: returns first).
19    pub fn select_model<'a>(&self, _task_class: &str, candidates: &'a [&str]) -> &'a str {
20        candidates.first().copied().unwrap_or("default")
21    }
22
23    /// Records outcome for learning (OSS: no-op).
24    pub fn record_outcome(&mut self, _model: &str, _task_class: &str, _accepted: bool, _cost: f64) {
25    }
26}