From 39569cc72b7ff2928dc7ea31887c8715bed9ceac Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 1 Jun 2026 10:33:56 +0800 Subject: [PATCH] docs(logbook): record operator summary cache closure --- docs/LOGBOOK.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/docs/LOGBOOK.md b/docs/LOGBOOK.md index e7f29ca9a..eb4d6a95f 100644 --- a/docs/LOGBOOK.md +++ b/docs/LOGBOOK.md @@ -26,6 +26,91 @@ - `active_runtime_gate_count=0`、`runtime_execution_authorized=false`。 - 未執行 Kali 掃描、未 SSH 變更 112 / 111 / 168、未開啟自動修復、未做 GitHub primary / Gitea 切換。 +## 2026-06-01|AwoooP Runs heavy summary 快取與 Callback Evidence 讀取體感修復 + +**背景**: + +- 使用者指出 AwoooP / Telegram 告警鏈路雖然逐步可見,但前端仍常像「空資料 / 卡住」,operator 無法穩定判斷流程跑到哪一段。 +- 本輪收斂在兩個 heavy read API:`/api/v1/platform/runs/callback-replies` 與 `/api/v1/platform/truth-chain/quality/summary`。不新增修復能力、不宣稱 24h 全自動修復達成,只改善真相鏈讀取穩定度與前端 loading/cache 可視性。 + +**本次調整**: + +- `apps/api/src/services/operator_summary_cache.py`: + - 新增短 TTL summary cache,先寫 process memory,再寫 shared Redis。 + - API Pod 內 Redis pool 未初始化時會主動 `init_redis_pool()`,避免 production 讀寫 cache 永遠 fallback miss。 +- `apps/api/src/services/platform_operator_service.py`: + - `list_callback_replies()` 接入 cache。 + - 修正 `callback_summary_cache_key` 被 per-incident `status_chain_cache_key` / `km_summary_cache_key` 覆蓋的變數陰影,避免「寫入一個 key、讀取另一個 key」造成 production 永遠 miss。 +- `apps/api/src/services/awooop_truth_chain_service.py`: + - `fetch_automation_quality_summary()` 接入短 TTL cache,保護 Runs / quality summary heavy 聚合。 +- `apps/api/src/api/v1/platform/operator_runs.py` / `truth_chain.py`: + - 新增 `refresh=true`,讓 operator 手動刷新時可略過短 TTL cache。 +- `apps/web/src/app/[locale]/awooop/runs/page.tsx`: + - TG Callback Evidence 面板新增 loading/cache metadata 顯示。 + - 有舊資料時 refresh 不再先清空成「空資料」;沒有資料且 API 尚未回來時顯示「正在同步,不判定為空資料」。 +- `.gitea/workflows/cd.yaml` / `scripts/alert_chain_smoke_test.py`: + - post-deploy smoke 改走 `https://awoooi.wooo.work` public API,避免舊 `192.168.0.125:32334` NodePort 從當前網路視角 connection refused 時誤判部署失敗。 + +**驗證**: + +```text +python3 -m py_compile apps/api/src/services/operator_summary_cache.py apps/api/src/services/platform_operator_service.py apps/api/src/services/awooop_truth_chain_service.py -> pass +DATABASE_URL=postgresql://test:test@localhost:5432/test PYTHONPATH=apps/api pytest apps/api/tests/test_operator_summary_cache.py apps/api/tests/test_awooop_operator_timeline_labels.py apps/api/tests/test_platform_router_order.py -q -> 66 passed +git diff --check -> pass +NEXT_PUBLIC_API_URL=https://awoooi.wooo.work NEXT_PRIVATE_BUILD_WORKER_COUNT=1 pnpm --dir apps/web run build -> pass(前一輪同組前端變更已驗證;本輪最後 API-only 修補未再改前端) +``` + +**Gitea / Production deploy**: + +```text +08260372 fix(api): initialize redis for operator summary cache + code-review run 3475 -> success + cd run 3474 -> success + +74fc19ac fix(api): keep callback summary cache key stable + code-review run 3479 -> success + cd run 3478 -> success + +k8s latest: + awoooi-api image = 192.168.0.110:5000/awoooi/api:74fc19ac50f8ecc6b0e5a0eec3c980b7d6793429 + awoooi-web image = 192.168.0.110:5000/awoooi/web:74fc19ac50f8ecc6b0e5a0eec3c980b7d6793429 + awoooi-worker image = 192.168.0.110:5000/awoooi/api:74fc19ac50f8ecc6b0e5a0eec3c980b7d6793429 + rollout status = api/web/worker successfully rolled out +``` + +**Production API evidence**: + +```text +callback-replies: + refresh 200 1.466989 cache=miss ttl=20 inbound=7 mirror=capturing + hit_1 200 0.029844 cache=hit age=0.049 ttl=20 inbound=7 mirror=capturing + hit_2 200 0.025979 cache=hit age=0.105 ttl=20 inbound=7 mirror=capturing + hit_3 200 0.021222 cache=hit age=0.151 ttl=20 inbound=7 mirror=capturing + +truth-chain quality summary: + refresh 200 8.048234 cache=miss ttl=30 evaluated=30 full_auto=false + hit_1 200 0.021164 cache=hit age=0.053 ttl=30 evaluated=30 full_auto=false + hit_2 200 0.035172 cache=hit age=0.116 ttl=30 evaluated=30 full_auto=false + +Runs page: + /zh-TW/awooop/runs?project_id=awoooi#tg-callback-evidence + 顯示 Operator 判讀、入站點擊鏡像累計 7、cache metadata badge(例:剛重新聚合 / TTL 20s) +``` + +**進度**: + +```text +Telegram/AwoooP callback truth-chain visibility: 97% +Heavy summary API read performance / cache: 100% +Frontend callback evidence loading/cache visibility: 95% +Post-deploy public smoke reliability: 100% +Sentry/SigNoz per-incident visibility: 92% +MCP / self-hosted MCP visibility: 97% +Ansible / PlayBook visibility: 90% +Overall AI automation flywheel: 82% +24h full AI Agent auto-repair production claim: 0%(尚未完成 24h 無人工介入驗證,仍不得宣稱達成) +``` + ## 2026-06-01|IwoooS 執行閘雷達 **背景**: