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.

Require collected negative control convergence

rcourtman3487b9a98e59
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 485e43c71d..4925258e1d 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -5692,6 +5692,11 @@ relevant health, running-state, or restart-count condition; a stale healthy
projection is a collection failure, never a model miss. These expectations are
derived from manifest oracles before execution and never from Patrol tool
selection, preserving non-circular scoring.
+Healthy negative controls use the same convergence rule in the opposite
+direction: their manifest-owned baseline predicates must be visible through
+the canonical resource projection before Patrol starts. A transient `starting`
+projection cannot force the model to spend a confirmation turn after the lab
+oracle has already established `healthy`.
Watch qualification must score the confirmed provider-visible symptom rather
than require an unproved causal attribution. In the correlated Docker scenario,
the stopped dependency remains the independently injected fault and the
diff --git a/internal/ai/qualification/client_test.go b/internal/ai/qualification/client_test.go
index 5e7f6a87b4..fbbb691890 100644
--- a/internal/ai/qualification/client_test.go
+++ b/internal/ai/qualification/client_test.go
@@ -47,7 +47,7 @@ func TestTriggerAndWaitAssociatesExactNewScopedRun(t *testing.T) {
}
}
-func TestValidateCollectedFaultProjectionUsesScenarioOracle(t *testing.T) {
+func TestValidateCollectedScenarioProjectionUsesFaultOracle(t *testing.T) {
manifest := validTestManifest()
manifest.Faults = []FaultSpec{
{ID: "stopped", Target: "dependency", Oracle: []Predicate{{Probe: "docker.running", Target: "dependency", Operator: "eq", Value: json.RawMessage("false")}}},
@@ -59,17 +59,33 @@ func TestValidateCollectedFaultProjectionUsesScenarioOracle(t *testing.T) {
"client": {Docker: &DockerResource{Health: "healthy"}},
"worker": {Docker: &DockerResource{RestartCount: 1}},
}
- if err := validateCollectedFaultProjection(manifest, resources); err == nil {
+ if err := validateCollectedScenarioProjection(manifest, resources); err == nil {
t.Fatal("expected pre-fault collected projection to be rejected")
}
resources["dependency"] = Resource{Docker: &DockerResource{ContainerState: "exited"}}
resources["client"] = Resource{Docker: &DockerResource{Health: "unhealthy"}}
resources["worker"] = Resource{Docker: &DockerResource{RestartCount: 2}}
- if err := validateCollectedFaultProjection(manifest, resources); err != nil {
+ if err := validateCollectedScenarioProjection(manifest, resources); err != nil {
t.Fatalf("expected collected projection to satisfy scenario-owned oracles: %v", err)
}
}
+func TestValidateCollectedScenarioProjectionRequiresNegativeControlBaseline(t *testing.T) {
+ manifest := validTestManifest()
+ manifest.Faults = nil
+ manifest.NegativeControls = []NegativeControl{{Resource: "healthy", Reason: "healthy control"}}
+ manifest.Baseline = []Predicate{{Probe: "docker.health", Target: "healthy", Operator: "eq", Value: json.RawMessage(`"healthy"`)}}
+ resources := map[string]Resource{"healthy": {Docker: &DockerResource{ContainerState: "running", Health: "starting"}}}
+
+ if err := validateCollectedScenarioProjection(manifest, resources); err == nil {
+ t.Fatal("expected stale starting projection to be rejected for a healthy negative control")
+ }
+ resources["healthy"] = Resource{Docker: &DockerResource{ContainerState: "running", Health: "healthy"}}
+ if err := validateCollectedScenarioProjection(manifest, resources); err != nil {
+ t.Fatalf("expected collected negative control to satisfy scenario-owned baseline: %v", err)
+ }
+}
+
func TestWaitForResourcesMatchingPollsPastStaleState(t *testing.T) {
var calls atomic.Int32
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
diff --git a/internal/ai/qualification/runner.go b/internal/ai/qualification/runner.go
index b53f69b667..3b8e49cc50 100644
--- a/internal/ai/qualification/runner.go
+++ b/internal/ai/qualification/runner.go
@@ -235,7 +235,7 @@ func (r *QualificationRunner) Run(ctx context.Context) (report RunReport, termin
poll, _ := positiveDuration(manifest.Collection.PollInterval)
var collectionErr error
collected, collectionErr = r.config.Client.WaitForResourcesMatching(ctx, prepared.ResourceNames, timeout, poll, func(resources map[string]Resource) error {
- return validateCollectedFaultProjection(manifest, resources)
+ return validateCollectedScenarioProjection(manifest, resources)
})
if collectionErr != nil {
return collectionErr
@@ -429,47 +429,67 @@ func (r *QualificationRunner) Run(ctx context.Context) (report RunReport, termin
return report, terminalErr
}
-func validateCollectedFaultProjection(manifest Manifest, resources map[string]Resource) error {
+func validateCollectedScenarioProjection(manifest Manifest, resources map[string]Resource) error {
for _, fault := range manifest.Faults {
for _, predicate := range fault.Oracle {
- resource, ok := resources[predicate.Target]
- if !ok {
- return fmt.Errorf("fault %s target %s is absent from collected resources", fault.ID, predicate.Target)
- }
- if resource.Docker == nil {
- return fmt.Errorf("fault %s target %s has no collected Docker projection", fault.ID, predicate.Target)
- }
- switch predicate.Probe {
- case "docker.health":
- var expected string
- if err := json.Unmarshal(predicate.Value, &expected); err != nil {
- return fmt.Errorf("fault %s has invalid collected health expectation: %w", fault.ID, err)
- }
- if !strings.EqualFold(strings.TrimSpace(resource.Docker.Health), strings.TrimSpace(expected)) {
- return fmt.Errorf("fault %s target %s collected health=%q want %q", fault.ID, predicate.Target, resource.Docker.Health, expected)
- }
- case "docker.running":
- var expected bool
- if err := json.Unmarshal(predicate.Value, &expected); err != nil {
- return fmt.Errorf("fault %s has invalid collected running expectation: %w", fault.ID, err)
- }
- running := strings.EqualFold(strings.TrimSpace(resource.Docker.ContainerState), "running")
- if running != expected {
- return fmt.Errorf("fault %s target %s collected running=%t state=%q want %t", fault.ID, predicate.Target, running, resource.Docker.ContainerState, expected)
- }
- case "docker.restart_count":
- var expected int
- if err := json.Unmarshal(predicate.Value, &expected); err != nil {
- return fmt.Errorf("fault %s has invalid collected restart-count expectation: %w", fault.ID, err)
- }
- observed := resource.Docker.RestartCount
- satisfied := predicate.Operator == "eq" && observed == expected || predicate.Operator == "gte" && observed >= expected
- if !satisfied {
- return fmt.Errorf("fault %s target %s collected restart_count=%d does not satisfy %s %d", fault.ID, predicate.Target, observed, predicate.Operator, expected)
- }
+ if err := validateCollectedDockerPredicate("fault "+fault.ID, predicate, resources); err != nil {
+ return err
}
}
}
+
+ negativeControls := make(map[string]struct{}, len(manifest.NegativeControls))
+ for _, control := range manifest.NegativeControls {
+ negativeControls[control.Resource] = struct{}{}
+ }
+ for _, predicate := range manifest.Baseline {
+ if _, ok := negativeControls[predicate.Target]; !ok {
+ continue
+ }
+ if err := validateCollectedDockerPredicate("negative control "+predicate.Target, predicate, resources); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func validateCollectedDockerPredicate(subject string, predicate Predicate, resources map[string]Resource) error {
+ resource, ok := resources[predicate.Target]
+ if !ok {
+ return fmt.Errorf("%s target %s is absent from collected resources", subject, predicate.Target)
+ }
+ if resource.Docker == nil {
+ return fmt.Errorf("%s target %s has no collected Docker projection", subject, predicate.Target)
+ }
+ switch predicate.Probe {
+ case "docker.health":
+ var expected string
+ if err := json.Unmarshal(predicate.Value, &expected); err != nil {
+ return fmt.Errorf("%s has invalid collected health expectation: %w", subject, err)
+ }
+ if !strings.EqualFold(strings.TrimSpace(resource.Docker.Health), strings.TrimSpace(expected)) {
+ return fmt.Errorf("%s target %s collected health=%q want %q", subject, predicate.Target, resource.Docker.Health, expected)
+ }
+ case "docker.running":
+ var expected bool
+ if err := json.Unmarshal(predicate.Value, &expected); err != nil {
+ return fmt.Errorf("%s has invalid collected running expectation: %w", subject, err)
+ }
+ running := strings.EqualFold(strings.TrimSpace(resource.Docker.ContainerState), "running")
+ if running != expected {
+ return fmt.Errorf("%s target %s collected running=%t state=%q want %t", subject, predicate.Target, running, resource.Docker.ContainerState, expected)
+ }
+ case "docker.restart_count":
+ var expected int
+ if err := json.Unmarshal(predicate.Value, &expected); err != nil {
+ return fmt.Errorf("%s has invalid collected restart-count expectation: %w", subject, err)
+ }
+ observed := resource.Docker.RestartCount
+ satisfied := predicate.Operator == "eq" && observed == expected || predicate.Operator == "gte" && observed >= expected
+ if !satisfied {
+ return fmt.Errorf("%s target %s collected restart_count=%d does not satisfy %s %d", subject, predicate.Target, observed, predicate.Operator, expected)
+ }
+ }
return nil
}