From e61bd05dd2d3e6ed514bac4c780d84cba88a791b Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Fri, 6 Nov 2026 20:58:12 +0000 Subject: [PATCH] Load historical receipt fixtures as one real saved snapshot Exercise the production persistence adapter once for the 128 completed findings rather than forcing 128 unrelated durable live edits. Keep the same source facts, persisted receipts, controls and cleanup assertions, and use explicit fixture writes without multi-statement parameter assumptions. Contract-Neutral: Improve integration fixture setup only; no runtime or retention contract change. Change-source: pulse-maintainer --- internal/api/patrol_receipt_lifecycle_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/api/patrol_receipt_lifecycle_test.go b/internal/api/patrol_receipt_lifecycle_test.go index 0f4aa6bb69..e47a7c3f61 100644 --- a/internal/api/patrol_receipt_lifecycle_test.go +++ b/internal/api/patrol_receipt_lifecycle_test.go @@ -37,8 +37,9 @@ func patrolReceiptDB(t *testing.T, dir string) *sql.DB { // below through this package's production finding projector and notifier. func seedPatrolReceipt(t *testing.T, db *sql.DB, id string, start, at time.Time) { t.Helper() - _, err := db.Exec(`INSERT OR IGNORE INTO notification_destination_state(destination_key,epoch,fingerprint) VALUES('webhook:fixture','00000000-0000-4000-8000-000000000001','fixture'); - INSERT INTO notification_delivery_receipts(alert_id,alert_start_nanos,destination_key,delivery_epoch,delivered_at,delivered_nanos,severity,success_order) + _, err := db.Exec(`INSERT OR IGNORE INTO notification_destination_state(destination_key,epoch,fingerprint) VALUES('webhook:fixture','00000000-0000-4000-8000-000000000001','fixture')`) + require.NoError(t, err) + _, err = db.Exec(`INSERT INTO notification_delivery_receipts(alert_id,alert_start_nanos,destination_key,delivery_epoch,delivered_at,delivered_nanos,severity,success_order) VALUES(?,?,'webhook:fixture','00000000-0000-4000-8000-000000000001',?,?,2,1)`, id, start.UnixNano(), at.Unix(), at.UnixNano()) require.NoError(t, err) } @@ -52,7 +53,7 @@ func patrolReceiptStore(t *testing.T, dir string) *ai.FindingsStore { } func TestPatrolReceiptLifecycleSettlesOnlyPositiveTerminalFacts(t *testing.T) { - store := patrolReceiptStore(t, t.TempDir()) + store := ai.NewFindingsStore() notificationDir := t.TempDir() n := notifications.NewNotificationManagerWithDeferredQueue("", notificationDir) t.Cleanup(n.Stop) @@ -65,13 +66,20 @@ func TestPatrolReceiptLifecycleSettlesOnlyPositiveTerminalFacts(t *testing.T) { seedPatrolReceipt(t, db, alerts.PatrolFindingNotificationIDPrefix+id, start, start) } const completed = 128 + historical := make(map[string]*ai.Finding, completed) for i := 0; i < completed; i++ { id := fmt.Sprintf("settled-%03d", i) f := patrolReceiptFinding(id, start) f.ResolvedAt = &end - require.True(t, store.Add(f)) + historical[id] = f seed(id) } + // Model one saved historical snapshot, not 128 unrelated durable live + // edits. The real loader still supplies every terminal finding fact. + persistence := ai.NewFindingsPersistenceAdapter(config.NewConfigPersistence(t.TempDir())) + require.NoError(t, persistence.SaveFindings(historical)) + require.NoError(t, store.SetPersistence(persistence)) + t.Cleanup(func() { require.NoError(t, store.ForceSave()) }) for _, id := range []string{"active", "dismissed", "missing"} { if id != "missing" { require.True(t, store.Add(patrolReceiptFinding(id, start)))