src/search/ranking.py computed result age as `(datetime.now() - dt).days`, where `dt` is parsed from a UTC-style published date with no timezone. Using local `datetime.now()` skewed the age by the host's UTC offset (off-by-up-to-a-day near boundaries), and was a latent crash: once neighbouring code becomes timezone-aware the naive/aware subtraction raises TypeError (the landmine called out in #1116). Recency is now measured against naive UTC. The scoring is also lifted out of the rank_search_results closure into a module-level, time-injectable `recency_score` so it's unit-testable, and `_utcnow_naive()` avoids `datetime.utcnow()` (removed in Python 3.14). Covered by tests/test_search_ranking_recency.py (5 cases); the existing tests/test_search_ranking.py still passes. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1.4 KiB
1.4 KiB