From 962db4495b8e0bf99a9be8480dc85f6f6dc78feb Mon Sep 17 00:00:00 2001 From: huangruiteng <14976749+huangruiteng@users.noreply.github.com> Date: Thu, 17 Sep 2026 08:16:56 +0800 Subject: [PATCH] test(manager): keep the evidence-window fixture off the UTC date rollover `test_turn_context_reads_a_bounded_window_and_declares_sources` built six days of receipts at `datetime.now(timezone.utc)` minus `(days_ago, minutes=index)`. When the shard runs between 00:00 and 00:11 UTC the oldest row lands on a seventh UTC date, so a correct 7-day window reports seven day buckets and the assertion `len(matched_by_day) == 6` fails. PR #4591's test-shard (1) failed exactly that way at 2026-09-17T00:08:46Z. Anchor the newest receipt to 18:00 UTC on the previous UTC day, which keeps every row in the past and at least eleven minutes inside its own UTC date, so the fixture exercises the per-day and total bounds instead of the wall clock. Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com> --- tests/test_chat_manager_context.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_chat_manager_context.py b/tests/test_chat_manager_context.py index bdb3a120a5..6a95e6b6ee 100644 --- a/tests/test_chat_manager_context.py +++ b/tests/test_chat_manager_context.py @@ -107,13 +107,22 @@ def test_turn_context_reads_a_bounded_window_and_declares_sources( ): now = datetime.now(timezone.utc) # A week question needs more than today; the per-day and total bounds must - # still hold, and the newest receipt must stay fully readable. + # still hold, and the newest receipt must stay fully readable. The six day + # buckets are anchored to a fixed UTC time-of-day on the previous UTC day so + # that the per-row minute offsets cannot cross a date boundary: a wall-clock + # anchor added a seventh bucket, and failed this assertion, for shards that + # ran between 00:00 and 00:11 UTC. + newest = (now - timedelta(days=1)).replace( + hour=18, minute=0, second=0, microsecond=0 + ) rows = [] for days_ago in range(6): for index in range(12): rows.append( { - "generated_at": (now - timedelta(days=days_ago, minutes=index)).isoformat(), + "generated_at": ( + newest - timedelta(days=days_ago, minutes=index) + ).isoformat(), "goal_id": "alpha", "agent_id": "worker", "todo_id": f"todo_{days_ago}_{index}",