Files
6krrt/tests/test_classifier_cascade.py
adlee-was-taken 7777002981 fix: replace raw datetime('now') comparisons with julianday() for ISO-T column 24h windows
Two sites in src/metrics.py (classifier_degradation_warning and
_declined_for) compared observed_at against datetime('now', ...) using
string comparison. Since observed_at is stored as ISO-8601 ('T'
separator) and datetime('now') returns a space separator, the 'T' > ' '
sorting made the time-of-day component irrelevant — a 24h window
silently admitted all rows on the cutoff's calendar date.

Replace both with julianday() on both sides, matching the pattern
already used in dispatcher.py and poller.py.

Add three tests in test_classifier_cascade.py using a just_outside
timestamp (midnight of the cutoff's calendar date — the exact shape
the old comparison wrongly admitted) and an inside timestamp, proving
the fix works.

Add tests/test_sql_time_windows.py as a tripwire: scans src/ for
any ISO-T column compared against datetime('now') with an operator,
with positive controls that verify the regexes match the bad pattern
and reject the safe julianday pattern.
2026-10-05 21:21:14 -04:00

14 KiB