From 10d5c275da8fa22b13328ed8fb41e822d731fe80 Mon Sep 17 00:00:00 2001 From: m3taversal Date: Fri, 24 Apr 2026 16:16:03 +0100 Subject: [PATCH] fix(backfill): normalize commit_date via datetime() in time-proximity query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SQLite datetime comparison fails lexicographically across ISO-T and space-separator formats: '2026-03-27 18:00:14' < '2026-03-27T17:43:04+00:00' because space (0x20) < T (0x54). PRs merged same-day but earlier than the commit hour were silently excluded from the time-proximity cascade. Shaga's 3 stigmergic-coordination claims resolved to PR #2032 (later, wrong) instead of #2025 (earlier, correct). Fixed by wrapping both sides in datetime(), which normalizes to space-separator before comparison. Verified: all 3 Shaga claims now resolve to #2025 via git_time_proximity. No change to totals (126 originator events, 5 proximity hits) — the fix corrects WHICH PR each proximity-matched claim resolves to, not whether. Caught by Ganymede review of 1d6b515. Co-Authored-By: Claude Opus 4.7 (1M context) --- scripts/backfill-events.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/backfill-events.py b/scripts/backfill-events.py index 5b596ab..5200bc6 100644 --- a/scripts/backfill-events.py +++ b/scripts/backfill-events.py @@ -344,11 +344,18 @@ def find_pr_for_claim( ) commit_date = date_out.strip() if date_out.strip() else None if commit_date: + # git %aI returns ISO 8601 with T-separator; prs.merged_at + # uses SQLite's space-separator. Lexicographic comparison + # fails across formats (space= ? - AND merged_at <= datetime(?, '+24 hours') + AND merged_at >= datetime(?) + AND merged_at <= datetime(datetime(?), '+24 hours') AND (branch LIKE 'leo/%' OR branch LIKE 'theseus/%' OR branch LIKE 'rio/%' OR branch LIKE 'astra/%' OR branch LIKE 'vida/%' OR branch LIKE 'clay/%')