mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-03 18:43:38 +01:00
Keep ambiguous workload parents out of legacy fallback
A unique native node ID must also resolve its own installation/node tuple before it can supply a guest parent. Preserve unique consistent legacy fallback, but withhold power and host-memory attribution for duplicate tuples, including incomplete guest fields. Change-source: pulse-maintainer Contract-Neutral: Correct the existing ambiguity-safe parent requirement; no new public contract, collector identity, transport or permission change. The focused legacy-fallback controls and own-parent desktop/mobile browser proof cover this behavioural repair.
This commit is contained in:
@@ -26,7 +26,9 @@ fields take precedence over inferred legacy guest-ID prefixes, whose positive VM
|
||||
may fill missing fields but cannot contradict them. Supplied node snapshots
|
||||
overlay only the same native ID and tuple; a shared native ID cannot erase
|
||||
another tuple. Ambiguous tuples or native-ID aliases do not provide parent
|
||||
evidence. Row status and host-relative memory use the validated row parent in grouped and flat modes;
|
||||
evidence. Legacy fallback must also resolve the candidate's own tuple back to
|
||||
that same node; a unique native ID cannot restore an ambiguous tuple, even
|
||||
when the guest's instance or node fields are absent. Row status and host-relative memory use the validated row parent in grouped and flat modes;
|
||||
a group label is not authority to supply another row's parent. Unrelated
|
||||
platforms do not inherit Proxmox parent state from matching labels.
|
||||
|
||||
@@ -41,6 +43,9 @@ host-memory denominator unavailable, never zero or another node's capacity.
|
||||
Verification: `workloadTopology.attribution.test.ts` and
|
||||
`workloadTopology.scope.test.ts` cover collided scopes, parent ambiguity,
|
||||
source-field precedence, legacy hints and unrelated platforms.
|
||||
`workloadTopology.ambiguousParent.test.ts` discriminates complete and incomplete
|
||||
guest fields, both native aliases, VM/LXC types and both inventory orders;
|
||||
unique, consistent legacy fallbacks remain valid.
|
||||
`WorkloadsSurface.performance.contract.test.tsx` checks both supplied inventory
|
||||
orders and same-node snapshot overlays; `useWorkloadTableMetricHistory.test.tsx`
|
||||
checks the native-ID transport boundary. Parent-bound browser proof checks real
|
||||
|
||||
51
frontend-modern/browser-verification/d89ec2be99dc920f.json
Normal file
51
frontend-modern/browser-verification/d89ec2be99dc920f.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"version": 1,
|
||||
"result": "passed",
|
||||
"base_sha": "7e86161e06dfa04957d845331b221d7de29f49b0",
|
||||
"changed_paths": [
|
||||
"frontend-modern/src/components/Workloads/workloadTopology.ts"
|
||||
],
|
||||
"content_sha256": {
|
||||
"frontend-modern/src/components/Workloads/workloadTopology.ts": "f6535409aba9cf8d5761e348e9e63ef355c2b5c5edecf0c0866ea98226af34ce"
|
||||
},
|
||||
"routes": [
|
||||
"/proxmox?tab=workloads",
|
||||
"/proxmox?tab=workloads&agent=node%7Clab%7Ceast-pve1",
|
||||
"/proxmox?tab=workloads&agent=lab-east-pve1"
|
||||
],
|
||||
"states": [
|
||||
"Chromium desktop and WebKit phone; light/dark; synthetic legacy guest IDs through actual production useWorkloadsDerivedState and WorkloadsSurface/WorkloadPanel/GuestRow; not authenticated App or native backend proof.",
|
||||
"Same tuple lab-east/pve1, native-a/native-c, offline/online, 8/64 GiB; native-a-101/VMID101, complete/incomplete fields; parent map null and actual host-memory row N/A.",
|
||||
"Unique fallback restored after duplicate removal: 13% of 8 GiB/offline parent; independent node remains 3% of 32 GiB.",
|
||||
"Distinct tuple groups, flat rows, Node filter/reload, missing parent, ambiguous removable bookmark."
|
||||
],
|
||||
"interactions": [
|
||||
"distinct tuple groups; each row uses its own node power and host-memory denominator",
|
||||
"unique native IDs cannot restore a duplicate tuple: complete/missing instance/missing node/missing both fields; both inventory orders; actual row host memory is N/A",
|
||||
"unique consistent incomplete guest fallback restores 8 GiB denominator and offline parent state without fabricating zero capacity",
|
||||
"inventory order cannot change parent attribution or remount the canonical row",
|
||||
"flat rows retain the same validated parent",
|
||||
"real Node filter selects only its tuple and serialises an unambiguous bookmark",
|
||||
"scoped bookmark survives reload through production URL sync",
|
||||
"missing/duplicated parent withholds host share; exact-parent restoration restores it",
|
||||
"ambiguous legacy bookmark stays a visible removable filter, not a first-node selection or inventory outage; clearing restores both rows",
|
||||
"unambiguous existing node-name hint still selects its node",
|
||||
"All sixteen final captures visually inspected; no horizontal overflow or page/console errors; API stubs only GET; browser/server cleanup observed."
|
||||
],
|
||||
"viewports": [
|
||||
{
|
||||
"width": 1365,
|
||||
"height": 900
|
||||
},
|
||||
{
|
||||
"width": 390,
|
||||
"height": 844
|
||||
}
|
||||
],
|
||||
"verified_at": "2026-10-09T22:00:10.608Z",
|
||||
"playwright": "1.56.1",
|
||||
"browser_versions": {
|
||||
"desktop": "141.0.7390.37",
|
||||
"phone": "26.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { Node } from '@/types/api';
|
||||
import type { WorkloadGuest } from '@/types/workloads';
|
||||
import { getCanonicalWorkloadId } from '@/utils/workloads';
|
||||
import {
|
||||
buildGuestParentNodeMap,
|
||||
buildNodeByInstance,
|
||||
workloadNodeScopeId,
|
||||
} from '../workloadTopology';
|
||||
|
||||
const node = (id: string, total: number, status: string): Node =>
|
||||
({ id, instance: 'lab-east', name: 'pve1', memory: { total }, status }) as Node;
|
||||
const first = node('native-a', 8 * 1024 ** 3, 'offline');
|
||||
const second = node('native-c', 64 * 1024 ** 3, 'online');
|
||||
const guest = (fields: Partial<WorkloadGuest> = {}): WorkloadGuest =>
|
||||
({
|
||||
id: 'native-a-101',
|
||||
vmid: 101,
|
||||
instance: 'lab-east',
|
||||
node: 'pve1',
|
||||
type: 'qemu',
|
||||
workloadType: 'vm',
|
||||
platformScopes: ['proxmox-pve'],
|
||||
...fields,
|
||||
}) as WorkloadGuest;
|
||||
const shapes: Array<{ label: string; fields: Partial<WorkloadGuest> }> = [
|
||||
{ label: 'complete fields', fields: {} },
|
||||
{ label: 'missing node', fields: { node: '' } },
|
||||
{ label: 'missing instance', fields: { instance: '' } },
|
||||
{ label: 'missing both', fields: { instance: '', node: '' } },
|
||||
{ label: 'whitespace fields', fields: { instance: ' ', node: '\t' } },
|
||||
{ label: 'absent fields', fields: { instance: undefined, node: undefined } },
|
||||
];
|
||||
|
||||
describe('Workloads ambiguous parent fallback', () => {
|
||||
for (const order of ['forward', 'reversed'] as const) {
|
||||
const inventory = order === 'forward' ? [first, second] : [second, first];
|
||||
describe(`${order} inventory`, () => {
|
||||
it.each(
|
||||
shapes.flatMap(({ label, fields }) =>
|
||||
['native-a-101', 'native-c-101'].flatMap((id) =>
|
||||
['qemu', 'lxc'].map((type) => ({ label, fields, id, type })),
|
||||
),
|
||||
),
|
||||
)('cannot restore an ambiguous tuple: $label / $id / $type', ({ fields, id, type }) => {
|
||||
const map = buildNodeByInstance(inventory);
|
||||
expect(map[workloadNodeScopeId({ instance: 'lab-east', node: 'pve1' })]).toBeUndefined();
|
||||
// Both IDs are unique; neither supplies evidence that the tuple is unique.
|
||||
expect(map['native-a']).toBe(first);
|
||||
expect(map['native-c']).toBe(second);
|
||||
const row = guest({
|
||||
...fields,
|
||||
id,
|
||||
type,
|
||||
workloadType: type === 'lxc' ? 'system-container' : 'vm',
|
||||
});
|
||||
expect(buildGuestParentNodeMap([row], map)[getCanonicalWorkloadId(row)]).toBeUndefined();
|
||||
});
|
||||
|
||||
it.each(shapes)(
|
||||
'retains consistent fallback when the parent tuple is unique: $label',
|
||||
({ fields }) => {
|
||||
const other = { ...second, instance: 'elsewhere' };
|
||||
const unique = order === 'forward' ? [first, other] : [other, first];
|
||||
const row = guest(fields);
|
||||
expect(
|
||||
buildGuestParentNodeMap([row], buildNodeByInstance(unique))[
|
||||
getCanonicalWorkloadId(row)
|
||||
],
|
||||
).toBe(first);
|
||||
},
|
||||
);
|
||||
|
||||
it('does not revive a duplicate tuple after a third snapshot', () => {
|
||||
const third = node('native-d', 16 * 1024 ** 3, 'online');
|
||||
const row = guest({ instance: '', node: '', id: 'native-d-101' });
|
||||
expect(
|
||||
buildGuestParentNodeMap([row], buildNodeByInstance([...inventory, third]))[
|
||||
getCanonicalWorkloadId(row)
|
||||
],
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -219,6 +219,8 @@ export const buildGuestParentNodeMap = (
|
||||
|
||||
// Legacy IDs may supply an otherwise missing parent, but must not
|
||||
// contradict source-owned instance/node fields or resolve an ID collision.
|
||||
// A unique native ID is not evidence of a unique tuple: revalidate the
|
||||
// candidate's tuple too, including when guest fields are incomplete.
|
||||
if (guest.id) {
|
||||
const lastDash = guest.id.lastIndexOf('-');
|
||||
if (
|
||||
@@ -231,6 +233,8 @@ export const buildGuestParentNodeMap = (
|
||||
const candidate = nodeMap[nodeId];
|
||||
if (
|
||||
candidate &&
|
||||
nodeMap[workloadNodeScopeId({ instance: candidate.instance, node: candidate.name })] ===
|
||||
candidate &&
|
||||
(!guest.instance?.trim() || guest.instance.trim() === candidate.instance?.trim()) &&
|
||||
(!guest.node?.trim() || guest.node.trim() === candidate.name?.trim())
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user