feat(governance): 新增 Agent Telegram digest policy
All checks were successful
CD Pipeline / tests (push) Successful in 1m28s
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / build-and-deploy (push) Successful in 4m8s
CD Pipeline / post-deploy-checks (push) Successful in 1m55s

This commit is contained in:
Your Name
2026-06-11 14:34:49 +08:00
parent 0d536f1406
commit 785494cb77
15 changed files with 1683 additions and 31 deletions

View File

@@ -58,6 +58,9 @@ from src.services.ai_agent_deployment_layout import (
from src.services.ai_agent_proactive_operations_contract import (
load_latest_ai_agent_proactive_operations_contract,
)
from src.services.ai_agent_telegram_action_required_digest_policy import (
load_latest_ai_agent_telegram_action_required_digest_policy,
)
from src.services.ai_agent_tool_adoption_approval_package import (
load_latest_ai_agent_tool_adoption_approval_package,
)
@@ -645,6 +648,35 @@ async def get_agent_tool_adoption_approval_package() -> dict[str, Any]:
) from exc
@router.get(
"/agent-telegram-action-required-digest-policy",
response_model=dict[str, Any],
summary="取得 AI Agent Telegram action-required digest policy",
description=(
"讀取最新已提交的 AI Agent Telegram action-required digest policy"
"此端點只回傳 critical / action-required / failure-only digest 規則與 redaction 邊界,"
"不送 Telegram、不寫 Telegram Gateway queue、不改 Alertmanager route / receiver、"
"不寫 AwoooP event、不觸發 workflow、不查外部掃描、不執行 runtime、不讀取 secret、"
"不回傳工作視窗對話內容。"
),
)
async def get_agent_telegram_action_required_digest_policy() -> dict[str, Any]:
"""Return the latest read-only AI Agent Telegram action-required digest policy."""
try:
return await asyncio.to_thread(load_latest_ai_agent_telegram_action_required_digest_policy)
except FileNotFoundError as exc:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=str(exc),
) from exc
except (json.JSONDecodeError, ValueError) as exc:
logger.error("ai_agent_telegram_action_required_digest_policy_invalid", error=str(exc))
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="AI Agent Telegram action-required digest policy 無效",
) from exc
@router.get(
"/runtime-surface-inventory",
response_model=dict[str, Any],

View File

@@ -0,0 +1,289 @@
"""
AI Agent Telegram action-required digest policy snapshot.
Loads the latest committed, read-only policy for deciding which AI Agent,
version, tool-adoption, scanner, and upgrade signals may become
action-required Telegram digest candidates. This module never sends Telegram
messages, writes Telegram Gateway queues, changes Alertmanager receivers,
triggers workflows, reads secrets, or exposes work-window transcripts.
"""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
from src.services.snapshot_paths import default_evaluations_dir
_DEFAULT_EVALUATIONS_DIR = default_evaluations_dir(Path(__file__))
_SNAPSHOT_PATTERN = "ai_agent_telegram_action_required_digest_policy_*.json"
_SCHEMA_VERSION = "ai_agent_telegram_action_required_digest_policy_v1"
_RUNTIME_AUTHORITY = "policy_only_no_telegram_send_or_route_change"
_TRANSCRIPT_MARKERS = {
"# In app browser",
"My request for Codex",
"Current URL:",
"AGENTS.md instructions",
"<environment_context>",
"批准!繼續",
}
def load_latest_ai_agent_telegram_action_required_digest_policy(
evaluations_dir: Path | None = None,
) -> dict[str, Any]:
"""Load the newest committed AI Agent Telegram digest policy."""
directory = evaluations_dir or _DEFAULT_EVALUATIONS_DIR
candidates = sorted(directory.glob(_SNAPSHOT_PATTERN))
if not candidates:
raise FileNotFoundError(
f"no AI Agent Telegram action-required digest policy snapshots found in {directory}"
)
latest = candidates[-1]
with latest.open(encoding="utf-8") as handle:
payload = json.load(handle)
if not isinstance(payload, dict):
raise ValueError(f"{latest}: expected JSON object")
_require_schema(payload, _SCHEMA_VERSION, str(latest))
_require_read_only_boundaries(payload, str(latest))
_require_rollup_consistency(payload, str(latest))
_require_success_noise_suppression(payload, str(latest))
_require_digest_gate_safety(payload, str(latest))
_require_message_redaction(payload, str(latest))
_require_no_plaintext_secret_payload_keys(payload, str(latest))
_require_no_conversation_transcript_content(payload, str(latest))
return payload
def _require_schema(payload: dict[str, Any], expected: str, label: str) -> None:
actual = payload.get("schema_version")
if actual != expected:
raise ValueError(f"{label}: expected schema_version={expected}, got {actual!r}")
def _require_read_only_boundaries(payload: dict[str, Any], label: str) -> None:
program_status = payload.get("program_status") or {}
if program_status.get("read_only_mode") is not True:
raise ValueError(f"{label}: program_status.read_only_mode must be true")
if program_status.get("runtime_authority") != _RUNTIME_AUTHORITY:
raise ValueError(f"{label}: runtime_authority must stay {_RUNTIME_AUTHORITY}")
operation_boundaries = payload.get("operation_boundaries") or {}
if operation_boundaries.get("read_only_policy_allowed") is not True:
raise ValueError(f"{label}: read_only_policy_allowed must be true")
blocked_operation_flags = {
"telegram_direct_send_allowed",
"telegram_test_message_allowed",
"telegram_gateway_queue_write_allowed",
"alertmanager_route_change_allowed",
"telegram_receiver_change_allowed",
"awooop_event_write_allowed",
"workflow_trigger_allowed",
"external_scan_allowed",
"runtime_execution_allowed",
"secret_plaintext_allowed",
"conversation_transcript_allowed",
}
allowed_operation_flags = sorted(
flag
for flag in blocked_operation_flags
if operation_boundaries.get(flag) is not False
)
if allowed_operation_flags:
raise ValueError(
f"{label}: operation boundaries must remain false: {allowed_operation_flags}"
)
approval_boundaries = payload.get("approval_boundaries") or {}
allowed_approval_flags = sorted(
flag for flag, value in approval_boundaries.items() if value is not False
)
if allowed_approval_flags:
raise ValueError(
f"{label}: approval boundaries must remain false: {allowed_approval_flags}"
)
def _require_rollup_consistency(payload: dict[str, Any], label: str) -> None:
rules = payload.get("digest_rules") or []
channels = payload.get("digest_channels") or []
categories = payload.get("trigger_categories") or []
rollups = payload.get("rollups") or {}
expected_counts = {
"rule_count": len(rules),
"channel_count": len(channels),
"trigger_category_count": len(categories),
}
mismatched = {
key: {"expected": expected, "actual": rollups.get(key)}
for key, expected in expected_counts.items()
if rollups.get(key) != expected
}
if mismatched:
raise ValueError(f"{label}: rollup counts must match payload sections: {mismatched}")
by_decision: dict[str, int] = {}
for rule in rules:
decision = str(rule.get("decision"))
by_decision[decision] = by_decision.get(decision, 0) + 1
if rollups.get("by_decision") != by_decision:
raise ValueError(f"{label}: rollups.by_decision must match digest rule decisions")
expected_lists = {
"action_required_rule_ids": {
rule.get("rule_id")
for rule in rules
if rule.get("decision") == "draft_action_required_digest"
},
"failure_escalation_rule_ids": {
rule.get("rule_id")
for rule in rules
if rule.get("decision") == "draft_failure_escalation_digest"
},
"suppressed_success_rule_ids": {
rule.get("rule_id")
for rule in rules
if rule.get("decision") == "suppress_success_noise"
},
}
for key, expected in expected_lists.items():
if set(rollups.get(key) or []) != expected:
raise ValueError(f"{label}: rollups.{key} mismatch")
zero_rollups = {
"telegram_direct_send_allowed_count",
"telegram_gateway_queue_write_allowed_count",
"route_change_allowed_count",
"conversation_transcript_allowed_count",
}
nonzero = sorted(key for key in zero_rollups if rollups.get(key) != 0)
if nonzero:
raise ValueError(f"{label}: digest safety counters must remain 0: {nonzero}")
def _require_success_noise_suppression(payload: dict[str, Any], label: str) -> None:
noisy_channels = [
channel.get("channel_id")
for channel in payload.get("digest_channels") or []
if channel.get("success_immediate_allowed") is not False
or channel.get("direct_send_allowed") is not False
]
if noisy_channels:
raise ValueError(f"{label}: digest channels must suppress success/direct send: {noisy_channels}")
noisy_rules = [
rule.get("rule_id")
for rule in payload.get("digest_rules") or []
if rule.get("signal_state") in {"success", "verified"}
and rule.get("decision") != "suppress_success_noise"
]
if noisy_rules:
raise ValueError(f"{label}: success/verified signals must suppress digest noise: {noisy_rules}")
summary_policy = str(payload.get("rate_limit_policy", {}).get("success_policy") or "")
if "成功" not in summary_policy or "不得" not in summary_policy or "Telegram" not in summary_policy:
raise ValueError(f"{label}: rate_limit_policy.success_policy must block success spam")
def _require_digest_gate_safety(payload: dict[str, Any], label: str) -> None:
unsafe_rules = [
rule.get("rule_id")
for rule in payload.get("digest_rules") or []
if rule.get("decision") in {
"draft_action_required_digest",
"draft_failure_escalation_digest",
}
and (
not rule.get("required_evidence")
or rule.get("telegram_direct_send_allowed") is not False
or rule.get("requires_openclaw_review") is not True
)
]
if unsafe_rules:
raise ValueError(f"{label}: digest candidate rules need evidence and OpenClaw gate: {unsafe_rules}")
immediate_non_failure = [
rule.get("rule_id")
for rule in payload.get("digest_rules") or []
if rule.get("decision") == "draft_failure_escalation_digest"
and rule.get("signal_state") not in {"failed", "blocked", "critical"}
]
if immediate_non_failure:
raise ValueError(f"{label}: failure escalation digest must stay failure-only: {immediate_non_failure}")
def _require_message_redaction(payload: dict[str, Any], label: str) -> None:
template = payload.get("message_template_contract") or {}
required_fields = set(template.get("required_fields") or [])
required = {
"stage",
"severity",
"target_id",
"evidence_ref",
"blocked_reason",
"next_action",
"owner_agent",
"approval_gate",
}
if not required.issubset(required_fields):
raise ValueError(f"{label}: message_template_contract.required_fields missing digest context")
forbidden_fields = set(template.get("forbidden_fields") or [])
required_forbidden = {
"secret_value",
"token",
"authorization_header",
"work_window_transcript",
"codex_user_message",
"prompt_text",
"chain_of_thought",
"session_id",
"browser_context",
}
if not required_forbidden.issubset(forbidden_fields):
raise ValueError(f"{label}: message_template_contract.forbidden_fields missing redaction boundary")
display = payload.get("display_redaction_contract") or {}
if display.get("conversation_transcript_display_allowed") is not False:
raise ValueError(f"{label}: conversation transcript display must remain false")
if display.get("redaction_required") is not True:
raise ValueError(f"{label}: display redaction must be required")
def _require_no_plaintext_secret_payload_keys(value: Any, label: str, path: str = "$") -> None:
if isinstance(value, dict):
forbidden_key_fragments = {
"secret_value",
"token_plaintext",
"authorization_header",
"private_key",
"credential_value",
}
for key, nested in value.items():
normalized_key = str(key).lower()
if any(fragment in normalized_key for fragment in forbidden_key_fragments):
raise ValueError(f"{label}: forbidden plaintext secret key at {path}.{key}")
_require_no_plaintext_secret_payload_keys(nested, label, f"{path}.{key}")
elif isinstance(value, list):
for index, nested in enumerate(value):
_require_no_plaintext_secret_payload_keys(nested, label, f"{path}[{index}]")
def _require_no_conversation_transcript_content(value: Any, label: str, path: str = "$") -> None:
if isinstance(value, str):
for marker in _TRANSCRIPT_MARKERS:
if marker in value:
raise ValueError(
f"{label}: forbidden work-window conversation content at {path}: {marker}"
)
elif isinstance(value, dict):
for key, nested in value.items():
_require_no_conversation_transcript_content(nested, label, f"{path}.{key}")
elif isinstance(value, list):
for index, nested in enumerate(value):
_require_no_conversation_transcript_content(nested, label, f"{path}[{index}]")

View File

@@ -13,9 +13,9 @@ def test_load_latest_ai_agent_proactive_operations_contract_reads_committed_snap
data = load_latest_ai_agent_proactive_operations_contract()
assert data["schema_version"] == "ai_agent_proactive_operations_contract_v1"
assert data["program_status"]["overall_completion_percent"] == 55
assert data["program_status"]["current_task_id"] == "P2-402C"
assert data["program_status"]["next_task_id"] == "P2-402D"
assert data["program_status"]["overall_completion_percent"] == 68
assert data["program_status"]["current_task_id"] == "P2-402D"
assert data["program_status"]["next_task_id"] == "P2-402E"
assert data["program_status"]["read_only_mode"] is True
assert data["program_status"]["runtime_authority"] == "contract_only_no_version_or_runtime_update"
assert data["approval_boundaries"]["runtime_version_update_allowed"] is False

View File

@@ -16,9 +16,9 @@ def test_ai_agent_proactive_operations_contract_endpoint_returns_committed_snaps
assert response.status_code == 200
data = response.json()
assert data["schema_version"] == "ai_agent_proactive_operations_contract_v1"
assert data["program_status"]["overall_completion_percent"] == 55
assert data["program_status"]["current_task_id"] == "P2-402C"
assert data["program_status"]["next_task_id"] == "P2-402D"
assert data["program_status"]["overall_completion_percent"] == 68
assert data["program_status"]["current_task_id"] == "P2-402D"
assert data["program_status"]["next_task_id"] == "P2-402E"
assert data["program_status"]["read_only_mode"] is True
assert data["approval_boundaries"]["runtime_version_update_allowed"] is False
assert data["approval_boundaries"]["package_upgrade_allowed"] is False

View File

@@ -0,0 +1,270 @@
from __future__ import annotations
import json
import pytest
from src.services.ai_agent_telegram_action_required_digest_policy import (
load_latest_ai_agent_telegram_action_required_digest_policy,
)
def test_load_latest_ai_agent_telegram_action_required_digest_policy_reads_committed_snapshot():
data = load_latest_ai_agent_telegram_action_required_digest_policy()
assert data["schema_version"] == "ai_agent_telegram_action_required_digest_policy_v1"
assert data["program_status"]["overall_completion_percent"] == 68
assert data["program_status"]["current_task_id"] == "P2-402D"
assert data["program_status"]["next_task_id"] == "P2-402E"
assert data["program_status"]["read_only_mode"] is True
assert data["program_status"]["runtime_authority"] == "policy_only_no_telegram_send_or_route_change"
assert data["operation_boundaries"]["read_only_policy_allowed"] is True
assert data["operation_boundaries"]["telegram_direct_send_allowed"] is False
assert data["operation_boundaries"]["telegram_gateway_queue_write_allowed"] is False
assert data["operation_boundaries"]["alertmanager_route_change_allowed"] is False
assert data["operation_boundaries"]["conversation_transcript_allowed"] is False
assert data["approval_boundaries"]["telegram_digest_send_approved"] is False
assert data["rollups"]["rule_count"] == len(data["digest_rules"]) == 8
assert data["rollups"]["channel_count"] == len(data["digest_channels"]) == 3
assert data["rollups"]["trigger_category_count"] == len(data["trigger_categories"]) == 5
assert data["rollups"]["by_decision"]["suppress_success_noise"] == 2
assert data["rollups"]["by_decision"]["draft_failure_escalation_digest"] == 3
assert data["rollups"]["by_decision"]["draft_action_required_digest"] == 3
assert data["rollups"]["telegram_direct_send_allowed_count"] == 0
assert data["rollups"]["telegram_gateway_queue_write_allowed_count"] == 0
assert data["rollups"]["route_change_allowed_count"] == 0
assert data["rollups"]["conversation_transcript_allowed_count"] == 0
assert "work_window_transcript" in data["message_template_contract"]["forbidden_fields"]
assert all(
rule["decision"] == "suppress_success_noise"
for rule in data["digest_rules"]
if rule["signal_state"] in {"success", "verified"}
)
def test_ai_agent_telegram_action_required_digest_policy_blocks_direct_send(tmp_path):
snapshot = _snapshot()
snapshot["operation_boundaries"]["telegram_direct_send_allowed"] = True
_write_snapshot(tmp_path, snapshot)
with pytest.raises(ValueError, match="operation boundaries"):
load_latest_ai_agent_telegram_action_required_digest_policy(tmp_path)
def test_ai_agent_telegram_action_required_digest_policy_rejects_rollup_mismatch(tmp_path):
snapshot = _snapshot()
snapshot["rollups"]["rule_count"] = 99
_write_snapshot(tmp_path, snapshot)
with pytest.raises(ValueError, match="rollup counts"):
load_latest_ai_agent_telegram_action_required_digest_policy(tmp_path)
def test_ai_agent_telegram_action_required_digest_policy_rejects_success_noise(tmp_path):
snapshot = _snapshot()
snapshot["digest_rules"][0]["decision"] = "draft_action_required_digest"
snapshot["digest_rules"][0]["requires_openclaw_review"] = True
snapshot["rollups"]["by_decision"] = {
"draft_action_required_digest": 2,
"draft_failure_escalation_digest": 1,
}
snapshot["rollups"]["action_required_rule_ids"] = [
"repo_only_freshness_snapshot_success",
"tool_install_or_ci_change_needs_approval",
]
snapshot["rollups"]["suppressed_success_rule_ids"] = []
_write_snapshot(tmp_path, snapshot)
with pytest.raises(ValueError, match="success/verified signals"):
load_latest_ai_agent_telegram_action_required_digest_policy(tmp_path)
def test_ai_agent_telegram_action_required_digest_policy_rejects_transcript_markers(tmp_path):
snapshot = _snapshot()
snapshot["message_template_contract"]["action_required_message_policy"] = (
"禁止放入:" + "My request for Codex"
)
_write_snapshot(tmp_path, snapshot)
with pytest.raises(ValueError, match="forbidden work-window conversation content"):
load_latest_ai_agent_telegram_action_required_digest_policy(tmp_path)
def test_ai_agent_telegram_action_required_digest_policy_requires_redaction_fields(tmp_path):
snapshot = _snapshot()
snapshot["message_template_contract"]["forbidden_fields"].remove("work_window_transcript")
_write_snapshot(tmp_path, snapshot)
with pytest.raises(ValueError, match="forbidden_fields"):
load_latest_ai_agent_telegram_action_required_digest_policy(tmp_path)
def _write_snapshot(tmp_path, snapshot: dict) -> None:
(tmp_path / "ai_agent_telegram_action_required_digest_policy_2026-06-11.json").write_text(
json.dumps(snapshot),
encoding="utf-8",
)
def _snapshot() -> dict:
return {
"schema_version": "ai_agent_telegram_action_required_digest_policy_v1",
"generated_at": "2026-06-11T23:58:00+08:00",
"program_status": {
"overall_completion_percent": 68,
"current_priority": "P2",
"current_task_id": "P2-402D",
"next_task_id": "P2-402E",
"read_only_mode": True,
"runtime_authority": "policy_only_no_telegram_send_or_route_change",
"status_note": "測試。",
},
"source_refs": ["docs/evaluations/example.json"],
"trigger_categories": [
{
"category_id": "success_noise",
"owner_agent": "Hermes",
"policy_intent": "測試。",
"blocked_now": ["send"],
},
{
"category_id": "tool_adoption_approval_required",
"owner_agent": "OpenClaw",
"policy_intent": "測試。",
"blocked_now": ["send"],
},
],
"digest_channels": [
{
"channel_id": "telegram_ops_digest_draft",
"purpose": "測試。",
"success_immediate_allowed": False,
"direct_send_allowed": False,
"queue_write_allowed": False,
"requires_telegram_gateway_e2e": True,
}
],
"digest_rules": [
{
"rule_id": "repo_only_freshness_snapshot_success",
"category_id": "success_noise",
"signal_state": "success",
"severity": "info",
"decision": "suppress_success_noise",
"owner_agent": "Hermes",
"required_evidence": ["snapshot"],
"channels": ["telegram_ops_digest_draft"],
"requires_openclaw_review": False,
"telegram_direct_send_allowed": False,
"next_action": "測試。",
},
{
"rule_id": "version_watch_source_failed",
"category_id": "tool_adoption_approval_required",
"signal_state": "failed",
"severity": "warning",
"decision": "draft_failure_escalation_digest",
"owner_agent": "Hermes",
"required_evidence": ["source_id"],
"channels": ["telegram_ops_digest_draft"],
"requires_openclaw_review": True,
"telegram_direct_send_allowed": False,
"next_action": "測試。",
},
{
"rule_id": "tool_install_or_ci_change_needs_approval",
"category_id": "tool_adoption_approval_required",
"signal_state": "action_required",
"severity": "warning",
"decision": "draft_action_required_digest",
"owner_agent": "OpenClaw",
"required_evidence": ["tool_id"],
"channels": ["telegram_ops_digest_draft"],
"requires_openclaw_review": True,
"telegram_direct_send_allowed": False,
"next_action": "測試。",
},
],
"message_template_contract": {
"required_fields": [
"stage",
"severity",
"target_id",
"evidence_ref",
"blocked_reason",
"next_action",
"owner_agent",
"approval_gate",
],
"forbidden_fields": [
"secret_value",
"token",
"authorization_header",
"work_window_transcript",
"codex_user_message",
"prompt_text",
"chain_of_thought",
"session_id",
"browser_context",
],
"success_message_policy": "成功不得送 Telegram。",
"action_required_message_policy": "測試。",
"failure_message_policy": "測試。",
},
"rate_limit_policy": {
"success_policy": "成功不得 Telegram 洗版。",
"digest_window_minutes": 30,
"dedupe_key_fields": ["category_id"],
"max_digest_items": 10,
"fallback_policy": "測試。",
},
"display_redaction_contract": {
"conversation_transcript_display_allowed": False,
"redaction_required": True,
"allowed_frontend_fields": ["政策規則摘要"],
"forbidden_frontend_content": ["內部對話內容"],
},
"agent_roles": [],
"operation_boundaries": {
"read_only_policy_allowed": True,
"telegram_direct_send_allowed": False,
"telegram_test_message_allowed": False,
"telegram_gateway_queue_write_allowed": False,
"alertmanager_route_change_allowed": False,
"telegram_receiver_change_allowed": False,
"awooop_event_write_allowed": False,
"workflow_trigger_allowed": False,
"external_scan_allowed": False,
"runtime_execution_allowed": False,
"secret_plaintext_allowed": False,
"conversation_transcript_allowed": False,
},
"approval_boundaries": {
"telegram_digest_send_approved": False,
"telegram_gateway_queue_write_approved": False,
"telegram_route_change_approved": False,
"alertmanager_receiver_change_approved": False,
"awooop_event_write_approved": False,
"workflow_trigger_approved": False,
"runtime_execution_approved": False,
"secret_plaintext_approved": False,
},
"rollups": {
"rule_count": 3,
"channel_count": 1,
"trigger_category_count": 2,
"by_decision": {
"suppress_success_noise": 1,
"draft_failure_escalation_digest": 1,
"draft_action_required_digest": 1,
},
"action_required_rule_ids": ["tool_install_or_ci_change_needs_approval"],
"failure_escalation_rule_ids": ["version_watch_source_failed"],
"suppressed_success_rule_ids": ["repo_only_freshness_snapshot_success"],
"telegram_direct_send_allowed_count": 0,
"telegram_gateway_queue_write_allowed_count": 0,
"route_change_allowed_count": 0,
"conversation_transcript_allowed_count": 0,
"next_approval_task_ids": ["P2-402E"],
},
}

View File

@@ -0,0 +1,52 @@
from __future__ import annotations
import json
from fastapi import FastAPI
from fastapi.testclient import TestClient
from src.api.v1.agents import router
def test_agent_telegram_action_required_digest_policy_endpoint_returns_committed_snapshot():
app = FastAPI()
app.include_router(router, prefix="/api/v1")
client = TestClient(app)
response = client.get("/api/v1/agents/agent-telegram-action-required-digest-policy")
assert response.status_code == 200
data = response.json()
assert data["schema_version"] == "ai_agent_telegram_action_required_digest_policy_v1"
assert data["program_status"]["overall_completion_percent"] == 68
assert data["program_status"]["current_task_id"] == "P2-402D"
assert data["program_status"]["next_task_id"] == "P2-402E"
assert data["program_status"]["read_only_mode"] is True
assert data["operation_boundaries"]["telegram_direct_send_allowed"] is False
assert data["operation_boundaries"]["telegram_test_message_allowed"] is False
assert data["operation_boundaries"]["telegram_gateway_queue_write_allowed"] is False
assert data["operation_boundaries"]["alertmanager_route_change_allowed"] is False
assert data["operation_boundaries"]["telegram_receiver_change_allowed"] is False
assert data["operation_boundaries"]["conversation_transcript_allowed"] is False
assert data["approval_boundaries"]["telegram_digest_send_approved"] is False
assert data["rollups"]["rule_count"] == 8
assert data["rollups"]["channel_count"] == 3
assert data["rollups"]["trigger_category_count"] == 5
assert data["rollups"]["telegram_direct_send_allowed_count"] == 0
assert data["rollups"]["telegram_gateway_queue_write_allowed_count"] == 0
assert data["rollups"]["route_change_allowed_count"] == 0
assert data["rollups"]["conversation_transcript_allowed_count"] == 0
assert any(
rule["rule_id"] == "telegram_delivery_silence_detected"
for rule in data["digest_rules"]
)
serialized = json.dumps(data, ensure_ascii=False)
for marker in [
"批准!繼續",
"My request for Codex",
"Current URL:",
"# In app browser",
"AGENTS.md instructions",
]:
assert marker not in serialized