fix(recovery): close cold-start runtime blockers

This commit is contained in:
ogt
2026-07-11 15:08:27 +08:00
parent 7cea825d92
commit 276410fbb6
38 changed files with 1494 additions and 145 deletions

View File

@@ -1,7 +1,7 @@
# AWOOOI 全棧冷啟動與主機重啟 SOP
> Version: v1.132
> Last updated: 2026-07-10 Asia/Taipei
> Version: v1.133
> Last updated: 2026-07-11 Asia/Taipei
> Scope: 99 / 110 / 111 / 112 / 120 / 121 / 188 全棧重啟恢復。112 仍是 Kali / VM guest 訊號,但 2026-06-30 全主機重啟後已納入 10 分鐘 SLO 的必要 boot / power signal此納入不代表授權任何破壞性 runtime apply。
---
@@ -10,6 +10,19 @@
本節是每次接手、開機、關機、重啟後的第一個判定錨點。若日期不是今天,必須先重跑 live check再更新本節與 `docs/workplans/2026-06-04-reboot-cold-start-backup-recovery-workplan.md`
### v1.133 2026-07-11 Cold-start runtime convergence
2026-07-11 14:58 最新完成 artifact 為 `/home/wooo/reboot-recovery/reboot-auto-recovery-slo-20260711-145616``OVERALL_DECLARATION=GREEN_WITH_EVIDENCE_WARNINGS``SERVICE_GREEN=1``PRODUCT_DATA_GREEN=1``BACKUP_CORE_GREEN=1``POST_START_BLOCKED=0``HOST_188_HYGIENE_BLOCKED=0`scorecard readiness `87%`。active blockers 只剩 `all_required_hosts_not_in_10_minute_reboot_window``fresh_all_host_reboot_event_missing``host_boot_observation_older_than_target_window`,三者都只能由下一次真實全主機 reboot drill 在同一 10 分鐘 window 驗收;不得靠重跑 verifier 或為了清分數擅自 reboot。
- 110 CPU incident 根因是 runner fail-closed cron 每分鐘無 `flock` 重複 `--apply`,多個 enforcer 重疊 mask runner 與 `systemctl daemon-reload`,使 PID 1 長時間高 CPU。現行合約為 `flock` + `timeout 180` + `--ensure`,只有 drift 才 applypost-verifier 為 `APPLY_PERFORMED=0``RECENT_APPLY_COUNT=0``SYSTEMD_RELOADS_SINCE_APPLY=0`、PID 1 CPU `0%`。runner 仍 fail-closedtoken 未讀取或變更。
- 188 edge Nginx 已透過 root-owned `/usr/local/sbin/awoooi-edge-maintenance` 固定 `check/apply/rollback-latest` executor 完成 backup、`nginx -t`、reload 與 SHA readback。live config / maintenance SHA 分別為 `577d37af17cf096719991d1acfb5e3cfc77ed4a197994817e656f8438d95127b` / `9807d067143527ae2c77e6c09e9d1659134384525e9cb4aa099db0950fcb48b2``EDGE_FALLBACK_READY=1`rollback 在 `/var/lib/awoooi-edge-maintenance/backups/edge-maintenance-20260711T141908+0800-190071-before-apply`。canonical config 必須保留 `/api/sentry-tunnel -> awoooi_web`public GET 回 `status=ok,target_configured=true`6/6 public route 2xx、raw 5xx `0`
- 111 的 canonical identity 是 M1 Pro MacBook Local Ollama fallback不是 Windows99 VM。Windows99 五個 required guest 是 `110/188/120/121/112`。110 透過 forced-command public key 只能執行 `/Users/ooo/.local/bin/awoooi-host-boot-readback`,禁止 shell / PTY / forwarding最新回讀 `boot_id=darwin_1783696973`、LaunchAgent enabled、Ollama active。scorecard 已觀測 99/110/111/112/120/121/188 全部 uptime`UNKNOWN_UPTIME_HOSTS=[]`
- SLO timer 已從 `OnUnitActiveSec=2min` 改為 `OnBootSec=2min` + `OnUnitInactiveSec=5min`,避免 2-3 分鐘 oneshot 因逾期而背靠背執行。
- 188 PostgreSQL `14/main` 的 production runtime 已證實由 `k3s-postgres-recovery` 以 host network、同一 `/var/lib/postgresql/14/main``unless-stopped` 提供。host `start.conf` 已改為 `manual`startup source/unit 已用 fixed-action hygiene executor 對齊並 reset stale failed state沒有重啟產品。independent checklist 回 `SYSTEMD_STATE=running`、failed units `0``HOST_HYGIENE_BLOCKED=0`、public routes 4/4 200rollback 在 `/var/lib/awoooi-host188-hygiene/backups/host188-hygiene-20260711T145537+0800-334605-before-reconcile`
- StockPlatform 2026-07-10 無資料來自 TWSE 官方颱風休市,不是 ingestion 中斷。交易日曆修正的 durable receipt 為 `raw.source_runs.source_run_id=3856`freshness / ingestion 皆 `status=ok`、latest trading date `2026-07-09`、四類 coverage 100%。
source regressionreboot P0 / installer / scorecard / API focused tests `59 passed`188 hygiene tests `7 passed``git diff --check` 通過。目前只是 local feature worktree依單一 pusher 鎖不 push mainproduction runtime receipt 不得被未 push source 狀態覆蓋。
### v1.132 2026-07-10 備份與 Gitea 可還原性閉環
重啟恢復不得再以「備份檔存在」或「Gitea HTTP 200」宣告備份正常。固定證據鏈為backup exporter/status freshness -> Gitea full dump isolated restore -> private bundle complete-set sync -> sample clone/fsck -> Prometheus rule/alert readback。任一層缺失都只能標示 degraded不能標示 restore-ready。

