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
Preserve standalone host continuity across restart
rcourtmand573d3a85f92
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 2cd69c868d..d8856df9d4 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -192,6 +192,12 @@ an add-only capacity posture.or no-data results, and partial or plain-text smartctl output must stillpreserve model, serial, health, and temperature data through the samehost-agent runtime boundary instead of leaving monitoring to guess.+ Server-side lifecycle admission must preserve that same continuity across+ Pulse restart and upgrade. When a standalone host comes back with the same+ durable machine/report identity and token continuity, the shared admission+ path must treat it as the existing system until live inventory rebuild+ catches up, rather than as a fresh enrolment competing for another+ monitored-system slot.4. Keep shared `internal/api/` helper edits isolated from agent lifecycle semantics: Patrol-specific status transport or alert-trigger wiring changes in shared handlers must not bleed into auto-register, installer, or fleet-control behavior unless this contract moves in the same slice.The same isolation rule applies to AI settings payload work in `internal/api/ai_handlers.go`: provider auth fields, masked-secret echoes, and provider-test model selection remain AI/runtime plus API-contract ownership and must not be reinterpreted as lifecycle setup or registration semantics just because they share backend helper layers.The same shared-helper rule now covers SSO outbound discovery and metadata fetches plus credential-file loads in `internal/api/sso_outbound.go`, `internal/api/saml_service.go`, and `internal/api/oidc_service.go`: lifecycle-adjacent setup or auth work may depend on that shared trust boundary, but it must not fork a second HTTP client, redirect policy, or file-read rule inside lifecycle-local flows.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 81efd6a3e6..953914d205 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -151,6 +151,13 @@ test, add, and update payloads must serialize through the shared ledger clientas `active:false`, and preview responses may legitimately return `no_change`,`removes_existing`, or `removes_multiple` with empty projected-system listswhen the disabled candidate no longer counts toward monitored-system capacity.+That same monitored-system admission contract now also owns restart-safe host+report continuity at the API boundary. `internal/api/monitored_system_limit_enforcement.go`+must treat a returning standalone host report as existing capacity when+monitoring can match it to recent persisted host continuity, so a server+restart or v6 upgrade does not emit a false over-limit `402` before the live+inventory rebuild catches up. Genuinely new host identities must still return+the canonical monitored-system blocked payload.## Extension Pointsdiff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex 39ecc751e3..d5c7ceaa68 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -196,6 +196,14 @@ publish those resources from the same canonical unified snapshot thatraw store-only inventory for broadcast. Otherwise cold hydrate and laterregistry-backed refreshes can swap the operator-visible infrastructure setunder one running session.+That same monitoring owner now also governs restart-safe standalone host+continuity for monitored-system usage and admission. `internal/monitoring/monitor_agents.go`+must persist recent host identity at report time, and+`internal/monitoring/monitored_system_usage.go` must project that continuity+back into the canonical read state through the unified-resources-owned overlay+path instead of rebuilding registry truth locally. A server restart or v6+upgrade must not briefly forget an already admitted standalone host and+misclassify its next report as a brand-new counted system.That same mock-runtime boundary also owns freshness while demos are running.The mock update loop must keep provider-backed TrueNAS and VMware records pluslegacy PBS and PMG summaries on current `LastSeen` and health state each tick,diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 0d2a5e4f90..59498ec01f 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -86,6 +86,12 @@ querying, and the operator-facing storage health presentation layer.provider-specific policy, infer a different over-cap rule, or bypass thecanonical monitored-system preview/resolver contract when the private hookis absent.+ That same adjacent monitored-system boundary also depends on restart-safe+ standalone host continuity. Storage- and recovery-adjacent setup or support+ flows may observe a returning host after server restart, but they must not+ reinterpret that gap as a new counted system or invent a storage-local+ grace rule when the shared API and monitoring boundary already carry recent+ host continuity.Any adjacent list surfaces that reuse `internal/api/resources.go` must alsopreserve the canonical unified-resource `name -> type -> id` order soduplicate-name storage and recovery resources do not reshuffle between colddiff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 1384e33f34..45f349cfc3 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -159,6 +159,13 @@ assembly branch.into the agent resource instead of publishing duplicate top-levelinfrastructure rows for the same machine under both `agent` and `k8s-node`identities.+ Canonical read-state overlays belong here as well: when monitoring or a+ preview path needs to project extra source-native records onto an existing+ settled read state, it must do so through+ `internal/unifiedresources/monitor_adapter.go` and+ `internal/unifiedresources/registry.go` so matcher seeding, manual links,+ and merge semantics stay unified-resource-owned instead of being rebuilt in+ consumers.6. Add canonical governed name-resolution or policy-aware resource lookup behavior through `internal/unifiedresources/resolve.go` and `internal/unifiedresources/resolve_context.go`7. Add or change resource drawer timeline/facet presentation through `frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx`, `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx`, `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx`, `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts`, `frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx`, `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`, and the governed `internal/api/resources.go` facet/timeline contract together8. Add or change discovery-support runtime under the resource drawer through `frontend-modern/src/components/Discovery/DiscoveryTab.tsx` for shell/presentation ownership and `frontend-modern/src/components/Discovery/useDiscoveryTabState.ts` for fetch, websocket-progress, and notes-mutation ownershipdiff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 62fb6786a6..ddfecc464d 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -38,6 +38,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources""github.com/rcourtman/pulse-go-rewrite/internal/updates""github.com/rcourtman/pulse-go-rewrite/internal/vmware"+ agentshost "github.com/rcourtman/pulse-go-rewrite/pkg/agents/host"authpkg "github.com/rcourtman/pulse-go-rewrite/pkg/auth""github.com/rcourtman/pulse-go-rewrite/pkg/cloudauth""github.com/rcourtman/pulse-go-rewrite/pkg/extensions"@@ -5736,6 +5737,77 @@ func TestContract_MonitoredSystemUsageUnavailableIncludesReason(t *testing.T) {}}+func TestContract_HostReportAdmissionPreservesRestartContinuityAtLimit(t *testing.T) {+ setMaxMonitoredSystemsLicenseForTests(t, 1)++ cfg := &config.Config{DataPath: t.TempDir()}+ report := agentshost.Report{+ Agent: agentshost.AgentInfo{+ ID: "agent-1",+ Version: "6.0.0-rc.1",+ },+ Host: agentshost.HostInfo{+ ID: "machine-1",+ MachineID: "machine-1",+ Hostname: "host-1.local",+ Platform: "linux",+ },+ Timestamp: time.Now().UTC(),+ }++ postReport := func(t *testing.T, handler *UnifiedAgentHandlers, input agentshost.Report) *httptest.ResponseRecorder {+ t.Helper()+ body, err := json.Marshal(input)+ if err != nil {+ t.Fatalf("marshal host report: %v", err)+ }+ req := httptest.NewRequest(http.MethodPost, "/api/agents/agent/report", bytes.NewReader(body))+ rec := httptest.NewRecorder()+ handler.HandleReport(rec, req)+ return rec+ }++ handler, _ := newUnifiedAgentHandlers(t, cfg)+ initialRec := postReport(t, handler, report)+ if initialRec.Code != http.StatusOK {+ t.Fatalf("initial host report should pass, got %d: %s", initialRec.Code, initialRec.Body.String())+ }++ restartedHandler, _ := newUnifiedAgentHandlers(t, cfg)+ restartReport := report+ restartReport.Timestamp = report.Timestamp.Add(30 * time.Second)+ restartRec := postReport(t, restartedHandler, restartReport)+ if restartRec.Code != http.StatusOK {+ t.Fatalf("restart continuity report should stay admitted, got %d: %s", restartRec.Code, restartRec.Body.String())+ }++ newHostReport := agentshost.Report{+ Agent: agentshost.AgentInfo{+ ID: "agent-2",+ Version: "6.0.0-rc.1",+ },+ Host: agentshost.HostInfo{+ ID: "machine-2",+ MachineID: "machine-2",+ Hostname: "host-2.local",+ Platform: "linux",+ },+ Timestamp: report.Timestamp.Add(time.Minute),+ }+ blockedRec := postReport(t, restartedHandler, newHostReport)+ if blockedRec.Code != http.StatusPaymentRequired {+ t.Fatalf("new host should remain blocked at limit, got %d: %s", blockedRec.Code, blockedRec.Body.String())+ }++ payload := decodeMonitoredSystemLimitBlockedPayload(t, blockedRec.Body.Bytes())+ if payload.Feature != maxMonitoredSystemsLicenseGateKey {+ t.Fatalf("feature=%q, want %q", payload.Feature, maxMonitoredSystemsLicenseGateKey)+ }+ if !payload.MonitoredSystemPreview.WouldExceedLimit {+ t.Fatalf("expected monitored_system_preview.would_exceed_limit=true, got %+v", payload.MonitoredSystemPreview)+ }+}+func TestContract_ResolveMonitoredSystemAdmissionPolicyHookUsesCanonicalInput(t *testing.T) {SetResolveMonitoredSystemAdmissionPolicy(nil)t.Cleanup(func() { SetResolveMonitoredSystemAdmissionPolicy(nil) })diff --git a/internal/api/monitored_system_limit_enforcement.go b/internal/api/monitored_system_limit_enforcement.goindex 7d05c10a6a..631333bb3f 100644--- a/internal/api/monitored_system_limit_enforcement.go+++ b/internal/api/monitored_system_limit_enforcement.go@@ -436,7 +436,7 @@ func enforceMonitoredSystemLimitForHostReport(report agentshost.Report,tokenRecord *config.APITokenRecord,) bool {- if monitor != nil && hostReportTargetsExistingHost(monitor.GetLiveHostsSnapshot(), report, tokenRecord) {+ if monitor != nil && monitor.HostReportMatchesKnownIdentity(report, tokenRecord) {return false}diff --git a/internal/api/unified_agent_handlers_test.go b/internal/api/unified_agent_handlers_test.goindex ecd1c8d686..908af47df1 100644--- a/internal/api/unified_agent_handlers_test.go+++ b/internal/api/unified_agent_handlers_test.go@@ -150,6 +150,69 @@ func TestUnifiedAgentHandlers_HandleReport_EnforcesMaxMonitoredSystemsForNewHost}}+func TestUnifiedAgentHandlers_HandleReport_PreservesExistingHostLimitContinuityAcrossRestart(t *testing.T) {+ setMaxMonitoredSystemsLicenseForTests(t, 1)++ cfg := &config.Config{DataPath: t.TempDir()}+ report := agentshost.Report{+ Agent: agentshost.AgentInfo{+ ID: "agent-1",+ Version: "6.0.0-rc.1",+ },+ Host: agentshost.HostInfo{+ ID: "machine-1",+ MachineID: "machine-1",+ Hostname: "host-1.local",+ Platform: "linux",+ },+ Timestamp: time.Now().UTC(),+ }++ postReport := func(t *testing.T, handler *UnifiedAgentHandlers, input agentshost.Report) *httptest.ResponseRecorder {+ t.Helper()+ body, err := json.Marshal(input)+ if err != nil {+ t.Fatalf("marshal report: %v", err)+ }+ req := httptest.NewRequest(http.MethodPost, "/api/agents/agent/report", bytes.NewReader(body))+ rec := httptest.NewRecorder()+ handler.HandleReport(rec, req)+ return rec+ }++ handler, _ := newUnifiedAgentHandlers(t, cfg)+ rec := postReport(t, handler, report)+ if rec.Code != http.StatusOK {+ t.Fatalf("initial host report should pass, got %d: %s", rec.Code, rec.Body.String())+ }++ restartedHandler, _ := newUnifiedAgentHandlers(t, cfg)+ restartReport := report+ restartReport.Timestamp = report.Timestamp.Add(30 * time.Second)+ restartRec := postReport(t, restartedHandler, restartReport)+ if restartRec.Code != http.StatusOK {+ t.Fatalf("existing host should still report after restart at limit, got %d: %s", restartRec.Code, restartRec.Body.String())+ }++ newReport := agentshost.Report{+ Agent: agentshost.AgentInfo{+ ID: "agent-2",+ Version: "6.0.0-rc.1",+ },+ Host: agentshost.HostInfo{+ ID: "machine-2",+ MachineID: "machine-2",+ Hostname: "host-2.local",+ Platform: "linux",+ },+ Timestamp: time.Now().UTC(),+ }+ newRec := postReport(t, restartedHandler, newReport)+ if newRec.Code != http.StatusPaymentRequired {+ t.Fatalf("new host should still be blocked at limit after restart, got %d: %s", newRec.Code, newRec.Body.String())+ }+}+func TestUnifiedAgentHandlers_HandleDeleteHost(t *testing.T) {for _, prefix := range []string{"/api/agents/agent/", "/api/agents/host/"} {handler, monitor := newUnifiedAgentHandlers(t, nil)diff --git a/internal/config/file_read_limits.go b/internal/config/file_read_limits.goindex 5a590ebb60..a1382a9cbd 100644--- a/internal/config/file_read_limits.go+++ b/internal/config/file_read_limits.go@@ -8,6 +8,7 @@ const (maxGuestMetadataFileSizeBytes int64 = 16 * 1024 * 1024maxHostMetadataFileSizeBytes int64 = 16 * 1024 * 1024maxDockerMetadataFileSizeBytes int64 = 16 * 1024 * 1024+ maxHostContinuityFileSizeBytes int64 = 16 * 1024 * 1024)// readLimitedRegularFileFS reads from the configured filesystem with a strictdiff --git a/internal/config/host_continuity.go b/internal/config/host_continuity.gonew file mode 100644index 0000000000..a82a5d40ff--- /dev/null+++ b/internal/config/host_continuity.go@@ -0,0 +1,247 @@+package config++import (+ "encoding/json"+ "fmt"+ "os"+ "path/filepath"+ "sort"+ "strings"+ "sync"+ "time"++ "github.com/rs/zerolog/log"+)++// HostContinuityEntry stores the minimum durable identity needed to recognise+// an existing standalone host across restart and upgrade boundaries before the+// next live report arrives.+type HostContinuityEntry struct {+ HostID string `json:"hostId"`+ ReportHostID string `json:"reportHostId,omitempty"`+ AgentReportedID string `json:"agentReportedId,omitempty"`+ Hostname string `json:"hostname,omitempty"`+ DisplayName string `json:"displayName,omitempty"`+ MachineID string `json:"machineId,omitempty"`+ TokenID string `json:"tokenId,omitempty"`+ AgentVersion string `json:"agentVersion,omitempty"`+ Platform string `json:"platform,omitempty"`+ LinkedNodeID string `json:"linkedNodeId,omitempty"`+ LinkedVMID string `json:"linkedVmId,omitempty"`+ LinkedContainerID string `json:"linkedContainerId,omitempty"`+ IsLegacy bool `json:"isLegacy,omitempty"`+ LastSeen time.Time `json:"lastSeen,omitempty"`+}++// HostContinuityStore persists recent standalone host identities so licensing+// and grandfather-floor continuity survive process restarts.+type HostContinuityStore struct {+ mu sync.RWMutex+ entries map[string]HostContinuityEntry+ dataPath string+ fs FileSystem+}++func NewHostContinuityStore(dataPath string, fs FileSystem) *HostContinuityStore {+ store := &HostContinuityStore{+ entries: make(map[string]HostContinuityEntry),+ dataPath: dataPath,+ fs: fs,+ }+ if store.fs == nil {+ store.fs = defaultFileSystem{}+ }+ if err := store.Load(); err != nil {+ log.Warn().Err(err).Msg("Failed to load host continuity state")+ }+ return store+}++func normalizeHostContinuityEntry(entry HostContinuityEntry) (HostContinuityEntry, bool) {+ entry.HostID = strings.TrimSpace(entry.HostID)+ if entry.HostID == "" {+ return HostContinuityEntry{}, false+ }++ entry.ReportHostID = strings.TrimSpace(entry.ReportHostID)+ entry.AgentReportedID = strings.TrimSpace(entry.AgentReportedID)+ entry.Hostname = strings.TrimSpace(entry.Hostname)+ entry.DisplayName = strings.TrimSpace(entry.DisplayName)+ entry.MachineID = strings.TrimSpace(entry.MachineID)+ entry.TokenID = strings.TrimSpace(entry.TokenID)+ entry.AgentVersion = strings.TrimSpace(entry.AgentVersion)+ entry.Platform = strings.TrimSpace(entry.Platform)+ entry.LinkedNodeID = strings.TrimSpace(entry.LinkedNodeID)+ entry.LinkedVMID = strings.TrimSpace(entry.LinkedVMID)+ entry.LinkedContainerID = strings.TrimSpace(entry.LinkedContainerID)+ return entry, true+}++func (s *HostContinuityStore) Load() error {+ filePath := filepath.Join(s.dataPath, "host_continuity.json")++ data, err := readLimitedRegularFileFS(s.fs, filePath, maxHostContinuityFileSizeBytes)+ if err != nil {+ if os.IsNotExist(err) {+ return nil+ }+ return fmt.Errorf("failed to read continuity file: %w", err)+ }++ entries := make(map[string]HostContinuityEntry)+ if err := json.Unmarshal(data, &entries); err != nil {+ return fmt.Errorf("failed to unmarshal continuity: %w", err)+ }++ normalized := make(map[string]HostContinuityEntry, len(entries))+ for _, entry := range entries {+ if normalizedEntry, ok := normalizeHostContinuityEntry(entry); ok {+ normalized[normalizedEntry.HostID] = normalizedEntry+ }+ }++ s.mu.Lock()+ s.entries = normalized+ s.mu.Unlock()+ return nil+}++func (s *HostContinuityStore) save() error {+ data, err := json.Marshal(s.entries)+ if err != nil {+ return fmt.Errorf("failed to marshal continuity: %w", err)+ }+ if err := persistMetadata(s.fs, s.dataPath, "host_continuity.json", data); err != nil {+ return err+ }+ return nil+}++func (s *HostContinuityStore) Upsert(entry HostContinuityEntry) error {+ normalized, ok := normalizeHostContinuityEntry(entry)+ if !ok {+ return fmt.Errorf("host continuity entry requires host ID")+ }++ s.mu.Lock()+ defer s.mu.Unlock()+ s.entries[normalized.HostID] = normalized+ return s.save()+}++func (s *HostContinuityStore) Delete(hostID string) error {+ hostID = strings.TrimSpace(hostID)+ if hostID == "" {+ return nil+ }++ s.mu.Lock()+ defer s.mu.Unlock()+ delete(s.entries, hostID)+ return s.save()+}++func (s *HostContinuityStore) Get(hostID string) (HostContinuityEntry, bool) {+ hostID = strings.TrimSpace(hostID)+ if hostID == "" {+ return HostContinuityEntry{}, false+ }++ s.mu.RLock()+ defer s.mu.RUnlock()+ entry, ok := s.entries[hostID]+ return entry, ok+}++func (s *HostContinuityStore) RecentEntries(since time.Time) []HostContinuityEntry {+ s.mu.RLock()+ defer s.mu.RUnlock()++ out := make([]HostContinuityEntry, 0, len(s.entries))+ for _, entry := range s.entries {+ if !since.IsZero() && entry.LastSeen.Before(since) {+ continue+ }+ out = append(out, entry)+ }+ sort.Slice(out, func(i, j int) bool {+ if out[i].LastSeen.Equal(out[j].LastSeen) {+ return out[i].HostID < out[j].HostID+ }+ return out[i].LastSeen.After(out[j].LastSeen)+ })+ return out+}++func (s *HostContinuityStore) Match(+ reportHostID string,+ machineID string,+ agentID string,+ hostname string,+ tokenID string,+ since time.Time,+) (HostContinuityEntry, bool) {+ s.mu.RLock()+ defer s.mu.RUnlock()++ candidates := uniqueTrimmedStrings(reportHostID, machineID, agentID)+ hostname = strings.TrimSpace(hostname)+ tokenID = strings.TrimSpace(tokenID)++ var best HostContinuityEntry+ matched := false++ for _, entry := range s.entries {+ if !since.IsZero() && entry.LastSeen.Before(since) {+ continue+ }++ matchedByAlias := false+ for _, candidate := range candidates {+ if entry.HostID == candidate ||+ entry.ReportHostID == candidate ||+ entry.MachineID == candidate ||+ entry.AgentReportedID == candidate {+ if !matched || entry.LastSeen.After(best.LastSeen) {+ best = entry+ matched = true+ }+ matchedByAlias = true+ break+ }+ }++ if matchedByAlias {+ continue+ }+ if hostname == "" || !strings.EqualFold(entry.Hostname, hostname) {+ continue+ }+ if tokenID != "" && (entry.TokenID == "" || entry.TokenID != tokenID) {+ continue+ }+ if !matched || entry.LastSeen.After(best.LastSeen) {+ best = entry+ matched = true+ }+ }++ return best, matched+}++func uniqueTrimmedStrings(values ...string) []string {+ out := make([]string, 0, len(values))+ seen := make(map[string]struct{}, len(values))+ for _, value := range values {+ trimmed := strings.TrimSpace(value)+ if trimmed == "" {+ continue+ }+ if _, ok := seen[trimmed]; ok {+ continue+ }+ seen[trimmed] = struct{}{}+ out = append(out, trimmed)+ }+ return out+}diff --git a/internal/config/host_continuity_test.go b/internal/config/host_continuity_test.gonew file mode 100644index 0000000000..86774ba926--- /dev/null+++ b/internal/config/host_continuity_test.go@@ -0,0 +1,70 @@+package config++import (+ "testing"+ "time"+)++func TestHostContinuityStoreRoundTripAndMatch(t *testing.T) {+ dir := t.TempDir()+ store := NewHostContinuityStore(dir, nil)++ now := time.Now().UTC().Truncate(time.Second)+ if err := store.Upsert(HostContinuityEntry{+ HostID: "host-1",+ ReportHostID: "machine-1",+ AgentReportedID: "agent-1",+ Hostname: "host-1.local",+ MachineID: "machine-1",+ TokenID: "token-1",+ LastSeen: now,+ }); err != nil {+ t.Fatalf("Upsert: %v", err)+ }++ reloaded := NewHostContinuityStore(dir, nil)+ if entry, ok := reloaded.Get("host-1"); !ok {+ t.Fatal("expected reloaded entry")+ } else if entry.TokenID != "token-1" || entry.Hostname != "host-1.local" {+ t.Fatalf("unexpected reloaded entry: %+v", entry)+ }++ if entry, ok := reloaded.Match("machine-1", "", "", "", "", now.Add(-time.Minute)); !ok {+ t.Fatal("expected match by report host ID")+ } else if entry.HostID != "host-1" {+ t.Fatalf("matched host ID = %q, want %q", entry.HostID, "host-1")+ }++ if entry, ok := reloaded.Match("", "", "", "host-1.local", "token-1", now.Add(-time.Minute)); !ok {+ t.Fatal("expected match by hostname and token")+ } else if entry.HostID != "host-1" {+ t.Fatalf("matched host ID = %q, want %q", entry.HostID, "host-1")+ }++ if _, ok := reloaded.Match("", "", "", "host-1.local", "token-2", now.Add(-time.Minute)); ok {+ t.Fatal("expected token mismatch not to match")+ }+}++func TestHostContinuityStoreRecentEntriesFiltersStaleState(t *testing.T) {+ dir := t.TempDir()+ store := NewHostContinuityStore(dir, nil)++ now := time.Now().UTC().Truncate(time.Second)+ for _, entry := range []HostContinuityEntry{+ {HostID: "host-new", Hostname: "new.local", LastSeen: now},+ {HostID: "host-old", Hostname: "old.local", LastSeen: now.Add(-96 * time.Hour)},+ } {+ if err := store.Upsert(entry); err != nil {+ t.Fatalf("Upsert(%s): %v", entry.HostID, err)+ }+ }++ recent := store.RecentEntries(now.Add(-72 * time.Hour))+ if len(recent) != 1 {+ t.Fatalf("RecentEntries count = %d, want 1", len(recent))+ }+ if recent[0].HostID != "host-new" {+ t.Fatalf("RecentEntries[0].HostID = %q, want %q", recent[0].HostID, "host-new")+ }+}diff --git a/internal/config/metadata_load_limits_test.go b/internal/config/metadata_load_limits_test.goindex 906211409a..5c1a12e424 100644--- a/internal/config/metadata_load_limits_test.go+++ b/internal/config/metadata_load_limits_test.go@@ -40,6 +40,14 @@ func TestMetadataStores_LoadRejectsOversizedFiles(t *testing.T) {return NewDockerMetadataStore(dir, nil).Load()},},+ {+ name: "host continuity",+ fileName: "host_continuity.json",+ maxBytes: maxHostContinuityFileSizeBytes,+ load: func(dir string) error {+ return NewHostContinuityStore(dir, nil).Load()+ },+ },}for _, tc := range testCases {@@ -83,6 +91,13 @@ func TestMetadataStores_LoadRejectsNonRegularFiles(t *testing.T) {return NewDockerMetadataStore(dir, nil).Load()},},+ {+ name: "host continuity",+ fileName: "host_continuity.json",+ load: func(dir string) error {+ return NewHostContinuityStore(dir, nil).Load()+ },+ },}for _, tc := range testCases {diff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.goindex 78e032deda..a170da145b 100644--- a/internal/monitoring/canonical_guardrails_test.go+++ b/internal/monitoring/canonical_guardrails_test.go@@ -123,6 +123,8 @@ func TestMonitoredSystemUsageReadinessGuardrailsRemainCanonical(t *testing.T) {"monitor.go": {"type MonitorSupplementalInventoryReadinessProvider interface {","SupplementalInventoryReadyAt(m *Monitor, orgID string) (time.Time, bool)",+ "hostContinuityStore *config.HostContinuityStore",+ "hostContinuityStore: config.NewHostContinuityStore(cfg.DataPath, nil),",},"monitored_system_usage.go": {"MonitoredSystemUsageUnavailableMonitorState",@@ -134,8 +136,11 @@ func TestMonitoredSystemUsageReadinessGuardrailsRemainCanonical(t *testing.T) {"UnavailableReason: MonitoredSystemUsageUnavailableSupplementalInventoryUnsettled,","if freshness.IsZero() || freshness.Before(readyAt) {","UnavailableReason: MonitoredSystemUsageUnavailableSupplementalInventoryRebuildPending,",+ "readState = m.monitoredSystemUsageReadStateWithHostContinuity(readState)","Count: unifiedresources.MonitoredSystemCount(readState),","Available: true,",+ "func (m *Monitor) monitoredSystemUsageReadStateWithHostContinuity(",+ "return unifiedresources.ReadStateWithRecords(readState, unifiedresources.SourceAgent, records)",},"truenas_poller.go": {"func (p *TrueNASPoller) SupplementalInventoryReadyAt(_ *Monitor, orgID string) (time.Time, bool) {",diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.goindex fe25ed582d..c52765fc09 100644--- a/internal/monitoring/monitor.go+++ b/internal/monitoring/monitor.go@@ -920,6 +920,7 @@ type Monitor struct {guestMetadataStore *config.GuestMetadataStoredockerMetadataStore *config.DockerMetadataStorehostMetadataStore *config.HostMetadataStore+ hostContinuityStore *config.HostContinuityStoremu sync.RWMutexstartTime time.TimerateTracker *RateTracker@@ -1469,6 +1470,7 @@ func New(cfg *config.Config) (*Monitor, error) {guestMetadataStore: config.NewGuestMetadataStore(cfg.DataPath, nil),dockerMetadataStore: config.NewDockerMetadataStore(cfg.DataPath, nil),hostMetadataStore: config.NewHostMetadataStore(cfg.DataPath, nil),+ hostContinuityStore: config.NewHostContinuityStore(cfg.DataPath, nil),startTime: time.Now(),rateTracker: NewRateTracker(),metricsHistory: NewMetricsHistory(1000, 24*time.Hour), // Keep up to 1000 points (~8h @ 30s)diff --git a/internal/monitoring/monitor_agents.go b/internal/monitoring/monitor_agents.goindex 3b2f1cf8ac..2a69a3a792 100644--- a/internal/monitoring/monitor_agents.go+++ b/internal/monitoring/monitor_agents.go@@ -15,10 +15,13 @@ import (agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"agentshost "github.com/rcourtman/pulse-go-rewrite/pkg/agents/host""github.com/rcourtman/pulse-go-rewrite/pkg/fsfilters"+ pkglicensing "github.com/rcourtman/pulse-go-rewrite/pkg/licensing""github.com/rs/zerolog""github.com/rs/zerolog/log")+const hostContinuityRetention = 72 * time.Hour+func (m *Monitor) RemoveDockerHost(hostID string) (models.DockerHost, error) {hostID = strings.TrimSpace(hostID)if hostID == "" {@@ -231,6 +234,7 @@ func (m *Monitor) RemoveHostAgent(hostID string) (models.Host, error) {if m.alertManager != nil {m.alertManager.HandleHostRemoved(host)}+ m.removeHostContinuity(hostID)return host, nil}@@ -716,6 +720,124 @@ func (m *Monitor) snapshotBackedUnifiedReadState() unifiedresources.ReadState {return unifiedresources.NewMonitorAdapter(registry)}+func (m *Monitor) hostContinuitySince(now time.Time) time.Time {+ if now.IsZero() {+ now = time.Now().UTC()+ }+ return now.Add(-hostContinuityRetention)+}++func (m *Monitor) matchPersistedHostContinuity(+ report agentshost.Report,+ tokenRecord *config.APITokenRecord,+) (config.HostContinuityEntry, bool) {+ if m == nil || m.hostContinuityStore == nil {+ return config.HostContinuityEntry{}, false+ }++ tokenID := ""+ if tokenRecord != nil {+ tokenID = tokenRecord.ID+ }++ return m.hostContinuityStore.Match(+ report.Host.ID,+ report.Host.MachineID,+ report.Agent.ID,+ report.Host.Hostname,+ tokenID,+ m.hostContinuitySince(time.Now().UTC()),+ )+}++func (m *Monitor) persistHostContinuity(host models.Host, report agentshost.Report) {+ if m == nil || m.hostContinuityStore == nil {+ return+ }++ entry := config.HostContinuityEntry{+ HostID: strings.TrimSpace(host.ID),+ ReportHostID: strings.TrimSpace(report.Host.ID),+ AgentReportedID: strings.TrimSpace(report.Agent.ID),+ Hostname: strings.TrimSpace(host.Hostname),+ DisplayName: strings.TrimSpace(host.DisplayName),+ MachineID: strings.TrimSpace(host.MachineID),+ TokenID: strings.TrimSpace(host.TokenID),+ AgentVersion: strings.TrimSpace(host.AgentVersion),+ Platform: strings.TrimSpace(host.Platform),+ LinkedNodeID: strings.TrimSpace(host.LinkedNodeID),+ LinkedVMID: strings.TrimSpace(host.LinkedVMID),+ LinkedContainerID: strings.TrimSpace(host.LinkedContainerID),+ IsLegacy: host.IsLegacy,+ LastSeen: host.LastSeen.UTC(),+ }+ if err := m.hostContinuityStore.Upsert(entry); err != nil {+ log.Warn().+ Err(err).+ Str("hostID", host.ID).+ Msg("failed to persist host continuity state")+ }+}++func (m *Monitor) removeHostContinuity(hostID string) {+ if m == nil || m.hostContinuityStore == nil {+ return+ }+ if err := m.hostContinuityStore.Delete(hostID); err != nil {+ log.Warn().+ Err(err).+ Str("hostID", hostID).+ Msg("failed to delete host continuity state")+ }+}++// HostReportMatchesKnownIdentity returns true when a host report targets either+// the live host snapshot or a recent persisted standalone-host continuity+// record.+func (m *Monitor) HostReportMatchesKnownIdentity(+ report agentshost.Report,+ tokenRecord *config.APITokenRecord,+) bool {+ if m == nil {+ return false+ }++ tokenID := ""+ if tokenRecord != nil {+ tokenID = tokenRecord.ID+ }+ if pkglicensing.HostReportTargetsExistingHosts(m.GetLiveHostsSnapshot(), report, tokenID) {+ return true+ }+ _, ok := m.matchPersistedHostContinuity(report, tokenRecord)+ return ok+}++func hostFromContinuityEntry(entry config.HostContinuityEntry) models.Host {+ return models.Host{+ ID: strings.TrimSpace(entry.HostID),+ Hostname: strings.TrimSpace(entry.Hostname),+ DisplayName: strings.TrimSpace(entry.DisplayName),+ Status: "online",+ LastSeen: entry.LastSeen,+ AgentVersion: strings.TrimSpace(entry.AgentVersion),+ MachineID: strings.TrimSpace(entry.MachineID),+ TokenID: strings.TrimSpace(entry.TokenID),+ Platform: strings.TrimSpace(entry.Platform),+ IsLegacy: entry.IsLegacy,+ LinkedNodeID: strings.TrimSpace(entry.LinkedNodeID),+ LinkedVMID: strings.TrimSpace(entry.LinkedVMID),+ LinkedContainerID: strings.TrimSpace(entry.LinkedContainerID),+ }+}++func (m *Monitor) recentStandaloneHostContinuityEntries() []config.HostContinuityEntry {+ if m == nil || m.hostContinuityStore == nil {+ return nil+ }+ return m.hostContinuityStore.RecentEntries(m.hostContinuitySince(time.Now().UTC()))+}+// RebuildTokenBindings reconstructs agent-to-token binding maps from the current// state of Docker hosts and host agents. This should be called after API tokens// are reloaded from disk to ensure bindings remain consistent with the new token set.@@ -1410,6 +1532,9 @@ func (m *Monitor) ApplyHostReport(report agentshost.Report, tokenRecord *config.sum := sha1.Sum([]byte(seed))baseIdentifier = fmt.Sprintf("agent-%s", hex.EncodeToString(sum[:6]))}+ if persisted, ok := m.matchPersistedHostContinuity(report, tokenRecord); ok {+ baseIdentifier = strings.TrimSpace(persisted.HostID)+ }readState := m.snapshotBackedUnifiedReadState()var existingHosts []*unifiedresources.HostView@@ -1876,6 +2001,7 @@ func (m *Monitor) ApplyHostReport(report agentshost.Report, tokenRecord *config.// Store cluster peer sensor data if present and evict stale entriesm.applyClusterSensors(report.ClusterSensors, timestamp)+ m.persistHostContinuity(host, report)return host, nil}diff --git a/internal/monitoring/monitor_host_agents_test.go b/internal/monitoring/monitor_host_agents_test.goindex 083ead9940..416ea2c123 100644--- a/internal/monitoring/monitor_host_agents_test.go+++ b/internal/monitoring/monitor_host_agents_test.go@@ -263,6 +263,97 @@ func TestApplyHostReportAllowsTokenReuseAcrossHosts(t *testing.T) {}}+func TestHostReportMatchesKnownIdentityUsesPersistedContinuity(t *testing.T) {+ now := time.Now().UTC()+ store := config.NewHostContinuityStore(t.TempDir(), nil)+ if err := store.Upsert(config.HostContinuityEntry{+ HostID: "host-1",+ ReportHostID: "machine-1",+ AgentReportedID: "agent-1",+ Hostname: "host-1.local",+ MachineID: "machine-1",+ TokenID: "token-1",+ LastSeen: now,+ }); err != nil {+ t.Fatalf("Upsert continuity: %v", err)+ }++ monitor := &Monitor{+ state: models.NewState(),+ hostContinuityStore: store,+ }++ report := agentshost.Report{+ Agent: agentshost.AgentInfo{+ ID: "agent-1",+ Version: "6.0.0-rc.1",+ },+ Host: agentshost.HostInfo{+ ID: "machine-1",+ MachineID: "machine-1",+ Hostname: "host-1.local",+ Platform: "linux",+ },+ Timestamp: now.Add(time.Minute),+ }++ if !monitor.HostReportMatchesKnownIdentity(report, &config.APITokenRecord{ID: "token-1"}) {+ t.Fatal("expected persisted continuity to count as a known host identity")+ }+}++func TestApplyHostReportReusesPersistedContinuityAcrossRestart(t *testing.T) {+ dir := t.TempDir()+ now := time.Now().UTC()++ newMonitor := func() *Monitor {+ monitor := &Monitor{+ state: models.NewState(),+ alertManager: alerts.NewManager(),+ hostTokenBindings: make(map[string]string),+ config: &config.Config{DataPath: dir},+ rateTracker: NewRateTracker(),+ hostContinuityStore: config.NewHostContinuityStore(dir, nil),+ }+ t.Cleanup(func() { monitor.alertManager.Stop() })+ return monitor+ }++ report := agentshost.Report{+ Agent: agentshost.AgentInfo{+ ID: "agent-1",+ Version: "6.0.0-rc.1",+ IntervalSeconds: 30,+ },+ Host: agentshost.HostInfo{+ ID: "machine-1",+ MachineID: "machine-1",+ Hostname: "host-1.local",+ Platform: "linux",+ },+ Timestamp: now,+ }+ token := &config.APITokenRecord{ID: "token-1", Name: "Token One"}++ firstMonitor := newMonitor()+ firstHost, err := firstMonitor.ApplyHostReport(report, token)+ if err != nil {+ t.Fatalf("first ApplyHostReport: %v", err)+ }++ restartedMonitor := newMonitor()+ restartReport := report+ restartReport.Timestamp = now.Add(30 * time.Second)+ restartedHost, err := restartedMonitor.ApplyHostReport(restartReport, token)+ if err != nil {+ t.Fatalf("restarted ApplyHostReport: %v", err)+ }++ if restartedHost.ID != firstHost.ID {+ t.Fatalf("expected persisted continuity to preserve host ID %q, got %q", firstHost.ID, restartedHost.ID)+ }+}+func TestApplyHostReportDisambiguatesCollidingIdentifiersAcrossTokens(t *testing.T) {t.Helper()diff --git a/internal/monitoring/monitor_unified_state_test.go b/internal/monitoring/monitor_unified_state_test.goindex 6d257569d4..55d1d56ebd 100644--- a/internal/monitoring/monitor_unified_state_test.go+++ b/internal/monitoring/monitor_unified_state_test.go@@ -5,6 +5,7 @@ import ("time""github.com/rcourtman/pulse-go-rewrite/internal/alerts"+ "github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/mock""github.com/rcourtman/pulse-go-rewrite/internal/models""github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"@@ -393,3 +394,66 @@ func TestMonitorMonitoredSystemUsageWaitsForSupplementalReadinessAndStoreFreshnet.Fatalf("MonitoredSystemUsage().Count = %d, want 1", usage.Count)}}++func TestMonitorMonitoredSystemUsageIncludesRecentStandaloneHostContinuity(t *testing.T) {+ now := time.Now().UTC()+ store := config.NewHostContinuityStore(t.TempDir(), nil)+ if err := store.Upsert(config.HostContinuityEntry{+ HostID: "host-1",+ ReportHostID: "machine-1",+ Hostname: "host-1.local",+ MachineID: "machine-1",+ LastSeen: now,+ }); err != nil {+ t.Fatalf("Upsert continuity: %v", err)+ }++ monitor := &Monitor{+ state: models.NewState(),+ hostContinuityStore: store,+ }++ usage := monitor.MonitoredSystemUsage()+ if !usage.Available {+ t.Fatalf("expected continuity-backed usage to be available, got %+v", usage)+ }+ if usage.Count != 1 {+ t.Fatalf("MonitoredSystemUsage().Count = %d, want 1", usage.Count)+ }+}++func TestMonitorMonitoredSystemUsageDoesNotDoubleCountLinkedProxmoxHostContinuity(t *testing.T) {+ now := time.Now().UTC()+ store := config.NewHostContinuityStore(t.TempDir(), nil)+ if err := store.Upsert(config.HostContinuityEntry{+ HostID: "host-1",+ ReportHostID: "machine-1",+ Hostname: "pve-1",+ MachineID: "machine-1",+ LinkedNodeID: "node-1",+ LastSeen: now,+ }); err != nil {+ t.Fatalf("Upsert continuity: %v", err)+ }++ state := models.NewState()+ state.UpdateNodes([]models.Node{{+ ID: "node-1",+ Name: "pve-1",+ Status: "online",+ LastSeen: now,+ }})++ monitor := &Monitor{+ state: state,+ hostContinuityStore: store,+ }++ usage := monitor.MonitoredSystemUsage()+ if !usage.Available {+ t.Fatalf("expected continuity-backed usage to be available, got %+v", usage)+ }+ if usage.Count != 1 {+ t.Fatalf("MonitoredSystemUsage().Count = %d, want 1", usage.Count)+ }+}diff --git a/internal/monitoring/monitored_system_usage.go b/internal/monitoring/monitored_system_usage.goindex e41be5d206..bae696223c 100644--- a/internal/monitoring/monitored_system_usage.go+++ b/internal/monitoring/monitored_system_usage.go@@ -55,6 +55,8 @@ func (m *Monitor) MonitoredSystemUsage() MonitoredSystemUsageSnapshot {}}+ readState = m.monitoredSystemUsageReadStateWithHostContinuity(readState)+return MonitoredSystemUsageSnapshot{Count: unifiedresources.MonitoredSystemCount(readState),ReadState: readState,@@ -62,6 +64,58 @@ func (m *Monitor) MonitoredSystemUsage() MonitoredSystemUsageSnapshot {}}+func (m *Monitor) monitoredSystemUsageReadStateWithHostContinuity(+ readState unifiedresources.ReadState,+) unifiedresources.ReadState {+ if m == nil || readState == nil {+ return readState+ }++ entries := m.recentStandaloneHostContinuityEntries()+ if len(entries) == 0 {+ return readState+ }++ liveHostIDs := make(map[string]struct{}, len(m.GetLiveHostsSnapshot()))+ for _, host := range m.GetLiveHostsSnapshot() {+ if id := strings.TrimSpace(host.ID); id != "" {+ liveHostIDs[id] = struct{}{}+ }+ }++ existingAgentIDs := make(map[string]struct{}, len(readState.Hosts()))+ for _, host := range readState.Hosts() {+ if host == nil {+ continue+ }+ if agentID := strings.TrimSpace(host.AgentID()); agentID != "" {+ existingAgentIDs[agentID] = struct{}{}+ }+ if resourceID := strings.TrimSpace(host.ID()); resourceID != "" {+ existingAgentIDs[resourceID] = struct{}{}+ }+ }++ records := make([]unifiedresources.IngestRecord, 0, len(entries))+ for _, entry := range entries {+ hostID := strings.TrimSpace(entry.HostID)+ if hostID == "" {+ continue+ }+ if _, ok := liveHostIDs[hostID]; ok {+ continue+ }+ if _, ok := existingAgentIDs[hostID]; ok {+ continue+ }+ records = append(records, unifiedresources.HostIngestRecord(hostFromContinuityEntry(entry)))+ }+ if len(records) == 0 {+ return readState+ }+ return unifiedresources.ReadStateWithRecords(readState, unifiedresources.SourceAgent, records)+}+func normalizedMonitorUsageOrgID(m *Monitor) string {if m == nil {return "default"diff --git a/internal/unifiedresources/adapters.go b/internal/unifiedresources/adapters.goindex 264f364c1f..1b76ec1579 100644--- a/internal/unifiedresources/adapters.go+++ b/internal/unifiedresources/adapters.go@@ -94,6 +94,17 @@ func identityFromHost(host models.Host) ResourceIdentity {}}+// HostIngestRecord converts a host snapshot into the canonical source-native+// ingest shape used by monitored-system previews and continuity projections.+func HostIngestRecord(host models.Host) IngestRecord {+ resource, identity := resourceFromHost(host)+ return IngestRecord{+ SourceID: host.ID,+ Resource: resource,+ Identity: identity,+ }+}+func resourceFromHost(host models.Host) (Resource, ResourceIdentity) {name := host.Hostnameif host.DisplayName != "" {diff --git a/internal/unifiedresources/monitor_adapter.go b/internal/unifiedresources/monitor_adapter.goindex f604464cbd..e4e62d36d7 100644--- a/internal/unifiedresources/monitor_adapter.go+++ b/internal/unifiedresources/monitor_adapter.go@@ -30,6 +30,33 @@ func NewMonitorAdapter(registry *ResourceRegistry) *MonitorAdapter {}}+// ReadStateWithRecords clones a supported read state and overlays additional+// source-native records without mutating the original live view.+func ReadStateWithRecords(+ readState ReadState,+ source DataSource,+ records []IngestRecord,+) ReadState {+ if readState == nil || len(records) == 0 || strings.TrimSpace(string(source)) == "" {+ return readState+ }++ adapter, ok := readState.(*MonitorAdapter)+ if !ok || adapter == nil {+ return readState+ }++ registry := adapter.currentRegistry()+ if registry == nil {+ return readState+ }++ cloned := NewRegistry(registry.store)+ cloned.IngestResources(registry.List())+ cloned.IngestRecords(source, records)+ return NewMonitorAdapter(cloned)+}+func (a *MonitorAdapter) currentRegistry() *ResourceRegistry {if a == nil {return nildiff --git a/internal/unifiedresources/monitor_adapter_read_state_test.go b/internal/unifiedresources/monitor_adapter_read_state_test.goindex 4c849671ad..96d7e7e473 100644--- a/internal/unifiedresources/monitor_adapter_read_state_test.go+++ b/internal/unifiedresources/monitor_adapter_read_state_test.go@@ -3,6 +3,8 @@ package unifiedresourcesimport ("testing""time"++ "github.com/rcourtman/pulse-go-rewrite/internal/models")var _ ReadState = (*MonitorAdapter)(nil)@@ -187,6 +189,36 @@ func TestMonitorAdapterStoragePoolViewsAttachCanonicalMetricsTarget(t *testing.T}}+func TestReadStateWithRecordsClonesMonitorAdapterAndOverlaysRecords(t *testing.T) {+ now := time.Date(2026, 4, 15, 12, 0, 0, 0, time.UTC)+ registry := NewRegistry(nil)+ registry.IngestRecords(SourceAgent, []IngestRecord{+ HostIngestRecord(models.Host{+ ID: "host-1",+ Hostname: "host-1.local",+ Status: "online",+ LastSeen: now,+ }),+ })++ base := NewMonitorAdapter(registry)+ overlay := ReadStateWithRecords(base, SourceAgent, []IngestRecord{+ HostIngestRecord(models.Host{+ ID: "host-2",+ Hostname: "host-2.local",+ Status: "online",+ LastSeen: now.Add(time.Minute),+ }),+ })++ if got := len(base.Hosts()); got != 1 {+ t.Fatalf("base host count = %d, want 1", got)+ }+ if got := len(overlay.Hosts()); got != 2 {+ t.Fatalf("overlay host count = %d, want 2", got)+ }+}+func TestMonitorAdapterRecordsSupplementalChangeTimeline(t *testing.T) {store := NewMemoryStore()adapter := NewMonitorAdapter(NewRegistry(store))diff --git a/internal/unifiedresources/registry.go b/internal/unifiedresources/registry.goindex b6bd98d02d..5cb6b48a7a 100644--- a/internal/unifiedresources/registry.go+++ b/internal/unifiedresources/registry.go@@ -299,6 +299,7 @@ func (rr *ResourceRegistry) IngestResources(resources []Resource) {rr.mu.Lock()rr.resources[resource.ID] = resource+ rr.matcher.Add(resource.ID, resource.Identity)rr.viewsDirty = truerr.mu.Unlock()}diff --git a/internal/unifiedresources/registry_test.go b/internal/unifiedresources/registry_test.goindex a3535925ff..6138b78c8d 100644--- a/internal/unifiedresources/registry_test.go+++ b/internal/unifiedresources/registry_test.go@@ -121,6 +121,60 @@ func TestResourceRegistry_ListUsesDeterministicNameTieBreakers(t *testing.T) {assertStringSlice(t, gotIDs, []string{"agent-1", "storage-a", "storage-b", "storage-z"})}+func TestResourceRegistry_IngestResourcesSeedsMatcherForOverlayRecords(t *testing.T) {+ rr := NewRegistry(nil)+ now := time.Date(2026, 4, 15, 12, 0, 0, 0, time.UTC)++ rr.IngestResources([]Resource{+ {+ ID: "node-1",+ Type: ResourceTypeAgent,+ Name: "tower",+ Status: StatusOnline,+ LastSeen: now,+ Sources: []DataSource{SourceProxmox},+ Identity: ResourceIdentity{+ MachineID: "machine-1",+ Hostnames: []string{"tower"},+ },+ Proxmox: &ProxmoxData{+ NodeName: "tower",+ Instance: "lab",+ },+ },+ })++ rr.IngestRecords(SourceAgent, []IngestRecord{+ {+ SourceID: "host-1",+ Resource: Resource{+ Type: ResourceTypeAgent,+ Name: "tower",+ Status: StatusOnline,+ LastSeen: now.Add(time.Minute),+ Agent: &AgentData{+ AgentID: "agent-1",+ },+ },+ Identity: ResourceIdentity{+ MachineID: "machine-1",+ Hostnames: []string{"tower"},+ },+ },+ })++ resources := rr.List()+ if len(resources) != 1 {+ t.Fatalf("expected overlay record to merge into seeded resource, got %d resources", len(resources))+ }+ if resources[0].Proxmox == nil || resources[0].Agent == nil {+ t.Fatalf("expected merged resource to keep seeded and overlay metadata, got %+v", resources[0])+ }+ if got := len(resources[0].Sources); got != 2 {+ t.Fatalf("expected merged sources from seed and overlay, got %d (%+v)", got, resources[0].Sources)+ }+}+func TestResourceRegistry_MergesPhysicalDiskTemperatureAggregate(t *testing.T) {rr := NewRegistry(nil)now := time.Date(2026, 3, 29, 12, 0, 0, 0, time.UTC)