A routing group's intent rule picks a model and the reasoning it is
asked for (useEffort, #2633). When that model's provider turned the
request away and the group failed over to another member, the request
went out at the agent's own level (or none), not the intent's.
ruleEffort (internal/gateway/rules.go) gave a rule's useEffort only to
candidates of the member the rule names. Now the rule's effort is the
turn's: a member the group fails over to is asked it too, fitted to its
own model's levels (fitLevel), and Try.RuleEffort records it, so the
Routing page says "set by the rule". Unchanged: a rule that names the
candidate goes before one it only fails over from; a member the user
fixed at an effort keeps its own (#189; ruleEffort isn't asked when
c.effort is set); a model whose levels aren't known is asked as the
agent asked.
Ported from skygunner's fix (github.com/skygunner/magpie
fix/3664-intent-effort-failover, 2136cf044), with two changes after
review:
- A nested group's rule now decides for that group's members only.
skygunner's version gave an inner group's useEffort to every candidate,
so when the whole inner group failed, the outer group's member outside
it was asked the inner rule's level. ruleEffort takes the outer
group's members (ms) and skips a nested rule for a candidate not
reached through that group. New TestNestedRuleEffortStaysInItsGroup.
- TestIntentEffortSurvivesTheGroupsFailover now covers four cases for
the failover member, each in its own magpie: unknown levels (agent's
high, nothing traced), the same levels (low), levels medium/high
(fitted to medium) and fixed at high (high, Fixed traced, RuleEffort
empty). The stale "Then asks nothing" comment now says its member is
asked the first rule's.
docs/subsystems/gateway-routing.md says both.
Run (all on mote via mote-run, at this tree rebased on 4b4c4a806):
gofmt -l internal/gateway: nothing
go vet ./internal/gateway/, GOOS=linux and GOOS=windows: ok
go test -timeout 45m -count=1 ./internal/gateway/: ok (595.7s)
(an earlier full run on the pre-scoping tree: ok, 670.6s)
Broken by hand (-run TestIntentEffortSurvivesTheGroupsFailover,
TestNestedRuleEffortStaysInItsGroup), each red:
origin/main's ruleEffort: "the intent's level: the member the group
failed over to sent ... reasoning_effort:medium"; nested
"within the inner group: q1=low/low q2=high/"
return asked without fitLevel: "fitted to its own: traced ..."
no unknown-levels check: "unknown levels: ... sent ..." (low, not high)
ruleEffort called for a fixed member (c.effort guard dropped):
"fixed at its own: ... sent ..." (low, not high)
nested scoping off (skygunner's version): "outside it: q1=low/low
q2=low/low f1=low/low"
Not run: go vet ./... and the rest of the suite (only internal/gateway
changed); no real-provider run.
Co-authored-by: skygunner <84759+skygunner@users.noreply.github.com>