From 9993fc511fc6eb19b82b0d516a0e1813f5072afc Mon Sep 17 00:00:00 2001 From: DJC1412 <108855841+DJC1412@users.noreply.github.com> Date: Sun, 20 Sep 2026 15:56:15 +0800 Subject: [PATCH] test(lark): date the manager-context fixtures from the run Two manager-context tests carried 2026-09-13 timestamps while retention drops material older than seven days measured against the wall clock, so both turned red on their own seven days later and took every open pull request with them. CI brackets the boundary: the 05:03Z main run passed this file, the 06:43Z main run failed it, with no merge in between. The helper resolves to whole minutes so the captured material and the expected payload still compare equal, and the context keeps preceding the turn that consumes it. Production code is untouched. Signed-off-by: DJC1412 <108855841+DJC1412@users.noreply.github.com> --- .../test_lark_goal_topic_runtime.py | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/extensions/test_lark_goal_topic_runtime.py b/tests/extensions/test_lark_goal_topic_runtime.py index a5e664726..c97b4482b 100644 --- a/tests/extensions/test_lark_goal_topic_runtime.py +++ b/tests/extensions/test_lark_goal_topic_runtime.py @@ -5,6 +5,7 @@ import subprocess import threading from collections.abc import Mapping +from datetime import UTC, datetime, timedelta from pathlib import Path from typing import Any @@ -24,6 +25,20 @@ from loopx.extensions.lark.goal_topic_connections import connect_lark_goal_topic +def _fixture_time(minutes_ago: int) -> str: + """One hour of topic history, placed relative to the run. + + Manager context is bounded by MANAGER_CONTEXT_MAX_AGE, so a literal date in + these fixtures turns the calendar into a test dependency. Whole-minute + resolution keeps repeated calls equal, as the fixed timestamps were. + """ + + moment = (datetime.now(UTC) - timedelta(minutes=minutes_ago)).replace( + second=0, microsecond=0 + ) + return moment.isoformat().replace("+00:00", "Z") + + def test_goal_topic_runtime_exposes_the_inbox_bridge() -> None: module = importlib.import_module("loopx.extensions.lark.goal_topic_runtime") @@ -342,7 +357,7 @@ def answer(route: Any, text: str) -> str: "message_id": "om_context_only", "chat_id": "oc_public_fixture", "root_id": "om_unrelated_thread", - "create_time": "2026-09-13T05:59:00Z", + "create_time": _fixture_time(61), "content": "先把这个背景放在这里", "mentions": [], "sender_type": "user", @@ -363,7 +378,7 @@ def answer(route: Any, text: str) -> str: "message_id": "om_context_only", "chat_id": "oc_public_fixture", "root_id": "om_unrelated_thread", - "create_time": "2026-09-13T05:59:00Z", + "create_time": _fixture_time(61), "content": "先把这个背景放在这里", "mentions": [], "sender_type": "user", @@ -387,7 +402,7 @@ def answer(route: Any, text: str) -> str: "message_id": "om_authorized", "chat_id": "oc_public_fixture", "root_id": "om_unrelated_thread", - "create_time": "2026-09-13T06:00:00Z", + "create_time": _fixture_time(60), "content": "@linkmacbot 结合上文给结论", "mentions": [{"id": "cli_public_fixture"}], "sender_type": "user", @@ -404,7 +419,7 @@ def answer(route: Any, text: str) -> str: assert route["context_materials"] == [ { "message_id": "om_context_only", - "create_time": "2026-09-13T05:59:00Z", + "create_time": _fixture_time(61), "content": "先把这个背景放在这里", } ] @@ -450,7 +465,7 @@ def decision(**options: Any) -> dict[str, Any]: "message_id": "om_invalid_authority", "chat_id": "oc_public_fixture", "root_id": "om_topic_alpha", - "create_time": "2026-09-13T06:00:00Z", + "create_time": _fixture_time(60), "content": "continue", "mentions": [], "sender_type": "user", @@ -516,7 +531,7 @@ def provider_runner( { "message_id": "om_old_authorized", "root_id": "om_topic_alpha", - "create_time": "2026-09-13T05:59:00Z", + "create_time": _fixture_time(61), "content": "@linkmacbot 历史请求只作背景", "mentions": [{"id": "cli_public_fixture"}], "sender_type": "user", @@ -545,7 +560,7 @@ def answer(route: Mapping[str, Any], _text: str) -> str: "message_id": "om_current_authorized", "chat_id": "oc_public_fixture", "root_id": "om_topic_alpha", - "create_time": "2026-09-13T06:00:00Z", + "create_time": _fixture_time(60), "content": "@linkmacbot 结合刚才内容回答", "mentions": [{"id": "cli_public_fixture"}], "sender_type": "user",