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.

feat: attach availability checks as facet on known resource row

rcourtman62c2b765d080
diff --git a/docs/release-control/v6/internal/SOURCE_OF_TRUTH.md b/docs/release-control/v6/internal/SOURCE_OF_TRUTH.md
index bc3b9bac17..2996ac5485 100644
--- a/docs/release-control/v6/internal/SOURCE_OF_TRUTH.md
+++ b/docs/release-control/v6/internal/SOURCE_OF_TRUTH.md
@@ -1,6 +1,6 @@
# Pulse v6 Source Of Truth
-Last updated: 2026-06-25
+Last updated: 2026-06-26
Status: ACTIVE
This file is the stable human governance layer for the active v6 release
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.json
index 4f0712afa1..d0af5af05b 100644
--- a/docs/release-control/v6/internal/status.json
+++ b/docs/release-control/v6/internal/status.json
@@ -1,6 +1,6 @@
{
"version": "6.0",
- "updated_at": "2026-06-25",
+ "updated_at": "2026-06-26",
"scope": {
"active_repos": [
"pulse",
@@ -7279,6 +7279,41 @@
"kind": "file"
}
]
+ },
+ {
+ "id": "availability-as-resource-facet",
+ "summary": "Agentless availability checks always mint a standalone network-endpoint resource and never attach to a known resource, so a check that monitors a Proxmox guest, Docker container, or Kubernetes workload appears as a disconnected duplicate on the Machines page instead of on the resource it actually monitors. The performance-and-scalability contract already requires agentless availability evidence to belong on the resource's bounded row path, but the ingest path has no cross-source attach: resolveLinkedResource only handles Proxmox<->agent links and findMatch is restricted to agent and physical_disk types, so SourceAvailability records always take the source-specific network-endpoint ID and the Availability facet never reaches an existing resource. The gap is the missing unambiguous attach (by explicit resource link or unique address/hostname correlation) plus platform-row surfacing of the attached facet.",
+ "owner": "project-owner",
+ "status": "planned",
+ "recorded_at": "2026-06-26",
+ "lane_ids": [
+ "L8",
+ "L13"
+ ],
+ "subsystem_ids": [
+ "frontend-primitives",
+ "monitoring",
+ "unified-resources"
+ ],
+ "proposed_resolution": "lane-expansion",
+ "coverage_impact": 7,
+ "evidence": [
+ {
+ "repo": "pulse",
+ "path": "docs/release-control/v6/internal/subsystems/performance-and-scalability.md",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "internal/monitoring/availability_poller.go",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "internal/unifiedresources/registry.go",
+ "kind": "file"
+ }
+ ]
}
],
"candidate_lanes": [
@@ -7330,20 +7365,40 @@
"patrol-intelligence",
"unified-resources"
]
+ },
+ {
+ "id": "availability-as-resource-facet",
+ "name": "Availability as Resource Facet",
+ "summary": "Promote availability-as-resource-facet into a governed lane expansion: extend unified-resource ingest so an availability check attaches as a facet on the known resource it monitors (explicit resource link first, unambiguous unique address/hostname correlation second, standalone network-endpoint fallback for genuinely unowned endpoints), keep the ingest on the existing unified-resource hot path with no per-row fetch, and surface the attached Availability facet on the platform resource row as a compact inline target/result readout with the protocol identity badge in the System column, per the performance-and-scalability bounded-row contract.",
+ "status": "planned",
+ "recorded_at": "2026-06-26",
+ "target_id": "v6-product-lane-expansion",
+ "current_lane_ids": [
+ "L8",
+ "L13"
+ ],
+ "coverage_gap_ids": [
+ "availability-as-resource-facet"
+ ],
+ "subsystem_ids": [
+ "frontend-primitives",
+ "monitoring",
+ "unified-resources"
+ ]
}
],
"work_claims": [
{
- "id": "opencode-coverage-gap-protection-posture-attention-queue",
- "agent_id": "opencode",
- "summary": "Patrol row-level actionable state labels: translate hidden investigation state into plain-language badges on collapsed Patrol finding rows",
+ "id": "codex-candidate-lane-availability-as-resource-facet",
+ "agent_id": "codex",
+ "summary": "Attach agentless availability checks as a facet on the known resource they monitor (explicit link + unique address correlation + network-endpoint fallback) and surface the facet on the platform resource row per the bounded-row contract.",
"target_id": "v6-product-lane-expansion",
- "claimed_at": "2026-06-25T22:24:34Z",
- "heartbeat_at": "2026-06-25T22:24:34Z",
- "expires_at": "2026-06-26T00:24:34Z",
+ "claimed_at": "2026-06-26T10:12:44Z",
+ "heartbeat_at": "2026-06-26T10:12:44Z",
+ "expires_at": "2026-06-26T14:12:44Z",
"work_item": {
- "kind": "coverage-gap",
- "id": "protection-posture-attention-queue"
+ "kind": "candidate-lane",
+ "id": "availability-as-resource-facet"
}
}
],
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index c85f5102b4..b44bf12a38 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -993,6 +993,12 @@ payload shape change when the portal presents compact client rows.
Mock mode must expose authored availability targets through those same
list, saved-test, and connections-ledger payloads so demo endpoints exercise
the canonical API contract rather than a frontend-only fixture.
+ Availability target payloads carry an optional `linkedResourceId` field
+ that, when set to a known resource id, requests the unified-resource
+ registry to attach the probe facet onto that resource instead of minting
+ a standalone `network-endpoint`. The field is advisory: the registry
+ still applies IP-correlation when no explicit link is provided, and a
+ link that would overwrite a different target's facet is ignored.
20. `frontend-modern/src/components/Settings/NodeModalAuthenticationSection.tsx` shared with `agent-lifecycle`: the node setup authentication section is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
21. `frontend-modern/src/components/Settings/NodeModalBasicInfoSection.tsx` shared with `agent-lifecycle`: the node setup basic-info section is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
22. `frontend-modern/src/components/Settings/nodeModalModel.ts` shared with `agent-lifecycle`: the pure node setup modal model is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 13dfa8bbb4..e0366e12f8 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -390,6 +390,11 @@ load from the config persistence boundary, schedule through
the default low-overhead check, while TCP and HTTP are canonical fallbacks for
devices or runtimes where ICMP is unavailable or the useful signal is a port or
web interface.
+Supplemental records carry the saved target's optional `LinkedResourceID`
+forward into `AvailabilityData` so the unified-resource registry can attach
+the probe facet onto the referenced resource. Monitoring does not perform the
+attach decision itself; it only forwards the link hint for the registry to
+resolve.
Availability target kind is monitoring-owned runtime metadata, not a frontend
guess. Saved targets carry the bounded `targetKind` values `machine`, `service`,
and `device`; monitoring must preserve that value in probe status, supplemental
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index 2968325cb2..499f503940 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -1433,12 +1433,14 @@ blocking `local-only`/`restricted` posture; non-blocking `sensitive` +
`local-first` and redaction-only metadata belongs in Data Handling, detail, and
AI/governance surfaces instead of spending default row visual budget.
Agentless availability evidence belongs on that same bounded row path.
-Infrastructure `network-endpoint` rows may replace otherwise empty host metric
-slots with one compact inline target/result readout, while the System column
-owns the protocol identity badge (`ICMP`, `TCP`, or `HTTP`). Recent check
-timing, latency history, and fuller failure context may stay in bounded
-tooltip or drawer detail, but the table must not duplicate the same probe
-protocol and result text across the resource identity cell and metric cells.
+Any resource row carrying an `AvailabilityData` facet—whether a standalone
+`network-endpoint` or a known guest that inherited the facet through explicit
+link or IP correlation—may replace otherwise empty host metric slots with one
+compact inline target/result readout, while the System column owns the
+protocol identity badge (`ICMP`, `TCP`, or `HTTP`). Recent check timing,
+latency history, and fuller failure context may stay in bounded tooltip or
+drawer detail, but the table must not duplicate the same probe protocol and
+result text across the resource identity cell and metric cells.
That text must derive from the existing resource payload and shared
presentation helper instead of adding a per-row fetch, extra hydration pass, or
unbounded badge stack.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 54cdc2eaaa..e2d4bbf929 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -1203,6 +1203,12 @@ recovery scope, or a storage/recovery-owned secret source.
disk cache, ZFS ARC sizing, storage-tier health, or capacity-planning
evidence; disk and pool truth stays on the canonical storage and
physical-disk resources.
+ `internal/unifiedresources/types.go` also carries `AvailabilityData`
+ (probe protocol, address, latency, failure state) as a resource facet for
+ agentless monitoring. Storage and recovery must not treat that availability
+ facet as protection status, backup health, or recovery readiness; an
+ unreachable probe on a storage resource is monitoring evidence, not a
+ backup or recovery failure.
## Forbidden Paths
@@ -1233,6 +1239,7 @@ recovery scope, or a storage/recovery-owned secret source.
18. Letting the recovery details panel lead with transport-shaped payloads; operator-facing details must summarize outcome, artifact, target, restore readiness, and readable metadata labels first, while raw JSON and provider-specific keys stay behind an explicitly technical disclosure.
19. Letting protection coverage navigation bypass the canonical recovery workspace and route-state owner; coverage actions may focus stale inventory, attention inventory, or all protected items, but they must not mutate local-only filter state or revive passive posture-counter cards as the navigation owner.
20. Letting storage or recovery surfaces invoke retired self-hosted trial acquisition; `POST /api/license/trial/start` and `/auth/trial-activate` must stay closed on the ordinary self-hosted router, and storage/recovery-adjacent billing or support handoffs must not treat trial activation as recovery identity, restore proof, or backup transport state.
+21. Treating an `AvailabilityData` facet on a storage resource as backup, protection, or recovery evidence; an agentless probe attached to a NAS, PBS, or datastore resource is monitoring reachability, not backup success, snapshot health, or restore readiness. Storage and recovery must read protection status from the canonical backup and storage resources, not from the availability probe facet.
## Completion Obligations
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 68d5fb9016..1475a567b8 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -1451,14 +1451,26 @@ Agentless availability checks are now canonical resources rather than
connection-only status rows. `SourceAvailability` emits `network-endpoint`
records with the saved target id, probe address, protocol, cadence, last check,
failure count, and threshold in `AvailabilityData`. Registry merge policy must
-preserve that payload and incident state without trying to fold endpoints into
-hosts, VMs, or storage resources solely because an address matches.
+preserve that payload and incident state. An availability record attaches as a
+facet onto a known resource when (a) the target carries an explicit
+`LinkedResourceID` referencing a resource already in the registry, or (b) the
+probe address unambiguously matches exactly one known resource by IP through
+`FindCandidates` with reason `ip` or `hostname+ip` (confidence at or above the
+merge threshold). Fuzzy hostname-only correlation (reason `hostname`, confidence
+below threshold) must not attach. When attached, the known resource inherits
+the `AvailabilityData` facet and `SourceAvailability` in its source list, and
+no standalone `network-endpoint` is minted. When no link resolves, the record
+falls back to a standalone `network-endpoint` as before. A second probe must
+not overwrite a facet already attached by a different target; the second probe
+stays standalone in that case.
Frontend resource adapters must preserve that same availability identity on
both REST and realtime paths: a thin `network-endpoint` update with
availability data is still `platformType=availability`, `sourceType=api`, and
must not regress to a generic platform badge in infrastructure rows or drawers.
Infrastructure row presentation must also consume that availability payload as
-operator evidence, not only as badge identity. `network-endpoint` rows should
+operator evidence, not only as badge identity. Any resource row carrying an
+`AvailabilityData` facet—whether a standalone `network-endpoint` or a known
+guest that inherited the facet through explicit link or IP correlation—must
surface one visible probe readout from either the top-level availability field
or the live-state `platformData.availability` mirror: the System column uses
the probe protocol as the compact identity badge (`ICMP`, `TCP`, or `HTTP`),
diff --git a/frontend-modern/src/api/availabilityTargets.ts b/frontend-modern/src/api/availabilityTargets.ts
index 42559931d7..127ba34a07 100644
--- a/frontend-modern/src/api/availabilityTargets.ts
+++ b/frontend-modern/src/api/availabilityTargets.ts
@@ -29,6 +29,7 @@ export interface AvailabilityTarget {
protocol: AvailabilityProbeProtocol;
port?: number;
path?: string;
+ linkedResourceId?: string;
enabled: boolean;
pollIntervalSeconds?: number;
timeoutMillis?: number;
diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
index f1ce598391..a9377ea2e8 100644
--- a/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
@@ -428,6 +428,16 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar
</span>
)}
</Show>
+ <Show when={availabilityProbe()}>
+ {(probe) => (
+ <span
+ class={`hidden shrink-0 whitespace-nowrap rounded px-1 text-[9px] font-medium lg:inline ${probe().toneClassName}`}
+ title={probe().detailLabel}
+ >
+ {probe().methodLabel}
+ </span>
+ )}
+ </Show>
<Show when={shouldShowResourceAlternateName(resource)}>
<span class="hidden min-w-0 max-w-[28%] shrink truncate text-[9px] text-muted lg:inline">
({resource.name})
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
index b319f455e1..2ae668bf8f 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
@@ -367,6 +367,38 @@ describe('UnifiedResourceTable performance contract', () => {
expect(getAllByText('7 ms')).toHaveLength(1);
});
+ it('renders availability badge for agent resources with ICMP protocol', async () => {
+ const resources = [
+ makeResource(1, {
+ type: 'agent',
+ platformType: 'agent',
+ sourceType: 'agent',
+ platformData: {
+ sources: ['agent'],
+ availability: {
+ protocol: 'icmp',
+ available: true,
+ latencyMillis: 5,
+ lastChecked: new Date().toISOString(),
+ },
+ },
+ }),
+ ];
+
+ const { container } = render(() => (
+ <UnifiedResourceTable
+ resources={resources}
+ expandedResourceId={null}
+ onExpandedResourceChange={vi.fn()}
+ groupingMode="flat"
+ />
+ ));
+
+ await waitFor(() => {
+ expect(container.textContent).toContain('ICMP');
+ });
+ });
+
it('adapts host columns from the measured table surface width instead of the window width', async () => {
const resources = [
makeResource(1, {
diff --git a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx
index 405d6460f7..96adcf26d8 100644
--- a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx
+++ b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx
@@ -32,6 +32,7 @@ interface AvailabilityForm {
protocol: AvailabilityProbeProtocol;
port: string;
path: string;
+ linkedResourceId: string;
enabled: boolean;
pollIntervalSeconds: string;
timeoutMillis: string;
@@ -62,6 +63,7 @@ const newAvailabilityForm = (
protocol: 'icmp',
port: '',
path: '',
+ linkedResourceId: '',
enabled: true,
pollIntervalSeconds: '60',
timeoutMillis: '2000',
@@ -76,6 +78,7 @@ const formFromTarget = (target: AvailabilityTarget): AvailabilityForm => ({
protocol: target.protocol ?? 'icmp',
port: target.port ? String(target.port) : '',
path: target.path ?? '',
+ linkedResourceId: target.linkedResourceId ?? '',
enabled: target.enabled ?? true,
pollIntervalSeconds: String(target.pollIntervalSeconds ?? 60),
timeoutMillis: String(target.timeoutMillis ?? 2000),
@@ -97,6 +100,7 @@ const payloadFromForm = (form: AvailabilityForm): AvailabilityTarget => {
protocol: form.protocol,
port: form.protocol === 'icmp' ? undefined : port,
path: form.protocol === 'http' ? form.path.trim() : undefined,
+ linkedResourceId: form.linkedResourceId.trim() || undefined,
enabled: form.enabled,
pollIntervalSeconds: parsePositiveInt(form.pollIntervalSeconds),
timeoutMillis: parsePositiveInt(form.timeoutMillis),
@@ -304,6 +308,19 @@ export const AvailabilityTargetSlot: Component<AvailabilityTargetSlotProps> = (p
: 'Use a full URL or a hostname. HTTP statuses below 500 count as reachable.'}
</span>
</label>
+ <label class={`${formField} sm:col-span-2`}>
+ <span class={formLabel}>Link to resource (optional)</span>
+ <input
+ class={formControl}
+ value={form().linkedResourceId}
+ onInput={(event) => updateForm({ linkedResourceId: event.currentTarget.value })}
+ placeholder="auto-detect by IP"
+ />
+ <span class={formHelpText}>
+ Link this check to a known resource so its status appears on that
+ resource's row. Leave empty to auto-detect by IP address.
+ </span>
+ </label>
<Show when={form().protocol !== 'icmp'}>
<label class={formField}>
<span class={formLabel}>Port</span>
diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.ts
index 1b0e6a2e77..64f7aab133 100644
--- a/frontend-modern/src/types/resource.ts
+++ b/frontend-modern/src/types/resource.ts
@@ -1343,6 +1343,7 @@ export interface ResourceVMwareMeta {
export interface ResourceAvailabilityMeta {
targetId?: string;
+ linkedResourceId?: string;
name?: string;
targetKind?: 'machine' | 'service' | 'device' | string;
address?: string;
diff --git a/frontend-modern/src/utils/__tests__/availabilityProbePresentation.test.ts b/frontend-modern/src/utils/__tests__/availabilityProbePresentation.test.ts
index 50c3511b7c..f8e853d01f 100644
--- a/frontend-modern/src/utils/__tests__/availabilityProbePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/availabilityProbePresentation.test.ts
@@ -133,4 +133,31 @@ describe('availabilityProbePresentation', () => {
expect(presentation?.detailLabel).toContain('HTTP /status - 503');
expect(presentation?.detailLabel).toContain('http probe returned 503 Service Unavailable');
});
+
+ it('returns a presentation for a non-endpoint resource carrying an availability facet', () => {
+ vi.spyOn(Date, 'now').mockReturnValue(new Date('2026-05-06T13:00:20Z').getTime());
+
+ const presentation = getAvailabilityProbePresentation(
+ makeAvailabilityResource({
+ id: 'vm:100',
+ type: 'vm',
+ platformType: 'proxmox',
+ platformId: 'proxmox-ve',
+ sourceType: 'agent',
+ status: 'online',
+ availability: {
+ protocol: 'icmp',
+ available: true,
+ latencyMillis: 3,
+ lastChecked: '2026-05-06T13:00:18Z',
+ },
+ platformData: {},
+ }),
+ );
+
+ expect(presentation).not.toBeNull();
+ expect(presentation?.methodLabel).toBe('ICMP');
+ expect(presentation?.resultLabel).toBe('3 ms');
+ expect(presentation?.toneClassName).toContain('emerald');
+ });
});
diff --git a/frontend-modern/src/utils/availabilityProbePresentation.ts b/frontend-modern/src/utils/availabilityProbePresentation.ts
index 94455dc7e9..429f62fa5c 100644
--- a/frontend-modern/src/utils/availabilityProbePresentation.ts
+++ b/frontend-modern/src/utils/availabilityProbePresentation.ts
@@ -121,10 +121,7 @@ export const getAvailabilityProbePresentation = (
| ResourceAvailabilityMeta
| undefined;
const availability = resource.availability ?? platformAvailability;
- if (
- !availability ||
- (resource.type !== 'network-endpoint' && resource.platformType !== 'availability')
- ) {
+ if (!availability) {
return null;
}
diff --git a/internal/api/availability_handlers_test.go b/internal/api/availability_handlers_test.go
index 30074e76a1..b232b6a253 100644
--- a/internal/api/availability_handlers_test.go
+++ b/internal/api/availability_handlers_test.go
@@ -229,3 +229,64 @@ func availabilityRequestBody(t *testing.T, target config.AvailabilityTarget) *by
}
return bytes.NewReader(payload)
}
+
+func TestAvailabilityTargetLinkedResourceIDRoundTrip(t *testing.T) {
+ persistence := config.NewConfigPersistence(t.TempDir())
+ handler := NewAvailabilityHandlers(
+ func(_ context.Context) *config.ConfigPersistence { return persistence },
+ nil,
+ )
+
+ createBody := availabilityRequestBody(t, config.AvailabilityTarget{
+ Name: "Energy monitor",
+ Address: "device.local",
+ Protocol: config.AvailabilityProbeICMP,
+ Enabled: true,
+ PollIntervalSecs: 30,
+ TimeoutMillis: 1000,
+ FailureThreshold: 2,
+ LinkedResourceID: "agent-test-123",
+ })
+ createReq := httptest.NewRequest(http.MethodPost, "/api/availability-targets", createBody)
+ createRec := httptest.NewRecorder()
+ handler.HandleAdd(createRec, createReq)
+ if createRec.Code != http.StatusCreated {
+ t.Fatalf("HandleAdd status = %d, body=%s", createRec.Code, createRec.Body.String())
+ }
+
+ var created config.AvailabilityTarget
+ if err := json.NewDecoder(createRec.Body).Decode(&created); err != nil {
+ t.Fatalf("decode created target: %v", err)
+ }
+ if created.LinkedResourceID != "agent-test-123" {
+ t.Fatalf("LinkedResourceID = %q, want %q", created.LinkedResourceID, "agent-test-123")
+ }
+
+ deleteReq := httptest.NewRequest(http.MethodDelete, "/api/availability-targets/"+created.ID, nil)
+ deleteRec := httptest.NewRecorder()
+ handler.HandleDelete(deleteRec, deleteReq)
+
+ createBodyNoID := availabilityRequestBody(t, config.AvailabilityTarget{
+ Name: "Energy monitor 2",
+ Address: "device2.local",
+ Protocol: config.AvailabilityProbeICMP,
+ Enabled: true,
+ PollIntervalSecs: 30,
+ TimeoutMillis: 1000,
+ FailureThreshold: 2,
+ })
+ createReqNoID := httptest.NewRequest(http.MethodPost, "/api/availability-targets", createBodyNoID)
+ createRecNoID := httptest.NewRecorder()
+ handler.HandleAdd(createRecNoID, createReqNoID)
+ if createRecNoID.Code != http.StatusCreated {
+ t.Fatalf("HandleAdd status = %d, body=%s", createRecNoID.Code, createRecNoID.Body.String())
+ }
+
+ var createdNoID config.AvailabilityTarget
+ if err := json.NewDecoder(createRecNoID.Body).Decode(&createdNoID); err != nil {
+ t.Fatalf("decode created target: %v", err)
+ }
+ if createdNoID.LinkedResourceID != "" {
+ t.Fatalf("LinkedResourceID = %q, want empty string", createdNoID.LinkedResourceID)
+ }
+}
diff --git a/internal/config/availability.go b/internal/config/availability.go
index 03563c3477..fa03e86f88 100644
--- a/internal/config/availability.go
+++ b/internal/config/availability.go
@@ -45,6 +45,7 @@ type AvailabilityTarget struct {
PollIntervalSecs int `json:"pollIntervalSeconds,omitempty"`
TimeoutMillis int `json:"timeoutMillis,omitempty"`
FailureThreshold int `json:"failureThreshold,omitempty"`
+ LinkedResourceID string `json:"linkedResourceId,omitempty"`
}
// NewAvailabilityTarget returns a new target with generated ID and defaults.
@@ -207,6 +208,7 @@ func NormalizeAvailabilityTarget(target AvailabilityTarget) AvailabilityTarget {
target.Address = normalizeAvailabilityAddress(target.Address)
}
target.Path = strings.TrimSpace(target.Path)
+ target.LinkedResourceID = strings.TrimSpace(target.LinkedResourceID)
target.ApplyDefaults()
return target
}
diff --git a/internal/monitoring/availability_poller.go b/internal/monitoring/availability_poller.go
index 5dff893597..fd5220a93f 100644
--- a/internal/monitoring/availability_poller.go
+++ b/internal/monitoring/availability_poller.go
@@ -452,6 +452,7 @@ func availabilityResourceFromTarget(target config.AvailabilityTarget, status Ava
resourceStatus := availabilityResourceStatus(target, status)
data := &unifiedresources.AvailabilityData{
TargetID: target.ID,
+ LinkedResourceID: strings.TrimSpace(target.LinkedResourceID),
Name: target.DisplayName(),
TargetKind: string(target.TargetKind),
Address: target.Address,
diff --git a/internal/unifiedresources/availability_link_test.go b/internal/unifiedresources/availability_link_test.go
new file mode 100644
index 0000000000..aa418ca8f7
--- /dev/null
+++ b/internal/unifiedresources/availability_link_test.go
@@ -0,0 +1,163 @@
+package unifiedresources
+
+import (
+ "testing"
+ "time"
+)
+
+// ingestAgentFixture ingests a single agent resource and returns its
+// canonical registry id, so availability link tests can reference the exact
+// resource a probe should attach to.
+func ingestAgentFixture(t *testing.T, rr *ResourceRegistry, sourceID, machineID string, ips ...string) string {
+ t.Helper()
+ now := time.Now().UTC()
+ rr.IngestRecords(SourceAgent, []IngestRecord{{
+ SourceID: sourceID,
+ Resource: Resource{
+ Type: ResourceTypeAgent,
+ Name: sourceID,
+ Status: StatusOnline,
+ LastSeen: now,
+ },
+ Identity: ResourceIdentity{MachineID: machineID, IPAddresses: ips},
+ }})
+ agents := rr.ListByType(ResourceTypeAgent)
+ if len(agents) != 1 {
+ t.Fatalf("expected 1 agent ingested, got %d", len(agents))
+ }
+ return agents[0].ID
+}
+
+func availabilityProbeRecord(targetID, address string, facet *AvailabilityData) IngestRecord {
+ now := time.Now().UTC()
+ if facet == nil {
+ facet = &AvailabilityData{TargetID: targetID, Address: address, Protocol: "icmp", Enabled: true, Available: true}
+ }
+ facet.TargetID = targetID
+ return IngestRecord{
+ SourceID: targetID,
+ Resource: Resource{
+ Type: ResourceTypeNetworkEndpoint,
+ Name: targetID,
+ Status: StatusOnline,
+ LastSeen: now,
+ Sources: []DataSource{SourceAvailability},
+ Availability: facet,
+ },
+ Identity: ResourceIdentity{IPAddresses: []string{address}},
+ }
+}
+
+func TestAvailabilityExplicitLinkAttachesFacetToKnownResource(t *testing.T) {
+ rr := NewRegistry(nil)
+ hostID := ingestAgentFixture(t, rr, "host-1", "machine-1")
+
+ rr.IngestRecords(SourceAvailability, []IngestRecord{
+ availabilityProbeRecord("probe-1", "192.0.2.10", &AvailabilityData{
+ LinkedResourceID: hostID,
+ Address: "192.0.2.10",
+ Protocol: "icmp",
+ Enabled: true,
+ Available: true,
+ }),
+ })
+
+ if got := rr.ListByType(ResourceTypeNetworkEndpoint); len(got) != 0 {
+ t.Fatalf("expected 0 standalone network endpoints, got %d", len(got))
+ }
+ host, ok := rr.Get(hostID)
+ if !ok || host == nil {
+ t.Fatalf("host %q missing after ingest", hostID)
+ }
+ if host.Availability == nil || host.Availability.TargetID != "probe-1" {
+ t.Fatalf("expected availability facet probe-1 on host, got %+v", host.Availability)
+ }
+ if !hasDataSource(host.Sources, SourceAvailability) {
+ t.Fatalf("expected host sources to include availability, got %v", host.Sources)
+ }
+}
+
+func TestAvailabilityUnlinkedUnmatchedMintsNetworkEndpoint(t *testing.T) {
+ rr := NewRegistry(nil)
+
+ rr.IngestRecords(SourceAvailability, []IngestRecord{
+ availabilityProbeRecord("probe-orphan", "198.51.100.7", nil),
+ })
+
+ if got := rr.ListByType(ResourceTypeNetworkEndpoint); len(got) != 1 {
+ t.Fatalf("expected 1 standalone network endpoint, got %d", len(got))
+ }
+}
+
+func TestAvailabilityExactIPMatchAttachesToKnownResource(t *testing.T) {
+ rr := NewRegistry(nil)
+ hostID := ingestAgentFixture(t, rr, "host-1", "machine-1", "203.0.113.9")
+
+ rr.IngestRecords(SourceAvailability, []IngestRecord{
+ availabilityProbeRecord("probe-ip", "203.0.113.9", &AvailabilityData{
+ Address: "203.0.113.9",
+ Protocol: "tcp",
+ Enabled: true,
+ Available: true,
+ }),
+ })
+
+ if got := rr.ListByType(ResourceTypeNetworkEndpoint); len(got) != 0 {
+ t.Fatalf("expected probe to attach (0 endpoints), got %d", len(got))
+ }
+ host, ok := rr.Get(hostID)
+ if !ok || host == nil || host.Availability == nil || host.Availability.TargetID != "probe-ip" {
+ t.Fatalf("expected availability facet probe-ip on host, got %+v", host)
+ }
+}
+
+func TestAvailabilityAmbiguousIPDoesNotAttach(t *testing.T) {
+ rr := NewRegistry(nil)
+ now := time.Now().UTC()
+ rr.IngestRecords(SourceAgent, []IngestRecord{
+ {SourceID: "h1", Resource: Resource{Type: ResourceTypeAgent, Name: "h1", Status: StatusOnline, LastSeen: now}, Identity: ResourceIdentity{MachineID: "m1", IPAddresses: []string{"203.0.113.9"}}},
+ {SourceID: "h2", Resource: Resource{Type: ResourceTypeAgent, Name: "h2", Status: StatusOnline, LastSeen: now}, Identity: ResourceIdentity{MachineID: "m2", IPAddresses: []string{"203.0.113.9"}}},
+ })
+
+ rr.IngestRecords(SourceAvailability, []IngestRecord{
+ availabilityProbeRecord("probe-amb", "203.0.113.9", nil),
+ })
+
+ if got := rr.ListByType(ResourceTypeNetworkEndpoint); len(got) != 1 {
+ t.Fatalf("expected 1 standalone endpoint (ambiguous IP, no attach), got %d", len(got))
+ }
+}
+
+func TestAvailabilityDoesNotOverwriteDifferentAttachedTarget(t *testing.T) {
+ rr := NewRegistry(nil)
+ hostID := ingestAgentFixture(t, rr, "host-1", "machine-1")
+
+ rr.IngestRecords(SourceAvailability, []IngestRecord{
+ availabilityProbeRecord("probe-a", "203.0.113.10", &AvailabilityData{
+ LinkedResourceID: hostID,
+ Address: "203.0.113.10",
+ Protocol: "icmp",
+ Enabled: true,
+ Available: true,
+ }),
+ })
+ // A second probe explicitly linked to the same host must not overwrite the
+ // first target's facet; it stays a standalone network-endpoint instead.
+ rr.IngestRecords(SourceAvailability, []IngestRecord{
+ availabilityProbeRecord("probe-b", "203.0.113.11", &AvailabilityData{
+ LinkedResourceID: hostID,
+ Address: "203.0.113.11",
+ Protocol: "tcp",
+ Enabled: true,
+ Available: true,
+ }),
+ })
+
+ host, ok := rr.Get(hostID)
+ if !ok || host == nil || host.Availability == nil || host.Availability.TargetID != "probe-a" {
+ t.Fatalf("expected first probe probe-a to remain attached, got %+v", host)
+ }
+ if got := rr.ListByType(ResourceTypeNetworkEndpoint); len(got) != 1 {
+ t.Fatalf("expected second probe to stay standalone (1 endpoint), got %d", len(got))
+ }
+}
diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.go
index 4045a2a17a..b31217eece 100644
--- a/internal/unifiedresources/code_standards_test.go
+++ b/internal/unifiedresources/code_standards_test.go
@@ -366,16 +366,19 @@ func TestAgentlessAvailabilityTargetKindStaysCanonical(t *testing.T) {
"AvailabilityTargetDevice AvailabilityTargetKind = \"device\"",
"TargetKind AvailabilityTargetKind `json:\"targetKind,omitempty\"`",
"target.TargetKind = AvailabilityTargetKind(strings.ToLower(strings.TrimSpace(string(target.TargetKind))))",
+ "LinkedResourceID string `json:\"linkedResourceId,omitempty\"`",
},
filepath.Join("..", "monitoring", "availability_poller.go"): {
"TargetKind string `json:\"targetKind,omitempty\"`",
"TargetKind: string(target.TargetKind),",
"TargetKind: string(target.TargetKind),",
"tags = append(tags, string(target.TargetKind))",
+ "LinkedResourceID: strings.TrimSpace(target.LinkedResourceID),",
},
"types.go": {
"Availability *AvailabilityData `json:\"availability,omitempty\"`",
"TargetKind string `json:\"targetKind,omitempty\"`",
+ "LinkedResourceID string `json:\"linkedResourceId,omitempty\"`",
},
filepath.Join("..", "..", "frontend-modern", "src", "api", "availabilityTargets.ts"): {
"export type AvailabilityTargetKind = 'machine' | 'service' | 'device';",
diff --git a/internal/unifiedresources/registry.go b/internal/unifiedresources/registry.go
index 9e9d1abb75..80186a238e 100644
--- a/internal/unifiedresources/registry.go
+++ b/internal/unifiedresources/registry.go
@@ -2249,6 +2249,23 @@ func (rr *ResourceRegistry) ingest(source DataSource, sourceID string, resource
}
}
+ // Agentless availability probes attach as a facet on the known resource
+ // they monitor instead of minting a parallel network-endpoint. An explicit
+ // linkedResourceId wins; otherwise an exact, unique IP match may attach.
+ // Lossy hostname-only correlation is intentionally avoided to prevent
+ // ambiguous one-sided merges, and the link is refused when it would
+ // overwrite a different target's already-attached facet or fold one probe
+ // into another.
+ if source == SourceAvailability && resource.Type == ResourceTypeNetworkEndpoint {
+ if linked := rr.resolveAvailabilityLink(resource); linked != "" {
+ if existing := rr.resources[linked]; existing != nil {
+ rr.mergeInto(existing, resource, source)
+ rr.bySource[source][sourceID] = existing.ID
+ return existing.ID
+ }
+ }
+ }
+
candidateID := rr.sourceSpecificID(resource.Type, source, sourceID)
if resource.Type == ResourceTypeAgent || resource.Type == ResourceTypePhysicalDisk {
@@ -2383,6 +2400,78 @@ func (rr *ResourceRegistry) resolveLinkedResource(source DataSource, sourceID st
return ""
}
+// resolveAvailabilityLink attaches an agentless availability probe to the
+// known resource it monitors, instead of minting a parallel
+// network-endpoint. An explicit linkedResourceId wins unambiguously;
+// otherwise the probe address may attach on an exact, unique IP overlap.
+// Lossy hostname-only correlation is intentionally avoided, and the link is
+// refused when it would overwrite a different target's already-attached
+// availability facet or fold one probe into another.
+func (rr *ResourceRegistry) resolveAvailabilityLink(resource Resource) string {
+ if resource.Availability == nil {
+ return ""
+ }
+
+ if linkedID := strings.TrimSpace(resource.Availability.LinkedResourceID); linkedID != "" {
+ existing := rr.resources[linkedID]
+ if existing != nil && !isAvailabilityOwnedResource(*existing) && availabilityFacetCompatible(existing, resource) {
+ return linkedID
+ }
+ }
+
+ matchID := ""
+ for _, candidate := range rr.matcher.FindCandidates(resource.Identity) {
+ if candidate.Reason != "ip" && candidate.Reason != "hostname+ip" {
+ continue
+ }
+ existing := rr.resources[candidate.ID]
+ if existing == nil || isAvailabilityOwnedResource(*existing) {
+ continue
+ }
+ if !availabilityFacetCompatible(existing, resource) {
+ continue
+ }
+ if matchID != "" && matchID != candidate.ID {
+ return ""
+ }
+ matchID = candidate.ID
+ }
+ return matchID
+}
+
+// isAvailabilityOwnedResource reports whether a resource is itself an
+// agentless availability endpoint (a standalone network-endpoint, or any
+// resource sourced only from availability), which probes must never fold into.
+func isAvailabilityOwnedResource(r Resource) bool {
+ if r.Type == ResourceTypeNetworkEndpoint {
+ return true
+ }
+ if len(r.Sources) == 0 {
+ return false
+ }
+ for _, s := range r.Sources {
+ if s != SourceAvailability {
+ return false
+ }
+ }
+ return true
+}
+
+// availabilityFacetCompatible reports whether an existing resource can accept
+// the incoming availability facet without silently overwriting a different
+// target's already-attached probe.
+func availabilityFacetCompatible(existing *Resource, incoming Resource) bool {
+ if existing == nil || existing.Availability == nil {
+ return true
+ }
+ current := strings.TrimSpace(existing.Availability.TargetID)
+ if current == "" {
+ return true
+ }
+ incomingID := strings.TrimSpace(incoming.Availability.TargetID)
+ return incomingID == "" || incomingID == current
+}
+
func (rr *ResourceRegistry) findCorroboratedOneSidedProxmoxLink(
hostAgentID string,
identity ResourceIdentity,
diff --git a/internal/unifiedresources/registry_test.go b/internal/unifiedresources/registry_test.go
index 75c3319c12..4350b0e6e5 100644
--- a/internal/unifiedresources/registry_test.go
+++ b/internal/unifiedresources/registry_test.go
@@ -4601,3 +4601,35 @@ func TestIngestStorageRoutesPBSPollerEntriesToPBSSource(t *testing.T) {
t.Fatalf("PVE-reported pbs-typed storage Sources = %v, want [%s]", pveStorage.Sources, SourceProxmox)
}
}
+
+func TestRegistryAvailabilityLinkAttachesFacetToKnownResource(t *testing.T) {
+ rr := NewRegistry(nil)
+ now := time.Now().UTC()
+ rr.IngestRecords(SourceAgent, []IngestRecord{{
+ SourceID: "host-1",
+ Resource: Resource{Type: ResourceTypeAgent, Name: "host-1", Status: StatusOnline, LastSeen: now},
+ Identity: ResourceIdentity{MachineID: "machine-1"},
+ }})
+ hostID := rr.ListByType(ResourceTypeAgent)[0].ID
+
+ rr.IngestRecords(SourceAvailability, []IngestRecord{{
+ SourceID: "probe-1",
+ Resource: Resource{
+ Type: ResourceTypeNetworkEndpoint, Name: "probe-1", Status: StatusOnline, LastSeen: now,
+ Sources: []DataSource{SourceAvailability},
+ Availability: &AvailabilityData{
+ TargetID: "probe-1", LinkedResourceID: hostID, Address: "192.0.2.10",
+ Protocol: "icmp", Enabled: true, Available: true,
+ },
+ },
+ Identity: ResourceIdentity{IPAddresses: []string{"192.0.2.10"}},
+ }})
+
+ if got := rr.ListByType(ResourceTypeNetworkEndpoint); len(got) != 0 {
+ t.Fatalf("expected 0 standalone network endpoints, got %d", len(got))
+ }
+ host, ok := rr.Get(hostID)
+ if !ok || host.Availability == nil || host.Availability.TargetID != "probe-1" {
+ t.Fatalf("expected availability facet probe-1 on host, got %+v", host.Availability)
+ }
+}
diff --git a/internal/unifiedresources/types.go b/internal/unifiedresources/types.go
index 8a8944d843..35d4d06436 100644
--- a/internal/unifiedresources/types.go
+++ b/internal/unifiedresources/types.go
@@ -1519,6 +1519,7 @@ type TrueNASShare struct {
// AvailabilityData contains agentless endpoint probe metadata for a resource.
type AvailabilityData struct {
TargetID string `json:"targetId,omitempty"`
+ LinkedResourceID string `json:"linkedResourceId,omitempty"`
Name string `json:"name,omitempty"`
TargetKind string `json:"targetKind,omitempty"`
Address string `json:"address,omitempty"`
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index 93620a3147..d65f58d2ed 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -2916,7 +2916,7 @@ class SubsystemLookupTest(unittest.TestCase):
{
"heading": "## Shared Boundaries",
"path": "internal/api/access_control_handlers.go",
- "line": 1074,
+ "line": 1080,
"heading_line": 136,
}
],