Skip to content

AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary

fix(store): enforce sighting finding id invariant

Hiten Shah375fd0bcc020
diff --git a/skills/last30days/scripts/store.py b/skills/last30days/scripts/store.py
index df0d5b77..39f82861 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 b74dba19..f5c1eb3a 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):