{html.escape(str(summary.get('stage') or 'unknown'))}"
+ " / "
+ f"{html.escape(str(summary.get('stage_status') or 'unknown'))}"
+ ),
+ (
+ "治理: "
+ f"first-class {int(summary.get('first_class_total') or 0)} / "
+ f"policy {int(summary.get('policy_enforced_total') or 0)} / "
+ f"legacy {int(summary.get('legacy_bridge_total') or 0)}"
+ ),
+ ]
+
+ agent = _top_gateway_bucket(by_agent, "agent_id")
+ tool = _top_gateway_bucket(by_tool, "tool_name")
+ scope = _top_gateway_bucket(by_scope, "required_scope")
+ if agent:
+ lines.append(f"Agent: {html.escape(agent)}")
+ if tool:
+ lines.append(f"Tool: {html.escape(tool)}")
+ if scope:
+ lines.append(f"Scope: {html.escape(scope)}")
+ if blockers:
+ lines.append(
+ "卡點: "
+ + html.escape(", ".join(str(item) for item in blockers[:3]))
+ )
+ return lines
+
+
def _sanitize_telegram_error(text: str) -> str:
"""遮蔽 Telegram Bot URL 中的 token,避免例外字串污染 log / trace。"""
return _TELEGRAM_BOT_URL_RE.sub(r"\1{item.label}
++ {hasRecords ? item.value : emptyLabel} +
+{item.label}
++ {item.value ?? emptyLabel} +
+