fix(integrations): skip the ledger page when the watchdog announced it

A failure streak reaching the alert threshold paged the operator even
when the watchdog had already announced an open incident for the same
connection. The ledger now checks for that announced incident first,
stamps the streak as announced and sends nothing; the watchdog's
recovery note still ends it.
This commit is contained in:
Marc-André Bombeck committed 2026-10-15 16:38:12 +02:00
1 parent 3e95755c3b
commit 0e5afe76a4
3 files changed
+103 -1

No files matched your search

@@ -361,6 +361,35 @@ describe("what pages and what does not", () => {
});
});
describe("the ledger and the watchdog page once between them", () => {
it("does not page a failure streak the watchdog already announced for the connection", async () => {
await prisma().integrationWatch.create({
data: {
userId: USER,
integration: "oura",
silentSince: new Date(NOW.getTime() - 3 * DAY),
incidentReason: "unexpected_silence",
incidentOpenedAt: new Date(NOW.getTime() - DAY),
alertedAt: new Date(NOW.getTime() - DAY),
},
});
for (let i = 0; i < 3; i++) {
await recordSyncFailure({
userId: USER,
integration: "oura",
kind: "transient",
message: "Oura error: 503",
errorCode: "503",
});
}
expect(dispatchNotification).not.toHaveBeenCalled();
const ledger = await prisma().integrationStatus.findUniqueOrThrow({
where: { userId_integration: { userId: USER, integration: "oura" } },
});
expect(ledger.alertedAt).not.toBeNull();
});
});
describe("recent-call ring", () => {
it("keeps the newest ten attempts, newest first, without any message text", async () => {
for (let i = 0; i < 7; i++) {