Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Preserve resolved provider in qualification scoring

rcourtman6e71bcb151f3
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 297097178d..4b7671d57d 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -5668,7 +5668,11 @@ than silently borrowing a direct-provider family price. Reviewed OpenRouter
routes use exact model IDs and model-specific review dates from the public
OpenRouter Models API; aliases, fast variants, routers, and other unreviewed
routes remain unknown and therefore fail any non-zero qualification cost
-budget until their actual route price is explicitly recorded.
+budget until their actual route price is explicitly recorded. Live scoring
+uses the provider resolved by Patrol readiness, even when the configured
+OpenRouter model is an unprefixed slash route such as
+`anthropic/claude-sonnet-5`; scorer replay persists and reuses that resolved
+provider so the same captured report prices deterministically.
After a non-interactive Patrol finding lifecycle write succeeds, the structured
tool result is authoritative and the remaining text-only provider turn is only
for operator-facing summary prose. That turn must use a bounded summary system
diff --git a/internal/ai/qualification/report.go b/internal/ai/qualification/report.go
index d2109c2c2f..3a7b59f781 100644
--- a/internal/ai/qualification/report.go
+++ b/internal/ai/qualification/report.go
@@ -250,6 +250,7 @@ func ReplayScore(report RunReport) RunReport {
report.Score = ScoreRun(ScoringInput{
Manifest: report.Manifest, GroundTruth: report.GroundTruth,
Run: report.PatrolRun, Findings: report.Findings,
+ Provider: report.Environment.Provider,
Model: report.Environment.Model,
CollectionLatency: report.Score.CollectionLatency,
EndToEndLatency: report.Score.EndToEndLatency,
diff --git a/internal/ai/qualification/runner.go b/internal/ai/qualification/runner.go
index b73f8d963b..b53f69b667 100644
--- a/internal/ai/qualification/runner.go
+++ b/internal/ai/qualification/runner.go
@@ -160,7 +160,10 @@ func (r *QualificationRunner) Run(ctx context.Context) (report RunReport, termin
}
}
model := settings.EffectivePatrolModel()
- provider, _ := splitModel(model)
+ provider := strings.ToLower(strings.TrimSpace(status.Readiness.Provider))
+ if provider == "" {
+ provider, _ = splitModel(model)
+ }
report.Environment = Environment{
GitSHA: r.config.GitSHA, GitDirty: r.config.GitDirty,
PulseVersion: version.Version,
@@ -386,9 +389,10 @@ func (r *QualificationRunner) Run(ctx context.Context) (report RunReport, termin
report.Score = ScoreRun(ScoringInput{
Manifest: manifest, GroundTruth: report.GroundTruth,
Run: report.PatrolRun, Findings: report.Findings,
- Model: report.Environment.Model, CollectionLatency: phaseDuration(report.Phases, "normal_collection_convergence"),
- EndToEndLatency: time.Since(faultStarted),
- FaultsIntact: faultsIntact, NoMutation: noMutation,
+ Provider: report.Environment.Provider, Model: report.Environment.Model,
+ CollectionLatency: phaseDuration(report.Phases, "normal_collection_convergence"),
+ EndToEndLatency: time.Since(faultStarted),
+ FaultsIntact: faultsIntact, NoMutation: noMutation,
})
if manifest.Track != TrackWatch && len(report.Investigation) == 0 {
report.Score.HardFailures = append(report.Score.HardFailures, "no completed investigation evidence")
diff --git a/internal/ai/qualification/scorer.go b/internal/ai/qualification/scorer.go
index 1592c38df9..73ff8da6dc 100644
--- a/internal/ai/qualification/scorer.go
+++ b/internal/ai/qualification/scorer.go
@@ -193,6 +193,7 @@ type ScoringInput struct {
GroundTruth GroundTruth
Run PatrolRun
Findings []Finding
+ Provider string
Model string
CollectionLatency time.Duration
EndToEndLatency time.Duration
@@ -211,6 +212,9 @@ func ScoreRun(input ScoringInput) Score {
EndToEndLatency: input.EndToEndLatency,
}
provider, model := splitModel(input.Model)
+ if resolvedProvider := strings.ToLower(strings.TrimSpace(input.Provider)); resolvedProvider != "" {
+ provider = resolvedProvider
+ }
usd, known, price := cost.EstimateUSD(provider, model, int64(input.Run.InputTokens), int64(input.Run.OutputTokens))
score.Cost = CostEstimate{Provider: provider, Model: model, USD: usd, Known: known, PricingAsOf: price.AsOf, InputPerMTok: price.InputUSDPerMTok, OutputPerMTok: price.OutputUSDPerMTok}
diff --git a/internal/ai/qualification/scorer_test.go b/internal/ai/qualification/scorer_test.go
index 1ee8ea5bc6..b3491ee4b9 100644
--- a/internal/ai/qualification/scorer_test.go
+++ b/internal/ai/qualification/scorer_test.go
@@ -27,6 +27,26 @@ func TestScoreRunUsesScenarioGroundTruthNotToolCalls(t *testing.T) {
}
}
+func TestScoreRunUsesResolvedProviderForUnprefixedOpenRouterRoute(t *testing.T) {
+ manifest := validTestManifest()
+ score := ScoreRun(ScoringInput{
+ Manifest: manifest,
+ Provider: "openrouter",
+ Model: "anthropic/claude-sonnet-5",
+ Run: PatrolRun{InputTokens: 32_246, OutputTokens: 806},
+ })
+
+ if !score.Cost.Known {
+ t.Fatalf("expected resolved OpenRouter route price, got %+v", score.Cost)
+ }
+ if score.Cost.Provider != "openrouter" || score.Cost.Model != "anthropic/claude-sonnet-5" {
+ t.Fatalf("unexpected resolved route: %+v", score.Cost)
+ }
+ if score.Cost.USD <= 0 || score.Cost.PricingAsOf != "2026-07-14" {
+ t.Fatalf("unexpected reviewed route estimate: %+v", score.Cost)
+ }
+}
+
func TestScoreRunPreservesDiagnosticsButFailsErroredPatrolRun(t *testing.T) {
manifest := validTestManifest()
manifest.Gates = GateSpec{