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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Rank facts by actionability so the cap never drops service-control
rcourtmanb3dc0d157339
diff --git a/internal/servicediscovery/formatters.go b/internal/servicediscovery/formatters.goindex 9eb5f80f2c..1a2ddb1fe4 100644--- a/internal/servicediscovery/formatters.go+++ b/internal/servicediscovery/formatters.go@@ -2,6 +2,7 @@ package servicediscoveryimport ("fmt"+ "sort""strings""time"@@ -120,31 +121,39 @@ func formatSingleDiscovery(d *ResourceDiscovery) string {// filterImportantFacts returns the most relevant facts for AI context.func filterImportantFacts(facts []DiscoveryFact) []DiscoveryFact {- var important []DiscoveryFact-- // Priority categories — facts the assistant needs to understand and act on- // the workload. Service + storage were previously dropped, yet a service- // fact (e.g. the systemd unit) is exactly how you restart/reload a workload,- // and a storage fact (e.g. the backing dataset/disk) is where its data- // physically lives — neither is redundant with the path/CLI sections.- priorityCategories := map[FactCategory]bool{- FactCategoryHardware: true, // GPU, TPU- FactCategoryDependency: true, // MQTT, database connections- FactCategorySecurity: true, // Auth info- FactCategoryVersion: true, // Version info- FactCategoryService: true, // how the service is managed (systemd unit, init)- FactCategoryStorage: true, // where data physically lives (pool/dataset/disk)+ // Priority ranking — facts the assistant needs to understand and act on the+ // workload, ordered most-actionable first so the cap never drops a fact that+ // helps it DO something (restart, auth) in favour of an informational one.+ // Service + storage were previously dropped entirely; a service fact (e.g.+ // the systemd unit) is exactly how you restart/reload a workload, and a+ // storage fact (the backing dataset/disk) is where its data lives — neither+ // is redundant with the path/CLI sections.+ priorityRank := map[FactCategory]int{+ FactCategoryService: 0, // how to restart/reload — most actionable+ FactCategorySecurity: 1, // auth/access+ FactCategoryDependency: 2, // MQTT, database connections+ FactCategoryHardware: 3, // GPU, TPU+ FactCategoryVersion: 4, // version info+ FactCategoryStorage: 5, // backing dataset/disk}+ var important []DiscoveryFactfor _, f := range facts {- if priorityCategories[f.Category] && f.Confidence >= 0.7 {+ if _, ok := priorityRank[f.Category]; ok && f.Confidence >= 0.7 {important = append(important, f)}}- // Limit to top 5 facts- if len(important) > 5 {- important = important[:5]+ // Stable sort by actionability so the most useful facts survive the cap;+ // within a category the analyzer's original order is preserved.+ sort.SliceStable(important, func(i, j int) bool {+ return priorityRank[important[i].Category] < priorityRank[important[j].Category]+ })++ // Cap to keep the pack concise (the analyzer already caps total facts at 12).+ const maxFacts = 8+ if len(important) > maxFacts {+ important = important[:maxFacts]}return importantdiff --git a/internal/servicediscovery/formatters_test.go b/internal/servicediscovery/formatters_test.goindex 8c59f764ba..62cf78b6a5 100644--- a/internal/servicediscovery/formatters_test.go+++ b/internal/servicediscovery/formatters_test.go@@ -216,7 +216,7 @@ func TestFormatScopeHint(t *testing.T) {func TestFilterImportantFactsLimit(t *testing.T) {var facts []DiscoveryFact- for i := 0; i < 7; i++ {+ for i := 0; i < 10; i++ {facts = append(facts, DiscoveryFact{Category: FactCategoryVersion,Key: "k",@@ -224,9 +224,30 @@ func TestFilterImportantFactsLimit(t *testing.T) {Confidence: 0.9,})}+ // A trailing, most-actionable service-control fact among many informational+ // ones must survive the cap (and sort to the front) — it is how the+ // assistant restarts the workload.+ facts = append(facts, DiscoveryFact{+ Category: FactCategoryService,+ Key: "systemd_unit",+ Value: "app.service",+ Confidence: 0.9,+ })important := filterImportantFacts(facts)- if len(important) != 5 {- t.Fatalf("expected 5 facts, got %d", len(important))+ if len(important) != 8 {+ t.Fatalf("expected cap of 8 facts, got %d", len(important))+ }+ if important[0].Category != FactCategoryService {+ t.Fatalf("expected the service-control fact surfaced first, got %s", important[0].Category)+ }+ found := false+ for _, f := range important {+ if f.Key == "systemd_unit" {+ found = true+ }+ }+ if !found {+ t.Fatalf("service-control fact was dropped by the cap")}}diff --git a/internal/servicediscovery/scenario_corpus_test.go b/internal/servicediscovery/scenario_corpus_test.goindex 61a4612934..8dea4d51d5 100644--- a/internal/servicediscovery/scenario_corpus_test.go+++ b/internal/servicediscovery/scenario_corpus_test.go@@ -118,6 +118,45 @@ func contextScenarioCorpus() []contextScenario {"tank/postgres",},},+ {+ name: "frigate Docker (fact-heavy)",+ userQuestion: "my driveway camera keeps going offline",+ discovery: &ResourceDiscovery{+ ID: MakeResourceID(ResourceTypeDocker, "nvr", "frigate"),+ ResourceType: ResourceTypeDocker,+ ResourceID: "frigate",+ TargetID: "nvr",+ Hostname: "nvr",+ ServiceType: "frigate",+ ServiceName: "Frigate NVR",+ ServiceVersion: "0.14.1",+ Category: CategoryNVR,+ CLIAccess: "docker exec frigate bash",+ ConfigPaths: []string{"/config/config.yml"},+ LogPaths: []string{"/config/frigate.log"},+ Ports: []PortInfo{{Port: 5000, Protocol: "tcp", Process: "frigate"}},+ // Six priority facts — more than the old cap of 5. The+ // service-control fact (how to restart the camera service) is last+ // in input order, so it must be sorted ahead of the informational+ // facts to survive the cap.+ Facts: []DiscoveryFact{+ {Category: FactCategoryVersion, Key: "frigate_version", Value: "0.14.1", Source: "config_files", Confidence: 0.95},+ {Category: FactCategoryHardware, Key: "coral_tpu", Value: "/dev/apex_0", Source: "gpu_devices", Confidence: 0.9},+ {Category: FactCategoryHardware, Key: "gpu", Value: "intel-vaapi", Source: "gpu_devices", Confidence: 0.85},+ {Category: FactCategoryDependency, Key: "mqtt_broker", Value: "mosquitto:1883", Source: "listening_ports", Confidence: 0.85},+ {Category: FactCategoryStorage, Key: "media_volume", Value: "/mnt/nvr zfs", Source: "disk_usage", Confidence: 0.8},+ {Category: FactCategoryService, Key: "restart", Value: "docker restart frigate", Source: "running_services", Confidence: 0.9},+ },+ },+ // To triage an offline camera the Assistant needs the config + log,+ // the detector (coral) it depends on, and how to restart the service.+ mustContain: []string{+ "docker exec frigate",+ "/config/config.yml",+ "coral_tpu",+ "docker restart frigate",+ },+ },}}