feat(failover): package-level default observer for transparently-built chains
CI / Build, Test & Lint (push) Successful in 10m43s

The transparent comma-Parse path builds failover chains via NewFailoverModel
with no options, so defaultFailoverConfig() left the observer nil and observers
only fired when a caller passed WithFailoverObserver explicitly. Add a
package-level default observer (SetFailoverObserver / DefaultFailoverObserver),
guarded by the existing defaultsMu, and seed it in defaultFailoverConfig() so
chains built transparently still notify it. An explicit WithFailoverObserver
still overrides the default per-chain. mort sets this at boot to persist
failover events.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 00:43:24 +02:00
parent 361999550e
commit 1206261e6a
3 changed files with 170 additions and 0 deletions
+6
View File
@@ -12,10 +12,16 @@ import (
// verify that Parse resolved to the correct model without network calls.
type recordingProvider struct {
lastModel string
// err, when non-nil, is returned from Complete so failover tests can drive
// a comma-Parse'd chain through a failover decision. Defaults to nil (success).
err error
}
func (p *recordingProvider) Complete(_ context.Context, req provider.Request) (provider.Response, error) {
p.lastModel = req.Model
if p.err != nil {
return provider.Response{}, p.err
}
return provider.Response{Text: "ok"}, nil
}