From 375fd0bcc0201128c8ac60033a7849780ff967a9 Mon Sep 17 00:00:00 2001 From: Hiten Shah Date: Sat, 16 May 2026 22:57:32 -0700 Subject: [PATCH] fix(store): enforce sighting finding id invariant --- skills/last30days/scripts/store.py | 2 +- tests/test_store.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/skills/last30days/scripts/store.py b/skills/last30days/scripts/store.py index df0d5b7..39f8286 100644 --- a/skills/last30days/scripts/store.py +++ b/skills/last30days/scripts/store.py @@ -163,7 +163,7 @@ MIGRATIONS: Dict[int, str] = { 2: """ CREATE TABLE IF NOT EXISTS finding_sightings ( id INTEGER PRIMARY KEY, - finding_id INTEGER REFERENCES findings(id) ON DELETE CASCADE, + finding_id INTEGER NOT NULL REFERENCES findings(id) ON DELETE CASCADE, run_id INTEGER REFERENCES research_runs(id) ON DELETE CASCADE, topic_id INTEGER REFERENCES topics(id) ON DELETE CASCADE, source TEXT NOT NULL, diff --git a/tests/test_store.py b/tests/test_store.py index b74dba1..f5c1eb3 100644 --- a/tests/test_store.py +++ b/tests/test_store.py @@ -451,9 +451,14 @@ def test_init_db_creates_finding_sightings_table(temp_db): table = conn.execute( "SELECT name FROM sqlite_master WHERE type='table' AND name='finding_sightings'" ).fetchone() + columns = { + row[1]: row[3] + for row in conn.execute("PRAGMA table_info(finding_sightings)").fetchall() + } conn.close() assert table is not None + assert columns["finding_id"] == 1 def test_store_findings_records_sightings_for_new_findings(temp_db):