Qualify stale readings and prevent false green on Infrastructure Map (#5693)

Map (/map) now respects explicit stale sourceStatus entries in
resolveMapHealth
so resources whose source stopped reporting never render a green Healthy
dot
when a backend health verdict is absent or still ok, while keeping
stronger
critical and attention verdicts ahead of staleness.

InfrastructureMapSurface now renders a filter-aware warning InlineNotice
(role="status") above the map stage whenever visible resources in the
active
view have stopped reporting or the whole estate's newest sample has aged
out.
The notice updates across By host and By role layouts, hides when search
or
filters narrow to current-only rows or zero matches, preserves existing
stale
sample age and legend cues, avoids leaking names under Hide names, and
clears
automatically on live recovery.

Includes unit tests for sourceStatus staleness, alert-verdict
precedence,
filtering, Hide names redaction, whole-estate expiry, and live recovery,
plus
paired desktop-light and phone-dark browser verification receipt
7876f11b1ec3eaf8.json.

Contract-Neutral: Uses existing Resource health/sourceStatus fields and
shared InlineNotice primitive on /map without changing API schemas,
classification contracts, access boundaries, or subsystem docs.

---
Fleet candidate `20261202T174600Z-web-product` from the `web-product`
lane. Reviewed tip `7200751a40a634dd70b47e4a6f3a13dd30d6ad44` on `main`.

[How Pulse handles
triage](https://github.com/rcourtman/Pulse/blob/main/docs/AI_TRANSPARENCY.md)
This commit is contained in:
pulse-triage[bot]
2026-12-02 19:43:55 +00:00
committed by GitHub
5 changed files with 407 additions and 4 deletions

View File

@@ -0,0 +1,41 @@
{
"version": 1,
"base_sha": "121f08ad7bb17107ffc88b8a6a23617569e61dba",
"verified_at": "2026-12-02T18:19:32Z",
"result": "passed",
"changed_paths": [
"frontend-modern/src/features/infrastructureMap/InfrastructureMapSurface.tsx",
"frontend-modern/src/features/infrastructureMap/infrastructureMapModel.ts"
],
"content_sha256": {
"frontend-modern/src/features/infrastructureMap/InfrastructureMapSurface.tsx": "8318ffcc3a6a7c0e35beca8cc2462c06b8023df5c661b1d3e2a7364c6abd0915",
"frontend-modern/src/features/infrastructureMap/infrastructureMapModel.ts": "cb0e088e866040a693a536efe5441d2f6290a3ead0d32773d3f0e74ba5cfe94d"
},
"routes": [
"/map"
],
"viewports": [
{
"width": 1280,
"height": 800
},
{
"width": 390,
"height": 844
}
],
"states": [
"Paired real-frontend production Vite builds of baseline 121f08ad7b and modified HEAD served with identical multi-host estate fixtures in pulse-worker-browser (Chromium), 0 console/page/HTTP errors and 0px horizontal overflow across all 12 captures",
"Desktop light (1280x800) partial stall: pve-stale with sourceStatus.proxmox=stale (no health.verdict) transitions from false green Online to muted Not reporting dot, and warning InlineNotice (role=status) qualifies 2 stale resources in view",
"Desktop light (1280x800) search filter (vm-web): warning InlineNotice hides cleanly when narrowed to current-only resources",
"Desktop light (1280x800) live WebSocket recovery: pushing fresh rawData clears the warning InlineNotice in place and restores pve-stale to Online",
"Desktop light (1280x800) whole-estate expired (15m): warning InlineNotice qualifies stale map readings alongside the preserved Last sample 15m ago pill",
"Phone dark (390x844, darkClass=true) partial stall and whole-estate expired: readable dark-mode amber contrast, clean wrapping, muted Not reporting dot on pve-stale, 0px horizontal overflow"
],
"interactions": [
"Loaded /map in desktop light (1280x800) and phone dark (390x844) across partial-stale and whole-stale estates",
"Typed vm-web into infrastructure-map-search to confirm filter-aware banner dismissal",
"Cleared search and pushed live WebSocket rawData recovery payload to confirm in-place banner clearance and Online recovery",
"Natively inspected all 12 paired before/after PNG captures via read_file"
]
}

View File

@@ -28,6 +28,7 @@ import { Button, ButtonLink } from '@/components/shared/Button';
import { EmptyState } from '@/components/shared/EmptyState';
import { FilterButtonGroup } from '@/components/shared/FilterButtonGroup';
import { FeaturePreviewTag } from '@/components/FeatureRelease';
import { InlineNotice } from '@/components/shared/InlineNotice';
import { PageHeader } from '@/components/shared/PageHeader';
import { StatusDot } from '@/components/shared/StatusDot';
import { showPressedTooltip } from '@/components/shared/Tooltip';
@@ -43,6 +44,7 @@ import {
sessionCanReadInfrastructureSettings,
} from '@/stores/sessionSettingsCapabilities';
import { MAP_DOC_URL } from '@/utils/docsLinks';
import type { Resource } from '@/types/resource';
import { formatBytes, formatSpeed } from '@/utils/format';
import type { StatusIndicatorVariant } from '@/utils/status';
import { showError, showSuccess } from '@/utils/toast';
@@ -77,6 +79,7 @@ import {
import {
anonymizeInfrastructureMapModel,
buildInfrastructureMapModel,
hasStaleMapResourceTelemetry,
isSampleTimestampExpired,
MAP_LINK_SATURATED_PERCENT,
MAP_LIVE_SAMPLE_MAX_AGE_MS,
@@ -96,11 +99,13 @@ import {
import {
buildServiceDiagram,
collectActiveTrafficTiles,
collectDiagramGroups,
countDiagramResources,
formatMapLatency,
formatMapLinkSpeed,
type DiagramNetwork,
type DiagramTile,
type ServiceDiagram,
type ServiceDiagramFilter,
} from './infrastructureMapServices';
@@ -200,6 +205,40 @@ const readInitialMapPrefs = (): {
}
};
const countVisibleStaleResources = (
diagram: ServiceDiagram | null,
layoutMode: MapLayoutMode,
byId: ReadonlyMap<string, Resource>,
): number => {
if (!diagram) return 0;
const seen = new Set<string>();
let stale = 0;
const visit = (tile: DiagramTile) => {
if (seen.has(tile.id)) return;
seen.add(tile.id);
if (tile.health === 'stale' || hasStaleMapResourceTelemetry(byId.get(tile.id))) {
stale += 1;
}
};
for (const tile of diagram.gateways) visit(tile);
if (layoutMode === 'hosts') {
for (const tile of diagram.access?.allTiles ?? []) visit(tile);
for (const frame of diagram.hostFrames) {
visit(frame.host);
for (const tile of frame.allTiles) visit(tile);
for (const pool of frame.pools) visit(pool);
}
for (const tile of diagram.sharedStorage?.allTiles ?? []) visit(tile);
for (const tile of diagram.backups?.allTiles ?? []) visit(tile);
for (const tile of diagram.checks?.allTiles ?? []) visit(tile);
return stale;
}
for (const group of collectDiagramGroups(diagram)) {
for (const tile of group.allTiles) visit(tile);
}
return stale;
};
const formatNetTelemetry = (rxBytes?: number, txBytes?: number): string => {
if (rxBytes === undefined && txBytes === undefined) return '';
const rx = rxBytes ?? 0;
@@ -923,6 +962,40 @@ export function InfrastructureMapSurface() {
if (!diagram) return false;
return matchedResourceCount() > 0 || diagram.gateways.length > 0;
});
const visibleStaleCount = createMemo(() =>
countVisibleStaleResources(activeDiagram(), layoutMode(), resourceById()),
);
const staleNotice = createMemo<{ headline: string; detail: string } | null>(() => {
if (liveModel().isEmpty || !hasVisibleMatches()) return null;
if (isEstateStale()) {
return {
headline: 'Map readings are stale.',
detail:
'No fresh telemetry has arrived recently. Shown status and metrics reflect the last received report, not current conditions.',
};
}
const count = visibleStaleCount();
if (count <= 0) return null;
const subject =
count === 1
? '1 resource in this view has stopped reporting.'
: `${count.toLocaleString()} resources in this view have stopped reporting.`;
return {
headline: 'Some map readings are stale.',
detail: `${subject} Shown status and metrics reflect the last received report, not current conditions.`,
};
});
createEffect(
on(
() => Boolean(staleNotice()),
() => {
if (typeof requestAnimationFrame !== 'undefined') {
requestAnimationFrame(measure);
}
},
{ defer: true },
),
);
const scene = createMemo(() => (hasVisibleMatches() ? (fitted()?.scene ?? null) : null));
const hits = createMemo(() => {
const out: MapHit[] = [];
@@ -1929,6 +2002,19 @@ export function InfrastructureMapSurface() {
</div>
</Show>
<Show when={staleNotice()}>
{(notice) => (
<InlineNotice
tone="warning"
role="status"
icon={<TriangleAlertIcon class="h-4 w-4" aria-hidden="true" />}
data-testid="infrastructure-map-stale-notice"
>
<strong>{notice().headline}</strong> {notice().detail}
</InlineNotice>
)}
</Show>
<div
ref={(element) => {
stageRef = element;

View File

@@ -2663,4 +2663,146 @@ describe('InfrastructureMapSurface persisted preferences, networks summary, keyb
clippedTileSpy.mockRestore();
}
});
it('shows a filter-aware stale-readings banner for partial stalls, sourceStatus staleness, and live recovery', () => {
const now = Date.now();
const freshTs = now - 10_000;
const makeSnapshot = (staleActive: boolean): Resource[] => [
resource({
id: 'pve-fresh',
type: 'agent',
name: 'pve-fresh',
platformType: 'proxmox-pve',
status: 'online',
lastSeen: freshTs,
health: { verdict: 'ok', reasons: [] },
sourceStatus: { proxmox: { status: 'online' } },
}),
resource({
id: 'vm-fresh',
type: 'vm',
name: 'vm-fresh',
platformType: 'proxmox-pve',
parentId: 'pve-fresh',
status: 'running',
lastSeen: freshTs,
health: { verdict: 'ok', reasons: [] },
sourceStatus: { proxmox: { status: 'online' } },
}),
resource({
id: 'pve-stale',
type: 'agent',
name: 'pve-stale',
platformType: 'proxmox-pve',
status: 'online',
lastSeen: freshTs,
sourceStatus: { proxmox: { status: staleActive ? 'stale' : 'online' } },
}),
resource({
id: 'vm-stale',
type: 'vm',
name: 'vm-stale',
platformType: 'proxmox-pve',
parentId: 'pve-stale',
status: 'running',
lastSeen: freshTs,
health: {
verdict: staleActive ? 'stale' : 'ok',
reasons: staleActive ? [{ code: 'telemetry_stale', detail: '12m' }] : [],
},
sourceStatus: { proxmox: { status: staleActive ? 'stale' : 'online' } },
}),
];
const [list, setList] = createSignal<Resource[]>(makeSnapshot(true));
resourcesMock.read = list;
render(() => <InfrastructureMapSurface />);
// Partial stall: pve-fresh is still fresh (liveSamplesExpired is false), yet
// both pve-stale (sourceStatus stale) and vm-stale (verdict stale) trigger the banner.
const notice = screen.getByTestId('infrastructure-map-stale-notice');
expect(notice).toHaveAttribute('role', 'status');
expect(notice).toHaveTextContent('Some map readings are stale.');
expect(notice).toHaveTextContent('2 resources in this view have stopped reporting.');
// Narrowing search to fresh-only resources hides the banner in By host layout.
const search = screen.getByTestId('infrastructure-map-search');
fireEvent.input(search, { target: { value: 'vm-fresh' } });
expect(screen.queryByTestId('infrastructure-map-stale-notice')).not.toBeInTheDocument();
// Switching to By role layout keeps the banner hidden for fresh-only matches,
// and shows a singular count when narrowed to one stale VM.
fireEvent.click(screen.getByRole('button', { name: /By role/i }));
expect(screen.queryByTestId('infrastructure-map-stale-notice')).not.toBeInTheDocument();
fireEvent.input(search, { target: { value: 'vm-stale' } });
expect(screen.getByTestId('infrastructure-map-stale-notice')).toHaveTextContent(
'1 resource in this view has stopped reporting.',
);
// Zero-match filter hides the stale notice.
fireEvent.input(search, { target: { value: 'does-not-exist' } });
expect(screen.queryByTestId('infrastructure-map-stale-notice')).not.toBeInTheDocument();
// Clearing search restores the full notice; Hide names keeps it without leaking hostnames.
fireEvent.input(search, { target: { value: '' } });
fireEvent.click(screen.getByRole('button', { name: /Hide names/i }));
const redactedNotice = screen.getByTestId('infrastructure-map-stale-notice');
expect(redactedNotice).toHaveTextContent('2 resources in this view have stopped reporting.');
expect(redactedNotice).not.toHaveTextContent('pve-stale');
// Live recovery clears the stale notice automatically.
setList(makeSnapshot(false));
expect(screen.queryByTestId('infrastructure-map-stale-notice')).not.toBeInTheDocument();
});
it('shows a whole-estate stale warning alongside the expired sample pill and clears on fresh telemetry', () => {
vi.useFakeTimers();
try {
const now = Date.parse('2026-12-02T17:50:00Z');
vi.setSystemTime(now);
const expiredTs = now - 15 * 60_000;
const makeSnapshot = (ts: number): Resource[] => [
resource({
id: 'pve-whole',
type: 'agent',
name: 'pve-whole',
platformType: 'proxmox-pve',
status: 'online',
health: { verdict: 'ok', reasons: [] },
lastSeen: ts,
}),
resource({
id: 'vm-whole',
type: 'vm',
name: 'vm-whole',
platformType: 'proxmox-pve',
parentId: 'pve-whole',
status: 'running',
health: { verdict: 'ok', reasons: [] },
lastSeen: ts,
}),
];
const [list, setList] = createSignal<Resource[]>(makeSnapshot(expiredTs));
resourcesMock.read = list;
render(() => <InfrastructureMapSurface />);
const notice = screen.getByTestId('infrastructure-map-stale-notice');
expect(notice).toHaveTextContent('Map readings are stale.');
expect(notice).toHaveTextContent('No fresh telemetry has arrived recently.');
expect(screen.getByTestId('infrastructure-map-stale-samples')).toHaveTextContent(
'Last sample 15m ago',
);
// Fresh telemetry clears both the warning banner and the expired sample pill.
setList(makeSnapshot(now - 5_000));
expect(screen.queryByTestId('infrastructure-map-stale-notice')).not.toBeInTheDocument();
expect(screen.queryByTestId('infrastructure-map-stale-samples')).not.toBeInTheDocument();
} finally {
vi.useRealTimers();
}
});
});

View File

@@ -7,6 +7,8 @@ import {
anonymizeInfrastructureMapModel,
buildInfrastructureMapModel,
computeMapLinkUtilizationPercent,
hasStaleMapResourceTelemetry,
hasStaleMapSourceStatus,
resolveMapHealth,
resolveMapTrafficTier,
type MapBlock,
@@ -1917,4 +1919,93 @@ describe('live network telemetry extraction', () => {
expect(splitHost.diskReadBytes).toBeUndefined();
expect(splitHost.diskWriteBytes).toBe(4_096);
});
it('prevents false green health when sourceStatus is stale while preserving stronger failure verdicts', () => {
const nowMs = Date.parse('2026-12-02T17:50:00Z');
const freshTs = nowMs - 10_000;
const freshIso = new Date(freshTs).toISOString();
const topLevelStale = resource({
id: 'pve-stale',
type: 'agent',
name: 'pve-stale',
platformType: 'proxmox-pve',
status: 'online',
lastSeen: freshTs,
sourceStatus: {
proxmox: { status: 'stale', lastSeen: freshIso },
agent: { status: 'online', lastSeen: freshIso },
},
network: { rxBytes: 20_000_000, txBytes: 1_000_000 },
});
const nestedStaleWithOkVerdict = resource({
id: 'vm-nested-stale',
type: 'vm',
name: 'vm-nested-stale',
platformType: 'proxmox-pve',
parentId: 'pve-stale',
status: 'running',
health: { verdict: 'ok', reasons: [] },
lastSeen: freshTs,
platformData: {
sourceStatus: { proxmox: { status: 'STALE' } },
},
});
const criticalWithStaleReason = resource({
id: 'vm-critical-stale',
type: 'vm',
name: 'vm-critical-stale',
platformType: 'proxmox-pve',
parentId: 'pve-stale',
status: 'running',
health: {
verdict: 'critical',
reasons: [
{ code: 'critical_alert', detail: 'cpu' },
{ code: 'telemetry_stale', detail: '15m' },
],
},
sourceStatus: { proxmox: { status: 'stale' } },
});
const offlineWithStaleSource = resource({
id: 'host-offline-stale',
type: 'agent',
name: 'host-offline-stale',
platformType: 'proxmox-pve',
status: 'offline',
sourceStatus: { proxmox: { status: 'stale' } },
});
const healthyCurrent = resource({
id: 'host-current',
type: 'agent',
name: 'host-current',
platformType: 'proxmox-pve',
status: 'online',
health: { verdict: 'ok', reasons: [] },
sourceStatus: { proxmox: { status: 'online' } },
});
expect(hasStaleMapSourceStatus(topLevelStale)).toBe(true);
expect(hasStaleMapSourceStatus(nestedStaleWithOkVerdict)).toBe(true);
expect(hasStaleMapSourceStatus(healthyCurrent)).toBe(false);
expect(resolveMapHealth(topLevelStale)).toBe('stale');
expect(resolveMapHealth(nestedStaleWithOkVerdict)).toBe('stale');
expect(resolveMapHealth(criticalWithStaleReason)).toBe('critical');
expect(resolveMapHealth(offlineWithStaleSource)).toBe('critical');
expect(resolveMapHealth(healthyCurrent)).toBe('ok');
expect(hasStaleMapResourceTelemetry(topLevelStale)).toBe(true);
expect(hasStaleMapResourceTelemetry(nestedStaleWithOkVerdict)).toBe(true);
expect(hasStaleMapResourceTelemetry(criticalWithStaleReason)).toBe(true);
expect(hasStaleMapResourceTelemetry(offlineWithStaleSource)).toBe(true);
expect(hasStaleMapResourceTelemetry(healthyCurrent)).toBe(false);
const model = buildInfrastructureMapModel([topLevelStale, nestedStaleWithOkVerdict], { nowMs });
const host = hostNamed(model.blocks, 'pve-stale');
expect(host.health).toBe('stale');
expect(host.netRxBytes).toBeUndefined();
expect(host.sections[0].items[0].health).toBe('stale');
});
});

View File

@@ -861,18 +861,61 @@ const certWarningOf = (resource: Resource): string | undefined => {
return undefined;
};
const asRecord = (value: unknown): Record<string, unknown> | undefined =>
value && typeof value === 'object' ? (value as Record<string, unknown>) : undefined;
const hasStaleSourceStatusEntry = (sourceStatus: Record<string, unknown> | undefined): boolean => {
if (!sourceStatus) return false;
for (const entry of Object.values(sourceStatus)) {
const status = asRecord(entry)?.status;
if (typeof status === 'string' && status.trim().toLowerCase() === 'stale') {
return true;
}
}
return false;
};
/**
* True when any source reported on the resource is explicitly marked stale,
* whether attached at top-level `sourceStatus` or nested under `platformData`.
*/
export const hasStaleMapSourceStatus = (resource: Resource): boolean =>
hasStaleSourceStatusEntry(asRecord(resource.sourceStatus)) ||
hasStaleSourceStatusEntry(asRecord(resource.platformData?.sourceStatus));
/**
* True when the resource carries stale telemetry evidence via its canonical
* health verdict or reasons, or via an explicit stale `sourceStatus` entry.
*/
export const hasStaleMapResourceTelemetry = (resource: Resource | undefined): boolean => {
if (!resource) return false;
if (resource.health?.verdict === 'stale') return true;
if (resource.health?.reasons?.some((reason) => reason.code === 'telemetry_stale')) return true;
return hasStaleMapSourceStatus(resource);
};
export const resolveMapHealth = (resource: Resource): MapHealth => {
const verdict = resource.health?.verdict;
if (verdict) return verdict;
if (verdict) {
if (verdict !== 'critical' && verdict !== 'attention' && hasStaleMapSourceStatus(resource)) {
return 'stale';
}
return verdict;
}
switch (resource.status) {
case 'online':
case 'running':
return 'ok';
case 'degraded':
case 'warning':
return 'attention';
case 'offline':
return 'critical';
default:
break;
}
if (hasStaleMapSourceStatus(resource)) return 'stale';
switch (resource.status) {
case 'online':
case 'running':
return 'ok';
case 'stopped':
case 'paused':
return 'off';