Make delivery and integration failures explicit

Persist reminder presentations and retry state, atomically complete collapsed deliveries, fall back across away reaches, and block permanent failures visibly (V-715, V-678). Fail closed when enabled integrations lack credentials and keep remote arms explicitly dark (V-691). Give mavweb one sanitized, request-correlated error contract (V-689). Owner explicitly requested direct commits to master.
This commit is contained in:
2026-08-13 02:50:59 +04:00
parent da9114b623
commit 35c6ff5a71
67 changed files with 3174 additions and 477 deletions
+33
View File
@@ -47,3 +47,36 @@ func TestGatherStateLoadsPrefixFamilies(t *testing.T) {
t.Fatal("the rule must fire on a gathered per-monitor fact")
}
}
func TestCollapseRemindersKeepsPersistedBundleSeparateFromNewDueRows(t *testing.T) {
now := time.Date(2026, 8, 13, 8, 0, 0, 0, time.UTC)
due := []store.Reminder{
{ID: 1, FireTs: now, NextFireTs: now, Payload: "one", DeliveryGroup: "reminder:old", PhraseBody: "old bundle"},
{ID: 2, FireTs: now.Add(time.Second), NextFireTs: now.Add(time.Second), Payload: "two", DeliveryGroup: "reminder:old", PhraseBody: "old bundle"},
{ID: 3, FireTs: now.Add(2 * time.Second), NextFireTs: now.Add(2 * time.Second), Payload: "three"},
}
got := collapseReminders(due)
if len(got) != 2 {
t.Fatalf("deliveries = %d, want old bundle plus new reminder: %+v", len(got), got)
}
if got[0].ID != 0 || len(got[0].Collapsed) != 2 || got[0].Collapsed[0].ID != 1 || got[0].Collapsed[1].ID != 2 {
t.Fatalf("old persisted bundle was changed: %+v", got[0])
}
if got[1].ID != 3 || len(got[1].Collapsed) != 0 {
t.Fatalf("new reminder joined the old phrase: %+v", got[1])
}
}
func TestCollapseRemindersMakesOneBundleForNewDueRows(t *testing.T) {
now := time.Date(2026, 8, 13, 8, 0, 0, 0, time.UTC)
due := []store.Reminder{
{ID: 1, FireTs: now, NextFireTs: now, Payload: "one"},
{ID: 2, FireTs: now, NextFireTs: now, Payload: "two"},
{ID: 3, FireTs: now, NextFireTs: now, Payload: "three"},
}
got := collapseReminders(due)
if len(got) != 1 || got[0].ID != 0 || len(got[0].Collapsed) != 3 {
t.Fatalf("new reminders did not collapse together: %+v", got)
}
}