test(incumbent): stamp the cache-rate fixture with now, not a fixed date #109
Reference in New Issue
Block a user
Delete Branch "fix/incumbent-test-time-bomb"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
tests/test_incumbent_routing.py::TestDebugLog::test_debug_log_emits_incumbent_identityhas been failing onmainwith no code change. This stamps its fixture with the current time so it cannot age out again.Why it failed
_seed_measured_cache_ratewroteobserved_at='2026-09-13T00:00:00+00:00'intoenergy_observations._measured_cache_ratesonly reads rows insideobjective.cache_rate_window_hours, which is 168 (7 days). Around 2026-09-20 the seeded rows left that window, so the incumbent was priced at the assumed rate instead of the measured one, and the test assertingmeasuredfailed.No production code is involved. The router behaves correctly: rows older than the window are supposed to be ignored.
Change
One helper in one test file:
_seed_measured_cache_ratenow stamps its rows withdatetime.now(timezone.utc).isoformat(), with a docstring note on why. The other fixed dates in the file are left alone on purpose. Theroute_decisionsseeds (2026-09-13) are read by_session_incumbent_lookup, which filters onsession_keyandidwith no time window, and themodelsrow (2026-09-01) is not time-filtered by anything this file exercises, so neither can age out the same way.Verification
tests/test_incumbent_routing.py: 26 passed (was 25 passed, 1 failed).ruff checkon the file reports the same three findings as the base commit (import order, unusedObjective, adict()call), shifted by one line. None are new.mainbefore the change, and the file went to 26 of 26 with only the timestamp changed.Why now
A red
mainhides regressions: the last several PRs have each had to say "one pre-existing failure".plans/agent-guardrails.mdalso plans averify_known_failures.txtthat currently lists this test; with this merged, that file can ship empty.🤖 Generated with Claude Code
https://claude.ai/code/session_01KkCGRantZsSwmcFpet6FTa