router: Router.Route consumes NormalizedInput directly (slice 11)

Change Route from (ctx, utterance string, now) to (ctx, input NormalizedInput, now).
The ingress-constructed NormalizedInput now reaches the cascade intact — no
reconstruction downstream. TryFastPath receives the same input, not a rebuilt one.
All callers (production, eval framework, tests) updated to construct NormalizedInput.
This commit is contained in:
2026-09-07 01:32:45 +04:00
parent a1e4743492
commit dad3cd0738
5 changed files with 15 additions and 13 deletions
+5 -5
View File
@@ -103,17 +103,17 @@ func (f Fixture) Now() (time.Time, error) {
// Router — the one thing a route decider must do to be scorable. *router.Router
// satisfies it directly; an LLM-only path wraps its Route in RouterFunc.
type Router interface {
Route(ctx context.Context, utterance string, now time.Time) (router.Decision, error)
Route(ctx context.Context, input router.NormalizedInput, now time.Time) (router.Decision, error)
}
// RouterFunc adapts a bare function to Router — for scoring a single stage
// (e.g. *router.LLMRouter, whose Route returns an extra ok bool) without
// standing up the whole cascade.
type RouterFunc func(ctx context.Context, utterance string, now time.Time) (router.Decision, error)
type RouterFunc func(ctx context.Context, input router.NormalizedInput, now time.Time) (router.Decision, error)
// Route implements Router.
func (f RouterFunc) Route(ctx context.Context, utterance string, now time.Time) (router.Decision, error) {
return f(ctx, utterance, now)
func (f RouterFunc) Route(ctx context.Context, input router.NormalizedInput, now time.Time) (router.Decision, error) {
return f(ctx, input, now)
}
// Outcome — one scored case. Reasons is empty exactly when Pass is true.
@@ -231,7 +231,7 @@ func Score(ctx context.Context, name string, r Router, f Fixture) (Report, error
for _, c := range f.Cases {
start := time.Now()
d, err := r.Route(ctx, c.Utterance, now)
d, err := r.Route(ctx, router.NormalizedInput{Text: c.Utterance}, now)
o := Outcome{Case: c, Decision: d, Err: err, Latency: time.Since(start)}
lat = append(lat, o.Latency)