Repository navigation
feat(cli): [router] config, tole route dry run and doctor lines (#586 part 1b) - #651
Merged
Merged
Conversation
tole_core::router: a Router returns a Route (tier light/standard/heavy, source, reason), never a model name, budget, allow list or secret. RuleRouter takes every matching rule, picks the cheapest tier (ties go cheaper; the first rule of that tier names the route), narrows to an allowed-tier set, and keeps the configured model when nothing matches. check() refuses a rule whose tier is not declared where it resolves or an unknown profile, naming the remedy. Route::record redacts with the process secrets before it caps. Platform-agnostic, no new dependency.
…part 1b) [router] is off unless the user config says enabled = true. Tiers ([router.tiers], profiles.<name>.models) and rules come from the user config only; a project config can only set enabled = false or narrow allow_tiers, and anything else is ignored with a warning. An unknown tier, kind or risk, an undeclared tier or an unknown profile is a load error naming the remedy, never a fallback to another model. tole route prints the tier, model and reason a run would get without calling a provider, redacted; tole doctor and config check show names only.
This was referenced Nov 12, 2026
A matching rule replaces the configured model, whether it comes from TOLE_MODEL, the config's model or a profile's default; only a session's own model and a cron job's --model pin are never routed. tole route now prints that configured model and where it came from (for example "from env TOLE_MODEL"), and the docs say both rules plainly, along with rules without profiles applying only to runs without a profile.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
Part 1b of #586: the
[router]config, thetole routedry run, and thetole doctor/config checklines. Nothing routes runs yet. #652 (part 2) does the wiring, off by default, and is stacked on this PR.Depends on: #650 (part 1a,
tole_core::router), which is merged. This branch has the latestdevelopmerged in (a merge commit), and the PR now targetsdevelop.Why
Owners need to declare tiers and rules, check them at load time, and see what a prompt would get before any run is routed. A cloned repository must not be able to route to a model the user did not declare.
Changes
config.rs:RouterConfig(enabled,allow_tiers,[router.tiers],[[router.rules]]) withdeny_unknown_fields.layeredtakes tiers and rules from the user layer only.config checkshows the state, tier names and rule names, never models or keywords.routing.rs(new):compilevalidates every rule with a remedy: an unknown tier, kind or risk, a bad rule or profile name, duplicate names,min_chars > max_chars, bad keywords, at most 64 rules.layered: a project can only setenabled = falseor narrowallow_tiers(intersected with the user's).project_warningwarns about anything else.Routing::from_config:Noneunless the user config saysenabled = true;Routing::decidereturns the route and the model it selects.Nonekeeps the configured model.doctor_lines: names only.explain: the dry-run text, with every string redacted before it is capped.Owner decisions (2026-11-13), now stated in the docs and the output:
TOLE_MODEL, the config'smodelor a profile's default. Only a session's own model (/model, ACP) and a cron job's--modelpin are never routed.profilesapplies only to runs without a profile and resolves through[router.tiers]. A rule withprofilesresolves throughprofiles.<name>.models.tole route PROMPT [--kind] [--risk] [--job] [--budget-left](with the global--profile) prints:configured model: m (from env TOLE_MODEL).It calls no provider.
tole doctorprints the router lines from the user config and fails on a broken router.Docs: CHANGELOG
[Unreleased], design A9.3 "as implemented, part 1", a README config row and usage line, and a threat-model row.Dependencies: no change.
Testing
cargo fmt --allcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspacecargo test -p tole-core --no-default-featurescargo check -p tole-cli --no-default-featurescargo clippy -p tole-cli --no-default-features --features shell-tools -- -D warningscargo test -p tole-cli --no-default-featuresdevelop.cora review --no-llm --staged: no issues.routing_tests.rs: 7 unit tests;tests/route_cli.rs: 2 tests on the real binary, including the configured model's source (from env TOLE_MODEL).allow_tiers;--kind;