Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Preserve reviewed maintenance with published manual-unlink repair

pulse-triage[bot]7de25acd17d4
diff --cc docs/release-control/v6/internal/subsystems/monitoring.md
index 1a471b1185,abcb21555c..eed66727d1
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@@ -6225,107 -5827,23 +6225,128 @@@ HTTP 200/503 split, reopens the persist
destination's recovery plus the new firing, with no recovery to the unannounced
destination. Quiet hours and disabled recovery controls still apply.
+### Observed Proxmox replication sync outcome
+
+Replication configuration is enriched only from the source node's per-job
+status endpoint. A successful timestamp plus an explicitly valid zero failure
+count and no failure/unknown-state evidence yields `lastSyncStatus: ok`;
+error text, positive failures or an explicit failed state yields `error`,
+including error-with-zero-failures. Missing, denied, malformed, never-synced,
+invalid-count or unknown-state responses do not acquire success from defaults.
+Job/source mismatches and ambiguous array identities are rejected before any
+status fields merge. Single legacy rows without IDs retain endpoint binding;
+a multi-row response requires exactly one matching job.
+
+`replication_test.go` covers native field shapes, failure/unknown controls,
+HTTP enrichment and identity. `monitor_full_coverage_test.go` carries the real
+client through four normal fourteen-job/five-node polls into model/wire state,
+with zero-count error, denied status, recovery and another-instance isolation.
+The unchanged replication table consumes those explicit outcomes. These local
+HTTP controls are not native restart recovery; issue #2606 remains separate.
+
+### Next guest polls preserve correlated agent filesystem inventory
+
+The previous-guest context carries disks and their original agent source time
+from a manually correlated VM/container even when the standalone host row was
+removed, and even if agent memory is unavailable. Standalone linked hosts use
+the same source-owned eligibility; a current platform row cannot renew agent
+disk evidence. The existing VM disk preference consumes this inventory without
+issuing another guest-agent read. Empty replacements, expiry and withdrawal
+remove eligibility; a new ordinary report restores it. Guest-read safety and
+backup deferrals remain independent of usable Pulse-agent filesystem data.
+
+`guest_linked_agent_disks_test.go` carries actual registry correlation, retained
+links and automatic link hints through ordinary VM construction and canonical
+projection. It covers disk-only evidence, source time, missing links, identical
+VMIDs in separate instances, expiry/offline/empty/withdrawal/recovery and a
+backup lock with zero filesystem calls. Sequential snapshot replacement pins
+inventory removal/recovery without restarting the monitor. These are synthetic
+source controls, not a native cause, thaw or installed recovery for #2616/#2619.
+
+### Runtime-owned Proxmox replication observations — #2606
+
+The ordinary PVE scheduler/provider/executor dispatches a bounded replication
+read independently of `cluster/resources` availability, traditional guest
+fallback and disabled guest-detail monitoring. Its ten-second context is
+captured from the monitor runtime before dispatch, not from the short-lived
+scheduled task. One read per registered instance/client coalesces overlapping
+cycles; runtime replacement and retirement cancel/invalidate the claim. A
+replacement client can recover on the next ordinary cycle without waiting for
+an old read. Publication checks cancellation, the claim and the current client
+under the same lock; a late obsolete completion cannot overwrite or clear a
+newer result, including a successful empty inventory.
+
+Only an explicitly decoded `data` array is a complete replication inventory.
+Missing/null/malformed envelopes, cancellation (including after final status
+body consumption), access/transport errors and unavailable endpoints preserve
+the prior jobs and their original `LastPolled`. A complete successful empty
+array removes only that instance's jobs. Individual uncanceled status-access
+failures retain the existing unknown-outcome contract, not inferred success.
+No wire fields, classification, permission contract or scheduler cadence change.
+
+`monitor_pve_replication_lifecycle_test.go` exercises ordinary fallback/disabled
+paths and canceled/unavailable versus complete empty reads; the owned-boundary
+controls in `monitor_pve_replication_owner_test.go` cover coalescing, cycle/runtime
+cancellation, replacement, retirement, late completion and ordinary recovery.
+`pkg/proxmox/replication_lifecycle_test.go` binds envelope and cancellation
+controls to the real HTTP client. Synthetic proofs do not establish #2606's
+reported eleven-hour cause, native PVE recovery or published availability.
+
+### Non-destructive PVE backup access guidance
+
+Backup storage-list/content access warnings name the attempted endpoint and
+point operators to the actual saved PVE connection, installed-version endpoint
+permissions and both user/token scopes without disabling privilege separation.
+Observed HTTP 401 is an authentication rejection; 403 is an access denial, not
+proof of a particular missing role. Unknown errors and proxy bodies quoting
+another status remain unconfirmed. The private HTTP error wrapper exposes only
+its numeric wire status for this distinction, never its body or credentials.
+Warnings and associated log guidance contain no unconditional ACL command,
+assumed account, token ID, token secret or role prescription. Endpoint text is
+bounded and control-quoted. Collection, inventory/error completeness, polling
+cadence and setup permissions are unchanged.
+
+`monitor_backup_poll_test.go` and `canonical_guardrails_test.go` retain the safe
+saved-identity/manual-token contract. `pve_backup_warning_test.go` exercises
+401/403/proxy errors through the real client and storage-list/content producer,
+as well as unknown evidence and hostile endpoint text. The HTTP status helper
+has wrapped-error/body-injection controls in `api_error_status_test.go`. These
+are local source controls, not a native permission diagnosis or availability.
+
+### Physical-disk chart metadata without invented History
+
+`GetPhysicalDiskTemperatureCharts` preserves a currently collected physical
+disk's identity, display name, node and instance even when its stored
+temperature series is empty. A retained-only disk with no observed samples
+does not introduce an empty chart entry. Neither current nor retained readings
+create historical timestamps, duplicate a single stored point or pad a flat
+series: stored sample values and times remain unchanged. This composes current
+disk metadata with the sparse-history and retained-observation boundaries;
+collection policy and native health claims are unchanged.
+
+`TestDiskTemperatureChartsRetainOnlyObservedSamples` in
+`internal/monitoring/monitor_metrics_slo_test.go` binds live-without-history
+metadata, retained-without-history exclusion and original single-point
+observations to the production chart path. These source controls do not
+establish native temperature collection or installed History acceptance.
++
+ ### Broadcast host coalescing honours operator splits
+
+ The websocket broadcast coalesced top-level host views with
+ `CoalescePresentationHostResources`, which applies no merge exclusions, while
+ the resources API's `ResourceRegistry.ListForPresentation` applies the
+ registry's. A host pair the operator split (unlink or report-merge) could
+ therefore be one broadcast row and two REST rows.
+ `Monitor.buildBroadcastFrontendStateFromSnapshotWithClock` now calls
+ `coalesceResourcesForPresentation`, which asks the view's read state for
+ `MonitorAdapter.CoalesceForPresentation` when its registry is store-backed
+ (the resource store's adapter, or a host-continuity overlay that loaded the
+ store's exclusions afresh), and otherwise the resource store's adapter: the
+ mock-mode view lists through a store-less registry that carries no operator
+ decisions. Both surfaces share `presentationExclusionFilter`. Polling, rebuild cadence,
+ alert evaluation and the broadcast payload shape are unchanged.
+ `TestBroadcastPresentationCoalesceHonoursMergeExclusions` compares broadcast
+ and REST row counts with and without the split, and
+ `TestBroadcastPresentationCoalescePrefersTheListingReadState` pins the
+ listing read state over an older store generation and the store's exclusions
+ for a mock-style view.
diff --cc docs/release-control/v6/internal/subsystems/unified-resources.md
index f0e05da945,fd67945711..434b7d18f8
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@@ -6956,16 -6920,89 +6956,103 @@@ vCenter reports no signals. The Overvie
navigation facets still come from the Overview query; the Health tab keeps
the filterable table.
+### Correlated guest disks retain the independent agent source
+
+`VMView.LinkedAgentDisks`, `ContainerView.LinkedAgentDisks` and
+`HostView.CurrentAgentDisks` expose detached agent-owned filesystem inventory
+with the agent source's own receipt time, independently of agent memory.
+Missing, non-online, expired, stale, undated or future agent sources cannot
+supply current disks just because the platform row keeps reporting. The
+registry's configured source lease remains authoritative; this adds no new
+expiry duration. Existing `HostView.Disks` retains last-known presentation.
+
+`linked_agent_disks_test.go` covers selection, source timestamps, nil views
+and detached inventory across all three views. No public model field, inferred
+link, guest command or safety-pause clearance is introduced.
++
+ ### Unlink replaces the pair's operator link
+
+ `POST /api/resources/{id}/link` records a `ResourceLink`; unlink and
+ report-merge record a `ResourceExclusion`. An operator decides each resource
+ pair one way, and the later decision replaces the earlier: the store's
+ `AddExclusion` deletes the pair's link rows and `AddLink` deletes its
+ exclusion rows, in the same transaction as the write, matching both ID
+ orders because canonical-ID succession can store either. Unlink used to add
+ only the exclusion. The link row survived, and `applyManualLinks`, which
+ never consults exclusions, kept the pair folded in the monitor's rebuilds and
+ in the resources API's registry, so the agent facet stayed on the VM and the
+ agent row stayed hidden although the API answered "Resources unlinked".
+ `GetLinks` and `GetExclusions` return only each pair's latest decision
+ (`effectiveManualPairDecisions` in `manual_link_decisions.go`), so a store
+ that still holds both rows for a pair, written before this change or
+ rewritten onto one pair by succession, reads its later write, and a tie
+ reads as apart. Every registry loads its links and exclusions from its store
+ when it is constructed, so the monitor's rebuild and the resources API's
+ store-backed registry apply one decision with no exclusion check in
+ `applyManualLinks`. Unlink keeps the exclusion, so identity matching and
+ presentation coalescing also keep a pair apart that would otherwise match
+ automatically.
+
+ Identity pins honour the exclusion too. While a Proxmox node was linked to a
+ standalone agent, the merged resource's pin could record the node's endpoint
+ hostname with the agent's machine key. After unlink the node completed that
+ key in `completeIdentityFromPins`, minted the agent's machine-derived ID and
+ folded into the agent by ID, a path no exclusion check sees, so the pair
+ stayed merged with the link row gone. A pin whose canonical ID the operator
+ excluded from the ID the record takes without the pin (its `chooseNewID` or
+ source-specific ID) now completes nothing. This covers pins already written
+ that way, not only new ones. Merges through an agent's own declared node link
+ (`resolveLinkedResource`) still ignore exclusions.
+
+ The resources API seeds its registry from the monitor's listing, which
+ already has the link applied, so it cannot split the pair itself: an unlink
+ shows on REST, `/api/state` and the websocket from the monitor's next
+ registry rebuild, the same generation in which a new link reaches the
+ broadcast. REST applies a new link at once, because its own registry applies
+ the store's links on top of the seed. The mock-mode view applies no operator
+ links, so in mock mode REST splits a manually linked pair as soon as the
+ unlink is recorded. Mock fixtures that identity matching merged stay merged
+ on every surface: the fixture graph is built without the store's exclusions.
+
+ The websocket broadcast coalesced host views with
+ `CoalescePresentationHostResources`, which honours no exclusions, while the
+ resources API's `ListForPresentation` honours the registry's, so a host pair
+ the operator split could be one broadcast row and two REST rows. The
+ broadcast now coalesces through `Monitor.coalesceResourcesForPresentation`,
+ which asks the read state that listed the rows for
+ `MonitorAdapter.CoalesceForPresentation` when its registry is store-backed
+ (the resource store's adapter, or a host-continuity overlay that loaded the
+ store's exclusions afresh). The mock view and other views built from an
+ already-unified list sit on a store-less registry, which declines, so the
+ resource store's adapter supplies the exclusions instead. Either applies its
+ current registry's exclusions through the same `presentationExclusionFilter`
+ that `ListForPresentation` uses; a rebuild published between listing the
+ rows and coalescing them is judged by the newer generation's exclusions for
+ that one broadcast. Both surfaces share one known limit: the filter compares
+ the IDs of the rows being merged, so a third same-host fragment that merges
+ first can carry an excluded pair into one row.
+
+ A write leaves one row for its pair: `AddLink` and `AddExclusion` also delete
+ a row of their own kind that succession stored in the other order, and the
+ in-memory store replaces a pair's rows on every write and stamps `CreatedAt`
+ as SQLite does. Reads keep the newest link per pair, so an older reversed copy
+ cannot win with its primary, and drop exclusions older than it; duplicate
+ exclusions already stored stay, which changes no decision. A registry resolves its `GetLinks` and `GetExclusions` results
+ together in `loadOverrides`, so an unlink committed between the two reads
+ cannot load both decisions for one generation. Report-merge still records
+ exclusions against candidate IDs derived from the merged resource's type,
+ which do not name the folded side of a cross-type manual link, so it does not
+ undo such a link; unlink does. `TestManualPairDecisionReplacesThePreviousOne` and
+ `TestManualPairDecisionReadsResolveStoredConflictsByRecency` pin the store
+ rule on SQLite and the in-memory store,
+ `TestUnlinkSplitsHostPairWhosePinTookTheOtherSidesKey` links and unlinks
+ node and agent pairs (IP and FQDN endpoints, either side primary) through
+ three monitor rebuilds per step,
+ `TestRegistryResolvesDecisionsAcrossItsTwoReads` loads a link read before an
+ unlink and the exclusion read after it,
+ `TestResourceUnlinkSplitsManuallyLinkedPair` drives link, unlink and relink
+ through the API handlers against a monitor adapter rebuilt twice per step,
+ and `TestMonitorAdapterCoalesceForPresentationHonoursExclusions`,
+ `TestBroadcastPresentationCoalesceHonoursMergeExclusions` and
+ `TestBroadcastPresentationCoalescePrefersTheListingReadState` pin broadcast
+ and REST row counts for a split host pair.
diff --cc internal/monitoring/monitor_host_agents_test.go
index efb99122d1,268d542f9d..7f1fe56568
--- a/internal/monitoring/monitor_host_agents_test.go
+++ b/internal/monitoring/monitor_host_agents_test.go
@@@ -6988,118 -6988,113 +6988,225 @@@ func TestBroadcastProjectionListsRegist
}
}
+func TestAgentLXCPartialInventoryPreservesSuccessAndInvalidatesOmissions(t *testing.T) {
+ state := models.NewState()
+ state.UpdateNodes([]models.Node{{ID: "node-id", Name: "node-a", Instance: "pve-a", LinkedAgentID: "agent-a"}})
+ m := &Monitor{state: state}
+ now := time.Date(2026, 10, 5, 16, 0, 0, 0, time.UTC)
+ row := func(vmid int) agentshost.ProxmoxLXCContainer {
+ return agentshost.ProxmoxLXCContainer{VMID: vmid, Name: "web", Disks: []agentshost.Disk{{Type: "rootfs", Device: "local:disk", Mountpoint: "/", TotalBytes: 4096, UsedBytes: 1024, FreeBytes: 3072}}}
+ }
+ m.applyAgentLXCFilesystems("node-id", "agent-a", &agentshost.ProxmoxLXCInventory{Status: "complete", Containers: []agentshost.ProxmoxLXCContainer{row(100), row(102)}}, now, 30)
+ foreignKey := agentLXCFilesystemCacheKey("pve-b", "node-a", 102)
+ m.proxmoxLXCFilesystemsCache[foreignKey] = agentLXCFilesystemCacheEntry{agentID: "agent-b", name: "foreign", expiresAt: now.Add(time.Hour)}
+ m.applyAgentLXCFilesystems("node-id", "agent-a", &agentshost.ProxmoxLXCInventory{Status: "partial", Containers: []agentshost.ProxmoxLXCContainer{row(100)}, OmittedVMIDs: []int{102}}, now.Add(time.Minute), 30)
+ if _, ok := m.proxmoxLXCFilesystemsCache[agentLXCFilesystemCacheKey("pve-a", "node-a", 102)]; ok {
+ t.Fatal("omitted guest kept a usable prior agent reading")
+ }
+ if _, ok := m.proxmoxLXCFilesystemsCache[foreignKey]; !ok {
+ t.Fatal("foreign instance cache was invalidated")
+ }
+ guest := models.Container{VMID: 100, Name: "web", Status: "running"}
+ m.enrichContainerWithAgentLXCFilesystems("pve-a", "node-a", &guest, now.Add(time.Minute))
+ if len(guest.Disks) != 1 || guest.Disks[0].Used != 1024 {
+ t.Fatalf("successful partial guest=%+v", guest)
+ }
+ m.applyAgentLXCFilesystems("node-id", "agent-a", &agentshost.ProxmoxLXCInventory{Status: "complete"}, now.Add(2*time.Minute), 30)
+ if _, ok := m.proxmoxLXCFilesystemsCache[agentLXCFilesystemCacheKey("pve-a", "node-a", 100)]; ok {
+ t.Fatal("complete empty collection retained a removed/stopped guest reading")
+ }
+ if _, ok := m.proxmoxLXCFilesystemsCache[foreignKey]; !ok {
+ t.Fatal("complete empty collection cleared a foreign instance")
+ }
+}
+
+func TestAgentLXCMalformedPartialInventoryCannotRenewOrInvalidate(t *testing.T) {
+ state := models.NewState()
+ state.UpdateNodes([]models.Node{{ID: "node-id", Name: "node-a", Instance: "pve-a", LinkedAgentID: "agent-a"}})
+ m := &Monitor{state: state}
+ now := time.Now()
+ key := agentLXCFilesystemCacheKey("pve-a", "node-a", 100)
+ original := agentLXCFilesystemCacheEntry{agentID: "agent-a", name: "web", expiresAt: now.Add(time.Minute)}
+ m.proxmoxLXCFilesystemsCache = map[string]agentLXCFilesystemCacheEntry{key: original}
+ m.applyAgentLXCFilesystems("node-id", "agent-a", &agentshost.ProxmoxLXCInventory{Status: "complete", OmittedVMIDs: []int{100}}, now, 30)
+ got := m.proxmoxLXCFilesystemsCache[key]
+ if !got.expiresAt.Equal(original.expiresAt) || got.name != "web" {
+ t.Fatal("malformed completeness changed cache")
+ }
+}
+
+func TestAgentLXCPartialWireReportReachesLinkedGuestWithoutStaleOmission(t *testing.T) {
+ m := newTestMonitor(t)
+ m.state.UpdateNodes([]models.Node{{ID: "node-id", Name: "node-a", Instance: "pve-a"}})
+ row := func(vmid int) agentshost.ProxmoxLXCContainer {
+ return agentshost.ProxmoxLXCContainer{VMID: vmid, Name: "web", Disks: []agentshost.Disk{{
+ Type: "rootfs", Device: "local:disk", Mountpoint: "/", TotalBytes: 4096, UsedBytes: 1024, FreeBytes: 3072,
+ }}}
+ }
+ report := agentshost.Report{
+ Agent: agentshost.AgentInfo{ID: "agent-a", IntervalSeconds: 30},
+ Host: agentshost.HostInfo{ID: "agent-a", MachineID: "agent-a", Hostname: "node-a", Platform: "linux"},
+ ProxmoxLXC: &agentshost.ProxmoxLXCInventory{
+ Status: agentshost.ProxmoxLXCCollectionComplete, Containers: []agentshost.ProxmoxLXCContainer{row(100), row(102)},
+ },
+ }
+ applyWire := func(sequence uint64) models.Host {
+ t.Helper()
+ report.Timestamp = time.Now().UTC()
+ report.SequenceID = agentshost.FormatReportSequenceID("partial-wire-test", sequence)
+ encoded, err := json.Marshal(report)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var decoded agentshost.Report
+ if err := json.Unmarshal(encoded, &decoded); err != nil {
+ t.Fatal(err)
+ }
+ host, err := m.ApplyHostReport(decoded, &config.APITokenRecord{ID: "partial-wire-token"})
+ if err != nil || host.LinkedNodeID != "node-id" {
+ t.Fatalf("wire report did not reach linked node: host=%+v err=%v", host, err)
+ }
+ return host
+ }
+ applyWire(1)
+ report.ProxmoxLXC.Status = agentshost.ProxmoxLXCCollectionPartial
+ report.ProxmoxLXC.Containers = []agentshost.ProxmoxLXCContainer{row(100)}
+ report.ProxmoxLXC.OmittedVMIDs = []int{102}
+ report.Agent.Modules = []agentshost.ModuleStatus{{Name: agentshost.ModuleNameTypedPrivilegeHelper, Enabled: true, State: "degraded", LastError: "proxmox.lxc_filesystems: helper Proxmox LXC filesystem inventory is incomplete"}}
+ host := applyWire(2)
+ if len(host.AgentModules) != 1 || host.AgentModules[0].State != "degraded" {
+ t.Fatalf("wire report lost partial helper health: %+v", host.AgentModules)
+ }
+ for _, vmid := range []int{100, 102} {
+ guest := models.Container{VMID: vmid, Name: "web", Status: "running"}
+ m.enrichContainerWithAgentLXCFilesystems("pve-a", "node-a", &guest, time.Now())
+ if vmid == 100 && (len(guest.Disks) != 1 || guest.Disks[0].Used != 1024) {
+ t.Fatalf("successful wire reading was lost: %+v", guest.Disks)
+ }
+ if vmid == 102 && len(guest.Disks) != 0 {
+ t.Fatalf("omitted wire guest kept a prior reading: %+v", guest.Disks)
+ }
+ }
+ report.ProxmoxLXC = &agentshost.ProxmoxLXCInventory{Status: agentshost.ProxmoxLXCCollectionComplete}
+ report.Agent.Modules[0].State, report.Agent.Modules[0].LastError = "running", ""
+ host = applyWire(3)
+ if len(host.AgentModules) != 1 || host.AgentModules[0].State != "running" || host.AgentModules[0].LastError != "" {
+ t.Fatalf("wire recovery did not clear partial helper health: %+v", host.AgentModules)
+ }
+ guest := models.Container{VMID: 100, Name: "web", Status: "running"}
+ m.enrichContainerWithAgentLXCFilesystems("pve-a", "node-a", &guest, time.Now())
+ if len(guest.Disks) != 0 {
+ t.Fatal("complete empty wire report retained a stopped guest reading")
+ }
+}
+
+ // presentationFixtureStore keeps the fixture registry: the broadcast's read
+ // refresh would otherwise rebuild it from the empty snapshot.
+ type presentationFixtureStore struct {
+ *unifiedresources.MonitorAdapter
+ }
+
+ func (presentationFixtureStore) TryReplaceRegistryForRead(models.StateSnapshot, time.Duration, func() map[unifiedresources.DataSource][]unifiedresources.IngestRecord) bool {
+ return false
+ }
+
+ // A host pair the operator split (unlink or report-merge) must be two
+ // broadcast rows exactly when the resources API lists two. The broadcast used
+ // to coalesce without the store's exclusions, so the websocket folded the
+ // pair the API kept apart.
+ func TestBroadcastPresentationCoalesceHonoursMergeExclusions(t *testing.T) {
+ now := time.Date(2026, 10, 7, 21, 0, 0, 0, time.UTC)
+ resources := []unifiedresources.Resource{
+ {
+ ID: "agent-runtime-alpha", Type: unifiedresources.ResourceTypeAgent, Name: "alpha",
+ Status: unifiedresources.StatusOnline, LastSeen: now,
+ Sources: []unifiedresources.DataSource{unifiedresources.SourceAgent},
+ Identity: unifiedresources.ResourceIdentity{Hostnames: []string{"alpha"}},
+ Agent: &unifiedresources.AgentData{AgentID: "agent-alpha", Hostname: "alpha"},
+ },
+ {
+ ID: "agent-docker-alpha", Type: unifiedresources.ResourceTypeAgent, Name: "alpha",
+ Status: unifiedresources.StatusOnline, LastSeen: now,
+ Sources: []unifiedresources.DataSource{unifiedresources.SourceDocker},
+ Identity: unifiedresources.ResourceIdentity{Hostnames: []string{"alpha"}},
+ Docker: &unifiedresources.DockerData{Hostname: "alpha"},
+ },
+ }
+ for _, split := range []bool{false, true} {
+ store := unifiedresources.NewMemoryStore()
+ if split {
+ if err := store.AddExclusion(unifiedresources.ResourceExclusion{ResourceA: "agent-runtime-alpha", ResourceB: "agent-docker-alpha"}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ registry := unifiedresources.NewRegistry(store)
+ registry.IngestResources(resources)
+ adapter := unifiedresources.NewMonitorAdapter(registry)
+ m := &Monitor{resourceStore: presentationFixtureStore{adapter}}
+
+ state := m.buildBroadcastFrontendStateFromSnapshotWithClock(models.EmptyStateSnapshot(), m.mockModeFence.begin(), func() time.Time { return now })
+ broadcastRows := 0
+ for _, resource := range state.Resources {
+ if resource.Name == "alpha" {
+ broadcastRows++
+ }
+ }
+
+ // The resources API seeds a store-backed registry from the monitor's
+ // listing and presents it through ListForPresentation.
+ rest := unifiedresources.NewRegistry(store)
+ rest.IngestResources(adapter.GetAll())
+ restRows := len(rest.ListForPresentation())
+
+ want := 1
+ if split {
+ want = 2
+ }
+ if broadcastRows != want || restRows != want {
+ t.Fatalf("split=%v: broadcast rows=%d REST rows=%d, want %d on both", split, broadcastRows, restRows, want)
+ }
+ }
+ }
+
+ // The rows a broadcast coalesces were listed by its view's read state, such as
+ // a host-continuity overlay that loaded the store's exclusions afresh, so its
+ // exclusions decide even when the resource store's generation predates them.
+ func TestBroadcastPresentationCoalescePrefersTheListingReadState(t *testing.T) {
+ now := time.Date(2026, 10, 7, 21, 0, 0, 0, time.UTC)
+ resources := []unifiedresources.Resource{
+ {ID: "agent-runtime-alpha", Type: unifiedresources.ResourceTypeAgent, Name: "alpha", Status: unifiedresources.StatusOnline, LastSeen: now,
+ Sources: []unifiedresources.DataSource{unifiedresources.SourceAgent}, Identity: unifiedresources.ResourceIdentity{Hostnames: []string{"alpha"}},
+ Agent: &unifiedresources.AgentData{AgentID: "agent-alpha", Hostname: "alpha"}},
+ {ID: "agent-docker-alpha", Type: unifiedresources.ResourceTypeAgent, Name: "alpha", Status: unifiedresources.StatusOnline, LastSeen: now,
+ Sources: []unifiedresources.DataSource{unifiedresources.SourceDocker}, Identity: unifiedresources.ResourceIdentity{Hostnames: []string{"alpha"}},
+ Docker: &unifiedresources.DockerData{Hostname: "alpha"}},
+ }
+ store := unifiedresources.NewMemoryStore()
+ base := unifiedresources.NewRegistry(store)
+ base.IngestResources(resources)
+ m := &Monitor{resourceStore: unifiedresources.NewMonitorAdapter(base)}
+ if err := store.AddExclusion(unifiedresources.ResourceExclusion{ResourceA: "agent-runtime-alpha", ResourceB: "agent-docker-alpha"}); err != nil {
+ t.Fatal(err)
+ }
+ overlay := unifiedresources.NewRegistry(store)
+ overlay.IngestResources(resources)
+ listing := unifiedresources.NewMonitorAdapter(overlay)
+ if got := len(m.coalesceResourcesForPresentation(listing, listing.GetAll())); got != 2 {
+ t.Fatalf("coalesced %d rows with the listing's exclusion, want 2", got)
+ }
+ if got := len(m.coalesceResourcesForPresentation(nil, listing.GetAll())); got != 1 {
+ t.Fatalf("without a listing read state the store generation decides: %d rows, want 1", got)
+ }
+
+ // The mock view lists through a store-less registry, which carries no
+ // operator decisions, so the resource store's adapter supplies them.
+ mockView := monitorUnifiedStateViewFromResources(resources, now)
+ withSplit := &Monitor{resourceStore: listing}
+ if got := len(withSplit.coalesceResourcesForPresentation(mockView.readState, mockView.resources)); got != 2 {
+ t.Fatalf("mock-style view coalesced %d rows, want the store's split to keep 2", got)
+ }
+ }
+
// A host agent linked to a Proxmox node merges into one read-state row that
// every PVE poll keeps online and fresh. Once the agent stops reporting, its
// retained filesystem summary must stop standing in for the node's disk (and