View File

@@ -1,6 +1,6 @@
# 188 Host Hygiene 維護窗口 Runbook
> 版本2026-06-26.v2
> 版本2026-07-11.v3
> 適用範圍:`192.168.0.188` host PostgreSQL `14/main`、`awoooi-startup.service`、certbot / ACME renewal hygiene。
> 狀態:`HOST_188_HYGIENE_GREEN`
@@ -16,18 +16,20 @@
## 2. 最新只讀證據
2026-06-26 12:02-12:13 Asia/Taipei live evidence
2026-07-11 14:55 Asia/Taipei live evidence 取代舊 2026-06-26 baseline
| 層級 | 證據 | 判定 |
|------|------|------|
| Host systemd | `systemctl is-system-running``running`failed units `0 loaded units listed` | host hygiene green |
| 產品容器 | MOMO、VibeWork、2026FIFA、ClawBot、MinIO、exporters、MOMO DB 等容器 healthy / up | 產品服務 green |
| PostgreSQL runtime | `k3s-postgres-recovery` container 為 `Running=true``NetworkMode=host`、restart policy `unless-stopped``pg_isready -h localhost -p 5432` accepting connections | production DB runtime green |
| Host PostgreSQL unit | `postgresql@14-main.service` reset 後 `Result=success / inactive``pg_lsclusters` 仍可能因 recovery container PID model 顯示 host cluster down | 不再作為 service blocker由 runtime-ready 判斷 |
| Startup unit | `/usr/local/bin/awoooi-startup.sh` 已改為 `postgres_runtime_ready()`,接受 active host unit 或 `k3s-postgres-recovery` host-network runtime不再自動執行 `pg_resetwal` | fail-closed 修復完成 |
| Host PostgreSQL unit | `/etc/postgresql/14/main/start.conf=manual``postgresql@14-main.service` 為 disabled / inactiverecovery container 同一 data/config mount 仍 accepting connections | 避免 host/container 雙啟動競爭 |
| Startup unit | source/live SHA 為 `d9b099382fbc618280241d398a2a3d2c89f004804ab793c177a25a43505ebe8d`unit SHA 為 `995705578f4ba50f02100f7f60f432fa86d3f37e13aaa6f1d93c1d8685a8cafb`metadata repair、kine write、ClawBot rebuild、188 SignOz 均預設 opt-in | fail-closed 修復完成 |
| Nginx / ACME route | `sentry.wooo.work``gitea.wooo.work``langfuse.wooo.work``signoz.wooo.work` HTTP-01 self-test token 均由 `/var/www/html` 正確回應 | challenge route green |
| certbot timers | duplicate apt `certbot.timer` 已停用snap `snap.certbot.renew.timer` enabled / active / waiting`certbot.service``snap.certbot.renew.service` `Result=success / inactive` | renewal runner hygiene green |
| public cert | shared `sentry.wooo.work` certificate valid until `2026-07-09 16:03:40 UTC` | 尚未宣稱已 renew等待 snap timer / ACME window |
| public cert | `sentry.wooo.work` certificate `notAfter=2026-09-24 13:44:28 UTC`snap renew timer enabled / waiting | certificate readback green |
controlled reconcile receipt`/usr/local/sbin/awoooi-host188-hygiene reconcile``PRODUCT_SERVICE_RESTARTS=0`rollback 為 `/var/lib/awoooi-host188-hygiene/backups/host188-hygiene-20260711T145537+0800-334605-before-reconcile`。獨立 checklist 回 `PASS=17 WARN=1 BLOCKED=0``HOST_HYGIENE_BLOCKED=0`warning 只說明 `pg_lsclusters` 看不到 container-owned PID model不是 DB 不可用。
---
@@ -138,7 +140,16 @@ docker ps --format '{{.Names}}\t{{.Status}}\t{{.Ports}}'
### Phase C受控修復
只在 maintenance window 內由 operator 執行;此文件不提供自動 apply。
先安裝固定動作 executor再分開執行 check / reconcile
```bash
scripts/reboot-recovery/bootstrap-host188-hygiene-executor.sh --check
scripts/reboot-recovery/bootstrap-host188-hygiene-executor.sh --apply
ssh ollama@192.168.0.188 'sudo -n /usr/local/sbin/awoooi-host188-hygiene check'
ssh ollama@192.168.0.188 'sudo -n /usr/local/sbin/awoooi-host188-hygiene reconcile'
```
executor 只能安裝 canonical startup source/unit、將 PG start mode 設為 manual、daemon-reload 與 reset stale failed state不能 start/restart/stop 產品、Docker、Nginx 或 PostgreSQL。回滾只允許 `sudo -n /usr/local/sbin/awoooi-host188-hygiene rollback-latest`
### Phase Dpost-check
@@ -170,16 +181,16 @@ curl -fsS https://awoooi.wooo.work/api/v1/health
| 服務恢復 | `100%` | routes、containers、cold-start、backup core 已 green |
| 188 host hygiene repair | `100%` | startup fail-closed、PostgreSQL runtime-ready 判斷、systemd failed units、ACME route 與 certbot timer hygiene 已收斂 |
| PostgreSQL runtime source-of-truth | `100%` | production DB runtime 以 `k3s-postgres-recovery` host-network container + `pg_isready` 判斷,不用 host `pg_lsclusters` 假紅 |
| certbot / ACME route hygiene | `95%` | HTTP-01 route 與 timer split 已修;正式 renew 成功仍等待 snap timer / ACME window |
| DR escrow | `BLOCKED` | `escrow_missing=5`不可用 188 host green 替代 |
| Wazuh registry | `BLOCKED` | manager registry accepted `0`,不可用 route `200` 或 transport count 替代 |
| certbot / ACME route hygiene | `100%` | snap renew timer activecertificate 有效到 2026-09-24續依正常 timer 監控 |
| DR escrow | `100%` | 2026-07-11 checklist 回 `escrow_missing=0`但仍與 host hygiene 分開記錄 |
| Wazuh registry | `NOT_EVALUATED_THIS_RUN` | 本輪 188 checklist 未取得 fresh manager registry acceptance不得沿用舊值作目前結論 |
---
## 8. 不得宣稱
- 不得宣稱 DR completecredential escrow evidence 仍缺 `5`
- 不得宣稱 Wazuh registry recoveredmanager registry accepted 仍為 `0`
- 不得宣稱 certbot certificate 已完成正式 renew目前完成的是 HTTP-01 route / timer hygiene / failed units 清除
- 不得用 188 host green 單獨宣稱全平台 DR completeDR 必須讀同一輪 backup/escrow scorecard
- 不得宣稱 Wazuh registry recovered本輪沒有 fresh manager registry acceptance readback
- 不得 certificate 目前有效就停用 snap renew timer / expiry 告警
- 不得把 `reset-failed` 單獨當成修復完成;本次完成是因 startup source、Nginx ACME route、timer split 與 postcheck 同時收斂。
- 不得宣稱這份文件批准任何新的 runtime action。

