new-api/middleware
zizi 0427cd067a Let Muse scene policy drive relay retries and model fallback
Muse now sends scene, routing policy, and degrade policy with each per-user request, so new-api should interpret those hints instead of leaving retry scope and fallback behavior implicit in static token settings alone.

This introduces a small Muse routing-policy interpreter, lets distributor switch quality-first traffic onto auto-group retry, and retries against lower-tier model candidates when the degrade policy allows it. The policy stays lightweight and still respects user-usable groups.

Constraint: Routing decisions must remain compatible with existing channel/group selection and not require schema changes
Constraint: Muse can hint policy, but new-api must still enforce only user-usable groups and channel availability
Rejected: Hardcoding physical channel/group choices inside Muse | would keep routing ownership outside new-api
Rejected: Expanding the policy into a full declarative DSL in phase 1 | overdesigned for the immediate routing/degrade handoff
Confidence: medium
Scope-risk: moderate
Reversibility: clean
Directive: Keep Muse routing policy interpretation small and observable; if more scenes appear, extend the helper rather than scattering policy branches across middleware
Tested: go test ./service -run MuseRoutingPolicy -count=1
Tested: go test ./service -count=1
Not-tested: Live relay selection against production channel inventory
2026-04-16 21:05:22 +08:00
..
2026-01-30 01:00:49 +08:00
2025-08-31 13:08:34 +08:00