M2: router gate (LLM-judge classifier, fail-open) - #26
Merged
Merged
Conversation
Signed-off-by: Jannes Stubbemann <jannes.stubbemann@gmail.com>
Signed-off-by: Jannes Stubbemann <jannes.stubbemann@gmail.com>
Signed-off-by: Jannes Stubbemann <jannes.stubbemann@gmail.com>
Signed-off-by: Jannes Stubbemann <jannes.stubbemann@gmail.com>
…eline Signed-off-by: Jannes Stubbemann <jannes.stubbemann@gmail.com>
Signed-off-by: Jannes Stubbemann <jannes.stubbemann@gmail.com>
Add the metrics facade crate (0.24, matching chorus-server) to chorus-core and increment a counter labelled by profile name and decision branch (fuse/single) next to the existing tracing::info! call in Pipeline::run. The counter is a no-op without a recorder installed, so existing tests are unaffected. Signed-off-by: Jannes Stubbemann <jannes.stubbemann@gmail.com>
…s, boundary test - Hoist metrics = "0.24" into [workspace.dependencies]; replace direct pins in chorus-core and chorus-server with metrics.workspace = true (DRY). - Replace silent unwrap_or_else fallback in Pipeline::router_for "classifier" arm with an if-let that emits tracing::warn! and returns AlwaysFuse when classifier_model is None (config validation normally prevents this, but the fallback now fails safe to higher-quality fusion rather than misusing single_model as the scorer). - Add /// doc comments to RouterConfig::classifier_model and ::threshold matching the style of nearby AggregatorConfig fields. - Add score_at_threshold_fuses test in classifier_tests: score == threshold routes to Fuse because the comparison is score < threshold (equality fuses). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Jannes Stubbemann <jannes.stubbemann@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the router gate, the M1 design's primary cost lever: a profile can route easy queries to a single model and fuse only the hard ones. Built TDD against
docs/plans/2026-06-18-m2-router-gate.md, each task independently reviewed plus a final whole-branch review.RouterConfiggainspolicy(always_fuse|classifier),classifier_model, andthreshold, with validation (policy known, model required for classifier, threshold in 0.0..=1.0, loop-guard covers the classifier model).ClassifierRouter: a cheap LLM-judge scores query difficulty 0..1; fuse if score >= threshold, else route to the single model. Fails OPEN to fusion on any backend error or unparseable score.Pipeline::newsignature unchanged sochorus-serverneeded no edits. Achorus_router_decisions_total{profile,decision}metric is emitted for both branches.metricshoisted to a workspace dependency.Deferred to the deploy track (needs live inference): threshold calibration on real traffic and the budget-panel sovereignty benchmark. The SearXNG tool adapter remains M2 scope, not in this PR.
Test Plan
cargo test --workspace(41 tests: 39 unit + 2 integration)cargo clippy --workspace --all-targets -- -D warningscleancargo fmt --all -- --checkcleancargo deny checkok🤖 Generated with Claude Code