From f769eb4a35f31ce1c4ed62c6ba7f796723f9fc93 Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Sat, 3 Oct 2026 10:43:19 -0400 Subject: [PATCH] test(incumbent): stamp the cache-rate fixture with now, not a fixed date _seed_measured_cache_rate wrote observed_at='2026-09-13T00:00:00+00:00', but _measured_cache_rates only reads rows inside objective.cache_rate_window_hours (168). Once the date aged out of that window, around 2026-09-20, the incumbent was priced at the assumed rate instead of the measured one and test_debug_log_emits_incumbent_identity failed on main, with no code change. Stamp the seeded rows with the current time so the fixture cannot age out. The file goes from 25 of 26 to 26 of 26; the full suite is 2544 passed. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01KkCGRantZsSwmcFpet6FTa --- tests/test_incumbent_routing.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_incumbent_routing.py b/tests/test_incumbent_routing.py index 8057368..bf03738 100644 --- a/tests/test_incumbent_routing.py +++ b/tests/test_incumbent_routing.py @@ -12,6 +12,7 @@ The database tests use the same offline temp-DB pattern as import sqlite3 import tempfile +from datetime import datetime, timezone from pathlib import Path import pytest @@ -469,16 +470,21 @@ def _seed_measured_cache_rate(conn, provider, model_id, objective.incumbent_rate_min_observations defaults to 25, so we seed enough rows to clear the floor. + + Rows are stamped "now", not a fixed date: _measured_cache_rates only reads + rows inside objective.cache_rate_window_hours (168), so a literal date + ages out of the window and the incumbent silently falls back to the + assumed rate. That is how this fixture started failing on 2026-09-20. """ + observed_at = datetime.now(timezone.utc).isoformat() for _ in range(observations): conn.execute( """INSERT INTO energy_observations ( model_id, provider, task_category, prompt_tokens, completion_tokens, cached_prompt_tokens, cached_tokens_source, observed_at - ) VALUES (?, ?, 'general', ?, 500, ?, 'reported', - '2026-09-13T00:00:00+00:00')""", - (model_id, provider, prompt_tokens, cached_tokens), + ) VALUES (?, ?, 'general', ?, 500, ?, 'reported', ?)""", + (model_id, provider, prompt_tokens, cached_tokens, observed_at), ) conn.commit() -- 2.49.1