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.

Keep backup activity on local calendar dates across clock changes

pulse-triage[bot]764b9767aa48
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 667fa30b34..c07d7c5925 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -20,6 +20,17 @@
## Purpose
+### Backup activity uses calendar-day chart slots
+
+The Proxmox backup activity producer supplies one slot per consecutive local
+date, including across daylight-saving and half-hour clock changes. The chart's
+labels and selectable day keys share that local-date basis; elapsed 24-hour
+steps cannot establish a calendar boundary. Count and volume retain identical
+slots, while future instants and unknown dates remain excluded. The registered
+activity presentation tests and source-bound desktop/narrow consuming browser
+journey cover date selection, metric changes and the matching backup details.
+No shared table, scrolling, query, policy or recovery operation changes.
+
### Backup-location choices preserve domain identity
The existing shared filter rail renders source-qualified backup-location
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 99d4c7b23a..681d923444 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -8468,6 +8468,7 @@
"allow_same_subsystem_tests": false,
"test_prefixes": [],
"exact_files": [
+ "frontend-modern/src/features/proxmox/__tests__/proxmoxBackupActivityPresentation.test.ts",
"frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.branchcov.test.ts",
"frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts",
"frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSourcePresentation.test.ts",
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 7990f8a9b3..9149d21db2 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -21,6 +21,24 @@
## Purpose
+### Backup activity ranges follow local calendar dates
+
+The existing 7/30/90/365-day Proxmox backup activity windows contain exactly
+that many consecutive local dates, ending today. Clock changes, including
+half-hour changes, cannot skip or duplicate a date, omit the first hours of
+the oldest date, or cut short a long final day. Count and volume use the same
+date buckets as the existing day filter. Future instants and undated evidence
+remain excluded; source classification, stored timestamps, aggregate posture,
+policy and backup/recovery operations are unchanged.
+
+`proxmoxBackupActivityPresentation.test.ts` exercises both clock-change
+directions in London, New York and Lord Howe, plus UTC and a fixed half-hour
+offset, across all four ranges and both metrics. Desktop/narrow consuming
+browser proof drives the real inventory/model/chart through date selection,
+volume, clearing and details. This is presentation correctness, not #3248's
+stale-posture cause or native recovery.
+
+
### Protection assessment batches share the consuming read's lifetime
Every protection-posture batch carries a cancellable transport signal owned by
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupActivityPresentation.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupActivityPresentation.test.ts
index ed9f5d3204..dc11a6eed2 100644
--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupActivityPresentation.test.ts
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupActivityPresentation.test.ts
@@ -542,3 +542,83 @@ describe('backup-date-evidence timeline', () => {
expect(timeline.points.reduce((total, point) => total + point.total, 0)).toBe(1);
});
});
+
+// These dates deliberately cross clock changes, unlike the stable February
+// fixtures above. Each test restores TZ before the next one and runs under the
+// repository's ordinary test command, not a separately maintained proof script.
+describe('backup activity uses local calendar days across clock changes', () => {
+ const cases = [
+ ['Europe/London', '2026-03-30T23:45:00'],
+ ['Europe/London', '2026-10-25T23:45:00'],
+ ['Europe/London', '2026-10-26T23:45:00'],
+ ['America/New_York', '2026-03-09T23:45:00'],
+ ['America/New_York', '2026-11-01T23:45:00'],
+ ['America/New_York', '2026-11-02T23:45:00'],
+ ['Australia/Lord_Howe', '2026-04-05T23:45:00'],
+ ['Australia/Lord_Howe', '2026-04-06T23:45:00'],
+ ['Australia/Lord_Howe', '2026-10-05T23:45:00'],
+ ['UTC', '2026-10-26T23:45:00'],
+ ['Asia/Kolkata', '2026-10-26T23:45:00'],
+ ] as const;
+
+ for (const [zone, localNow] of cases) {
+ it.each([...BACKUP_ACTIVITY_RANGE_DAYS])(
+ `${zone} at ${localNow} has exactly %s local days and includes both boundaries`,
+ (days) => {
+ vi.stubEnv('TZ', zone);
+ try {
+ const now = new Date(localNow);
+ // Use UTC only as an independent calendar-date oracle. The product
+ // must still classify actual instants in the operator's local zone.
+ const calendarDay = (offset: number) =>
+ new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate() + offset))
+ .toISOString()
+ .slice(0, 10);
+ const expectedKeys = Array.from({ length: days }, (_, i) => calendarDay(i - days + 1));
+ const dayMs = (offset: number, hours: number, minutes = 0) =>
+ new Date(
+ now.getFullYear(),
+ now.getMonth(),
+ now.getDate() + offset,
+ hours,
+ minutes,
+ ).getTime();
+ const items: ActivityItem[] = [
+ ...Array.from({ length: days }, (_, i) => ({
+ ts: dayMs(i - days + 1, 12),
+ kind: 'archive' as const,
+ bytes: 1024,
+ })),
+ // The first quarter hour of the oldest day must not disappear
+ // after a backward clock change (including a half-hour change).
+ { ts: dayMs(1 - days, 0, 15), kind: 'pbs', bytes: 2048 },
+ { ts: now.getTime(), kind: 'snapshot', bytes: 4096 },
+ { ts: dayMs(-days, 23, 59), kind: 'pbs', bytes: 8192 },
+ { ts: now.getTime() + 1, kind: 'snapshot', bytes: 8192 },
+ { kind: 'archive', bytes: 8192 },
+ ];
+ for (const mode of ['count', 'volume'] as const) {
+ const timeline = buildBackupActivityTimeline(days, items, itemMs, classify, {
+ now,
+ getValue: mode === 'volume' ? (item) => item.bytes ?? 0 : undefined,
+ });
+ expect(timeline.points.map((point) => point.key)).toEqual(expectedKeys);
+ expect(new Set(timeline.points.map((point) => point.key)).size).toBe(days);
+ expect(
+ timeline.points.every(
+ (point) => point.counts.archive === (mode === 'volume' ? 1024 : 1),
+ ),
+ ).toBe(true);
+ expect(timeline.points[0].counts.pbs).toBe(mode === 'volume' ? 2048 : 1);
+ expect(timeline.points.at(-1)!.counts.snapshot).toBe(mode === 'volume' ? 4096 : 1);
+ expect(timeline.points.reduce((total, point) => total + point.total, 0)).toBe(
+ mode === 'volume' ? days * 1024 + 2048 + 4096 : days + 2,
+ );
+ }
+ } finally {
+ vi.unstubAllEnvs();
+ }
+ },
+ );
+ }
+});
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts b/frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts
index 9a98ba8ed7..f2f4763c1d 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts
@@ -81,12 +81,6 @@ function emptyCounts(): Record<BackupActivitySegmentKind, number> {
return { archive: 0, pbs: 0, ok: 0, failed: 0, running: 0, snapshot: 0 };
}
-function startOfLocalDayMs(date: Date): number {
- const copy = new Date(date);
- copy.setHours(0, 0, 0, 0);
- return copy.getTime();
-}
-
export function buildBackupActivityTimeline<T>(
days: BackupActivityRangeDays,
items: readonly T[],
@@ -100,15 +94,16 @@ export function buildBackupActivityTimeline<T>(
): BackupActivityTimeline {
const now = options?.now ?? new Date();
const getValue = options?.getValue ?? (() => 1);
- const todayStart = startOfLocalDayMs(now);
- const windowStart = todayStart - (days - 1) * 24 * 60 * 60 * 1000;
const buckets = new Map<string, BackupActivityPoint>();
const orderedKeys: string[] = [];
for (let i = 0; i < days; i += 1) {
- const dayStart = windowStart + i * 24 * 60 * 60 * 1000;
- const key = recoveryDateKeyFromTimestamp(dayStart);
+ // Labels and day filters are local calendar dates, not 24-hour intervals.
+ // Construct each date independently so clock changes cannot skip a date,
+ // duplicate a bucket or exclude the oldest day's first hour.
+ const day = new Date(now.getFullYear(), now.getMonth(), now.getDate() - days + 1 + i);
+ const key = recoveryDateKeyFromTimestamp(day.getTime());
orderedKeys.push(key);
buckets.set(key, { key, total: 0, counts: emptyCounts() });
}
@@ -118,13 +113,13 @@ export function buildBackupActivityTimeline<T>(
if (ts === undefined || !Number.isFinite(ts)) continue;
// A future time on today's date is still not observed past activity.
if (ts > now.getTime()) continue;
- if (ts < windowStart) continue;
- if (ts >= todayStart + 24 * 60 * 60 * 1000) continue;
const kind = classify(item);
if (!kind) continue;
const value = getValue(item);
if (!Number.isFinite(value) || value <= 0) continue;
const key = recoveryDateKeyFromTimestamp(ts);
+ // Membership in the calendar window includes the entire first local day
+ // and today's observed hours even when a day lasts 23, 25 or 24.5 hours.
const bucket = buckets.get(key);
if (!bucket) continue;
bucket.counts[kind] += value;