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.

Qualify Docker storage collection against a live fault

rcourtmanb0b39f00dc66
diff --git a/docs/qualification/PATROL_ASSISTANT_CUSTOMER_JOURNEY.md b/docs/qualification/PATROL_ASSISTANT_CUSTOMER_JOURNEY.md
index 1511033332..daa6d4acc5 100644
--- a/docs/qualification/PATROL_ASSISTANT_CUSTOMER_JOURNEY.md
+++ b/docs/qualification/PATROL_ASSISTANT_CUSTOMER_JOURNEY.md
@@ -65,7 +65,7 @@ reproduction evidence, not a representative customer success rate.
| 2. Shared evidence | Preserve canonical risk reasons and SMART counters, source/time semantics and history across tools/turns. | Regression tests preserve unknown versus zero and all canonical evidence. Real responses can inspect the same facts as the product. | Implemented and qualified for the named shared-evidence defects. Canonical disk detail, risk and cadence pass real data-path proof. Affected package and concurrency checks pass. Integrated CI later exposed remaining query and allocation regressions. The final bounded query-reuse correction passes complete selected exact-base worker comparisons and full metrics/database and focused race checks. Final landing CI passed and PRs #1928 and #1929 merged. Real-model interpretation failures remain tracked in step 5. |
| 3. Diagnostic orchestration | Correct proposal-as-proof. Audit triage budgets, unmatched-signal evaluation, assessment completion and investigation cutoffs. | No code-written causal conclusion. No quality inferred from tool, flag or finding counts. Each retained pass has an objective reason. Safety boundaries and incomplete outcomes remain explicit. | Proposal promotion and capture inference were removed in c5d2f56dda. Commit 668af3fe6b removes investigation success-call floors, checkpoint instructions and generic call-count wrap-up rules. The detection slice removes contextless follow-up passes, flag/report-count policy and first-finding completion modes. Full chat and AI suites, focused API and conversation race tests pass. Real-model/action outcome qualification remains open. |
| 4. Issue through verified outcome | Follow existing issue/investigation/action records into Assistant, approval, execution and independent readback. | Accepted proposal is visibly distinct from execution and verification. Rejected or unsupported actions do not become success. Uncertainty can survive an action proposal. | Existing foundation, full journey qualification pending. |
-| 5. Ground-truth qualification and landing | Extend existing qualification tooling only where necessary. Exercise healthy/unhealthy, dependency, missing-access, storage/backup and approved/rejected action cases. Inspect the final browser journey at desktop and narrow widths. | Record exact source/model/permissions, evidence, decisions, faults/misses, latency and verification. Fix in-scope failures, pass appropriate proofs and land scoped commits. | Pending. |
+| 5. Ground-truth qualification and landing | Extend existing qualification tooling only where necessary. Exercise healthy/unhealthy, dependency, missing-access, storage/backup and approved/rejected action cases. Inspect the final browser journey at desktop and narrow widths. | Record exact source/model/permissions, evidence, decisions, faults/misses, latency and verification. Fix in-scope failures, pass appropriate proofs and land scoped commits. | Partial. Regression, controlled browser and live collector evidence are recorded below. Real-model diagnosis, linked approval/action outcomes and installed collector qualification remain open. |
Use one shared runtime and the existing qualification runner, not a second
product intelligence engine or a new parallel lifecycle. Preserve independent
@@ -2014,3 +2014,36 @@ full API rerun passes under that account (286.960s), as do the incoming
startup-replay and legacy-boundary source checks. Frontend type checks and all
29 incoming alert tests pass. The exact staged hook gates landing.
Private receipts are under `tmp/patrol-archive-retirement/` in the workspace.
+
+### Live collector storage evidence, 2026-09-06
+
+`TestCollectContainerStorageFaultLive` calls the production Docker client and
+`collectContainer` implementation against the existing storage-pressure lab.
+The opt-in command, run on the worker beside its Docker Unix socket, is:
+
+```sh
+PULSE_QUALIFY_ORACLE_DOCKER_CONTEXT=default go test ./internal/dockeragent -run '^TestCollectContainerStorageFaultLive$' -count=1 -timeout=240s -v
+```
+
+The final test passed in 8.694s on Docker 29.8.0 against the runtime source tree
+of `186ce504c8f0fa6e0174f3b10f3d99f6278f10fc`. Its SHA256 is
+`cdf303f4de23c020690c81b0b57190c728319788cb0aaff906b0d4d9d864541e`.
+Independent filesystem observations measured 8,380,416 available bytes before
+the fault, zero during it and 8,380,416 after recovery. The service stayed
+running. Collected and JSON-decoded health followed healthy, unhealthy, healthy,
+while the unrelated control remained healthy. Docker returned zero native
+`Mounts` throughout. The report retained the single tmpfs destination, type,
+8 MiB configuration options and writable setting from `HostConfig.Tmpfs`.
+Configured size is not a measured capacity counter in the report.
+
+The test targets exact run-owned container IDs and labels. Existing fixture
+cleanup passed, its second cleanup was a no-op and inventory matched the
+pre-run snapshot. The test skips without explicit opt-in. All four existing
+mount regression cases also pass. Private logs are in
+`tmp/patrol-storage-collector-live/` in the workspace.
+
+This proves live collection and report serialization only. It does not send a
+report to Pulse, enroll or replace a production agent, call a provider, or
+qualify approval, execution, diagnosis or model recovery. No runtime or frontend
+source changed in this slice, so no new browser claim is made. Prior storage
+diagnosis failures and the cached autonomous-provider refusal remain open.
diff --git a/internal/dockeragent/collect_tmpfs_live_test.go b/internal/dockeragent/collect_tmpfs_live_test.go
new file mode 100644
index 0000000000..ca0bb459b9
--- /dev/null
+++ b/internal/dockeragent/collect_tmpfs_live_test.go
@@ -0,0 +1,148 @@
+package dockeragent
+
+import (
+ "context"
+ "encoding/json"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/moby/moby/client"
+ "github.com/rcourtman/pulse-go-rewrite/internal/ai/qualification"
+ agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
+ "github.com/rs/zerolog"
+)
+
+// This opt-in proof calls the real collector against the existing bounded lab.
+// It does not enroll an agent, send reports to Pulse, or invoke a model.
+func TestCollectContainerStorageFaultLive(t *testing.T) {
+ dockerContext := os.Getenv("PULSE_QUALIFY_ORACLE_DOCKER_CONTEXT")
+ if dockerContext == "" {
+ t.Skip("set PULSE_QUALIFY_ORACLE_DOCKER_CONTEXT to an explicit disposable Docker context")
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
+ defer cancel()
+ endpoint, err := exec.CommandContext(ctx, "docker", "context", "inspect", dockerContext,
+ "--format", "{{.Endpoints.docker.Host}}").Output()
+ if err != nil {
+ t.Fatal(err)
+ }
+ host := strings.TrimSpace(string(endpoint))
+ if !strings.HasPrefix(host, "unix://") {
+ t.Fatal("run this proof beside the disposable Docker daemon using a Unix socket context")
+ }
+ moduleClient, err := newMobyDockerClient(client.WithHost(host), client.WithAPIVersionNegotiation())
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { _ = moduleClient.Close() })
+ agent := &Agent{docker: moduleClient, runtime: RuntimeDocker, logger: zerolog.Nop(),
+ cfg: Config{CollectDiskMetrics: true}, prevContainerCPU: make(map[string]cpuSample)}
+ manifest, err := qualification.LoadManifest(filepath.Join("..", "..", "tests", "qualification", "patrol",
+ "scenarios", "investigation.docker-storage-pressure.json"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ driver := qualification.NewDockerLab(nil, qualification.DockerTarget{Context: dockerContext})
+ lab, prepareErr := driver.Prepare(ctx, manifest, "collector-"+time.Now().UTC().Format("20060102t150405.000000000"))
+ if lab != nil {
+ t.Cleanup(func() {
+ cleanupCtx, cleanupCancel := context.WithTimeout(context.Background(), time.Minute)
+ defer cleanupCancel()
+ result := driver.Cleanup(cleanupCtx, manifest, lab)
+ encoded, _ := json.Marshal(result)
+ t.Logf("cleanup=%s", encoded)
+ if !result.Passed || !result.SecondCleanupNoop || !result.InventoryUnchanged {
+ t.Errorf("disposable inventory cleanup failed: %+v", result)
+ }
+ })
+ }
+ if prepareErr != nil {
+ t.Fatal(prepareErr)
+ }
+
+ check := func(phase, serviceHealth string, predicates []qualification.Predicate) {
+ t.Helper()
+ observations, err := driver.Observe(ctx, manifest, lab, predicates)
+ encoded, _ := json.Marshal(observations)
+ t.Logf("%s oracle=%s", phase, encoded)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, alias := range []string{"service", "control"} {
+ id := lab.ResourceIDs[alias]
+ filters := newDockerFilters()
+ filters.Add("id", id)
+ for _, key := range []string{"io.pulse.owner", "io.pulse.profile", "io.pulse.component"} {
+ value := lab.BaselineStates[alias].Labels[key]
+ if value == "" {
+ t.Fatalf("missing fixture ownership label %s", key)
+ }
+ filters.Add("label", key+"="+value)
+ }
+ containers, err := moduleClient.ContainerList(ctx, dockerContainerListOptions{All: true, Filters: filters})
+ if err != nil || len(containers) != 1 || containers[0].ID != id {
+ t.Fatalf("exact owned fixture %s unavailable: count=%d error=%v", alias, len(containers), err)
+ }
+ collected, err := agent.collectContainer(ctx, containers[0])
+ if err != nil {
+ t.Fatal(err)
+ }
+ encoded, err := json.Marshal(collected)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var report agentsdocker.Container
+ if err := json.Unmarshal(encoded, &report); err != nil {
+ t.Fatal(err)
+ }
+ wantHealth := "healthy"
+ if alias == "service" {
+ wantHealth = serviceHealth
+ }
+ if report.ID != id || report.State != "running" || report.Health != wantHealth {
+ t.Fatalf("%s %s report identity/state/health mismatch: %s", phase, alias, encoded)
+ }
+ if alias == "service" {
+ const destination = "/var/lib/service-cache"
+ inspect, err := moduleClient.ContainerInspect(ctx, id)
+ if err != nil || inspect.HostConfig == nil {
+ t.Fatalf("inspect storage configuration: %v", err)
+ }
+ options, ok := inspect.HostConfig.Tmpfs[destination]
+ if !ok || !strings.Contains(options, "size=8388608") {
+ t.Fatalf("fixture tmpfs configuration missing: %q", options)
+ }
+ matches := 0
+ for _, mount := range report.Mounts {
+ if mount.Destination == destination {
+ matches++
+ if mount.Type != "tmpfs" || !mount.RW || mount.Mode != options {
+ t.Fatalf("collector changed tmpfs configuration: %+v", mount)
+ }
+ }
+ }
+ if matches != 1 {
+ t.Fatalf("expected one storage mount in report, got %d", matches)
+ }
+ t.Logf("%s raw_mount_count=%d native_tmpfs_options=%q", phase, len(inspect.Mounts), options)
+ }
+ t.Logf("%s %s report=%s", phase, alias, encoded)
+ }
+ }
+ check("baseline", "healthy", manifest.Baseline)
+ for _, fault := range manifest.Faults {
+ if err := driver.ApplyFault(ctx, manifest, lab, fault); err != nil {
+ t.Fatal(err)
+ }
+ check("storage-full", "unhealthy", fault.Oracle)
+ if err := driver.RevertFault(ctx, manifest, lab, fault); err != nil {
+ t.Fatal(err)
+ }
+ check("recovered", "healthy", fault.RevertOracle)
+ }
+ check("restored-baseline", "healthy", manifest.Baseline)
+}