View File

@@ -1,7 +1,7 @@
# AWOOOI 重開機恢復 SOP
> **版本**: v5.26
> **最後更新**: 2026-07-10 (台北時間)
> **版本**: v5.27
> **最後更新**: 2026-07-11 (台北時間)
> **更新者**: Codex
> **觸發事件**: 2026-07-11 Agent99 多排程 SSH contention、執行身份與 false-down readback 收斂
@@ -21,6 +21,20 @@
## 架構概覽與依賴圖
### 2026-07-11 P0 Cold-start 實機收旂
最新完成 artifact `/home/wooo/reboot-recovery/reboot-auto-recovery-slo-20260711-145616` 回報 `GREEN_WITH_EVIDENCE_WARNINGS`、readiness `87%`、service/data/backup/post-start/188 hygiene 皆綠。唯三 blockers 是 `all_required_hosts_not_in_10_minute_reboot_window``fresh_all_host_reboot_event_missing``host_boot_observation_older_than_target_window`;它們只能在下一次真實全主機 reboot 後同一 10 分鐘 window 驗收,未取得執行當下的 break-glass 指令前不得為了清分數重啟。
- 99 VMware required guest set 是 `110/188/120/121/112`。111 是 M1 Pro MacBook Local Ollama已用 110 public key + forced command 回傳 Darwin boot/uptime/Ollama status不授權 shell。舊版把 111 當 Windows99 VMX 的敘述依 live inventory 標記為 superseded。
- 110 runner fail-closed authority 只能使用 `flock` + `timeout` + `--ensure`,不得每分鐘無條件 mask + daemon-reload。完成條件是 apply/reload count 為 0 且 PID 1 CPU 收旂。
- edge fallback 只走 `/usr/local/sbin/awoooi-edge-maintenance check|apply|rollback-latest`canonical/live SHA parity、backup、`nginx -t`、reload、public route verifier 缺一不可完成。`/api/sentry-tunnel` 必須在 generic `/api/` 前且 proxy 到 web。
- 111 host probe 只讀 `boot_id=darwin_<epoch>` / uptime / LaunchAgent / local Ollama`UNKNOWN_UPTIME_HOSTS=[]` 才可進 reboot-event detector。
- SLO timer 使用 `OnBootSec=2min` + `OnUnitInactiveSec=5min`;禁止恢復 `OnUnitActiveSec=2min`,否則 2-3 分鐘 oneshot 會連續排程並製造 CPU / 告警噪音。
- 188 production PG 由 `k3s-postgres-recovery` host-network container 管理host `start.conf=manual``awoooi-host188-hygiene reconcile` 只安裝 startup source/unit、daemon-reload、reset stale failed state禁止產品 restart。startup 內 containerd/Docker metadata 刪除、kine write、ClawBot rebuild、188 legacy SignOz 均預設 fail-closed/opt-in。
- 2026-07-10 Stock gap 來自 TWSE 颱風休市,不是 ingestion 中斷。交易日曆修正後 freshness/ingestion 皆 green不得對休市日無限重跑 ETL。
下一次 reboot drill 必須在 T+0 由 boot-id 變更自動觸發 Agent99/110 SLO laneT+10 前產生同一 run 的 VM power、host uptime、services/routes、Stock freshness、backup、Telegram lifecycle 與 KM writeback receipt。若任一主機不在 window不得宣稱 10 分鐘 SLA 完成。
### 2026-07-10 P0 Agent99 Transport / Verified Remediation 覆蓋
99 的 Agent99 是全主機恢復控制節點。Windows 開機後由既有 Agent99 scheduled tasks 啟動;`Status` 讀到 boot identity 變更時,只能用 single-flight queue 觸發一次 `Recover`,並以 10 分鐘 cooldown 避免併發恢復。每次執行必須寫入 `bootState``recoveryTrigger``recoverySlo` evidence。只有實際全主機重啟事件、五主機 reachability、必要服務、public routes 與 freshness 全部在同一個 10 分鐘 window 通過,才可宣稱 reboot recovery SLO 達標。