Auditor recorded output

← All 27 packs

Waiver

Migration test never checks pre-existing rows, so it cannot catch the regression it names

buglow tests/test_store.py:10

The finding

The test is named keeps_open_events_open and its docstring says events from a database without resolved_at stay open. But it drops the events table and rebuilds it empty, then sets user_version and runs the migration. No row exists while the resolved_at migration runs. Every event is inserted with upsert_event only after the store is fully migrated. So suppose the migration back-filled resolved_at on existing rows (for example UPDATE events SET resolved_at = ..., or a non-NULL default in an ALTER/table rebuild). Every legacy open event would then silently close. This test would still pass, because it only exercises rows created under the new schema. The ack half of the claim is vacuous too. Event a is never acked, so acked_by is None holds whether or not resolve_missing touches ack columns. Net effect: a regression that closes all open events during upgrade on real homelab databases would not be detected.

    1| from __future__ import annotations
    2| 
    3| import json
    4| import sqlite3
    5| import threading
    6| from datetime import UTC, datetime, timedelta, timezone
    7| 
    8| import pytest
    9| 
   10| from argus_scout.approvals import StandingApprovals
   11| from argus_scout.events import StatusEvent
   12| from argus_scout.heartbeat import HeartbeatPolicy, reannounce_due
   13| from argus_scout.recommendations import Confidence, Recommendation, Status
   14| from argus_scout.severity import Severity
   15| from argus_scout.store import SqliteStore, Store
   16| from argus_scout.store.sqlite import MIGRATIONS, SCHEMA_VERSION, migrate
   17| 
   18| T0 = datetime(2026, 3, 1, 12, 0, tzinfo=UTC)
   19| 
   20| 
   21| def event(event_id="disk-1", *, source="nas", severity="warning", summary="Disk 3 is 91% full", **extra) -> StatusEvent:
   22|     return StatusEvent.from_dict(

The work pack

Recommendation. After rebuilding the pre-resolved_at schema and before reopening with SqliteStore, insert at least one legacy event row with raw SQL, and ack one of them (set acked_by/acked_at). After migration, assert that the legacy event appears in open_events() with resolved_at IS NULL. Then call resolve_missing on the acked legacy event and assert acked_by is still the original value.

Acceptance criteria

  • Address: Migration test never checks pre-existing rows, so it cannot catch the regression it names
  • Keep the change scoped to the cited file/symbols unless impact requires otherwise
  • After rebuilding the pre-resolved_at schema and before reopening with SqliteStore, insert at least one legacy event row with raw SQL, and ack one of them (set acked_by/acked_at). After migration, assert that the legacy event appears
  • Re-check tests/test_store.py after the fix

Status

  1. claimed
  2. resolved

The fix

1cf66db972 test: the resolved_at migration test carries legacy open and acked rows through the upgrade.

diff --git a/tests/test_store.py b/tests/test_store.pyindex 43f383a..a5277d6 100644--- a/tests/test_store.py+++ b/tests/test_store.py@@ -428,23 +428,39 @@ def test_resolved_column_migration_keeps_open_events_open(tmp_path):     """A database from before ``resolved_at``: its events stay open, and resolving one never touches the ack."""     db = tmp_path / "old.db"     before = MIGRATIONS.index(next(m for m in MIGRATIONS if "resolved_at" in m))-    with SqliteStore(db) as s:-        pass+    columns = (+        "source, event_id, fingerprint, severity, generated_at, expires_at, first_seen, last_seen, seen_count,"+        " acked_at, acked_by, last_announced_at, broadcast_count, data"+    )+    with SqliteStore(db) as s:  # the legacy rows: one open, one acked+        s.upsert_event(event("a"), now=T0)+        s.upsert_event(event("k", summary="kept"), now=T0)+        s.ack_event("nas", "k", "someone", at=T0)     conn = sqlite3.connect(db)-    conn.execute("DROP TABLE events")  # rebuild at the pre-resolved_at schema+    legacy = conn.execute(f"SELECT {columns} FROM events").fetchall()+    conn.execute("DROP TABLE events")  # rebuild at the pre-resolved_at schema, rows and all     conn.executescript(MIGRATIONS[0].split("CREATE TABLE recommendations")[0])+    conn.executemany(f"INSERT INTO events ({columns}) VALUES ({', '.join('?' * 14)})", legacy)     conn.execute(f"PRAGMA user_version = {before}")     conn.commit()     conn.close()     with SqliteStore(db) as s:         assert s.schema_version == SCHEMA_VERSION+    conn = sqlite3.connect(db)+    assert conn.execute("SELECT event_id, resolved_at FROM events ORDER BY event_id").fetchall() == [+        ("a", None),+        ("k", None),+    ]+    conn.close()     with SqliteStore(db) as s:-        s.upsert_event(event("a"), now=T0)+        assert [e.event_id for e in s.open_events(now=T0)] == ["a"]  # the legacy open event is still open         s.upsert_event(event("b", summary="other"), now=T0)-        assert s.resolve_missing("nas", ["b"], at=T0) == ["a"]-        assert s.resolve_missing("nas", ["b"], at=T0) == []  # idempotent+        assert sorted(s.resolve_missing("nas", ["b", "k"], at=T0)) == ["a"]+        assert s.resolve_missing("nas", ["b", "k"], at=T0) == []  # idempotent         assert [e.event_id for e in s.open_events(now=T0)] == ["b"]         assert s.get_entry("nas", "a").acked_by is None+        assert s.resolve_missing("nas", ["b"], at=T0) == ["k"]  # resolving the acked legacy event...+        assert s.get_entry("nas", "k").acked_by == "someone"  # ...keeps the person's ack         assert s.events_by_fingerprint(event("a").fingerprint) == []-        assert s.prune(T0 + timedelta(seconds=1))["events"] == 1+        assert s.prune(T0 + timedelta(seconds=1))["events"] == 2         assert s.get_entry("nas", "a") is None and s.get_entry("nas", "b") is not None

How it was judged

Waiver evidence waived: Test-only finding: the fix strengthens a test, so the same test runs on both trees and passes on dev's source. Verified locally by mutation: the strengthened test fails when the guarded behaviour is b

Judged 24 Nov 2026, 04:56 UTC against dev at d0c0f66.

This fix strengthens a test. The stronger test passes on dev's code as well, so there is no failure on dev for it to show. It resolved on a written waiver of at least twenty characters, recorded with the pack:

Test-only finding: the fix strengthens a test, so the same test runs on both trees and passes on dev's source. Verified locally by mutation: the strengthened test fails when the guarded behaviour is broken, where the old one passed.