Skip to content

The agent that grows with you

test(cron): pin diagnostic category on Bot Chat failure notices

Teknium85b89548ff1a
diff --git a/tests/cron/test_cron_bot_chat_delivery.py b/tests/cron/test_cron_bot_chat_delivery.py
index 1e50dc84025..c098abc3e2a 100644
--- a/tests/cron/test_cron_bot_chat_delivery.py
+++ b/tests/cron/test_cron_bot_chat_delivery.py
@@ -109,7 +109,7 @@ def test_deliver_message_carries_cron_attribution(tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
captured = {}
- def fake_deliver(home, owner, message, *, delivery_id):
+ def fake_deliver(home, owner, message, *, delivery_id, notification_category="result"):
captured["message"] = message
return {"status": "settled", "message": message, "delivery_id": delivery_id}
@@ -121,6 +121,28 @@ def test_deliver_message_carries_cron_attribution(tmp_path, monkeypatch):
assert "the payload" in captured["message"]
+def test_failure_notice_reaches_the_owner_as_a_diagnostic(tmp_path, monkeypatch):
+ """A delivered ``for_failure`` notice keeps ``notification_category="diagnostic"`` through
+ the owner transport (R1/R2 minor: the category was accepted but dropped)."""
+ from tools import bot_live_delivery as mailbox
+
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ seen = []
+
+ def fake_deliver(home, owner, message, *, delivery_id, notification_category="result"):
+ seen.append(notification_category)
+ return {"status": "settled", "message": message, "delivery_id": delivery_id,
+ "notification_category": notification_category}
+
+ monkeypatch.setattr(mailbox, "find_canonical_live_owner", lambda home: {"session_id": "local-bot"})
+ monkeypatch.setattr(mailbox, "deliver_to_live_owner", fake_deliver)
+ monkeypatch.setattr("gateway.warning_notifications.warning_notifications_enabled", lambda *a, **k: True)
+ job = {"id": "j1", "name": "n", "execution_id": "r1"}
+ assert _deliver_to_bot_chat(job, "boom", "", for_failure=True) is None
+ assert _deliver_to_bot_chat(dict(job, execution_id="r2"), "ok", "") is None
+ assert seen == ["diagnostic", "result"]
+
+
def test_deliver_without_authority_is_unverified_not_a_second_writer(tmp_path, monkeypatch):
"""No running authority → explicit unverified status; never a local CLI turn."""
import subprocess
@@ -144,7 +166,7 @@ def test_failure_notice_to_a_profile_hiding_warnings_is_suppressed_not_sent(tmp_
(tmp_path / "config.yaml").write_text("display: {suppress_warning_notifications: true}\n")
admitted = []
- def fake_deliver(home, owner, message, *, delivery_id):
+ def fake_deliver(home, owner, message, *, delivery_id, notification_category="result"):
admitted.append(message)
return {"status": "queued", "message": message, "delivery_id": delivery_id}
diff --git a/tests/cron/test_cron_delivery_redaction.py b/tests/cron/test_cron_delivery_redaction.py
index 903263631b6..23e1a21f76f 100644
--- a/tests/cron/test_cron_delivery_redaction.py
+++ b/tests/cron/test_cron_delivery_redaction.py
@@ -60,7 +60,7 @@ def _deliver_bot_chat(job: dict, content: str) -> str:
captured = {}
- def _fake_deliver(home, owner, message, *, delivery_id):
+ def _fake_deliver(home, owner, message, *, delivery_id, notification_category="result"):
captured["message"] = message
return {"status": "settled", "message": message, "delivery_id": delivery_id}