Surface service + storage facts in the AI context pack

filterImportantFacts kept only hardware/dependency/security/version
facts, dropping 'service' and 'storage'. But a service fact (e.g. the
systemd unit) is exactly how the Assistant restarts/reloads a workload,
and a storage fact (the backing dataset/disk) is where its data lives —
neither is redundant with the CLI/path sections, and both are what a
real question like 'the database is slow, restart it' needs. Add both to
the priority categories.

Corpus: add a postgresql LXC cell whose required context includes the
systemd unit and data filesystem. Teeth-checked — the case fails without
the filter change. Build + vet + gofmt clean, full servicediscovery
package green.
This commit is contained in:
rcourtman 2026-06-07 12:19:02 +01:00
parent 65cf18a8cf
commit b216e38304
2 changed files with 41 additions and 1 deletions

View file

@ -122,12 +122,18 @@ func formatSingleDiscovery(d *ResourceDiscovery) string {
func filterImportantFacts(facts []DiscoveryFact) []DiscoveryFact {
var important []DiscoveryFact
// Priority categories
// 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)
}
for _, f := range facts {

View file

@ -84,6 +84,40 @@ func contextScenarioCorpus() []contextScenario {
"/opt/homeassistant/config -> /config",
},
},
{
name: "postgresql LXC",
userQuestion: "the database is slow and I may need to restart it",
discovery: &ResourceDiscovery{
ID: MakeResourceID(ResourceTypeSystemContainer, "minipc", "112"),
ResourceType: ResourceTypeSystemContainer,
ResourceID: "112",
TargetID: "minipc",
Hostname: "pg-primary",
ServiceType: "postgresql",
ServiceName: "PostgreSQL",
ServiceVersion: "16.3",
Category: CategoryDatabase,
CLIAccess: "pct exec 112 -- bash",
ConfigPaths: []string{"/etc/postgresql/16/main/postgresql.conf"},
DataPaths: []string{"/var/lib/postgresql/16/main"},
LogPaths: []string{"/var/log/postgresql/postgresql-16-main.log"},
Ports: []PortInfo{{Port: 5432, Protocol: "tcp", Process: "postgres"}},
Facts: []DiscoveryFact{
{Category: FactCategoryService, Key: "systemd_unit", Value: "postgresql@16-main.service", Source: "running_services", Confidence: 0.9},
{Category: FactCategoryStorage, Key: "data_filesystem", Value: "zfs tank/postgres", Source: "disk_usage", Confidence: 0.85},
},
},
// To triage slowness and restart, the Assistant needs how to reach
// the guest, the config + log, AND how the service is managed (the
// systemd unit) and where its data lives (the dataset) — service and
// storage facts the context pack used to drop.
mustContain: []string{
"pct exec 112",
"postgresql.conf",
"postgresql@16-main.service",
"tank/postgres",
},
},
}
}