feat(governance): auto-deprecate low-trust unused playbooks (>30d)
Some checks failed
Code Review / ai-code-review (push) Successful in 41s
CD Pipeline / tests (push) Successful in 3m29s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled

trust_drift previously fired alerts forever for playbooks stuck below
the 0.2 threshold. With user authorization for governance-class
auto-fixes, check_trust_drift now retires playbooks that have been
unused for 30+ days (or never used and created 30+ days ago) by
flipping status to 'deprecated' before alerting.

Alerts now report drifted_count, auto_deprecated_count, and the kept
playbook_ids that still need human review (those in their 30d trial
window). Existing alert noise from the four currently-drifted
playbooks should drop to whatever fraction is genuinely in trial.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-05-02 12:07:32 +08:00
parent 607358c4dd
commit 3059897318
3 changed files with 150 additions and 7 deletions

View File

@@ -6,6 +6,27 @@
---
## 2026-05-02 | trust_drift 飛輪自治:低信任未使用 playbook 自動 deprecate
承接統帥對 governance 類告警的全面授權。trust_drift 過去只發 Telegram 告警4 個低信任 playbook 一直在告警表內噴噪音。
### 完成
- 新增閾值 `TRUST_DRIFT_AUTO_DEPRECATE_AFTER_DAYS = 30`
- 改寫 `governance_agent.check_trust_drift`trust < 0.2 且 (`last_used_at` 早於 30 天前 或 從沒用過 + `created_at` 早於 30 天前) → 直接 `status = 'deprecated'` 並 commit。
- alert payload 加 `auto_deprecated_count` / `auto_deprecated_ids``playbook_ids` 只列剩下需人工複核的(在試用期內)。
- 試用期內(< 30 天)的低信任 playbook 仍會出現在 alert給 SRE 手動覆核空間。
### 驗證
- `pytest tests/test_governance_agent.py` → 20 passed。
- 新增 3 個 case
- 全部 ≥ 0.2 → 不告警,不 deprecate
- 低信任 + 最近用過 → 告警但不 deprecate
- 低信任 + 30 天沒用 / 創建 30 天從沒用過 → 自動 deprecate
### 後續
- 觀察 1 週看 deprecate 比例,若仍多需重新檢視 0.2 閾值或 EWMA 退化曲線。
- knowledge_degradation63% stale/ governance_slo_data_gap 需獨立設計refresh job + ADR-100 emitter下一輪處理。
## 2026-05-02 | 手動批准路徑 SSH action 解析修補
承接同日早上 docker prune 飛輪部署後,使用者反饋仍有 incident 點「批准」後執行失敗。AOL 顯示 `Could not parse operation type`,根因是 `parse_operation_from_action` 只懂 kubectl 與中文重啟,不認識 `ssh ...` action所有 SSH 修復動作從 K8s executor 退場。