Repository navigation
feat: edit routes and groups as resources, and let the dry run say which route it used - #44
Merged
Merged
Conversation
…ich route it used
Routing could only be changed through generic patches, which can append and
remove but not insert or move. The UI therefore appended every new rule after
the catch-all, where its forward or deny can never be chosen, while the config
stayed perfectly valid.
Routes and groups are now resources, like providers and proxies:
- POST /routes, PUT /routes/{name}: a whole route per write, rules in the
order given. Renaming moves the keys that use it and default_route in the
same version. `keys` sets exactly which keys use the route; keys moved out
fall back to the default route.
- DELETE /routes/{name}?reassign_to=: the keys that use it move to the route
the user picked, or to the default route. The default route cannot be
deleted.
- PUT /default_route. Moving the default away from the synthesised one
writes that route into the file first, so it stays as an ordinary route.
- POST /groups, PUT/DELETE /groups/{name}: renaming moves the rules that
forward to the group; a group still referenced cannot be deleted.
- GET /models: every model the gateway can serve and which upstreams serve it.
The engine and the views change to match:
- The built-in "all upstreams" group (__all__) exists whenever there are
upstreams, not only while the default route is synthesised. Writing the
default route into the file used to make its own catch-all invalid.
- The synthesised catch-all rule is called 兜底; names starting with __ are
reserved; duplicate group names are rejected.
- A rule that only adds a guard is valid.
- The overview gives every rule in full (conditions, target, deny reason,
rewrite, guard) plus catch_all / phase_two / shadowed, marks the
synthesised route and group as builtin, reports routes without a
catch-all, and judges cache risk per group, so a sticky round robin is no
longer flagged.
The dry run no longer falls back to the first key in the file: it evaluates
a key's route, a named route, or an unsaved draft, returns the route it
used, and says for each matching rule whether it decided, added something,
or had no effect. It also stops blaming a numeric condition that held, and
treats assistant_internal as any assistant request when explaining a miss.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ch to the router A rule's intent condition only ever matches requests whose class is set to route; the rest are answered locally or passed through before routing and carry no class. route_probes sets the chosen classes to route in the same write as the route, so a new intent rule does not silently never match. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Thanks for the PR. One thing before review: this targets
No need to close and reopen: click Edit next to the PR title and change the base branch to See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract. |
Merged
fylorn
added a commit
that referenced
this pull request
Sep 19, 2026
Routes and groups are edited as resources (#44): a whole route per write with rules in the order given, keys and the default route moved along on rename, and the keys of a deleted route sent where the user picked. The built-in all-upstreams group stays once the default route is written down, a rule may carry only a guard, and the dry run evaluates a key's route, a named route or an unsaved draft and says which route it used. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
3 tasks done
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.
Why
Routing could only be changed through the generic config patch, which can append and remove but not insert or move. The desktop UI therefore appended every new rule after the catch-all, where its forward or deny can never be chosen, while the config stayed perfectly valid. Rules could not be edited in place either, and the dry run silently fell back to the first key in the file, so it could answer for a different route than the one the user had in mind.
This is the core half of the routing page redesign in ThinkWatch-Lite.
What
Routes and groups are resources, like providers and proxies:
POST /routes,PUT /routes/{name}— one whole route per write, rules in the order given. Renaming moves the keys that use it anddefault_routein the same version.keyssets exactly which keys use the route; keys moved out fall back to the default route.route_probessets the chosen assistant request classes toroutein the same write, since anintentcondition never matches classes that are answered locally or passed through.DELETE /routes/{name}?reassign_to=— the keys that use it move to the route the user picked, or to the default route. The default route cannot be deleted.PUT /default_route— moving the default away from the synthesised route writes that route into the file first, so it stays as an ordinary route.POST /groups,PUT/DELETE /groups/{name}— renaming moves the rules that forward to the group; a group still referenced cannot be deleted; the built-in group cannot be edited.GET /models— every model the gateway can serve and which upstreams serve it (same catalog as/v1/models), for suggestions.Engine and views:
__all__) exists whenever there are upstreams, not only while the default route is synthesised. Writing the default route into the file used to make its own catch-all invalid.兜底; names starting with__are reserved; duplicate group names are rejected.When::is_catch_allnow accounts forintent.catch_all/phase_two/shadowed, marks the synthesised route and group asbuiltin, reports routes without a catch-all, and judges cache risk per group, so a sticky round robin is no longer flagged.Dry run: evaluates a key's route, a named route, or an unsaved draft, and refuses rather than guessing when given none. The result names the route it used, and each matching rule says whether it decided the outcome, added something, or had no effect. It also stops reporting a numeric condition that held as the mismatch, and treats
assistant_internalas any assistant request when explaining one.Breaking changes
RuleView.denyis now the reason (Option<String>) instead of a flag, and/dryrunreturns 400 withoutclient,routeordraft. The desktop app is the only consumer and moves in lockstep.Checks
cargo fmt --check,cargo clippy --workspace --all-targets -D warnings,cargo test --workspaceandscripts/smoke.sh(49 passed, 0 failed) pass locally. New tests:tests/routes.rs(19), new cases intests/dryrun.rs, engine and config unit tests.🤖 Generated with Claude Code