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.

Surface Docker bind mounts in the AI context pack + seed Discovery scenario oracle

rcourtmana256742ab501
diff --git a/internal/servicediscovery/formatters.go b/internal/servicediscovery/formatters.go
index ea89fb4339..484618763d 100644
--- a/internal/servicediscovery/formatters.go
+++ b/internal/servicediscovery/formatters.go
@@ -77,6 +77,21 @@ func formatSingleDiscovery(d *ResourceDiscovery) string {
sb.WriteString(fmt.Sprintf("- **Log Paths:** %s\n", strings.Join(d.LogPaths, ", ")))
}
+ // Docker bind mounts — where the container's paths actually live on the
+ // host. A container path like /config is meaningless for editing or backing
+ // up persistent files without its host source, so surface the mapping so the
+ // assistant can act on the real files, not the ephemeral container view.
+ if len(d.DockerMounts) > 0 {
+ sb.WriteString("- **Docker Mounts (host -> container):**\n")
+ for _, m := range d.DockerMounts {
+ line := fmt.Sprintf(" - %s -> %s", m.Source, m.Destination)
+ if m.ReadOnly {
+ line += " (read-only)"
+ }
+ sb.WriteString(line + "\n")
+ }
+ }
+
// Ports
if len(d.Ports) > 0 {
var ports []string
diff --git a/internal/servicediscovery/scenario_corpus_test.go b/internal/servicediscovery/scenario_corpus_test.go
new file mode 100644
index 0000000000..260377de3d
--- /dev/null
+++ b/internal/servicediscovery/scenario_corpus_test.go
@@ -0,0 +1,102 @@
+package servicediscovery
+
+import (
+ "strings"
+ "testing"
+)
+
+// The Discovery -> Assistant context oracle.
+//
+// Long-horizon goal: opening the Assistant on any workload should give it, with
+// zero user re-explanation, everything it needs to act — how to reach the
+// guest, where the app's config/data/logs/automations live, what is listening.
+// The verifiable test is per workload: given a realistic discovered resource,
+// the AI context pack (FormatForAIContext — what Chat and Patrol actually see)
+// must surface the context a real troubleshooting/management question requires.
+//
+// This corpus grows one service-type cell at a time. Each case pins the
+// must-have context for a concrete user question; a missing substring is a
+// concrete gap in what the Assistant can do, to be closed in the analyzer
+// (what discovery captures) or the formatter (what reaches the Assistant).
+type contextScenario struct {
+ name string // service-type cell
+ userQuestion string // the real question this context must answer
+ discovery *ResourceDiscovery // a realistic discovered workload
+ mustContain []string // substrings the context pack must include
+}
+
+func contextScenarioCorpus() []contextScenario {
+ return []contextScenario{
+ {
+ name: "home-assistant LXC",
+ userQuestion: "my blinds automation didn't fire this morning",
+ discovery: &ResourceDiscovery{
+ ID: MakeResourceID(ResourceTypeSystemContainer, "delly", "101"),
+ ResourceType: ResourceTypeSystemContainer,
+ ResourceID: "101",
+ TargetID: "delly",
+ Hostname: "home-assistant",
+ ServiceType: "home-assistant",
+ ServiceName: "Home Assistant",
+ ServiceVersion: "2026.5.1",
+ Category: CategoryHomeAuto,
+ CLIAccess: "pct exec 101 -- bash",
+ ConfigPaths: []string{"/config/configuration.yaml", "/config/automations.yaml"},
+ DataPaths: []string{"/config"},
+ LogPaths: []string{"/config/home-assistant.log"},
+ Ports: []PortInfo{{Port: 8123, Protocol: "tcp", Process: "python3"}},
+ },
+ // To act on "automation didn't fire" the Assistant needs: how to
+ // reach the guest, the automations file, and the log to inspect.
+ mustContain: []string{
+ "pct exec 101",
+ "/config/automations.yaml",
+ "/config/home-assistant.log",
+ },
+ },
+ {
+ name: "home-assistant Docker (bind mount)",
+ userQuestion: "edit my blinds automation on the host",
+ discovery: &ResourceDiscovery{
+ ID: MakeResourceID(ResourceTypeDocker, "nuc", "homeassistant"),
+ ResourceType: ResourceTypeDocker,
+ ResourceID: "homeassistant",
+ TargetID: "nuc",
+ Hostname: "nuc",
+ ServiceType: "home-assistant",
+ ServiceName: "Home Assistant",
+ Category: CategoryHomeAuto,
+ CLIAccess: "docker exec homeassistant bash",
+ ConfigPaths: []string{"/config/automations.yaml"},
+ DockerMounts: []DockerBindMount{
+ {
+ ContainerName: "homeassistant",
+ Source: "/opt/homeassistant/config",
+ Destination: "/config",
+ Type: "bind",
+ },
+ },
+ },
+ // The container path /config is meaningless for editing from the host
+ // without its bind-mount source on the host filesystem.
+ mustContain: []string{
+ "docker exec homeassistant",
+ "/opt/homeassistant/config -> /config",
+ },
+ },
+ }
+}
+
+func TestContextScenarioCorpus(t *testing.T) {
+ for _, sc := range contextScenarioCorpus() {
+ t.Run(sc.name, func(t *testing.T) {
+ pack := FormatForAIContext([]*ResourceDiscovery{sc.discovery})
+ for _, want := range sc.mustContain {
+ if !strings.Contains(pack, want) {
+ t.Errorf("context pack for %q (question: %q) is missing %q —\nthe Assistant could not answer the question without it.\n--- context pack ---\n%s",
+ sc.name, sc.userQuestion, want, pack)
+ }
+ }
+ })
+ }
+}