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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
fix(patrol): split truenas from agent run history
rcourtmanf0ce8d71d9cb
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 8de5d0438d..8f067329e0 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -203,6 +203,11 @@ history, and chat sessions must not keep legacy plaintext files on the runtimeprimary path once the process can read them. Plaintext AI persistence files mayonly serve as migration input and must be rewritten immediately intoencrypted-at-rest storage on load.+That same Patrol runtime ownership also governs Patrol run-summary taxonomy.+`internal/ai/` must keep API-backed TrueNAS systems distinct from unified-agent+hosts in runtime counts, triage summaries, and persisted Patrol run history+instead of collapsing both surfaces back into `hosts_checked` or generic+`agent` resource wording.That same config-persistence boundary also owns fixed runtime file paths: theresolved data directory must be normalized once and fixed AI/runtime filenamesmust rejoin through the shared storage-path helper instead of rawdiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex b75145a08c..fce6fca536 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -218,6 +218,7 @@ Own canonical runtime payload shapes between backend and frontend.14. Keep recovery platform-query vocabulary canonical across that same `/api/recovery/*` surface: operator-facing transport must emit `platform` as the canonical query field, accepted legacy `provider` aliases must remain compatibility-only input, and `internal/api/contract_test.go` must pin that fallback behavior in the same slice as any handler change15. Keep recovery payload platform vocabulary canonical across that same `/api/recovery/*` surface: point payloads must expose `platform`, rollup payloads must expose `platforms`, and any compatibility `provider` / `providers` aliases must remain secondary fallback fields rather than replacing the shared response model16. Keep recovery linked-resource vocabulary canonical across that same `/api/recovery/*` surface: points and rollups must expose `itemResourceId` as the canonical linked-resource field, accepted legacy `subjectResourceId` aliases must remain compatibility-only input or secondary payload fields, and the shared proof surface must pin that normalization in the same slice as any handler change+17. Keep Patrol run-history payload taxonomy canonical across `/api/ai/patrol/runs` and `/api/ai/patrol/runs/:id`: run records must expose `truenas_checked` as a first-class count when API-backed TrueNAS systems were scanned, and the frontend Patrol client may only coerce missing historical values to `0` as compatibility normalization for older persisted runs, not as a replacement for the canonical backend field.17. Keep recovery external item-reference vocabulary canonical across that same `/api/recovery/*` surface: point and rollup payloads must expose `itemRef` as the canonical external item-reference field, accepted legacy `subjectRef` aliases must remain compatibility-only secondary payload fields, and the shared proof surface must pin that normalization in the same slice as any handler change18. Keep first-host lookup completion explicit on the shared install-state APIboundary: whendiff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex b2c7c0e316..304e80a952 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -218,6 +218,12 @@ work extends shared components instead of creating new local variants.destination chips to render, but canonical href, label, dedupe, andinfrastructure-fallback truth must stay in`frontend-modern/src/routing/resourceLinks.ts` instead of freezing raw+14. Keep shared feature-shell Patrol run fixtures on the canonical run-record+ contract. When `frontend-modern/src/features/patrol/` consumes Patrol run+ history, the shared normalized record must preserve provider-backed counts+ such as `truenas_checked` instead of letting feature-local fixtures or+ fallback objects collapse API-backed TrueNAS systems back into generic+ agent-host presentation.route strings or provider-local link builders inside feature panels.14. Keep the authenticated app root aligned with that same first-session path.`frontend-modern/src/App.tsx` must land `/` on the dashboard shell and letdiff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.mdindex 1abc11857d..fb9b55b845 100644--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md@@ -217,6 +217,11 @@ The same supporting-chip rule applies to timing: the primary summary card mayshow health and active-finding support, but it should not add another recencypill once header metadata, verification, and findings footer already carry thegoverned activity/verification timestamps.+That same Patrol-owned run-history surface must keep platform-backed system+counts canonical too. When the backend distinguishes API-backed TrueNAS+systems from unified-agent hosts in Patrol run history, the run-history chips+and selected-run breakdown must render `TrueNAS` separately instead of+collapsing those systems back into the generic `agent` count.That summary-card/metrics-strip split also applies to findings counts. Theprimary assessment card may keep health as supporting context, but activefindings, warning counts, and critical counts belong to the supporting metricdiff --git a/frontend-modern/src/api/__tests__/patrol.test.ts b/frontend-modern/src/api/__tests__/patrol.test.tsindex 1826e9b202..0a5b35e0f5 100644--- a/frontend-modern/src/api/__tests__/patrol.test.ts+++ b/frontend-modern/src/api/__tests__/patrol.test.ts@@ -119,6 +119,7 @@ describe('patrol api', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 1,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -143,6 +144,7 @@ describe('patrol api', () => {expect(result[0]).toMatchObject({alertIdentifier: 'canonical-alert-1',effective_scope_resource_ids: ['resource-1', 'resource-2'],+ truenas_checked: 1,triage_flags: 2,triage_skipped_llm: true,});@@ -161,6 +163,7 @@ describe('patrol api', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -180,6 +183,7 @@ describe('patrol api', () => {await expect(getPatrolRun('run-2')).resolves.toMatchObject({id: 'run-2',alertIdentifier: 'canonical-alert-2',+ truenas_checked: 0,tool_call_count: 1,});});diff --git a/frontend-modern/src/api/patrol.ts b/frontend-modern/src/api/patrol.tsindex b92e90bf75..0b2feeb29c 100644--- a/frontend-modern/src/api/patrol.ts+++ b/frontend-modern/src/api/patrol.ts@@ -418,6 +418,7 @@ export interface PatrolRunRecord {docker_checked: number;storage_checked: number;hosts_checked: number;+ truenas_checked: number;pbs_checked: number;pmg_checked: number;kubernetes_checked: number;@@ -446,7 +447,16 @@ function normalizePatrolRunRecord(run: PatrolRunRecord | null | undefined): Patrif (!run || typeof run !== 'object' || Array.isArray(run)) {return null;}- return promoteLegacyAlertIdentifier(run as PatrolRunRecord & { alert_identifier?: string });+ const normalized = promoteLegacyAlertIdentifier(+ run as PatrolRunRecord & { alert_identifier?: string; truenas_checked?: number },+ );+ return {+ ...normalized,+ truenas_checked:+ typeof normalized.truenas_checked === 'number' && Number.isFinite(normalized.truenas_checked)+ ? normalized.truenas_checked+ : 0,+ };}function normalizeHistoryLimit(limit: number): number {diff --git a/frontend-modern/src/components/patrol/RunHistoryEntry.tsx b/frontend-modern/src/components/patrol/RunHistoryEntry.tsxindex 4b87ce5189..c47505e11c 100644--- a/frontend-modern/src/components/patrol/RunHistoryEntry.tsx+++ b/frontend-modern/src/components/patrol/RunHistoryEntry.tsx@@ -307,6 +307,12 @@ export function RunHistoryEntry(props: RunHistoryEntryProps) {{run.hosts_checked !== 1 ? 's' : ''}</span></Show>+ <Show when={run.truenas_checked > 0}>+ <span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-teal-50 text-teal-700 dark:bg-teal-900 dark:text-teal-300">+ <HardDriveIcon class="w-3 h-3" /> {run.truenas_checked} TrueNAS+ {run.truenas_checked !== 1 ? ' systems' : ' system'}+ </span>+ </Show><Show when={run.pbs_checked > 0}><span class="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-indigo-50 text-indigo-700 dark:bg-indigo-900 dark:text-indigo-300"><DatabaseIcon class="w-3 h-3" /> {run.pbs_checked} PBSdiff --git a/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx b/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsxindex 3b95471ca5..fce4bd0108 100644--- a/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx+++ b/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx@@ -39,6 +39,7 @@ describe('PatrolStatusBar', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -80,6 +81,7 @@ describe('PatrolStatusBar', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -124,6 +126,7 @@ describe('PatrolStatusBar', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -170,6 +173,7 @@ describe('PatrolStatusBar', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -212,6 +216,7 @@ describe('PatrolStatusBar', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -257,6 +262,7 @@ describe('PatrolStatusBar', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -310,6 +316,7 @@ describe('PatrolStatusBar', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -338,6 +345,7 @@ describe('PatrolStatusBar', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -365,6 +373,7 @@ describe('PatrolStatusBar', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -423,6 +432,7 @@ describe('PatrolStatusBar', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,diff --git a/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx b/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsxindex 5a84fa4f65..7062f0d238 100644--- a/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx+++ b/frontend-modern/src/components/patrol/__tests__/RunHistoryEntry.test.tsx@@ -69,6 +69,7 @@ describe('RunHistoryEntry', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -274,4 +275,26 @@ describe('RunHistoryEntry', () => {expect(screen.getByText('3 triage flags')).toBeInTheDocument();expect(screen.getByText('LLM skipped')).toBeInTheDocument();});++ it('renders TrueNAS run coverage separately from agent hosts', () => {+ render(() => (+ <RunHistoryEntry+ run={{+ ...run,+ id: 'run-truenas',+ resources_checked: 2,+ docker_checked: 1,+ truenas_checked: 1,+ }}+ isLive={false}+ patrolStream={patrolStream}+ selected={true}+ onSelect={vi.fn()}+ />+ ));++ expect(screen.getByText('1 container')).toBeInTheDocument();+ expect(screen.getByText('1 TrueNAS system')).toBeInTheDocument();+ expect(screen.queryByText('1 agent')).not.toBeInTheDocument();+ });});diff --git a/frontend-modern/src/components/patrol/__tests__/RunHistoryPanel.test.tsx b/frontend-modern/src/components/patrol/__tests__/RunHistoryPanel.test.tsxindex 38bc9eae8f..dca344d724 100644--- a/frontend-modern/src/components/patrol/__tests__/RunHistoryPanel.test.tsx+++ b/frontend-modern/src/components/patrol/__tests__/RunHistoryPanel.test.tsx@@ -38,6 +38,7 @@ describe('RunHistoryPanel', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,diff --git a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.tsindex 7dd19d576d..8c913c7fb8 100644--- a/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts+++ b/frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts@@ -510,6 +510,7 @@ export function usePatrolIntelligenceState() {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsxindex dbabc46187..2de681a404 100644--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx@@ -784,6 +784,7 @@ describe('AIIntelligence entitlement gating', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -933,6 +934,7 @@ describe('AIIntelligence entitlement gating', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -1050,6 +1052,7 @@ describe('AIIntelligence entitlement gating', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -1081,6 +1084,7 @@ describe('AIIntelligence entitlement gating', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -1112,6 +1116,7 @@ describe('AIIntelligence entitlement gating', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -1195,6 +1200,7 @@ describe('AIIntelligence entitlement gating', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -1258,6 +1264,7 @@ describe('AIIntelligence entitlement gating', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -1329,6 +1336,7 @@ describe('AIIntelligence entitlement gating', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,diff --git a/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.tsindex e6a1537f42..2d348c51ee 100644--- a/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts+++ b/frontend-modern/src/utils/__tests__/patrolRunPresentation.test.ts@@ -128,6 +128,7 @@ describe('patrolRunPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -156,6 +157,7 @@ describe('patrolRunPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -184,6 +186,7 @@ describe('patrolRunPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,diff --git a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.tsindex 2292480382..96cfab0ee1 100644--- a/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts+++ b/frontend-modern/src/utils/__tests__/patrolSummaryPresentation.test.ts@@ -318,6 +318,7 @@ describe('getPatrolSummaryPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -361,6 +362,7 @@ describe('getPatrolSummaryPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -389,6 +391,7 @@ describe('getPatrolSummaryPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -416,6 +419,7 @@ describe('getPatrolSummaryPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -460,6 +464,7 @@ describe('getPatrolSummaryPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -503,6 +508,7 @@ describe('getPatrolSummaryPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -546,6 +552,7 @@ describe('getPatrolSummaryPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,@@ -585,6 +592,7 @@ describe('getPatrolSummaryPresentation', () => {docker_checked: 0,storage_checked: 0,hosts_checked: 0,+ truenas_checked: 0,pbs_checked: 0,pmg_checked: 0,kubernetes_checked: 0,diff --git a/internal/ai/patrol.go b/internal/ai/patrol.goindex 8f94cd37c5..224200ad8b 100644--- a/internal/ai/patrol.go+++ b/internal/ai/patrol.go@@ -134,6 +134,7 @@ type PatrolRunRecord struct {DockerChecked int `json:"docker_checked"`StorageChecked int `json:"storage_checked"`HostsChecked int `json:"hosts_checked"`+ TrueNASChecked int `json:"truenas_checked"`PBSChecked int `json:"pbs_checked"`PMGChecked int `json:"pmg_checked"`KubernetesChecked int `json:"kubernetes_checked"`@@ -178,6 +179,7 @@ type patrolRunRecordJSON struct {DockerChecked int `json:"docker_checked"`StorageChecked int `json:"storage_checked"`HostsChecked int `json:"hosts_checked"`+ TrueNASChecked int `json:"truenas_checked"`PBSChecked int `json:"pbs_checked"`PMGChecked int `json:"pmg_checked"`KubernetesChecked int `json:"kubernetes_checked"`@@ -252,6 +254,7 @@ func (r PatrolRunRecord) MarshalJSON() ([]byte, error) {DockerChecked: normalized.DockerChecked,StorageChecked: normalized.StorageChecked,HostsChecked: normalized.HostsChecked,+ TrueNASChecked: normalized.TrueNASChecked,PBSChecked: normalized.PBSChecked,PMGChecked: normalized.PMGChecked,KubernetesChecked: normalized.KubernetesChecked,@@ -300,6 +303,7 @@ func (r *PatrolRunRecord) UnmarshalJSON(data []byte) error {DockerChecked: payload.DockerChecked,StorageChecked: payload.StorageChecked,HostsChecked: payload.HostsChecked,+ TrueNASChecked: payload.TrueNASChecked,PBSChecked: payload.PBSChecked,PMGChecked: payload.PMGChecked,KubernetesChecked: payload.KubernetesChecked,diff --git a/internal/ai/patrol_history_persistence.go b/internal/ai/patrol_history_persistence.goindex bb90d8c500..4779818938 100644--- a/internal/ai/patrol_history_persistence.go+++ b/internal/ai/patrol_history_persistence.go@@ -54,6 +54,7 @@ func (a *PatrolHistoryPersistenceAdapter) SavePatrolRunHistory(runs []PatrolRunRDockerChecked: normalized.DockerChecked,StorageChecked: normalized.StorageChecked,HostsChecked: normalized.HostsChecked,+ TrueNASChecked: normalized.TrueNASChecked,PBSChecked: normalized.PBSChecked,PMGChecked: normalized.PMGChecked,KubernetesChecked: normalized.KubernetesChecked,@@ -108,6 +109,7 @@ func (a *PatrolHistoryPersistenceAdapter) LoadPatrolRunHistory() ([]PatrolRunRecDockerChecked: r.DockerChecked,StorageChecked: r.StorageChecked,HostsChecked: r.HostsChecked,+ TrueNASChecked: r.TrueNASChecked,PBSChecked: r.PBSChecked,PMGChecked: r.PMGChecked,KubernetesChecked: r.KubernetesChecked,diff --git a/internal/ai/patrol_history_persistence_test.go b/internal/ai/patrol_history_persistence_test.goindex 75314f85f6..4f7132294e 100644--- a/internal/ai/patrol_history_persistence_test.go+++ b/internal/ai/patrol_history_persistence_test.go@@ -525,6 +525,7 @@ func TestPatrolHistoryPersistenceAdapter_SaveAndLoad(t *testing.T) {DockerChecked: 1,StorageChecked: 1,HostsChecked: 0,+ TrueNASChecked: 1,PBSChecked: 0,NewFindings: 1,ExistingFindings: 2,@@ -557,6 +558,9 @@ func TestPatrolHistoryPersistenceAdapter_SaveAndLoad(t *testing.T) {if strings.Join(loaded[0].EffectiveScopeResourceIDs, ",") != strings.Join(runs[0].EffectiveScopeResourceIDs, ",") {t.Fatalf("expected effective scope IDs %v, got %v", runs[0].EffectiveScopeResourceIDs, loaded[0].EffectiveScopeResourceIDs)}+ if loaded[0].TrueNASChecked != runs[0].TrueNASChecked {+ t.Fatalf("expected TrueNASChecked=%d, got %d", runs[0].TrueNASChecked, loaded[0].TrueNASChecked)+ }}func TestPatrolHistoryPersistenceAdapter_PreservesEmptySnapshotsAndParityFields(t *testing.T) {@@ -577,6 +581,7 @@ func TestPatrolHistoryPersistenceAdapter_PreservesEmptySnapshotsAndParityFields(ScopeResourceTypes: []string{"vm"},ResourcesChecked: 2,GuestsChecked: 2,+ TrueNASChecked: 1,PMGChecked: 1,NewFindings: 0,ExistingFindings: 1,@@ -617,6 +622,9 @@ func TestPatrolHistoryPersistenceAdapter_PreservesEmptySnapshotsAndParityFields(if loaded[0].PMGChecked != 1 {t.Fatalf("expected PMGChecked=1, got %d", loaded[0].PMGChecked)}+ if loaded[0].TrueNASChecked != 1 {+ t.Fatalf("expected TrueNASChecked=1, got %d", loaded[0].TrueNASChecked)+ }if loaded[0].RejectedFindings != 1 {t.Fatalf("expected RejectedFindings=1, got %d", loaded[0].RejectedFindings)}diff --git a/internal/ai/patrol_resource_state_test.go b/internal/ai/patrol_resource_state_test.goindex 969b852d52..cd47bf4371 100644--- a/internal/ai/patrol_resource_state_test.go+++ b/internal/ai/patrol_resource_state_test.go@@ -13,8 +13,11 @@ func TestGetResourceCurrentState(t *testing.T) {state := models.StateSnapshot{Storage: []models.Storage{{ID: "storage-1", Name: "local", Usage: 42, Status: "active"}},Nodes: []models.Node{{ID: "node-1", Name: "node-1", CPU: 0.2, Memory: models.Memory{Usage: 33}, Status: "online"}},- Hosts: []models.Host{{ID: "host-1", Hostname: "host-1", CPUUsage: 27.5, Memory: models.Memory{Usage: 41.0}, Status: "online"}},- VMs: []models.VM{{ID: "vm-1", Name: "vm-1", CPU: 0.1, Memory: models.Memory{Usage: 44}, Status: "running"}},+ Hosts: []models.Host{+ {ID: "host-1", Hostname: "host-1", CPUUsage: 27.5, Memory: models.Memory{Usage: 41.0}, Status: "online"},+ {ID: "truenas-1", Hostname: "truenas-1", DisplayName: "TrueNAS Main", Platform: "truenas", CPUUsage: 18.0, Memory: models.Memory{Usage: 52.0}, Status: "online"},+ },+ VMs: []models.VM{{ID: "vm-1", Name: "vm-1", CPU: 0.1, Memory: models.Memory{Usage: 44}, Status: "running"}},Containers: []models.Container{{ID: "ct-1", Name: "ct-1", CPU: 0.3, Memory: models.Memory{Usage: 55}, Status: "running"},},@@ -34,6 +37,7 @@ func TestGetResourceCurrentState(t *testing.T) {{alert: AlertInfo{ResourceType: "usage", Type: "usage", ResourceID: "storage-1", ResourceName: "local"}, assert: "Storage 'local'"},{alert: AlertInfo{ResourceType: "node", ResourceID: "node-1", ResourceName: "node-1"}, assert: "Node 'node-1'"},{alert: AlertInfo{ResourceType: "agent", ResourceID: "host-1", ResourceName: "host-1"}, assert: "Agent host 'host-1'"},+ {alert: AlertInfo{ResourceType: "truenas", ResourceID: "truenas-1", ResourceName: "TrueNAS Main"}, assert: "TrueNAS 'truenas-1'"},{alert: AlertInfo{ResourceType: "vm", ResourceID: "vm-1", ResourceName: "vm-1"}, assert: "VM 'vm-1'"},{alert: AlertInfo{ResourceType: "system-container", ResourceID: "ct-1", ResourceName: "ct-1"}, assert: "Container 'ct-1'"},{alert: AlertInfo{ResourceType: "app-container", ResourceID: "dc-1", ResourceName: "web"}, assert: "Docker container 'web'"},diff --git a/internal/ai/patrol_run.go b/internal/ai/patrol_run.goindex 2d593fa8e7..b4205ec496 100644--- a/internal/ai/patrol_run.go+++ b/internal/ai/patrol_run.go@@ -277,6 +277,7 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger TriggedockerChecked intstorageChecked inthostsChecked int+ trueNASChecked intpbsChecked intpmgChecked intkubernetesChecked int@@ -345,12 +346,14 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger Trigge}if cfg.AnalyzeHosts {runStats.hostsChecked = resourceCounts.hosts+ runStats.trueNASChecked = resourceCounts.truenas}if cfg.AnalyzeKubernetes {runStats.kubernetesChecked = resourceCounts.kubernetes}runStats.resourceCount = runStats.nodesChecked + runStats.guestsChecked +runStats.dockerChecked + runStats.storageChecked + runStats.pbsChecked + runStats.pmgChecked + runStats.hostsChecked ++ runStats.trueNASChecked +runStats.kubernetesChecked// Determine if we can run LLM analysis (requires AI service + circuit breaker not open)@@ -573,6 +576,7 @@ func (p *PatrolService) runPatrolWithTrigger(ctx context.Context, trigger TriggeDockerChecked: runStats.dockerChecked,StorageChecked: runStats.storageChecked,HostsChecked: runStats.hostsChecked,+ TrueNASChecked: runStats.trueNASChecked,PBSChecked: runStats.pbsChecked,PMGChecked: runStats.pmgChecked,KubernetesChecked: runStats.kubernetesChecked,@@ -713,6 +717,7 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)dockerChecked intstorageChecked inthostsChecked int+ trueNASChecked intpbsChecked intpmgChecked intkubernetesChecked int@@ -757,6 +762,7 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)}if cfg.AnalyzeHosts {resourceCount += resourceCounts.hosts+ resourceCount += resourceCounts.truenas}if cfg.AnalyzeKubernetes {resourceCount += resourceCounts.kubernetes@@ -801,6 +807,7 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)}if cfg.AnalyzeHosts {runStats.hostsChecked = resourceCounts.hosts+ runStats.trueNASChecked = resourceCounts.truenas}if cfg.AnalyzeKubernetes {runStats.kubernetesChecked = resourceCounts.kubernetes@@ -934,6 +941,7 @@ func (p *PatrolService) runScopedPatrol(ctx context.Context, scope PatrolScope)DockerChecked: runStats.dockerChecked,StorageChecked: runStats.storageChecked,HostsChecked: runStats.hostsChecked,+ TrueNASChecked: runStats.trueNASChecked,PBSChecked: runStats.pbsChecked,PMGChecked: runStats.pmgChecked,KubernetesChecked: runStats.kubernetesChecked,@@ -2083,7 +2091,11 @@ func lookupPatrolAlertResourceState(alert AlertInfo, snap patrolRuntimeState) pareturn resource}case "agent":- if resource, ok := patrolLookupAgentAlertResourceState(alert, snap); ok {+ if resource, ok := patrolLookupHostAlertResourceState(alert, snap); ok {+ return resource+ }+ case "truenas":+ if resource, ok := patrolLookupHostAlertResourceState(alert, snap); ok {return resource}}@@ -2158,8 +2170,8 @@ func patrolLookupGuestAlertResourceState(alert AlertInfo, snap patrolRuntimeStat}type patrolHostAlertRow struct {- id, name, hostname, status string- cpu, memory float64+ id, name, hostname, status, platform, resourceType string+ cpu, memory float64}func patrolHostAlertRows(snap patrolRuntimeState) []patrolHostAlertRow {@@ -2168,12 +2180,14 @@ func patrolHostAlertRows(snap patrolRuntimeState) []patrolHostAlertRow {rows := make([]patrolHostAlertRow, 0, len(hosts))for _, host := range hosts {rows = append(rows, patrolHostAlertRow{- id: host.ID(),- name: host.Name(),- hostname: host.Hostname(),- status: string(host.Status()),- cpu: host.CPUPercent(),- memory: host.MemoryPercent(),+ id: host.ID(),+ name: host.Name(),+ hostname: host.Hostname(),+ status: string(host.Status()),+ platform: host.Platform(),+ resourceType: patrolHostResourceType(host.Platform()),+ cpu: host.CPUPercent(),+ memory: host.MemoryPercent(),})}return rows@@ -2182,18 +2196,27 @@ func patrolHostAlertRows(snap patrolRuntimeState) []patrolHostAlertRow {rows := make([]patrolHostAlertRow, 0, len(snap.Hosts))for _, host := range snap.Hosts {rows = append(rows, patrolHostAlertRow{- id: host.ID,- name: host.DisplayName,- hostname: host.Hostname,- status: host.Status,- cpu: host.CPUUsage,- memory: host.Memory.Usage,+ id: host.ID,+ name: host.DisplayName,+ hostname: host.Hostname,+ status: host.Status,+ platform: host.Platform,+ resourceType: patrolHostResourceType(host.Platform),+ cpu: host.CPUUsage,+ memory: host.Memory.Usage,})}return rows}-func patrolLookupAgentAlertResourceState(alert AlertInfo, snap patrolRuntimeState) (patrolAlertResourceState, bool) {+func patrolHostResourceType(platform string) string {+ if strings.EqualFold(strings.TrimSpace(platform), "truenas") {+ return "truenas"+ }+ return "agent"+}++func patrolLookupHostAlertResourceState(alert AlertInfo, snap patrolRuntimeState) (patrolAlertResourceState, bool) {for _, host := range patrolHostAlertRows(snap) {if !patrolAlertNameMatches(alert, host.id, host.name, host.hostname) {continue@@ -2203,7 +2226,7 @@ func patrolLookupAgentAlertResourceState(alert AlertInfo, snap patrolRuntimeStatname = host.name}return patrolAlertResourceState{- resourceType: "agent",+ resourceType: host.resourceType,name: name,status: host.status,cpu: host.cpu,@@ -2239,7 +2262,7 @@ func (p *PatrolService) isResourceOnlineState(alert AlertInfo, snap patrolRuntimreturn false}switch resource.resourceType {- case "node", "agent":+ case "node", "agent", "truenas":return resource.status == "online"case "vm", "system-container", "app-container":return resource.status == "running" || resource.status == string(unifiedresources.StatusOnline)@@ -2302,6 +2325,8 @@ func (p *PatrolService) getResourceCurrentStateState(alert AlertInfo, snap patroreturn "Storage not found in current state (may have been removed)"case "node":return "Node not found in current state"+ case "truenas":+ return "TrueNAS system not found in current state"case "agent":return "Agent host not found in current state"case "vm":@@ -2320,6 +2345,9 @@ func (p *PatrolService) getResourceCurrentStateState(alert AlertInfo, snap patrocase "node":return fmt.Sprintf("Node '%s': CPU %.1f%%, Memory %.1f%%, Status: %s",resource.name, resource.cpu, resource.memory, resource.status)+ case "truenas":+ return fmt.Sprintf("TrueNAS '%s': CPU %.1f%%, Memory %.1f%%, Status: %s",+ resource.name, resource.cpu, resource.memory, resource.status)case "agent":return fmt.Sprintf("Agent host '%s': CPU %.1f%%, Memory %.1f%%, Status: %s",resource.name, resource.cpu, resource.memory, resource.status)diff --git a/internal/ai/patrol_run_test.go b/internal/ai/patrol_run_test.goindex 42cd7c264c..991739f3db 100644--- a/internal/ai/patrol_run_test.go+++ b/internal/ai/patrol_run_test.go@@ -608,6 +608,15 @@ func TestPatrolRuntimeResourceHelpers_PrepareCanonicalInventory(t *testing.T) {Hostname: "agent.local",},})+ trueNASHostView := unifiedresources.NewHostView(&unifiedresources.Resource{+ ID: "truenas-1",+ Name: "truenas-main",+ Type: unifiedresources.ResourceTypeAgent,+ Agent: &unifiedresources.AgentData{+ Hostname: "truenas-main.local",+ Platform: "truenas",+ },+ })pbsView := unifiedresources.NewPBSInstanceView(&unifiedresources.Resource{ID: "pbs-1",Name: "pbs-a",@@ -629,7 +638,7 @@ func TestPatrolRuntimeResourceHelpers_PrepareCanonicalInventory(t *testing.T) {nodes: []*unifiedresources.NodeView{&nodeView},vms: []*unifiedresources.VMView{vmView},containers: []*unifiedresources.ContainerView{ctView},- hosts: []*unifiedresources.HostView{&hostView},+ hosts: []*unifiedresources.HostView{&hostView, &trueNASHostView},dockerHosts: []*unifiedresources.DockerHostView{&dockerHostView},dockerCtrs: []*unifiedresources.DockerContainerView{&dockerCtrView},storage: []*unifiedresources.StoragePoolView{&storageView},@@ -649,6 +658,7 @@ func TestPatrolRuntimeResourceHelpers_PrepareCanonicalInventory(t *testing.T) {},Hosts: []models.Host{{ID: "agent-1", DisplayName: "agent-display", Hostname: "agent.local"},+ {ID: "truenas-1", DisplayName: "truenas-display", Hostname: "truenas-main.local", Platform: "truenas"},},KubernetesClusters: []models.KubernetesCluster{{ID: "k8s-1", CustomDisplayName: "cluster-custom", Name: "cluster-a"},@@ -674,15 +684,15 @@ func TestPatrolRuntimeResourceHelpers_PrepareCanonicalInventory(t *testing.T) {}counts := patrolRuntimeCountResources(state)- if counts.nodes != 1 || counts.guests != 2 || counts.storage != 2 || counts.docker != 1 || counts.hosts != 1 || counts.pbs != 1 || counts.pmg != 1 || counts.kubernetes != 1 {+ if counts.nodes != 1 || counts.guests != 2 || counts.storage != 2 || counts.docker != 1 || counts.hosts != 1 || counts.truenas != 1 || counts.pbs != 1 || counts.pmg != 1 || counts.kubernetes != 1 {t.Fatalf("unexpected canonical runtime counts: %#v", counts)}- if counts.total() != 10 {- t.Fatalf("expected canonical runtime total 10, got %#v", counts)+ if counts.total() != 11 {+ t.Fatalf("expected canonical runtime total 11, got %#v", counts)}resourceIDs := patrolRuntimeSortedResourceIDs(state)- for _, want := range []string{"node-1", "qemu/100", "lxc/200", "storage-1", "docker-1", "ctr-1", "agent-1", "pbs-1", "pmg-1", "k8s-1", "disk-1", "/dev/sda"} {+ for _, want := range []string{"node-1", "qemu/100", "lxc/200", "storage-1", "docker-1", "ctr-1", "agent-1", "truenas-1", "pbs-1", "pmg-1", "k8s-1", "disk-1", "/dev/sda"} {found := falsefor _, got := range resourceIDs {if got == want {@@ -696,7 +706,7 @@ func TestPatrolRuntimeResourceHelpers_PrepareCanonicalInventory(t *testing.T) {}known := patrolRuntimeKnownResources(state)- for _, want := range []string{"node-a", "vm-a", "ct-a", "local-zfs", "docker.local", "docker-custom", "web", "web-snapshot", "agent.local", "agent-display", "cluster-a", "cluster-custom", "Samsung SSD"} {+ for _, want := range []string{"node-a", "vm-a", "ct-a", "local-zfs", "docker.local", "docker-custom", "web", "web-snapshot", "agent.local", "agent-display", "truenas-main", "truenas-main.local", "truenas-display", "cluster-a", "cluster-custom", "Samsung SSD"} {if !known[want] {t.Fatalf("expected known runtime resources to include %q", want)}@@ -1700,6 +1710,26 @@ func TestIsResourceOnline_Agent(t *testing.T) {}}+func TestIsResourceOnline_TrueNAS(t *testing.T) {+ ps := NewPatrolService(nil, nil)+ state := models.StateSnapshot{+ Hosts: []models.Host{+ {ID: "tn1", Hostname: "truenas-1", DisplayName: "TrueNAS One", Platform: "truenas", Status: "online"},+ {ID: "tn2", Hostname: "truenas-2", Platform: "truenas", Status: "offline"},+ },+ }++ alert := AlertInfo{ResourceID: "tn1", ResourceType: "truenas"}+ if !ps.isResourceOnlineState(alert, patrolRuntimeStateForTest(ps, state)) {+ t.Error("expected TrueNAS tn1 to be online")+ }++ alert = AlertInfo{ResourceID: "tn2", ResourceType: "truenas"}+ if ps.isResourceOnlineState(alert, patrolRuntimeStateForTest(ps, state)) {+ t.Error("expected TrueNAS tn2 to be offline")+ }+}+func TestIsResourceOnline_UnknownType(t *testing.T) {ps := NewPatrolService(nil, nil)state := models.StateSnapshot{}@@ -1853,6 +1883,26 @@ func TestIsResourceOnline_UsesReadStateWhenLegacySlicesEmpty(t *testing.T) {}}+func TestIsResourceOnline_UsesReadStateForTrueNASWhenLegacySlicesEmpty(t *testing.T) {+ ps := NewPatrolService(nil, nil)+ state := newPatrolRuntimeState(models.StateSnapshot{})+ hostView := unifiedresources.NewHostView(&unifiedresources.Resource{+ ID: "tn1",+ Name: "truenas-1",+ Type: unifiedresources.ResourceTypeAgent,+ Status: unifiedresources.StatusOnline,+ Agent: &unifiedresources.AgentData{+ Hostname: "truenas-1",+ Platform: "truenas",+ },+ })+ state.readState = &mockReadState{hosts: []*unifiedresources.HostView{&hostView}}++ if !ps.isResourceOnlineState(AlertInfo{ResourceID: "tn1", ResourceType: "truenas", Type: "offline"}, state) {+ t.Fatal("expected TrueNAS host to be online via readState")+ }+}+func TestGetResourceCurrentState_UsesReadStateWhenLegacySlicesEmpty(t *testing.T) {ps := NewPatrolService(nil, nil)state := newPatrolRuntimeState(models.StateSnapshot{})diff --git a/internal/ai/patrol_state.go b/internal/ai/patrol_state.goindex 1e10aab27c..be94a426ad 100644--- a/internal/ai/patrol_state.go+++ b/internal/ai/patrol_state.go@@ -18,6 +18,7 @@ const (patrolRuntimeResourceDockerHost patrolRuntimeResourceKind = "docker-host"patrolRuntimeResourceDockerItem patrolRuntimeResourceKind = "docker-container"patrolRuntimeResourceHost patrolRuntimeResourceKind = "host"+ patrolRuntimeResourceTrueNAS patrolRuntimeResourceKind = "truenas"patrolRuntimeResourcePBS patrolRuntimeResourceKind = "pbs"patrolRuntimeResourcePMG patrolRuntimeResourceKind = "pmg"patrolRuntimeResourceK8sCluster patrolRuntimeResourceKind = "k8s-cluster"@@ -157,6 +158,12 @@ func patrolVisitRuntimeResources(s patrolRuntimeState, visit func(patrolRuntimeRemit := func(kind patrolRuntimeResourceKind, ids []string, aliases ...string) bool {return visit(patrolRuntimeResourceRecord{kind: kind, ids: ids, aliases: aliases})}+ hostResourceKind := func(platform string) patrolRuntimeResourceKind {+ if strings.EqualFold(strings.TrimSpace(platform), "truenas") {+ return patrolRuntimeResourceTrueNAS+ }+ return patrolRuntimeResourceHost+ }if rs := s.readState; rs != nil {for _, n := range rs.Nodes() {@@ -190,7 +197,7 @@ func patrolVisitRuntimeResources(s patrolRuntimeState, visit func(patrolRuntimeR}}for _, h := range rs.Hosts() {- if !emit(patrolRuntimeResourceHost, []string{h.ID()}, h.Name(), h.Hostname()) {+ if !emit(hostResourceKind(h.Platform()), []string{h.ID()}, h.Name(), h.Hostname()) {return}}@@ -241,7 +248,7 @@ func patrolVisitRuntimeResources(s patrolRuntimeState, visit func(patrolRuntimeR}}for _, h := range s.Hosts {- if !emit(patrolRuntimeResourceHost, []string{h.ID}, h.DisplayName, h.Hostname) {+ if !emit(hostResourceKind(h.Platform), []string{h.ID}, h.DisplayName, h.Hostname) {return}}@@ -429,13 +436,14 @@ type patrolRuntimeResourceCounts struct {docker intstorage inthosts int+ truenas intpbs intpmg intkubernetes int}func (c patrolRuntimeResourceCounts) total() int {- return c.nodes + c.guests + c.docker + c.storage + c.hosts + c.pbs + c.pmg + c.kubernetes+ return c.nodes + c.guests + c.docker + c.storage + c.hosts + c.truenas + c.pbs + c.pmg + c.kubernetes}func patrolRuntimeCountResources(s patrolRuntimeState) patrolRuntimeResourceCounts {@@ -452,6 +460,8 @@ func patrolRuntimeCountResources(s patrolRuntimeState) patrolRuntimeResourceCouncounts.storage++case patrolRuntimeResourceHost:counts.hosts+++ case patrolRuntimeResourceTrueNAS:+ counts.truenas++case patrolRuntimeResourcePBS:counts.pbs++case patrolRuntimeResourcePMG:diff --git a/internal/ai/patrol_test.go b/internal/ai/patrol_test.goindex 8756bcf9fd..95800d865b 100644--- a/internal/ai/patrol_test.go+++ b/internal/ai/patrol_test.go@@ -498,6 +498,7 @@ func TestPatrolRunRecord(t *testing.T) {ResourcesChecked: 10,NodesChecked: 2,GuestsChecked: 5,+ TrueNASChecked: 1,NewFindings: 1,Status: "issues_found",}@@ -526,6 +527,9 @@ func TestPatrolRunRecord(t *testing.T) {if record.GuestsChecked != 5 {t.Errorf("Expected 5 guests checked, got %d", record.GuestsChecked)}+ if record.TrueNASChecked != 1 {+ t.Errorf("Expected 1 TrueNAS system checked, got %d", record.TrueNASChecked)+ }if record.NewFindings != 1 {t.Errorf("Expected 1 new finding, got %d", record.NewFindings)}@@ -567,13 +571,17 @@ func TestPatrolRunRecordJSONCanonicalOutput(t *testing.T) {"started_at":"2026-03-11T00:00:00Z","completed_at":"2026-03-11T00:01:00Z","duration_ms":60000,- "alert_identifier":"instance:node:100::metric/cpu"+ "alert_identifier":"instance:node:100::metric/cpu",+ "truenas_checked":1}`), &decodedCanonical); err != nil {t.Fatalf("unmarshal canonical patrol run: %v", err)}if decodedCanonical.AlertIdentifier != "instance:node:100::metric/cpu" {t.Fatalf("expected canonical alert_identifier to load, got %q", decodedCanonical.AlertIdentifier)}+ if decodedCanonical.TrueNASChecked != 1 {+ t.Fatalf("expected truenas_checked to load, got %d", decodedCanonical.TrueNASChecked)+ }var decoded PatrolRunRecordif err := json.Unmarshal([]byte(`{@@ -581,13 +589,17 @@ func TestPatrolRunRecordJSONCanonicalOutput(t *testing.T) {"started_at":"2026-03-11T00:00:00Z","completed_at":"2026-03-11T00:01:00Z","duration_ms":60000,- "alert_identifier":"instance:node:100::metric/cpu"+ "alert_identifier":"instance:node:100::metric/cpu",+ "truenas_checked":1}`), &decoded); err != nil {t.Fatalf("unmarshal canonical patrol run: %v", err)}if decoded.AlertIdentifier != "instance:node:100::metric/cpu" {t.Fatalf("expected canonical alert_identifier to populate canonical field, got %q", decoded.AlertIdentifier)}+ if decoded.TrueNASChecked != 1 {+ t.Fatalf("expected truenas_checked to populate canonical field, got %d", decoded.TrueNASChecked)+ }}func TestPatrolStatus_Fields(t *testing.T) {diff --git a/internal/ai/patrol_triage.go b/internal/ai/patrol_triage.goindex 5660cef2f0..62f2929fe1 100644--- a/internal/ai/patrol_triage.go+++ b/internal/ai/patrol_triage.go@@ -44,6 +44,7 @@ type TriageSummary struct {TotalPhysicalDisks intTotalStorage intTotalDocker int+ TotalTrueNAS intTotalPBS intTotalPMG intFlaggedCount int@@ -350,7 +351,7 @@ func triageAlertChecksState(snap patrolRuntimeState, scopedSet map[string]bool)flags = append(flags, TriageFlag{ResourceID: alert.ResourceID,ResourceName: resourceName,- ResourceType: triageResourceType("", alert.ResourceID),+ ResourceType: triageRuntimeResourceType(snap, "", alert.ResourceID),Category: triageAlertCategory(alert.Type),Severity: severity,Reason: reason,@@ -373,7 +374,7 @@ func triageConnectivityChecksState(snap patrolRuntimeState, guestIntel map[strinflags = append(flags, TriageFlag{ResourceID: entry.resourceID,ResourceName: triageResourceName(entry.resourceID, entry.resourceID),- ResourceType: triageConnectionResourceType(entry.resourceID),+ ResourceType: triageRuntimeResourceType(snap, "", entry.resourceID),Category: "connectivity",Severity: "critical",Reason: "Instance disconnected",@@ -455,9 +456,9 @@ func FormatTriageBriefing(triage *TriageResult) string {sb.WriteString("# Deterministic Triage Results\n")scanned := triage.Summary.TotalNodes + triage.Summary.TotalGuests + triage.Summary.TotalStorage +- triage.Summary.TotalDocker + triage.Summary.TotalPBS + triage.Summary.TotalPMG+ triage.Summary.TotalDocker + triage.Summary.TotalTrueNAS + triage.Summary.TotalPBS + triage.Summary.TotalPMGsb.WriteString(fmt.Sprintf(- "Scanned %d resources: %d nodes, %d guests, %d storage resources (%d pools, %d physical disks), %d docker hosts, %d PBS, %d PMG.\n\n",+ "Scanned %d resources: %d nodes, %d guests, %d storage resources (%d pools, %d physical disks), %d docker hosts, %d TrueNAS systems, %d PBS, %d PMG.\n\n",scanned,triage.Summary.TotalNodes,triage.Summary.TotalGuests,@@ -465,6 +466,7 @@ func FormatTriageBriefing(triage *TriageResult) string {triage.Summary.TotalStoragePools,triage.Summary.TotalPhysicalDisks,triage.Summary.TotalDocker,+ triage.Summary.TotalTrueNAS,triage.Summary.TotalPBS,triage.Summary.TotalPMG,))@@ -516,6 +518,10 @@ func FormatTriageBriefing(triage *TriageResult) string {if healthyDocker < 0 {healthyDocker = 0}+ healthyTrueNAS := triage.Summary.TotalTrueNAS - triageUniqueFlaggedByType(triage.Flags, "truenas")+ if healthyTrueNAS < 0 {+ healthyTrueNAS = 0+ }healthyPBS := triage.Summary.TotalPBS - triageUniqueFlaggedByType(triage.Flags, "pbs")if healthyPBS < 0 {healthyPBS = 0@@ -525,7 +531,7 @@ func FormatTriageBriefing(triage *TriageResult) string {healthyPMG = 0}- totalHealthy := healthyNodes + healthyGuests + healthyStorage + healthyDocker + healthyPBS + healthyPMG+ totalHealthy := healthyNodes + healthyGuests + healthyStorage + healthyDocker + healthyTrueNAS + healthyPBS + healthyPMGsb.WriteString(fmt.Sprintf("## Healthy Resources (%d)\n", totalHealthy))sb.WriteString(fmt.Sprintf("Nodes: %d healthy\n", healthyNodes))sb.WriteString(fmt.Sprintf("Guests: %d running, %d stopped\n", triage.Summary.RunningGuests, triage.Summary.StoppedGuests))@@ -534,6 +540,7 @@ func FormatTriageBriefing(triage *TriageResult) string {triage.Summary.TotalStoragePools,triage.Summary.TotalPhysicalDisks))sb.WriteString(fmt.Sprintf("Docker: %d hosts\n", healthyDocker))+ sb.WriteString(fmt.Sprintf("TrueNAS: %d systems\n", healthyTrueNAS))sb.WriteString(fmt.Sprintf("PBS: %d instances\n", healthyPBS))sb.WriteString(fmt.Sprintf("PMG: %d instances\n", healthyPMG))@@ -552,6 +559,7 @@ func triageBuildSummaryState(snap patrolRuntimeState, flaggedIDs map[string]boolTotalPhysicalDisks: len(physicalDisks),TotalStorage: len(storagePools) + len(physicalDisks),TotalDocker: counts.docker,+ TotalTrueNAS: counts.truenas,TotalPBS: counts.pbs,TotalPMG: counts.pmg,FlaggedCount: len(flaggedIDs),@@ -722,6 +730,26 @@ func triageResourceType(knownType, resourceID string) string {return triageConnectionResourceType(resourceID)}+func triageRuntimeResourceType(snap patrolRuntimeState, knownType, resourceID string) string {+ if normalized := triageCanonicalResourceType(knownType); normalized != "" {+ return normalized+ }++ normalizedID := strings.ToLower(strings.TrimSpace(resourceID))+ if normalizedID == "" {+ return triageConnectionResourceType(resourceID)+ }++ for _, host := range patrolHostAlertRows(snap) {+ if strings.EqualFold(strings.TrimSpace(host.id), normalizedID) ||+ strings.EqualFold(strings.TrimSpace(host.hostname), normalizedID) {+ return host.resourceType+ }+ }++ return triageConnectionResourceType(resourceID)+}+func triageGuestResourceType(knownType, resourceID string) string {canonicalType := triageCanonicalResourceType(knownType)switch canonicalType {@@ -740,7 +768,7 @@ func triageGuestResourceType(knownType, resourceID string) string {func triageCanonicalResourceType(resourceType string) string {switch normalized := strings.ToLower(strings.TrimSpace(resourceType)); normalized {- case "vm", "system-container", "app-container", "node", "storage", "docker-host", "pbs", "pmg", "agent", "physical_disk", "physical-disk":+ case "vm", "system-container", "app-container", "node", "storage", "docker-host", "pbs", "pmg", "agent", "truenas", "physical_disk", "physical-disk":if normalized == "physical-disk" {return "physical_disk"}@@ -763,6 +791,8 @@ func triageConnectionResourceType(resourceID string) string {return "storage"case strings.HasPrefix(id, "docker-host:"), strings.HasPrefix(id, "docker-host/"), strings.HasPrefix(id, "app-container:"), strings.HasPrefix(id, "app-container/"), strings.HasPrefix(id, "docker-"), strings.Contains(id, "docker"):return "docker-host"+ case strings.HasPrefix(id, "truenas-"), strings.HasPrefix(id, "truenas:"), strings.HasPrefix(id, "truenas/"), strings.Contains(id, "truenas"):+ return "truenas"case strings.HasPrefix(id, "pbs-"), strings.HasPrefix(id, "pbs/"), strings.Contains(id, "pbs"):return "pbs"case strings.HasPrefix(id, "pmg-"), strings.HasPrefix(id, "pmg/"), strings.Contains(id, "pmg"):diff --git a/internal/ai/patrol_triage_test.go b/internal/ai/patrol_triage_test.goindex 71d8439dc6..046cb3bf47 100644--- a/internal/ai/patrol_triage_test.go+++ b/internal/ai/patrol_triage_test.go@@ -613,6 +613,7 @@ func TestFormatTriageBriefing(t *testing.T) {TotalPhysicalDisks: 0,TotalStorage: 1,TotalDocker: 1,+ TotalTrueNAS: 1,TotalPBS: 1,TotalPMG: 0,FlaggedCount: 1,@@ -633,7 +634,7 @@ func TestFormatTriageBriefing(t *testing.T) {if !strings.Contains(out, "## Healthy Resources") {t.Fatalf("expected healthy summary section, got:\n%s", out)}- if !strings.Contains(out, "Scanned 6 resources: 1 nodes, 2 guests, 1 storage resources (1 pools, 0 physical disks), 1 docker hosts, 1 PBS, 0 PMG.") {+ if !strings.Contains(out, "Scanned 7 resources: 1 nodes, 2 guests, 1 storage resources (1 pools, 0 physical disks), 1 docker hosts, 1 TrueNAS systems, 1 PBS, 0 PMG.") {t.Fatalf("expected explicit storage breakdown in scanned summary, got:\n%s", out)}if !strings.Contains(out, "Storage: 1 resources monitored (1 pools, 0 physical disks)") {@@ -723,6 +724,21 @@ func TestTriageBuildSummaryState_UsesReadStateWhenLegacySlicesEmpty(t *testing.Treturn &host}(),},+ hosts: []*unifiedresources.HostView{+ func() *unifiedresources.HostView {+ host := unifiedresources.NewHostView(&unifiedresources.Resource{+ ID: "truenas-1",+ Name: "truenas-main",+ Type: unifiedresources.ResourceTypeAgent,+ Status: unifiedresources.StatusOnline,+ Agent: &unifiedresources.AgentData{+ Hostname: "truenas-main",+ Platform: "truenas",+ },+ })+ return &host+ }(),+ },pbs: []*unifiedresources.PBSInstanceView{func() *unifiedresources.PBSInstanceView {pbs := unifiedresources.NewPBSInstanceView(&unifiedresources.Resource{@@ -768,7 +784,7 @@ func TestTriageBuildSummaryState_UsesReadStateWhenLegacySlicesEmpty(t *testing.T}summary := triageBuildSummaryState(state, map[string]bool{"qemu/100": true})- if summary.TotalNodes != 1 || summary.TotalStoragePools != 1 || summary.TotalPhysicalDisks != 1 || summary.TotalStorage != 2 || summary.TotalDocker != 1 || summary.TotalPBS != 1 || summary.TotalPMG != 1 {+ if summary.TotalNodes != 1 || summary.TotalStoragePools != 1 || summary.TotalPhysicalDisks != 1 || summary.TotalStorage != 2 || summary.TotalDocker != 1 || summary.TotalTrueNAS != 1 || summary.TotalPBS != 1 || summary.TotalPMG != 1 {t.Fatalf("unexpected non-guest summary counts from readState: %#v", summary)}if summary.TotalGuests != 3 || summary.RunningGuests != 2 || summary.StoppedGuests != 1 {@@ -779,6 +795,37 @@ func TestTriageBuildSummaryState_UsesReadStateWhenLegacySlicesEmpty(t *testing.T}}+func TestTriageAlertChecksState_ResolvesTrueNASHostsToCanonicalResourceType(t *testing.T) {+ state := patrolRuntimeState{+ Hosts: []models.Host{+ {+ ID: "truenas-1",+ Hostname: "truenas-main",+ DisplayName: "TrueNAS Main",+ Platform: "truenas",+ Status: "online",+ },+ },+ ActiveAlerts: []models.Alert{+ {+ ResourceID: "truenas-1",+ ResourceName: "TrueNAS Main",+ Type: "offline",+ Level: "critical",+ Message: "TrueNAS is offline",+ },+ },+ }++ flags := triageAlertChecksState(state, nil)+ if len(flags) != 1 {+ t.Fatalf("expected 1 alert-backed triage flag, got %d", len(flags))+ }+ if flags[0].ResourceType != "truenas" {+ t.Fatalf("expected TrueNAS resource type, got %#v", flags[0])+ }+}+func triageFindFlag(flags []TriageFlag, predicate func(TriageFlag) bool) *TriageFlag {for _, flag := range flags {if predicate(flag) {diff --git a/internal/api/ai_patrol_handlers_test.go b/internal/api/ai_patrol_handlers_test.goindex ed1365232e..39832a66ca 100644--- a/internal/api/ai_patrol_handlers_test.go+++ b/internal/api/ai_patrol_handlers_test.go@@ -406,6 +406,7 @@ func TestHandleGetPatrolRunHistory_PreservesExplicitEmptySnapshotCollections(t *ScopeResourceTypes: []string{"vm"},ResourcesChecked: 2,PMGChecked: 1,+ TrueNASChecked: 1,ExistingFindings: 1,RejectedFindings: 1,FindingsSummary: "ok",@@ -445,6 +446,9 @@ func TestHandleGetPatrolRunHistory_PreservesExplicitEmptySnapshotCollections(t *if got := run["pmg_checked"]; got != float64(1) {t.Fatalf("expected pmg_checked=1, got %#v", got)}+ if got := run["truenas_checked"]; got != float64(1) {+ t.Fatalf("expected truenas_checked=1, got %#v", got)+ }if got := run["rejected_findings"]; got != float64(1) {t.Fatalf("expected rejected_findings=1, got %#v", got)}diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 4319b85b14..f80898f01a 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -4606,6 +4606,7 @@ func TestContract_PatrolRunRecordJSONSnapshot(t *testing.T) {DockerChecked: 0,StorageChecked: 0,HostsChecked: 0,+ TrueNASChecked: 1,PBSChecked: 0,PMGChecked: 1,KubernetesChecked: 1,@@ -4644,6 +4645,7 @@ func TestContract_PatrolRunRecordJSONSnapshot(t *testing.T) {"docker_checked":0,"storage_checked":0,"hosts_checked":0,+ "truenas_checked":1,"pbs_checked":0,"pmg_checked":1,"kubernetes_checked":1,diff --git a/internal/config/persistence.go b/internal/config/persistence.goindex 86f11e37a3..34cd07c83b 100644--- a/internal/config/persistence.go+++ b/internal/config/persistence.go@@ -2407,6 +2407,7 @@ type PatrolRunRecord struct {DockerChecked int `json:"docker_checked"`StorageChecked int `json:"storage_checked"`HostsChecked int `json:"hosts_checked"`+ TrueNASChecked int `json:"truenas_checked"`PBSChecked int `json:"pbs_checked"`PMGChecked int `json:"pmg_checked"`KubernetesChecked int `json:"kubernetes_checked"`@@ -2451,6 +2452,7 @@ type patrolRunRecordJSON struct {DockerChecked int `json:"docker_checked"`StorageChecked int `json:"storage_checked"`HostsChecked int `json:"hosts_checked"`+ TrueNASChecked int `json:"truenas_checked"`PBSChecked int `json:"pbs_checked"`PMGChecked int `json:"pmg_checked"`KubernetesChecked int `json:"kubernetes_checked"`@@ -2527,6 +2529,7 @@ func (r PatrolRunRecord) MarshalJSON() ([]byte, error) {DockerChecked: normalized.DockerChecked,StorageChecked: normalized.StorageChecked,HostsChecked: normalized.HostsChecked,+ TrueNASChecked: normalized.TrueNASChecked,PBSChecked: normalized.PBSChecked,PMGChecked: normalized.PMGChecked,KubernetesChecked: normalized.KubernetesChecked,@@ -2575,6 +2578,7 @@ func (r *PatrolRunRecord) UnmarshalJSON(data []byte) error {DockerChecked: payload.DockerChecked,StorageChecked: payload.StorageChecked,HostsChecked: payload.HostsChecked,+ TrueNASChecked: payload.TrueNASChecked,PBSChecked: payload.PBSChecked,PMGChecked: payload.PMGChecked,KubernetesChecked: payload.KubernetesChecked,diff --git a/tests/integration/tests/34-truenas-patrol-history-breakdown.spec.ts b/tests/integration/tests/34-truenas-patrol-history-breakdown.spec.tsnew file mode 100644index 0000000000..790d0fcd0b--- /dev/null+++ b/tests/integration/tests/34-truenas-patrol-history-breakdown.spec.ts@@ -0,0 +1,264 @@+import fs from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';+import { test as base, expect } from '@playwright/test';++import { createAuthenticatedStorageState } from './helpers';++const __dirname = path.dirname(fileURLToPath(import.meta.url));++type WorkerFixtures = {+ authStorageStatePath: string;+};++const SCREENSHOT_PATH = '/tmp/truenas-patrol-run-history.png';++const test = base.extend<{}, WorkerFixtures>({+ storageState: async ({ authStorageStatePath }, use) => {+ await use(authStorageStatePath);+ },+ authStorageStatePath: [async ({ browser }, use, workerInfo) => {+ const storageStatePath = path.resolve(+ __dirname,+ '..',+ '..',+ 'tmp',+ 'playwright-auth',+ `truenas-patrol-history-breakdown-${workerInfo.project.name}.json`,+ );+ fs.mkdirSync(path.dirname(storageStatePath), { recursive: true });+ await createAuthenticatedStorageState(browser, storageStatePath);+ try {+ await use(storageStatePath);+ } finally {+ fs.rmSync(storageStatePath, { force: true });+ }+ }, { scope: 'worker' }],+});++test.describe('TrueNAS patrol run history', () => {+ test.setTimeout(180_000);++ test('keeps TrueNAS patrol counts separate from agent hosts in run history', async ({ page }) => {+ await page.route('**/api/resources**', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ data: [],+ meta: { page: 1, limit: 200, total: 0, totalPages: 0 },+ }),+ });+ });++ await page.route('**/api/ai/patrol/status', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ runtime_state: 'active',+ running: false,+ enabled: true,+ last_patrol_at: '2026-03-30T09:00:00Z',+ last_activity_at: '2026-03-30T09:03:00Z',+ next_patrol_at: '2026-03-30T15:00:00Z',+ last_duration_ms: 180000,+ resources_checked: 2,+ findings_count: 0,+ error_count: 0,+ healthy: true,+ interval_ms: 21600000,+ fixed_count: 0,+ blocked_reason: '',+ blocked_at: '',+ license_required: false,+ license_status: 'active',+ summary: {+ critical: 0,+ warning: 0,+ watch: 0,+ info: 0,+ },+ using_quickstart: false,+ quickstart_credits_total: 0,+ quickstart_credits_remaining: 0,+ }),+ });+ });++ await page.route('**/api/ai/patrol/runs*', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify([+ {+ id: 'run-truenas-breakdown',+ started_at: '2026-03-30T09:00:00Z',+ completed_at: '2026-03-30T09:03:00Z',+ duration_ms: 180000,+ type: 'full',+ trigger_reason: 'scheduled',+ resources_checked: 2,+ nodes_checked: 0,+ guests_checked: 0,+ docker_checked: 1,+ storage_checked: 0,+ hosts_checked: 0,+ truenas_checked: 1,+ pbs_checked: 0,+ pmg_checked: 0,+ kubernetes_checked: 0,+ new_findings: 0,+ existing_findings: 0,+ rejected_findings: 0,+ resolved_findings: 0,+ auto_fix_count: 0,+ findings_summary: 'TrueNAS patrol complete',+ finding_ids: [],+ error_count: 0,+ status: 'healthy',+ triage_flags: 0,+ tool_call_count: 0,+ },+ ]),+ });+ });++ await page.route('**/api/ai/patrol/autonomy', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ autonomy_level: 'monitor',+ full_mode_unlocked: false,+ investigation_budget: 15,+ investigation_timeout_sec: 300,+ }),+ });+ });++ await page.route('**/api/ai/models', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({ models: [] }),+ });+ });++ await page.route('**/api/settings/ai', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ patrol_enabled: true,+ patrol_interval_minutes: 360,+ patrol_model: '',+ model: '',+ alert_triggered_analysis: true,+ patrol_alert_triggers_enabled: true,+ patrol_anomaly_triggers_enabled: true,+ patrol_event_triggers_enabled: true,+ patrol_auto_fix: false,+ auto_fix_model: '',+ }),+ });+ });++ await page.route('**/api/ai/unified/findings*', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ findings: [],+ count: 0,+ active_count: 0,+ }),+ });+ });++ await page.route('**/api/ai/intelligence/correlations*', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({ correlations: [], count: 0 }),+ });+ });++ await page.route('**/api/ai/intelligence', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ timestamp: '2026-03-30T09:03:00Z',+ overall_health: {+ score: 100,+ grade: 'A',+ trend: 'stable',+ factors: [],+ prediction: 'Infrastructure is healthy with no significant issues detected.',+ },+ findings_count: {+ critical: 0,+ warning: 0,+ watch: 0,+ info: 0,+ total: 0,+ },+ predictions_count: 0,+ recent_changes_count: 0,+ recent_changes: [],+ learning: {+ resources_with_knowledge: 0,+ total_notes: 0,+ resources_with_baselines: 0,+ patterns_detected: 0,+ correlations_learned: 0,+ incidents_tracked: 0,+ },+ }),+ });+ });++ await page.route('**/api/ai/circuit/status', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ state: 'closed',+ can_patrol: true,+ consecutive_failures: 0,+ total_successes: 1,+ total_failures: 0,+ }),+ });+ });++ await page.route('**/api/ai/approvals', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({ approvals: [] }),+ });+ });++ await page.route('**/api/ai/remediation/plans', async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({ plans: [] }),+ });+ });++ await page.goto('/ai', { waitUntil: 'domcontentloaded' });++ await expect(page.getByRole('button', { name: 'Findings' })).toBeVisible();+ await page.getByRole('button', { name: 'Runs' }).click();+ await page.getByRole('button', { name: /Checked 2 resources/i }).click();++ await expect(page.getByText('1 container')).toBeVisible();+ await expect(page.getByText('1 TrueNAS system')).toBeVisible();+ await expect(page.getByText(/1 agent/)).toHaveCount(0);++ await page.screenshot({ path: SCREENSHOT_PATH, fullPage: true });+ });+});