From c17e3814ee871eee8a4c2704d57c5da68bcd6be0 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sat, 11 Jul 2026 12:02:05 +0100 Subject: [PATCH] Rename the demo Patrol snapshot parameter so the SRC-04b guard passes synthesizeDemoPatrolFindings took its patrolRuntimeState parameter as 'state', which trips the textual direct-state-access ban in TestNoDirectStateAccessForMigratedResources even though the struct is the sanctioned snapshot wrapper. The rest of the Patrol code names these parameters 'snap' for exactly this reason, so the demo function now follows suit. No behavior change. --- internal/ai/demo.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/ai/demo.go b/internal/ai/demo.go index b180e1944..86cbb9769 100644 --- a/internal/ai/demo.go +++ b/internal/ai/demo.go @@ -307,11 +307,11 @@ func (p *PatrolService) backfillDemoRunHistory(template PatrolRunRecord, now tim // pins a set of deliberate anomalies (an offline Docker edge host, a degraded // PBS instance, unhealthy containers), which gives the surface a stable core // of findings across cycles. -func synthesizeDemoPatrolFindings(state patrolRuntimeState, now time.Time) []*Finding { +func synthesizeDemoPatrolFindings(snap patrolRuntimeState, now time.Time) []*Finding { var findings []*Finding // Offline Docker host: the demo scenario keeps one edge host offline. - for _, host := range state.DockerHosts { + for _, host := range snap.DockerHosts { if !strings.EqualFold(strings.TrimSpace(host.Status), "offline") { continue } @@ -343,8 +343,8 @@ func synthesizeDemoPatrolFindings(state patrolRuntimeState, now time.Time) []*Fi // Highest-utilization storage pool, quoting its actual numbers. var topStorage *models.Storage - for i := range state.Storage { - s := &state.Storage[i] + for i := range snap.Storage { + s := &snap.Storage[i] if s.Total <= 0 || !s.Enabled || strings.EqualFold(strings.TrimSpace(s.Status), "offline") { continue } @@ -386,7 +386,7 @@ func synthesizeDemoPatrolFindings(state patrolRuntimeState, now time.Time) []*Fi } // Degraded backup server: the demo scenario keeps one PBS instance degraded. - for _, pbs := range state.PBSInstances { + for _, pbs := range snap.PBSInstances { statusBad := !strings.EqualFold(strings.TrimSpace(pbs.Status), "online") healthBad := pbs.ConnectionHealth != "" && !strings.EqualFold(strings.TrimSpace(pbs.ConnectionHealth), "healthy") if !statusBad && !healthBad { @@ -418,7 +418,7 @@ func synthesizeDemoPatrolFindings(state patrolRuntimeState, now time.Time) []*Fi // Unhealthy or restart-looping containers on online Docker hosts. containerFindings := 0 - for _, host := range state.DockerHosts { + for _, host := range snap.DockerHosts { if strings.EqualFold(strings.TrimSpace(host.Status), "offline") { continue } @@ -470,7 +470,7 @@ func synthesizeDemoPatrolFindings(state patrolRuntimeState, now time.Time) []*Fi } // Degraded mail gateway: the demo scenario keeps one PMG instance degraded. - for _, pmg := range state.PMGInstances { + for _, pmg := range snap.PMGInstances { if strings.EqualFold(strings.TrimSpace(pmg.Status), "online") { continue } @@ -512,12 +512,12 @@ func synthesizeDemoPatrolFindings(state patrolRuntimeState, now time.Time) []*Fi topGuest = &guestRef{id: id, name: name, node: node, kind: kind, usage: mem.Usage, used: mem.Used, total: mem.Total} } } - for i := range state.VMs { - vm := &state.VMs[i] + for i := range snap.VMs { + vm := &snap.VMs[i] consider(vm.ID, vm.Name, vm.Node, "VM", vm.Status, vm.Memory) } - for i := range state.Containers { - ct := &state.Containers[i] + for i := range snap.Containers { + ct := &snap.Containers[i] consider(ct.ID, ct.Name, ct.Node, "Container", ct.Status, ct.Memory) } if topGuest != nil && topGuest.usage >= 85 {