fix(governance): keep trust drift watchdog on governance agent
This commit is contained in:
@@ -72,13 +72,15 @@ class GovernanceAgent:
|
||||
# 1. Playbook 信任度漂移
|
||||
# =========================================================================
|
||||
|
||||
async def check_trust_drift(self) -> dict[str, Any]:
|
||||
async def check_trust_drift(self, emit_alert: bool = True) -> dict[str, Any]:
|
||||
"""Playbook trust_score < 0.2 → 告警建議廢棄;30 天沒用過的直接 auto-deprecate
|
||||
|
||||
2026-04-26 P2.2 by Claude
|
||||
2026-05-02 ogt + Claude Sonnet 4.6: 加 auto_deprecate_low_trust_unused 自治路徑
|
||||
守衛條件:trust < 0.2 AND (last_used_at < 30 天前 OR 從未使用且創建超過 30 天)
|
||||
→ status 改 'deprecated',alert 改報「N 個告警 + M 個 auto-deprecated」
|
||||
2026-05-05 Codex: emit_alert=False 供 W-6 watchdog 查詢統計,維持
|
||||
governance_agent 單一入口,但避免與 hourly self-check 發出雙重 Telegram。
|
||||
"""
|
||||
async with get_db_context() as db:
|
||||
result = await db.execute(
|
||||
@@ -118,7 +120,7 @@ class GovernanceAgent:
|
||||
ids=auto_deprecated_ids[:10],
|
||||
)
|
||||
|
||||
if drifted:
|
||||
if drifted and emit_alert:
|
||||
drift_ratio = len(drifted) / total if total > 0 else 0.0
|
||||
await self._alert(
|
||||
"trust_drift",
|
||||
|
||||
Reference in New Issue
Block a user