Repository navigation
feat(core): Router seam and deterministic RuleRouter (#586 part 1a) - #650
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.
🔍 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 1a of #586: the
Routerseam and its deterministic baseline,RuleRouter, intole-core. Nothing routes yet. The[router]config, thetole routedry run and the doctor lines are in the stacked #651. The wiring into runs, cron runs and delegated children comes in part 2, off by default.Why
The design (
profiles-collaboration-secrets.mdA9.2/A9.3) requires a simple rule baseline before any learned router (LayaRouter) is trusted: LLMRouterBench shows many routers fail to beat one. The tie and doubt rules follow the routing-collapse result: ties go to the cheaper tier.Changes
crates/tole-core/src/router.rs(new): platform-agnostic, no I/O, no new dependency, builds with--no-default-features.Tier(light < standard < heavy, cost order) andTaskKind(chat,run,mission,cron,delegate);Brief: the owner-side facts about a run (kind, prompt, highest tool risk, profile, job, budget left). The prompt is read only for its size and the owner's keywords.Rule/When: every set condition must hold (kinds,min_chars/max_chars,min_risk/max_risk,profiles,jobs,budget_below,keywords).profilesapplies only to runs without a profile. A rule's tier is therefore always checked against the tier map it resolves through.budget_below.Routertrait andRuleRouter:Route { tier: None, source: Default }, so the configured model stays.Routecarries only a tier, a source and a reason. It has no field for a model name, budget, allow list or secret.Route::model(&Tiers)errors on an undeclared tier and never falls back to another model.Route::recordredacts every string with theSecretSetbefore capping at 300 characters.RuleRouter::checkrefuses, at load time and with a remedy, a rule whose tier is not declared where it resolves, or an unknown profile.crates/tole-core/src/router_tests.rs(new): 10 tests.[Unreleased]. The threat-model row and the design "as implemented" note are in feat(cli): [router] config, tole route dry run and doctor lines (#586 part 1b) #651, which makes the behaviour reachable.Testing
route(6 of 10 failed), then green.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-featurescora review --no-llm --staged: no issues.budget_below;max_riskis ignored;