fix: use shared bound cron predicate

maintainer edit: make gateway execution, WebUI automation listing, and delete protection agree on the new bound cron shape. Legacy delivery payloads that carry sessionKey are excluded from the WebUI-bound automation surface.
This commit is contained in:
chengyongru
2026-06-11 23:09:21 +08:00
parent b4b6c04657
commit 3725b42e0e
5 changed files with 43 additions and 15 deletions
+2 -2
View File
@@ -184,16 +184,16 @@ async def test_session_automations_route_filters_by_webui_session(
name=name,
schedule=hourly,
message=message,
channel="websocket",
to=to,
session_key=f"websocket:{to}",
)
cron.add_job(
name="Legacy same target",
schedule=hourly,
message="Legacy job should not be treated as bound",
deliver=True,
channel="websocket",
to="abc",
session_key="websocket:abc",
)
cron.register_system_job(
CronJob(
+22
View File
@@ -65,6 +65,28 @@ def test_add_job_preserves_channel_meta_and_session_key(tmp_path) -> None:
assert reloaded.payload.session_key == "slack:C123:1234567890.123456"
def test_list_bound_agent_jobs_excludes_legacy_delivery_payloads(tmp_path) -> None:
service = CronService(tmp_path / "cron" / "jobs.json")
schedule = CronSchedule(kind="every", every_ms=60_000)
bound = service.add_job(
name="Bound",
schedule=schedule,
message="new bound job",
session_key="websocket:chat-1",
)
service.add_job(
name="Legacy same session",
schedule=schedule,
message="legacy job",
deliver=True,
channel="websocket",
to="chat-1",
session_key="websocket:chat-1",
)
assert service.list_bound_agent_jobs_for_session("websocket:chat-1") == [bound]
@pytest.mark.asyncio
async def test_channel_meta_and_session_key_survive_store_reload(tmp_path) -> None:
store_path = tmp_path / "cron" / "jobs.json"