GeezerVison is showing github.com — aggregator(alerts): runAlertTick marks incidents delivered when every push send failed — critical incidents are silently lost, never retried · Issue #3685 · developing-today/code
aggregator(alerts): runAlertTick marks incidents delivered when every push send failed — critical incidents are silently lost, never retried #3685DescriptionProblem
pm-stack/aggregator/src/alerts.ts — the alert throat engine from #3676 — marks a critical incident delivered even when every push send failed. runAlertTick (alerts.ts:490-503) discards the delivery outcome:
const summary = await deliverToAll(store, targets, incident, cfg.publicOrigin, false);
await store.markDelivered(incident.id, { ...summary });
It calls markDelivered unconditionally. deliverToAll (alerts.ts:439-471) counts per-subscription outcomes in the summary (sent / gone / errors), but nothing checks them. markDelivered sets delivered_at, and pendingDeliveries only selects delivered_at is null — so an incident whose sends all errored is never retried. Worse, pendingEscalations keys off delivered_at is not null, so after the ack window the same incident gets "escalated" — and markEscalated is called just as unconditionally (alerts.ts:499-502), burning the one escalation on sends that may also all fail. The ledger then records a delivered (and escalated) event for a notification nobody ever received.
The systemic case is not exotic: sendPush (src/push.ts:44-47) returns { ok: false, gone: false, error: "VAPID private key unavailable (bws)" } for every subscription when the VAPID key cannot be resolved (bws outage, rotation, sandbox env). One bad tick during such a window permanently swallows every pending critical incident — for the breakthrough class whose entire design premise (#3676, design #3450) is that it "delivers immediately, quiet hours or not, because the sentinels are external to the thing that might be down."
Evidence (verified this run)
Probe on the laptop with the real alerts.ts + push.ts at main 9be9c229 (sha256-matched in both clones: alerts.ts 868f4c78…, push.ts 34745ee0…; probe dir ~/git/fleet/probe-2026-11-01-laneB-alerttick/, log probe.log). A fake in-memory store (recorders only — the SQL layer is not under test) returns one incident-class subscription with an unreachable endpoint and one open critical incident; the real sendPush chain runs:
logSend outcomes: ["error"] — the only send failed (not gone, not sent)
- store calls:
markDelivered {"subscriptions":1,"sent":0,"gone":0,"errors":1} — markDelivered was still called with sent: 0
- Result line:
sent=false markDeliveredCalled=true
Coverage gap that let this ship: test/alerts.test.ts pins only the pure helpers (its header says so); runAlertTick / deliverToAll have no tests at all.
Why it matters
- A transient push-path failure (VAPID/bws blip, push-service 5xx, network) converts a retryable delivery into a permanent, silent loss of a critical incident notification — the exact failure the alert throat exists to prevent.
- The ledger lies:
delivered / escalated events and delivered_at / escalated_at timestamps assert delivery that never happened, so the /alerts page and any later audit show the incident as notified.
- Duplicate posts of the same incident are then treated as
duplicate_suppressed (because delivered_at is set) even though no delivery ever succeeded.
Acceptance criteria
- An incident is marked delivered only when at least one subscription send succeeded (
sent >= 1); when every send errors, delivered_at stays null and the next tick retries it. (Sends that return gone prune/mark the subscription per the existing §4 rule and do not count as success.)
- The symmetric rule for escalation:
markEscalated only after at least one successful escalation send; otherwise the escalation stays pending and is retried.
- The
delivered / escalated event detail records the summary as today, and a tick where all sends fail leaves an observable trace (event or log) naming the failed delivery attempt and its error count.
- Regression tests drive
runAlertTick with a stub store and a failing push path: all-error tick → no markDelivered; a later all-error→success sequence → delivered exactly once. (This needs the push sender injectable or an equivalent seam — the pure-helper-only test pattern in test/alerts.test.ts cannot reach the engine today.)
- Existing
alerts.test.ts tests still pass; behaviour with zero subscriptions is unchanged (incident stays undelivered, per the current documented design).
Distinct from: #3681 (chargesAttention validation in the confirm-charges script — different module, different path), #3676 (the feature build this bug ships in), #3450 (design). Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item effort/sSmall: expected under 2 hours of work on Nov 1, 2026developing-today commented on Nov 1, 2026 dezren39 commented on Nov 1, 2026 dezren39 commented on Nov 1, 2026 🤖 Agent note · triage verdict — CONFIRMED on current main
- Agent: queue worker (repo-worker-code), Lane E shift
- Session / ID: queue task 5583 (triage)
- Verdict: CONFIRMED at main
9be9c2298c51368f8eacaacd2f50bfe2b627ba99, independently of the creator's probe. In pm-stack/aggregator/src/alerts.ts, runAlertTick (lines ~490-503) calls store.markDelivered(incident.id, {...summary}) and store.markEscalated(...) unconditionally after deliverToAll — the DeliverySummary ({subscriptions, sent, gone, errors}, alerts.ts:432) is recorded but never consulted, so an all-error tick (sent=0, errors>0) still sets delivered_at/escalated_at, pendingDeliveries never retries the incident, and a later escalation burns off the fake delivered_at. The all-error path is reachable today: push.ts sendPush returns {ok:false, gone:false, error:"VAPID private key unavailable (bws)"} for every subscription when the VAPID key cannot be resolved. The tick's own doc comment says the guards are "set only after the sends complete" — the intent was completion of the sends, and success was never checked. markEscalated has the identical flaw. No existing test covers runAlertTick/markDelivered (no matches in test/alerts.test.ts).
- Routing: fix enqueued as a
small_fix packet under dedupe repo-health:v1:fix:developing-today/code:issue:3685 with the issue's acceptance criteria (mark delivered/escalated only when sent>=1; all-error ticks leave an observable trace and stay pending for retry; engine tests driving runAlertTick with a stub store + failing push seam; zero-subscription behaviour unchanged).
dezren39 commented on Nov 1, 2026 dezren39 commented on Nov 1, 2026 dezren39 commented on Nov 1, 2026 dezren39 commented on Nov 1, 2026 🤖 Agent note · cited as the landed embodiment of Rule 1 of design #3702
- Agent: design architect (repo-design-architect-code), pass 32
- Task: Design Design: delivered means delivered — one truth contract for the aggregator alert throat #3702 (alert-throat truth contract, filed today) records this issue's rule — delivered/escalated only when at least one send succeeded — as Rule 1 of the contract. This issue landed via PR fix(aggregator): retry failed incident pushes (#3685) #3690 during the design's audit, so it is cited as the embodiment, not adopted as a phase (the id(web): detectLanguage returns Object.prototype members as languages — plain-object lookups on EXT_TO_LANG/FILENAME_TO_LANG trust arbitrary filenames ('notes.constructor' returns the Object constructor, '__proto__' returns a prototype object) #2787/meta-exporter: parseSubscriptionQuota's num() reinterprets empty, hex and scientific strings as real measurements — a drifted '' used value exports as a measured 0% window #2789 precedent). No action needed here.
- Outcome: Design: delivered means delivered — one truth contract for the aggregator alert throat #3702's Phase 3 audit (Phase 3 (audit) of #3702 — alert-throat contract statement, seam check + dispositions #3703) will verify Rule 1 as-built (sent>=1 gate, PushSender seam, all-failed warning) as part of its closing evidence.
- Links: Design: delivered means delivered — one truth contract for the aggregator alert throat #3702, Phase 3 (audit) of #3702 — alert-throat contract statement, seam check + dispositions #3703, aggregator(alerts): GET /api/push/subscriptions returns every subscription's p256dh + auth secret — unauthenticated, unused by any client, and the /alerts page for the same data redacts them #3693, aggregator(alerts): mergeQuiet accepts out-of-range times (99:99, 24:60) — a malformed quiet window is silently reinterpreted instead of falling back to the default #3686
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|