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.

Make notification delivery failures actionable

pulse-triage[bot]0f2d7ae05564
diff --git a/docs/API.md b/docs/API.md
index cc52102d65..f887402612 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -595,6 +595,12 @@ Common reporting error codes:
- `no_resources`, `too_many_resources`, `body_too_large`, `invalid_body`
### Queue and Dead-Letter Tools
+- `GET /api/notifications/delivery-log?limit=200` (admin, `settings:read`)
+ - Returns recent per-attempt delivery evidence with destination identifiers,
+ alert identifiers, outcomes, timestamps, failure classes, and redacted error
+ text. Completed attempts are retained for 7 days; dead-letter attempts are
+ retained for 30 days, so the response reports both windows explicitly.
+ - `limit` defaults to 50 and is capped at 200.
- `GET /api/notifications/queue/stats` (admin)
- Returns counts for all rows still retained by the queue. Status counts have
different retention windows and are not a delivery rate or lifetime total.
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index 1958090041..933ae3526f 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -151,6 +151,10 @@ first step before platform-local cleanup.
- Open **Alerts → Notifications** first. Pulse shows a delivery warning when
failed or dead-lettered notifications remain in the persistent queue; a
missing queue-health read is shown as unavailable rather than healthy.
+- **Recent delivery activity** appears directly below that warning. It names
+ the destination and affected alert, shows an absolute timestamp for timeline
+ correlation, and includes safely redacted provider errors. Completed attempts
+ remain for 7 days and dead-letter attempts remain for 30 days.
- After correcting the destination, use **Retry retained deliveries**. Use
**Dismiss retained failures** only when those deliveries should not be sent.
Both actions preserve delivery history; do not delete `notification_queue.db`
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index f7946b1817..991935724a 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -6897,6 +6897,11 @@ enabled gate, and they do not enroll or select an agent, open or alter a
command session, change fleet policy or update state, or add any
agent-routed capability. Agent lifecycle obligations over `internal/api/`
are unchanged by this surface.
+The delivery-log read may span the notifications-owned 30-day dead-letter
+window while naming the shorter seven-day completed-attempt retention in its
+metadata. That wider evidence window and the Alerts navigation into it do not
+inspect removed-host clients, agent enrollment, or agent transport state and
+must not be presented as agent/server lifecycle diagnosis.
### Least-privilege agent profile
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index b74df341b1..7fd1cd0f80 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -2306,8 +2306,15 @@ notifications-owned delivery log (`AlertDeliveryLogCard` fed by
newest-first record of real alert delivery attempts with plain-language
outcome labels, destination names resolved from the loaded webhook configs,
failure classes, and secret-redacted error text. The card names its retention
-window and says that test sends skip the queue, and an unreadable log renders
-as unavailable rather than empty. The same card interleaves alert-owned
+windows separately: completed attempts remain for seven days while
+dead-letter attempts can remain for 30 days. It requests the bounded maximum
+of 200 rows, displays an absolute semantic timestamp for timeline correlation
+with relative time as secondary hover context, and says that test sends skip
+the queue. An unreadable log renders as unavailable rather than empty. The
+card sits directly below delivery health and recovery controls on the
+Notifications route; a degraded Overview warning links to that route so the
+diagnostic evidence and safe retry/dismiss actions are reachable from the
+warning. The same card interleaves alert-owned
`notification_suppressed` and `notification_deferred` evidence from
`GET /api/alerts/events` with those attempts, ordered by the recorded event or
attempt time. Held rows name the affected resource, alert type, and
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 3bbd7f4e23..d21a4ada8b 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -4754,6 +4754,11 @@ first — `entries` carrying `notificationId`, `type`, `destinationId`,
`timestamp` — alongside `window_days` and retention metadata, because the
counts are retention-bounded and must not read as lifetime history; webhook
secrets are redacted from error text before the payload leaves the API. The
+read spans the longest retained class (30 days) so dead-letter evidence is not
+silently excluded, while `completed_retention_days: 7` and
+`dead_letter_retention_days: 30` disclose the mixed completeness of that
+window. `limit` defaults to 50 and is capped at 200; the Alerts evidence view
+requests that bounded maximum. The
frontend transport in `frontend-modern/src/api/notifications.ts` validates
entry shape and drops malformed rows rather than rendering them. It must route
`entries` through the shared `arrayOrEmpty` normalization helper instead of
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 770324a27c..e2a6891ee9 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -6848,7 +6848,13 @@ lines use the shared red emphasis tokens in both themes, and entry rows wrap
without horizontal overflow at mobile widths. The unavailable state is a
`role="alert"` message distinct from the empty state, because "cannot read
the log" and "no attempts" mean opposite things to someone deciding whether
-to trust their alerting.
+to trust their alerting. The card renders immediately after the delivery-health
+warning and recovery controls, and the Overview warning uses the shared
+`ButtonLink` primitive to navigate to the Notifications route. Attempt and
+held-event rows use semantic `time` elements with visible absolute local
+timestamps for timeline correlation and retain relative time only as hover
+context. The explanatory copy names the seven-day completed and 30-day
+dead-letter windows separately.
### Storage rows distinguish retained observations
diff --git a/docs/release-control/v6/internal/subsystems/notifications.md b/docs/release-control/v6/internal/subsystems/notifications.md
index 4c3c4c0e6c..6bfe2aaad2 100644
--- a/docs/release-control/v6/internal/subsystems/notifications.md
+++ b/docs/release-control/v6/internal/subsystems/notifications.md
@@ -374,8 +374,13 @@ written before that column existed resolve destination identity from their
retained operational links. `GET /api/notifications/delivery-log`
(settings-read scope) serves the log as local operator evidence: webhook
secrets are redacted from error text at the API boundary, the payload names
-its retention window instead of presenting itself as lifetime history, and an
-unreadable queue is an error, never an empty log. This per-attempt surface is
+its retention windows instead of presenting itself as lifetime history, and an
+unreadable queue is an error, never an empty log. The API queries the longest
+retained class (30 days) and reports `completed_retention_days: 7` plus
+`dead_letter_retention_days: 30`, because completed audit rows are removed with
+their seven-day queue rows while dead-letter audit rows remain with their
+30-day queue rows. Reads default to 50 entries and are capped at 200; the
+operator evidence view requests that bounded maximum. This per-attempt surface is
deliberately distinct from the content-free telemetry aggregate above, which
remains identity-free. Test sends bypass the queue and must not appear in the
delivery log, and the destinations UI says so where the log renders.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 3ad026d7d4..5e59a5afa7 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -5702,6 +5702,10 @@ delivery outcomes and the delivery gate state only; they add no storage,
backup, snapshot, restore, retention, cleanup, or recovery capability, write
nothing, and leave storage and recovery state, evidence freshness,
persistence, and admission contracts unchanged.
+The delivery-log read may span the notifications-owned 30-day dead-letter
+window and name separate seven-day completed-attempt retention. Those values
+describe notification queue cleanup only; they are not backup retention,
+recovery-point age, restore evidence, or authority to inspect or alter storage.
The alerts-owned per-incident snooze and resume routes share the same boundary:
they pause and restore notification and escalation policy while monitoring and
resolution detection continue. A snooze is not a recovery point, backup hold,
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index e07b4ef276..163eb89878 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,31 +1,27 @@
{
"version": 1,
- "base_sha": "47c1cee895fea1c395871acb307acbf3711cb4d5",
- "verified_at": "2026-08-30T21:19:54Z",
+ "base_sha": "22fd662fb794f63efb9d3ca2158de73c4e07e1b8",
+ "verified_at": "2026-08-30T23:35:47Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/features/alerts/AlertIncidentSynthesisSummary.tsx",
- "frontend-modern/src/features/alerts/AlertOverviewActiveAlertsSection.tsx",
- "frontend-modern/src/features/alerts/incidentSynthesisPresentation.ts",
- "frontend-modern/src/features/alerts/useAlertOverviewState.ts",
- "frontend-modern/src/i18n/messages.de.ts",
- "frontend-modern/src/i18n/messages.es.ts",
- "frontend-modern/src/i18n/messages.ts",
- "frontend-modern/src/types/api.ts"
+ "frontend-modern/src/api/notifications.ts",
+ "frontend-modern/src/features/alerts/AlertDeliveryHealthCard.tsx",
+ "frontend-modern/src/features/alerts/AlertDeliveryLogCard.tsx",
+ "frontend-modern/src/features/alerts/OverviewTab.tsx",
+ "frontend-modern/src/features/alerts/tabs/DestinationsTab.tsx",
+ "frontend-modern/src/features/alerts/useNotificationDeliveryLog.ts",
+ "frontend-modern/src/utils/alertDestinationsPresentation.ts"
],
"content_sha256": {
- "frontend-modern/src/features/alerts/AlertIncidentSynthesisSummary.tsx": "4c407221597fbe5bd39853d0cc4f35f62955e5e5354d5f520328bd61593f2f0a",
- "frontend-modern/src/features/alerts/AlertOverviewActiveAlertsSection.tsx": "d313bc7c99659a875bf474af48fbfc46e825e69fadca4787adf80c3d1e4d9ccc",
- "frontend-modern/src/features/alerts/incidentSynthesisPresentation.ts": "db413b54911aadb73a300b6460260a7c6dc2ce245375a0323cb6e0244f96f3e5",
- "frontend-modern/src/features/alerts/useAlertOverviewState.ts": "338aecd07546264d19e0db9a29a9c01ea337a416f316a3a4d24383d4eb9ab22e",
- "frontend-modern/src/i18n/messages.de.ts": "8240c64256088196a224939438b510aecbf55372639b5db4182af5becde4df59",
- "frontend-modern/src/i18n/messages.es.ts": "a932a856c2b4d83efe79c50c96e597767ba4a08c2e1252bdfca29a2e89b87875",
- "frontend-modern/src/i18n/messages.ts": "43a757e00eaa7879c400895c9c59a930e31513dbf03e0ae6d60f7e72a6ad9962",
- "frontend-modern/src/types/api.ts": "f6f313ff304c6d9eaf72fe3225cc7e1615e9f989c44862080ccdcbe267bb8cec"
+ "frontend-modern/src/api/notifications.ts": "3351869d747f2b915173d4923c61ee020256930c35d545976c1050976d38e587",
+ "frontend-modern/src/features/alerts/AlertDeliveryHealthCard.tsx": "1f8109a0405636c6e28af4f182fa20c03fe466379962f613960bf9e8eb9aac50",
+ "frontend-modern/src/features/alerts/AlertDeliveryLogCard.tsx": "b3eb5fb9d465d70d2ce38d36cef287a15df6f79736139fad1f7186b015446760",
+ "frontend-modern/src/features/alerts/OverviewTab.tsx": "663960cfbc9980fac55593e7bcc20d9a72c7ba1947d6c9a73d7ffc242f9b561d",
+ "frontend-modern/src/features/alerts/tabs/DestinationsTab.tsx": "f09fe60111afdc634f5dd6dd631c5f0947f3b6fd7d8b213adb17f5b3c27c0534",
+ "frontend-modern/src/features/alerts/useNotificationDeliveryLog.ts": "047fe800ad7c4f8ed875f83214a5a161a4342c31799e5efeca5ca2c54054bed1",
+ "frontend-modern/src/utils/alertDestinationsPresentation.ts": "e46ef2147f70229dc5a78c3167c7ec2021059816799e585b7f3e092fa861fdd3"
},
- "routes": [
- "/alerts/overview"
- ],
+ "routes": ["/alerts/overview", "/alerts/notifications"],
"viewports": [
{
"width": 1280,
@@ -37,17 +33,17 @@
}
],
"states": [
- "settled Alerts overview backed by the local mock runtime and a deterministic supported-cause Alert contract fixture",
- "supported infrastructure cause summary with runtime classification, affected-resource count, and bounded observation count",
- "expanded synthesis evidence with resource names, typed failure classes, observation times, and long evidence identifiers",
- "expanded linked signal cards beneath the declared primary alert",
- "desktop and narrow layouts with no horizontal overflow or clipped alert actions"
+ "degraded delivery health with one failed and two dead-lettered retained deliveries",
+ "mixed-retention activity with a named webhook, alert identifier, failure class, redacted-safe error text, and absolute timestamp",
+ "refresh in progress with the activity refresh control disabled",
+ "empty delivery activity after a successful refresh",
+ "unavailable delivery activity after a failed refresh",
+ "desktop and narrow layouts with health before activity and no horizontal overflow"
],
"interactions": [
- "opened the Alerts overview after the local backend and WebSocket stream reported connected",
- "expanded Review synthesis evidence and inspected both independent detector observations",
- "expanded the linked signal group and confirmed the supporting alert retained its own actions and lifecycle card",
- "repeated the expanded evidence and linked-signal checks at 1280x800 and 390x844",
- "removed the temporary browser-only contract fixture and retained only the production synthesis implementation"
+ "followed Review delivery activity from Alerts Overview to the Notifications route at 1280x800 and 390x844",
+ "confirmed the Notifications activity request used the bounded limit=200 query",
+ "inspected seven-day completed and 30-day dead-letter retention copy plus semantic absolute timestamps at both viewports",
+ "refreshed activity through loading, restored, empty, and unavailable responses and confirmed loading disabled the refresh control"
]
}
diff --git a/frontend-modern/public/docs/API.md b/frontend-modern/public/docs/API.md
index b3a090c556..4f5e37e6d3 100644
--- a/frontend-modern/public/docs/API.md
+++ b/frontend-modern/public/docs/API.md
@@ -594,6 +594,12 @@ Common reporting error codes:
- `no_resources`, `too_many_resources`, `body_too_large`, `invalid_body`
### Queue and Dead-Letter Tools
+- `GET /api/notifications/delivery-log?limit=200` (admin, `settings:read`)
+ - Returns recent per-attempt delivery evidence with destination identifiers,
+ alert identifiers, outcomes, timestamps, failure classes, and redacted error
+ text. Completed attempts are retained for 7 days; dead-letter attempts are
+ retained for 30 days, so the response reports both windows explicitly.
+ - `limit` defaults to 50 and is capped at 200.
- `GET /api/notifications/queue/stats` (admin)
- Returns counts for all rows still retained by the queue. Status counts have
different retention windows and are not a delivery rate or lifetime total.
diff --git a/frontend-modern/public/docs/TROUBLESHOOTING.md b/frontend-modern/public/docs/TROUBLESHOOTING.md
index 1958090041..933ae3526f 100644
--- a/frontend-modern/public/docs/TROUBLESHOOTING.md
+++ b/frontend-modern/public/docs/TROUBLESHOOTING.md
@@ -151,6 +151,10 @@ first step before platform-local cleanup.
- Open **Alerts → Notifications** first. Pulse shows a delivery warning when
failed or dead-lettered notifications remain in the persistent queue; a
missing queue-health read is shown as unavailable rather than healthy.
+- **Recent delivery activity** appears directly below that warning. It names
+ the destination and affected alert, shows an absolute timestamp for timeline
+ correlation, and includes safely redacted provider errors. Completed attempts
+ remain for 7 days and dead-letter attempts remain for 30 days.
- After correcting the destination, use **Retry retained deliveries**. Use
**Dismiss retained failures** only when those deliveries should not be sent.
Both actions preserve delivery history; do not delete `notification_queue.db`
diff --git a/frontend-modern/src/api/__tests__/notifications.test.ts b/frontend-modern/src/api/__tests__/notifications.test.ts
index 8e4216a162..a14d671d27 100644
--- a/frontend-modern/src/api/__tests__/notifications.test.ts
+++ b/frontend-modern/src/api/__tests__/notifications.test.ts
@@ -336,13 +336,17 @@ describe('NotificationsAPI', () => {
timestamp: '2026-08-20T11:00:00Z',
},
],
- window_days: 7,
+ window_days: 30,
+ completed_retention_days: 7,
+ dead_letter_retention_days: 30,
} as any);
const log = await NotificationsAPI.getDeliveryLog(25);
expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/notifications/delivery-log?limit=25');
- expect(log.windowDays).toBe(7);
+ expect(log.windowDays).toBe(30);
+ expect(log.completedRetentionDays).toBe(7);
+ expect(log.deadLetterRetentionDays).toBe(30);
expect(log.entries).toHaveLength(2);
expect(log.entries[0]).toEqual(
expect.objectContaining({
@@ -365,6 +369,8 @@ describe('NotificationsAPI', () => {
expect(log.entries).toEqual([]);
// A missing or nonsensical window falls back to the seven-day default.
expect(log.windowDays).toBe(7);
+ expect(log.completedRetentionDays).toBe(7);
+ expect(log.deadLetterRetentionDays).toBe(7);
});
it('normalizes a malformed delivery-log collection through the shared API boundary', async () => {
@@ -375,7 +381,12 @@ describe('NotificationsAPI', () => {
const log = await NotificationsAPI.getDeliveryLog();
- expect(log).toEqual({ entries: [], windowDays: 7 });
+ expect(log).toEqual({
+ entries: [],
+ windowDays: 7,
+ completedRetentionDays: 7,
+ deadLetterRetentionDays: 7,
+ });
});
it('retries retained terminal deliveries through the operator recovery endpoint', async () => {
diff --git a/frontend-modern/src/api/notifications.ts b/frontend-modern/src/api/notifications.ts
index b776edd3e7..9d8cab763f 100644
--- a/frontend-modern/src/api/notifications.ts
+++ b/frontend-modern/src/api/notifications.ts
@@ -162,6 +162,8 @@ export interface NotificationDeliveryLogEntry {
export interface NotificationDeliveryLog {
entries: NotificationDeliveryLogEntry[];
windowDays: number;
+ completedRetentionDays: number;
+ deadLetterRetentionDays: number;
}
export interface NotificationTestResult {
@@ -361,9 +363,23 @@ export class NotificationsAPI {
if (entry) entries.push(entry);
}
const windowDays = nonNegativeCount(payload.window_days);
+ const normalizedWindowDays = windowDays && windowDays > 0 ? windowDays : 7;
+ const completedRetentionDays = nonNegativeCount(payload.completed_retention_days);
+ const deadLetterRetentionDays = nonNegativeCount(payload.dead_letter_retention_days);
return {
entries,
- windowDays: windowDays && windowDays > 0 ? windowDays : 7,
+ windowDays: normalizedWindowDays,
+ // Older servers exposed only window_days plus the dead-letter window.
+ // Preserve an honest seven-day completed-row fallback while accepting
+ // their explicit 30-day dead-letter retention field.
+ completedRetentionDays:
+ completedRetentionDays && completedRetentionDays > 0
+ ? completedRetentionDays
+ : Math.min(normalizedWindowDays, 7),
+ deadLetterRetentionDays:
+ deadLetterRetentionDays && deadLetterRetentionDays > 0
+ ? deadLetterRetentionDays
+ : normalizedWindowDays,
};
}
diff --git a/frontend-modern/src/features/alerts/AlertDeliveryHealthCard.test.tsx b/frontend-modern/src/features/alerts/AlertDeliveryHealthCard.test.tsx
index af282a450b..d3c89697dd 100644
--- a/frontend-modern/src/features/alerts/AlertDeliveryHealthCard.test.tsx
+++ b/frontend-modern/src/features/alerts/AlertDeliveryHealthCard.test.tsx
@@ -1,4 +1,5 @@
import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { Route, Router } from '@solidjs/router';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { NotificationQueueHealth } from '@/api/notifications';
@@ -42,14 +43,22 @@ describe('AlertDeliveryHealthCard', () => {
const onRetryFailures = vi.fn();
const onDismissFailures = vi.fn();
render(() => (
- <AlertDeliveryHealthCard
- health={degradedHealth}
- unavailable={false}
- refreshing={false}
- onRefresh={onRefresh}
- onRetryFailures={onRetryFailures}
- onDismissFailures={onDismissFailures}
- />
+ <Router>
+ <Route
+ path="/"
+ component={() => (
+ <AlertDeliveryHealthCard
+ health={degradedHealth}
+ unavailable={false}
+ refreshing={false}
+ onRefresh={onRefresh}
+ onRetryFailures={onRetryFailures}
+ onDismissFailures={onDismissFailures}
+ detailsHref="/alerts/notifications"
+ />
+ )}
+ />
+ </Router>
));
expect(screen.getByRole('alert')).toHaveTextContent('Notification delivery needs attention');
@@ -64,6 +73,13 @@ describe('AlertDeliveryHealthCard', () => {
expect(screen.getByRole('alert')).toHaveTextContent(
'Check destination credentials, tokens, and account permissions',
);
+ expect(screen.getByRole('alert')).toHaveTextContent(
+ 'dismiss retained failures to clear this warning without deleting delivery history',
+ );
+ expect(screen.getByRole('link', { name: 'Review delivery activity' })).toHaveAttribute(
+ 'href',
+ '/alerts/notifications',
+ );
fireEvent.click(screen.getByRole('button', { name: 'Refresh delivery status' }));
expect(onRefresh).toHaveBeenCalledTimes(1);
diff --git a/frontend-modern/src/features/alerts/AlertDeliveryHealthCard.tsx b/frontend-modern/src/features/alerts/AlertDeliveryHealthCard.tsx
index 20210b9c18..b470dfb50c 100644
--- a/frontend-modern/src/features/alerts/AlertDeliveryHealthCard.tsx
+++ b/frontend-modern/src/features/alerts/AlertDeliveryHealthCard.tsx
@@ -2,13 +2,14 @@ import AlertTriangleIcon from 'lucide-solid/icons/alert-triangle';
import RefreshCwIcon from 'lucide-solid/icons/refresh-cw';
import type { NotificationQueueHealth } from '@/api/notifications';
-import { Button } from '@/components/shared/Button';
+import { Button, ButtonLink } from '@/components/shared/Button';
import { Card } from '@/components/shared/Card';
import {
getAlertDestinationsDeliveryDismissLabel,
getAlertDestinationsDeliveryHealthDescription,
getAlertDestinationsDeliveryHealthTitle,
getAlertDestinationsDeliveryRefreshLabel,
+ getAlertDestinationsDeliveryReviewLabel,
getAlertDestinationsDeliveryRetryLabel,
} from '@/utils/alertDestinationsPresentation';
@@ -21,6 +22,7 @@ interface AlertDeliveryHealthCardProps {
dismissingFailures?: boolean;
onRetryFailures?: () => void;
onDismissFailures?: () => void;
+ detailsHref?: string;
}
export function AlertDeliveryHealthCard(props: AlertDeliveryHealthCardProps) {
@@ -54,6 +56,11 @@ export function AlertDeliveryHealthCard(props: AlertDeliveryHealthCardProps) {
</div>
</div>
<div class="flex flex-shrink-0 flex-wrap items-center gap-2">
+ {props.detailsHref ? (
+ <ButtonLink variant="secondary" size="sm" href={props.detailsHref}>
+ {getAlertDestinationsDeliveryReviewLabel()}
+ </ButtonLink>
+ ) : null}
{props.onRetryFailures ? (
<Button
variant="secondary"
diff --git a/frontend-modern/src/features/alerts/AlertDeliveryLogCard.test.tsx b/frontend-modern/src/features/alerts/AlertDeliveryLogCard.test.tsx
index 9b80695551..a464dc46da 100644
--- a/frontend-modern/src/features/alerts/AlertDeliveryLogCard.test.tsx
+++ b/frontend-modern/src/features/alerts/AlertDeliveryLogCard.test.tsx
@@ -45,6 +45,8 @@ const log: NotificationDeliveryLog = {
},
],
windowDays: 7,
+ completedRetentionDays: 7,
+ deadLetterRetentionDays: 30,
};
describe('AlertDeliveryLogCard', () => {
@@ -87,7 +89,12 @@ describe('AlertDeliveryLogCard', () => {
it('renders an honest empty state when no deliveries were attempted', () => {
render(() => (
<AlertDeliveryLogCard
- log={{ entries: [], windowDays: 7 }}
+ log={{
+ entries: [],
+ windowDays: 30,
+ completedRetentionDays: 7,
+ deadLetterRetentionDays: 30,
+ }}
unavailable={false}
refreshing={false}
onRefresh={vi.fn()}
@@ -98,6 +105,26 @@ describe('AlertDeliveryLogCard', () => {
expect(screen.getByText(/No alert deliveries were attempted/)).toBeInTheDocument();
});
+ it('shows the mixed retention windows and visible correlation timestamps', () => {
+ const { container } = render(() => (
+ <AlertDeliveryLogCard
+ log={log}
+ unavailable={false}
+ refreshing={false}
+ onRefresh={vi.fn()}
+ webhooks={webhooks}
+ />
+ ));
+
+ expect(screen.getByText(/Completed attempts are retained for 7 days/)).toBeInTheDocument();
+ expect(
+ screen.getByText(/failures that exhausted retries remain available for 30 days/),
+ ).toBeInTheDocument();
+ const timestamps = Array.from(container.querySelectorAll('time'));
+ expect(timestamps[0]).toHaveAttribute('datetime', log.entries[0].timestamp);
+ expect(timestamps[0]).not.toHaveTextContent(/ago$/);
+ });
+
it('interleaves held notifications with delivery attempts, newest first', () => {
const heldEvents: AlertEvent[] = [
{
@@ -147,7 +174,12 @@ describe('AlertDeliveryLogCard', () => {
it('shows held rows even when no delivery was attempted', () => {
render(() => (
<AlertDeliveryLogCard
- log={{ entries: [], windowDays: 7 }}
+ log={{
+ entries: [],
+ windowDays: 30,
+ completedRetentionDays: 7,
+ deadLetterRetentionDays: 30,
+ }}
unavailable={false}
refreshing={false}
onRefresh={vi.fn()}
diff --git a/frontend-modern/src/features/alerts/AlertDeliveryLogCard.tsx b/frontend-modern/src/features/alerts/AlertDeliveryLogCard.tsx
index 67f4852d0d..c11b0f8c07 100644
--- a/frontend-modern/src/features/alerts/AlertDeliveryLogCard.tsx
+++ b/frontend-modern/src/features/alerts/AlertDeliveryLogCard.tsx
@@ -100,9 +100,23 @@ export function AlertDeliveryLogCard(props: AlertDeliveryLogCardProps) {
};
const entries = () => props.log?.entries ?? [];
- const windowDays = () => props.log?.windowDays ?? 7;
+ const completedRetentionDays = () => props.log?.completedRetentionDays ?? 7;
+ const deadLetterRetentionDays = () => props.log?.deadLetterRetentionDays ?? 30;
const rows = () => mergeDeliveryLogRows(entries(), props.heldEvents ?? []);
+ const absoluteTimestamp = (value: string): string => {
+ const parsed = new Date(value);
+ if (Number.isNaN(parsed.getTime())) return value;
+ return parsed.toLocaleString(undefined, {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit',
+ second: '2-digit',
+ });
+ };
+
const heldResourceLabel = (event: AlertEvent): string => {
const resource = event.resourceName || event.alertId;
if (event.alertType) return `${resource} (${event.alertType})`;
@@ -110,7 +124,7 @@ export function AlertDeliveryLogCard(props: AlertDeliveryLogCardProps) {
};
return (
- <Card padding="sm" class="sm:p-4">
+ <Card id="notification-delivery-activity" padding="sm" class="scroll-mt-24 sm:p-4">
<div class="flex flex-col gap-3">
<div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
<div class="min-w-0">
@@ -118,7 +132,10 @@ export function AlertDeliveryLogCard(props: AlertDeliveryLogCardProps) {
{getAlertDestinationsDeliveryLogTitle()}
</h3>
<p class="mt-1 text-sm leading-6 text-gray-600 dark:text-gray-400">
- {getAlertDestinationsDeliveryLogDescription(windowDays())}
+ {getAlertDestinationsDeliveryLogDescription(
+ completedRetentionDays(),
+ deadLetterRetentionDays(),
+ )}
</p>
</div>
<button
@@ -168,9 +185,13 @@ export function AlertDeliveryLogCard(props: AlertDeliveryLogCardProps) {
>
{alertSummary(row.entry)}
</span>
- <span class="ml-auto flex-shrink-0 text-xs text-gray-500 dark:text-gray-400">
- {formatRelativeTime(row.entry.timestamp)}
- </span>
+ <time
+ class="ml-auto flex-shrink-0 text-xs text-gray-500 dark:text-gray-400"
+ dateTime={row.entry.timestamp}
+ title={formatRelativeTime(row.entry.timestamp)}
+ >
+ {absoluteTimestamp(row.entry.timestamp)}
+ </time>
</div>
<Show
when={
@@ -208,9 +229,13 @@ export function AlertDeliveryLogCard(props: AlertDeliveryLogCardProps) {
<span class="min-w-0 truncate text-sm text-gray-600 dark:text-gray-400">
{describeAlertEventReason(row.event.reason)}
</span>
- <span class="ml-auto flex-shrink-0 text-xs text-gray-500 dark:text-gray-400">
- {formatRelativeTime(row.event.occurredAt)}
- </span>
+ <time
+ class="ml-auto flex-shrink-0 text-xs text-gray-500 dark:text-gray-400"
+ dateTime={row.event.occurredAt}
+ title={formatRelativeTime(row.event.occurredAt)}
+ >
+ {absoluteTimestamp(row.event.occurredAt)}
+ </time>
</div>
</li>
)
diff --git a/frontend-modern/src/features/alerts/OverviewTab.tsx b/frontend-modern/src/features/alerts/OverviewTab.tsx
index f6e62a93d9..b8f0caf65f 100644
--- a/frontend-modern/src/features/alerts/OverviewTab.tsx
+++ b/frontend-modern/src/features/alerts/OverviewTab.tsx
@@ -84,6 +84,7 @@ export function OverviewTab(props: {
unavailable={deliveryHealthState.deliveryHealthUnavailable()}
refreshing={deliveryHealthState.refreshingDeliveryHealth()}
onRefresh={() => void deliveryHealthState.loadDeliveryHealth()}
+ detailsHref="/alerts/notifications"
/>
</Show>
<AlertOverviewStatsCards state={overviewState} />
diff --git a/frontend-modern/src/features/alerts/__tests__/useAlertDestinationsTabState.test.tsx b/frontend-modern/src/features/alerts/__tests__/useAlertDestinationsTabState.test.tsx
index 47aac9e2f7..998bd3caaa 100644
--- a/frontend-modern/src/features/alerts/__tests__/useAlertDestinationsTabState.test.tsx
+++ b/frontend-modern/src/features/alerts/__tests__/useAlertDestinationsTabState.test.tsx
@@ -162,7 +162,9 @@ describe('useAlertDestinationsTabState', () => {
timestamp: '2026-08-20T12:00:00Z',
},
],
- windowDays: 7,
+ windowDays: 30,
+ completedRetentionDays: 7,
+ deadLetterRetentionDays: 30,
});
vi.mocked(AlertsAPI.getEvents).mockResolvedValue([
{
@@ -256,7 +258,12 @@ describe('useAlertDestinationsTabState', () => {
vi.mocked(NotificationsAPI.getWebhooks).mockResolvedValue([]);
vi.mocked(NotificationsAPI.getHealth).mockRejectedValue(new Error('offline'));
- vi.mocked(NotificationsAPI.getDeliveryLog).mockResolvedValue({ entries: [], windowDays: 7 });
+ vi.mocked(NotificationsAPI.getDeliveryLog).mockResolvedValue({
+ entries: [],
+ windowDays: 30,
+ completedRetentionDays: 7,
+ deadLetterRetentionDays: 30,
+ });
// The backend reports the test went out while the activation gate keeps
// real alerts suppressed; plain success here is the postmortem trap.
vi.mocked(NotificationsAPI.testNotification).mockResolvedValue({
@@ -327,7 +334,12 @@ describe('useAlertDestinationsTabState', () => {
terminalFailuresAffectHealth: true,
},
});
- vi.mocked(NotificationsAPI.getDeliveryLog).mockResolvedValue({ entries: [], windowDays: 7 });
+ vi.mocked(NotificationsAPI.getDeliveryLog).mockResolvedValue({
+ entries: [],
+ windowDays: 30,
+ completedRetentionDays: 7,
+ deadLetterRetentionDays: 30,
+ });
vi.mocked(NotificationsAPI.retryTerminalFailures).mockResolvedValue({
affected: 3,
success: true,
diff --git a/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryLog.test.tsx b/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryLog.test.tsx
index e97033227e..e715732afb 100644
--- a/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryLog.test.tsx
+++ b/frontend-modern/src/features/alerts/__tests__/useNotificationDeliveryLog.test.tsx
@@ -29,11 +29,14 @@ describe('useNotificationDeliveryLog', () => {
timestamp: '2026-08-20T12:00:00Z',
},
],
- windowDays: 7,
+ windowDays: 30,
+ completedRetentionDays: 7,
+ deadLetterRetentionDays: 30,
});
const state = useNotificationDeliveryLog();
await state.loadDeliveryLog();
+ expect(NotificationsAPI.getDeliveryLog).toHaveBeenCalledWith(200);
expect(state.deliveryLog()?.entries).toHaveLength(1);
expect(state.deliveryLogUnavailable()).toBe(false);
dispose();
@@ -55,7 +58,9 @@ describe('useNotificationDeliveryLog', () => {
vi.mocked(NotificationsAPI.getDeliveryLog).mockRejectedValueOnce(new Error('network down'));
vi.mocked(NotificationsAPI.getDeliveryLog).mockResolvedValue({
entries: [],
- windowDays: 7,
+ windowDays: 30,
+ completedRetentionDays: 7,
+ deadLetterRetentionDays: 30,
});
const state = useNotificationDeliveryLog();
diff --git a/frontend-modern/src/features/alerts/tabs/DestinationsTab.tsx b/frontend-modern/src/features/alerts/tabs/DestinationsTab.tsx
index 66c0ba7c86..ffbe6110b3 100644
--- a/frontend-modern/src/features/alerts/tabs/DestinationsTab.tsx
+++ b/frontend-modern/src/features/alerts/tabs/DestinationsTab.tsx
@@ -92,6 +92,15 @@ export function DestinationsTab(props: DestinationsTabProps) {
/>
</Show>
+ <AlertDeliveryLogCard
+ log={state.deliveryLog()}
+ unavailable={state.deliveryLogUnavailable()}
+ refreshing={state.refreshingDeliveryLog()}
+ onRefresh={() => void state.loadDeliveryLog()}
+ webhooks={state.webhooks()}
+ heldEvents={state.heldEvents()}
+ />
+
<Show when={state.hasLoadError()}>
<AlertDestinationsLoadErrorCard
error={props.configLoadError() || state.webhookLoadError() || ''}
@@ -141,15 +150,6 @@ export function DestinationsTab(props: DestinationsTabProps) {
props.setHasUnsavedChanges(true);
}}
/>
-
- <AlertDeliveryLogCard
- log={state.deliveryLog()}
- unavailable={state.deliveryLogUnavailable()}
- refreshing={state.refreshingDeliveryLog()}
- onRefresh={() => void state.loadDeliveryLog()}
- webhooks={state.webhooks()}
- heldEvents={state.heldEvents()}
- />
</Show>
</div>
);
diff --git a/frontend-modern/src/features/alerts/useNotificationDeliveryLog.ts b/frontend-modern/src/features/alerts/useNotificationDeliveryLog.ts
index 5e90170e2e..648ea22633 100644
--- a/frontend-modern/src/features/alerts/useNotificationDeliveryLog.ts
+++ b/frontend-modern/src/features/alerts/useNotificationDeliveryLog.ts
@@ -8,6 +8,7 @@ import { logger } from '@/utils/logger';
const HELD_EVENT_TYPES = ['notification_suppressed', 'notification_deferred'];
const HELD_EVENT_WINDOW_DAYS = 7;
const HELD_EVENT_LIMIT = 100;
+const DELIVERY_LOG_LIMIT = 200;
// The delivery log is the positive half of delivery evidence: health warns
// when something is wrong, the log shows what actually fired and where it
@@ -48,7 +49,10 @@ export function useNotificationDeliveryLog() {
// primary delivery-attempt log.
void loadHeldEvents();
try {
- const log = await NotificationsAPI.getDeliveryLog();
+ // Request the server's bounded maximum. A degraded queue can retain more
+ // than the default page of 50 failures, and the evidence view should not
+ // hide them behind unrelated successful attempts when space is available.
+ const log = await NotificationsAPI.getDeliveryLog(DELIVERY_LOG_LIMIT);
setDeliveryLog(log);
setDeliveryLogUnavailable(false);
} catch (error) {
diff --git a/frontend-modern/src/utils/__tests__/alertDestinationsPresentation.test.ts b/frontend-modern/src/utils/__tests__/alertDestinationsPresentation.test.ts
index 821454cd02..f6093bf0ff 100644
--- a/frontend-modern/src/utils/__tests__/alertDestinationsPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/alertDestinationsPresentation.test.ts
@@ -183,7 +183,7 @@ describe('alertDestinationsPresentation', () => {
failureClassesAvailable: true,
}),
).toBe(
- '1 failed delivery retained for 7 days and 2 dead-lettered deliveries retained for 30 days. These notifications were not delivered. Pulse removes expired records hourly, so this warning clears after the last retained failure reaches its retention limit if no new terminal failures occur. Most recent terminal failures were classified as authentication (3). Check destination credentials, tokens, and account permissions. Recoverable retry attempts do not trigger this warning.',
+ '1 failed delivery retained for 7 days and 2 dead-lettered deliveries retained for 30 days. These notifications were not delivered. Most recent terminal failures were classified as authentication (3). Check destination credentials, tokens, and account permissions. Review delivery activity in Notifications for timestamps, destinations, alerts, and safely redacted errors. After correcting the destination, retry them; dismiss retained failures to clear this warning without deleting delivery history. Otherwise Pulse removes expired records hourly after their retention limit. Recoverable retry attempts do not trigger this warning.',
);
expect(
getAlertDestinationsDeliveryHealthDescription({
@@ -224,8 +224,9 @@ describe('alert destinations delivery log copy', () => {
it('names the retention window and the test-send caveat so absence is not read as failure', () => {
expect(getAlertDestinationsDeliveryLogTitle()).toBe('Recent delivery activity');
- const description = getAlertDestinationsDeliveryLogDescription(7);
- expect(description).toContain('last 7 days');
+ const description = getAlertDestinationsDeliveryLogDescription(7, 30);
+ expect(description).toContain('retained for 7 days');
+ expect(description).toContain('remain available for 30 days');
expect(description).toContain('held notifications');
expect(description).toContain('Test sends skip the queue');
expect(getAlertDestinationsDeliveryLogEmpty()).toContain('No alert deliveries were attempted');
diff --git a/frontend-modern/src/utils/__tests__/docsLinks.test.ts b/frontend-modern/src/utils/__tests__/docsLinks.test.ts
index a010ea7aec..76dbe0b821 100644
--- a/frontend-modern/src/utils/__tests__/docsLinks.test.ts
+++ b/frontend-modern/src/utils/__tests__/docsLinks.test.ts
@@ -210,6 +210,24 @@ describe('docsLinks', () => {
expect(apiReference).toContain('without deleting delivery history');
});
+ it('ships the mixed-retention notification delivery-log contract', () => {
+ const apiReference = readFileSync(path.join(repoRoot, 'docs', 'API.md'), 'utf8');
+ const shippedAPIReference = readFileSync(
+ path.join(frontendRoot, 'public', 'docs', 'API.md'),
+ 'utf8',
+ );
+ const queueToolsSection = (reference: string) =>
+ reference.split('### Queue and Dead-Letter Tools')[1]?.split('\n### ')[0];
+
+ const canonicalQueueTools = queueToolsSection(apiReference);
+ expect(queueToolsSection(shippedAPIReference)).toBe(canonicalQueueTools);
+ const compactQueueTools = canonicalQueueTools?.replace(/\s+/g, ' ');
+ expect(compactQueueTools).toContain('`GET /api/notifications/delivery-log?limit=200`');
+ expect(compactQueueTools).toContain('Completed attempts are retained for 7 days');
+ expect(compactQueueTools).toContain('dead-letter attempts are retained for 30 days');
+ expect(compactQueueTools).toContain('`limit` defaults to 50 and is capped at 200');
+ });
+
it('ships the bulk active-alert delivery diagnosis contract', () => {
const apiReference = readFileSync(path.join(repoRoot, 'docs', 'API.md'), 'utf8');
const shippedAPIReference = readFileSync(
diff --git a/frontend-modern/src/utils/alertDestinationsPresentation.ts b/frontend-modern/src/utils/alertDestinationsPresentation.ts
index cc706d6824..9cbd0e8558 100644
--- a/frontend-modern/src/utils/alertDestinationsPresentation.ts
+++ b/frontend-modern/src/utils/alertDestinationsPresentation.ts
@@ -91,6 +91,7 @@ export const ALERT_DESTINATIONS_DELIVERY_UNAVAILABLE_TITLE =
export const ALERT_DESTINATIONS_DELIVERY_REFRESH_LABEL = 'Refresh delivery status';
export const ALERT_DESTINATIONS_DELIVERY_RETRY_LABEL = 'Retry retained deliveries';
export const ALERT_DESTINATIONS_DELIVERY_DISMISS_LABEL = 'Dismiss retained failures';
+export const ALERT_DESTINATIONS_DELIVERY_REVIEW_LABEL = 'Review delivery activity';
export function getAlertDestinationsConfigLoadError() {
return ALERT_DESTINATIONS_CONFIG_LOAD_ERROR;
@@ -210,7 +211,7 @@ export function getAlertDestinationsDeliveryHealthDescription(input: {
diagnostic = `Most recent terminal failures were classified as ${dominant[0].replace('_', ' ')} (${dominant[1]}). ${guidanceByClass[dominant[0]] ?? guidanceByClass.unknown}`;
}
}
- return `${summary}. These notifications were not delivered. Pulse removes expired records hourly, so this warning clears after the last retained failure reaches its retention limit if no new terminal failures occur. ${diagnostic} Recoverable retry attempts do not trigger this warning.`;
+ return `${summary}. These notifications were not delivered. ${diagnostic} Review delivery activity in Notifications for timestamps, destinations, alerts, and safely redacted errors. After correcting the destination, retry them; dismiss retained failures to clear this warning without deleting delivery history. Otherwise Pulse removes expired records hourly after their retention limit. Recoverable retry attempts do not trigger this warning.`;
}
export function getAlertDestinationsDeliveryRefreshLabel() {
@@ -225,6 +226,10 @@ export function getAlertDestinationsDeliveryDismissLabel() {
return ALERT_DESTINATIONS_DELIVERY_DISMISS_LABEL;
}
+export function getAlertDestinationsDeliveryReviewLabel() {
+ return ALERT_DESTINATIONS_DELIVERY_REVIEW_LABEL;
+}
+
export function getAlertDestinationsDeliveryRetryConfirmation(count: number) {
return `Retry ${count} retained ${count === 1 ? 'delivery' : 'deliveries'} now? A destination that accepted an earlier attempt may receive a duplicate.`;
}
@@ -257,8 +262,11 @@ export function getAlertDestinationsDeliveryLogTitle() {
// The test-send caveat matters: test messages skip the queue entirely, so a
// user who sends a test and then checks this log would otherwise read its
// absence as a delivery failure.
-export function getAlertDestinationsDeliveryLogDescription(windowDays: number) {
- return `Delivery attempts and held notifications for real alerts over the last ${windowDays} days. Test sends skip the queue and are not listed here.`;
+export function getAlertDestinationsDeliveryLogDescription(
+ completedRetentionDays: number,
+ deadLetterRetentionDays: number,
+) {
+ return `Delivery attempts and held notifications for real alerts. Completed attempts are retained for ${completedRetentionDays} days; failures that exhausted retries remain available for ${deadLetterRetentionDays} days. Test sends skip the queue and are not listed here.`;
}
export function getAlertDestinationsDeliveryLogEmpty() {
diff --git a/internal/api/alerting/notifications.go b/internal/api/alerting/notifications.go
index d443185501..31ab95e156 100644
--- a/internal/api/alerting/notifications.go
+++ b/internal/api/alerting/notifications.go
@@ -1064,7 +1064,7 @@ func (h *NotificationHandlers) GetDeliveryLog(w http.ResponseWriter, r *http.Req
}
entries, err := manager.GetDeliveryLog(
- time.Now().Add(-completedQueueRetentionDays*24*time.Hour), limit,
+ time.Now().Add(-deadLetterQueueRetentionDays*24*time.Hour), limit,
)
if err != nil {
log.Warn().Err(err).Msg("Failed to read notification delivery log")
@@ -1083,7 +1083,8 @@ func (h *NotificationHandlers) GetDeliveryLog(w http.ResponseWriter, r *http.Req
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]interface{}{
"entries": entries,
- "window_days": completedQueueRetentionDays,
+ "window_days": deadLetterQueueRetentionDays,
+ "completed_retention_days": completedQueueRetentionDays,
"dead_letter_retention_days": deadLetterQueueRetentionDays,
"entries_are_retention_bounded": true,
})
diff --git a/internal/api/alerting/notifications_health_test.go b/internal/api/alerting/notifications_health_test.go
index b1744003e9..5321f1d14d 100644
--- a/internal/api/alerting/notifications_health_test.go
+++ b/internal/api/alerting/notifications_health_test.go
@@ -7,6 +7,7 @@ import (
"net/http/httptest"
"strings"
"testing"
+ "time"
"github.com/rcourtman/pulse-go-rewrite/internal/notifications"
"github.com/stretchr/testify/mock"
@@ -143,7 +144,10 @@ func TestGetDeliveryLogReturnsEntriesWithRedactedErrors(t *testing.T) {
mockMonitor := new(MockNotificationMonitor)
mockManager := new(MockNotificationManager)
mockMonitor.On("GetNotificationManager").Return(mockManager)
- mockManager.On("GetDeliveryLog", mock.Anything, 25).Return([]notifications.DeliveryLogEntry{
+ mockManager.On("GetDeliveryLog", mock.MatchedBy(func(since time.Time) bool {
+ age := time.Since(since)
+ return age >= 29*24*time.Hour && age <= 31*24*time.Hour
+ }), 25).Return([]notifications.DeliveryLogEntry{
{
NotificationID: "webhook-1",
Type: "webhook",
@@ -185,6 +189,7 @@ func TestGetDeliveryLogReturnsEntriesWithRedactedErrors(t *testing.T) {
FailureClass string `json:"failureClass"`
} `json:"entries"`
WindowDays int `json:"window_days"`
+ CompletedRetentionDays int `json:"completed_retention_days"`
DeadLetterRetentionDays int `json:"dead_letter_retention_days"`
EntriesAreRetentionBounded bool `json:"entries_are_retention_bounded"`
}
@@ -205,7 +210,8 @@ func TestGetDeliveryLogReturnsEntriesWithRedactedErrors(t *testing.T) {
!strings.Contains(response.Entries[0].ErrorMessage, "token=REDACTED") {
t.Fatalf("error message not redacted: %q", response.Entries[0].ErrorMessage)
}
- if response.WindowDays != 7 ||
+ if response.WindowDays != 30 ||
+ response.CompletedRetentionDays != 7 ||
response.DeadLetterRetentionDays != 30 ||
!response.EntriesAreRetentionBounded {
t.Fatalf("retention context = %#v", response)
diff --git a/internal/notifications/delivery_log.go b/internal/notifications/delivery_log.go
index 2fc21c83a1..71fd5af519 100644
--- a/internal/notifications/delivery_log.go
+++ b/internal/notifications/delivery_log.go
@@ -70,8 +70,11 @@ func deliveryOutcome(status NotificationQueueStatus, success bool, attempts int)
}
// GetDeliveryLog returns recorded delivery attempts on or after since, newest
-// first. Rows share the queue's retention windows, so a window longer than
-// the completed-row retention must not be presented as complete history.
+// first. Callers can use the longest queue retention window: audit cleanup
+// removes sent, failed, and cancelled rows with their seven-day queue records,
+// while dead-letter rows remain available with their queue records for 30
+// days. The API names both windows so that mixed retention is not presented as
+// uniformly complete history.
func (nq *NotificationQueue) GetDeliveryLog(since time.Time, limit int) ([]DeliveryLogEntry, error) {
if nq == nil {
return nil, fmt.Errorf("notification queue not initialized")
diff --git a/internal/notifications/delivery_log_test.go b/internal/notifications/delivery_log_test.go
index 8948b9df57..2f679f5dd1 100644
--- a/internal/notifications/delivery_log_test.go
+++ b/internal/notifications/delivery_log_test.go
@@ -160,6 +160,56 @@ func TestGetDeliveryLogHonorsLimitAndCap(t *testing.T) {
}
}
+func TestGetDeliveryLogCanReadRetainedDeadLetterWindow(t *testing.T) {
+ nq, err := NewNotificationQueue(t.TempDir())
+ if err != nil {
+ t.Fatalf("NewNotificationQueue: %v", err)
+ }
+ defer func() { _ = nq.Stop() }()
+
+ now := time.Now().UTC()
+ notif := &QueuedNotification{
+ ID: "webhook-retained-dlq",
+ Type: "webhook",
+ Status: QueueStatusPending,
+ Config: []byte(`{}`),
+ CreatedAt: now.Add(-20 * 24 * time.Hour),
+ }
+ if err := nq.Enqueue(notif); err != nil {
+ t.Fatalf("enqueue: %v", err)
+ }
+ notif.Status = QueueStatusDLQ
+ notif.Attempts = 3
+ if err := nq.RecordAudit(notif, false, "destination unreachable"); err != nil {
+ t.Fatalf("record delivery: %v", err)
+ }
+ if _, err := nq.db.Exec(
+ `UPDATE notification_audit SET timestamp = ? WHERE notification_id = ?`,
+ now.Add(-20*24*time.Hour).Unix(),
+ notif.ID,
+ ); err != nil {
+ t.Fatalf("age dead-letter audit row: %v", err)
+ }
+
+ sevenDayEntries, err := nq.GetDeliveryLog(now.Add(-7*24*time.Hour), 0)
+ if err != nil {
+ t.Fatalf("GetDeliveryLog seven-day window: %v", err)
+ }
+ if len(sevenDayEntries) != 0 {
+ t.Fatalf("seven-day entries = %#v, want old dead-letter excluded", sevenDayEntries)
+ }
+
+ thirtyDayEntries, err := nq.GetDeliveryLog(now.Add(-30*24*time.Hour), 0)
+ if err != nil {
+ t.Fatalf("GetDeliveryLog thirty-day window: %v", err)
+ }
+ if len(thirtyDayEntries) != 1 ||
+ thirtyDayEntries[0].NotificationID != notif.ID ||
+ thirtyDayEntries[0].Outcome != DeliveryOutcomeDeadLetter {
+ t.Fatalf("thirty-day entries = %#v, want retained dead-letter evidence", thirtyDayEntries)
+ }
+}
+
func TestGetDeliveryLogFallsBackToOperationalLinksForLegacyRows(t *testing.T) {
nq, err := NewNotificationQueue(t.TempDir())
if err != nil {