From e9a8a2b3e90064afbae638b83c3854ac22f7bb25 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 31 May 2026 15:52:24 +0800 Subject: [PATCH] =?UTF-8?q?test(alerts):=20=E5=B0=8D=E9=BD=8A=20no-action?= =?UTF-8?q?=20=E4=BF=AE=E5=BE=A9=E8=AA=9E=E6=84=8F=E6=B8=AC=E8=A9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/tests/test_approval_execution_no_action.py | 4 ++++ docs/LOGBOOK.md | 4 ++-- .../specs/2026-04-15-MASTER-ai-autonomous-flywheel-v2.md | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/api/tests/test_approval_execution_no_action.py b/apps/api/tests/test_approval_execution_no_action.py index 1b7fcedd..fc11e1ab 100644 --- a/apps/api/tests/test_approval_execution_no_action.py +++ b/apps/api/tests/test_approval_execution_no_action.py @@ -63,6 +63,8 @@ async def test_no_action_execution_resolves_incident_once(monkeypatch): approval.id, success=True, execution_kind="no_action", + repair_executed=False, + repair_attempted=False, ) assert "未執行修復" in timeline_add_event.await_args.kwargs["title"] assert alert_completed.await_args.kwargs["execution_kind"] == "no_action" @@ -129,5 +131,7 @@ async def test_no_action_execution_returns_true_when_resolve_raises(monkeypatch) approval.id, success=True, execution_kind="no_action", + repair_executed=False, + repair_attempted=False, ) incident_service.resolve_incident.assert_awaited_once_with("INC-TEST-002") diff --git a/docs/LOGBOOK.md b/docs/LOGBOOK.md index ab0300bb..b62260f6 100644 --- a/docs/LOGBOOK.md +++ b/docs/LOGBOOK.md @@ -68,8 +68,8 @@ python3 -m json.tool apps/web/messages/en.json -> pass cd apps/api && ruff check --select E9,F401,F821,F841 src/services/operator_outcome.py src/services/approval_db.py src/services/approval_execution.py src/services/awooop_truth_chain_service.py src/services/platform_operator_service.py src/services/telegram_gateway.py tests/test_operator_outcome.py tests/test_awooop_operator_timeline_labels.py tests/test_telegram_message_templates.py -> pass -cd apps/api && DATABASE_URL=postgresql+asyncpg://test:test@localhost:5432/test pytest tests/test_operator_outcome.py tests/test_awooop_truth_chain_service.py tests/test_awooop_operator_timeline_labels.py tests/test_telegram_message_templates.py tests/test_incident_timeline_service.py -q - -> 159 passed +cd apps/api && DATABASE_URL=postgresql+asyncpg://test:test@localhost:5432/test pytest tests/test_approval_execution_no_action.py tests/test_operator_outcome.py tests/test_awooop_truth_chain_service.py tests/test_awooop_operator_timeline_labels.py tests/test_telegram_message_templates.py tests/test_incident_timeline_service.py -q + -> 161 passed pnpm --dir apps/web exec tsc --noEmit --tsBuildInfoFile /tmp/awoooi-operator-outcome-20260531.tsbuildinfo -> pass NEXT_PUBLIC_API_URL=https://awoooi.wooo.work pnpm --dir apps/web run build diff --git a/docs/superpowers/specs/2026-04-15-MASTER-ai-autonomous-flywheel-v2.md b/docs/superpowers/specs/2026-04-15-MASTER-ai-autonomous-flywheel-v2.md index 7aa81b83..5b6f254a 100644 --- a/docs/superpowers/specs/2026-04-15-MASTER-ai-autonomous-flywheel-v2.md +++ b/docs/superpowers/specs/2026-04-15-MASTER-ai-autonomous-flywheel-v2.md @@ -2688,7 +2688,7 @@ Phase 6 完成後 - 觸發:使用者指出批准後、已處理、執行中、degraded 等狀態仍缺少終局結論,operator 看不出「處理結果是什麼、是否需要人工介入、人工介入透過什麼通知方式接手」。Production 抽查也看到部分 approval 的 `telegram_result_total=0`,舊 `_push_execution_result_to_alert()` 在找不到 Redis 原始 Telegram message id 時會靜默 return。 - 修正:新增 `operator_outcome_v1` 共用契約,集中輸出 `state`、`summary_zh`、`needs_human`、`human_action_required`、`human_action_reason`、`next_action`、`notification.channels`、`evidence`、`blockers`。AwoooP truth-chain、platform status-chain、Telegram 首屏、Telegram callback snapshot 與前台 status-chain 全部讀同一份 outcome。approval execution result 改在最終驗證、AOL / KM / incident log 寫入後送出;若缺原始 Telegram message id,改送 standalone 群組結果通知並寫 `TELEGRAM_RESULT_SENT`,不再靜默失聯。 - 語意收斂:`OBSERVE` / `NO_ACTION` / diagnostic / parse_failed / unsupported_action 會寫入 `execution_kind`、`repair_executed=false`、`repair_attempted=false`。diagnostic-only、verification degraded、execution failed、read-only dry-run、write-observed、blocked、PENDING / WAITING_APPROVAL 都會明確標示人工需求、通知通道與下一步,不再把診斷或觀察顯示成修復完成。 -- Verification:API `py_compile` pass;i18n JSON parse pass;targeted `ruff --select E9,F401,F821,F841` pass;`test_operator_outcome.py` + `test_awooop_truth_chain_service.py` + `test_awooop_operator_timeline_labels.py` + `test_telegram_message_templates.py` + `test_incident_timeline_service.py` -> 159 passed;web `tsc --noEmit` pass;production API URL build pass;`git diff --check` pass。 +- Verification:API `py_compile` pass;i18n JSON parse pass;targeted `ruff --select E9,F401,F821,F841` pass;`test_approval_execution_no_action.py` + `test_operator_outcome.py` + `test_awooop_truth_chain_service.py` + `test_awooop_operator_timeline_labels.py` + `test_telegram_message_templates.py` + `test_incident_timeline_service.py` -> 161 passed;web `tsc --noEmit` pass;production API URL build pass;`git diff --check` pass。 - 判讀:T154c 補的是「operator-facing disposition contract」與「result notification reliability」,不是擴權自動修復。新版後新 incident 的批准結果會落到 Telegram / DB / AwoooP 同一份 outcome;歷史全量補發需另開 backfill,避免一次洗版。 **T152 Ansible runtime readiness surfaced(2026-05-24 台北)**: