@@ -106,10 +106,10 @@ class TestIngestBusEvents:
106106 def test_ingest_from_bus_db (self , storage , bus_db ):
107107 """Test basic ingestion from an event-bus database."""
108108 with patch ("agent_session_analytics.bus_ingest.EVENT_BUS_DB" , bus_db ):
109- result = ingest_bus_events (storage , days = 7 )
109+ result = ingest_bus_events (storage )
110110
111111 assert result ["status" ] == "ok"
112- assert result ["events_ingested" ] == 4 # 4 within 7 days
112+ assert result ["events_ingested" ] == 5 # First run gets ALL events
113113
114114 def test_incremental_ingestion (self , storage , bus_db ):
115115 """Test that second ingestion only picks up new events."""
@@ -160,11 +160,11 @@ def test_missing_db_skips(self, storage):
160160 def test_raw_events_stored (self , storage , bus_db ):
161161 """Test that raw event JSON is stored in raw_bus_events table."""
162162 with patch ("agent_session_analytics.bus_ingest.EVENT_BUS_DB" , bus_db ):
163- ingest_bus_events (storage , days = 7 )
163+ ingest_bus_events (storage )
164164
165165 # Check raw_bus_events table
166166 rows = storage .execute_query ("SELECT * FROM raw_bus_events ORDER BY event_id" )
167- assert len (rows ) == 4 # 4 within 7 days
167+ assert len (rows ) == 5 # First run gets ALL events
168168
169169 # Verify raw JSON is parseable and contains original fields
170170 raw = json .loads (rows [0 ]["entry_json" ])
@@ -187,19 +187,20 @@ def test_raw_events_dedup(self, storage, bus_db):
187187 def test_repo_extraction (self , storage , bus_db ):
188188 """Test that repo is correctly extracted from channel."""
189189 with patch ("agent_session_analytics.bus_ingest.EVENT_BUS_DB" , bus_db ):
190- ingest_bus_events (storage , days = 7 )
190+ ingest_bus_events (storage )
191191
192192 rows = storage .execute_query (
193193 "SELECT repo FROM bus_events WHERE event_type = 'gotcha_discovered' ORDER BY event_id"
194194 )
195195 assert rows [0 ]["repo" ] == "dotfiles"
196196
197- def test_full_history_ingestion (self , storage , bus_db ):
198- """Test ingestion with large days window gets all events ."""
197+ def test_first_run_ignores_days_param (self , storage , bus_db ):
198+ """Test that first run ingests ALL events regardless of days param ."""
199199 with patch ("agent_session_analytics.bus_ingest.EVENT_BUS_DB" , bus_db ):
200- result = ingest_bus_events (storage , days = 30 )
200+ # Even with days=1, first run should get all 5 events (including 10-day-old one)
201+ result = ingest_bus_events (storage , days = 1 )
201202
202- assert result ["events_ingested" ] == 5 # All events including old one
203+ assert result ["events_ingested" ] == 5
203204
204205
205206class TestQueryBusEvents :
@@ -209,7 +210,7 @@ class TestQueryBusEvents:
209210 def storage_with_bus_events (self , storage , bus_db ):
210211 """Storage with bus events ingested."""
211212 with patch ("agent_session_analytics.bus_ingest.EVENT_BUS_DB" , bus_db ):
212- ingest_bus_events (storage , days = 30 )
213+ ingest_bus_events (storage )
213214 return storage
214215
215216 def test_query_all (self , storage_with_bus_events ):
0 commit comments