diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index 394cf4dac..6335cf102 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -329,6 +329,8 @@ jobs: ;; apps/api/src/api/v1/webhooks.py) ;; + apps/api/tests/test_alertmanager_webhook_metrics.py) + ;; apps/api/src/core/config.py) ;; apps/api/src/db/base.py) @@ -986,6 +988,7 @@ jobs: tests/test_iwooos_security_operating_system.py \ tests/test_awoooi_production_deploy_readback_blocker.py \ tests/test_awoooi_priority_work_order_readback_api.py \ + tests/test_alertmanager_webhook_metrics.py \ tests/test_telegram_alert_ai_automation_matrix_api.py \ tests/e2e_network_test.py::TestHMACVerification::test_valid_hmac_signature \ tests/test_p0_cicd_baseline_source_readiness_api.py \ diff --git a/docs/LOGBOOK.md b/docs/LOGBOOK.md index e62e649b8..acee2e1d5 100644 --- a/docs/LOGBOOK.md +++ b/docs/LOGBOOK.md @@ -53129,6 +53129,25 @@ production browser smoke: - 沒有使用 GitHub / gh / GitHub API / GitHub Actions。 - 沒有重啟主機,沒有 Docker / Nginx / K3s / DB / firewall restart,沒有 workflow_dispatch,沒有 DROP / TRUNCATE / restore / prune。 +## 2026-07-02 — P0 CD #4439 Alertmanager metrics profile 修正 + +**完成內容**: +- Gitea public run log 讀回 `#4439` 失敗點為 tests job 的 B5:`AWOOOI_CD_TEST_PROFILE=full` 後進入 `BLOCKER b5_docker_socket_unavailable`,不是 `apps/api/tests/test_alertmanager_webhook_metrics.py` 單測失敗。 +- 根因是 `apps/api/src/api/v1/webhooks.py` 已在 controlled-runtime allowlist,但新增的 `apps/api/tests/test_alertmanager_webhook_metrics.py` 未列入 changed-file classifier,導致 narrow Alertmanager metrics patch 誤落 full/B5。 +- `.gitea/workflows/cd.yaml` 已補上 `apps/api/tests/test_alertmanager_webhook_metrics.py` controlled-runtime allowlist 與 focused pytest 清單;`ops/runner/test_cd_controlled_runtime_profile.py` 新增防回歸測試。 +- 修正方向是 source classifier / focused verifier,不是打開 Docker socket、恢復 legacy runner 或放寬 runner pressure gate。 + +**本地驗證結果**: +- `DATABASE_URL=sqlite+aiosqlite:////tmp/awoooi-codex-api-test.db PYTHONPATH=apps/api python3.11 -m pytest -q apps/api/tests/test_alertmanager_webhook_metrics.py ops/runner/test_cd_controlled_runtime_profile.py -p no:cacheprovider`:`48 passed`。 +- `python3.11 -m py_compile apps/api/src/api/v1/webhooks.py apps/api/tests/test_alertmanager_webhook_metrics.py ops/runner/test_cd_controlled_runtime_profile.py`:通過。 +- `python3.11 ops/runner/guard-gitea-runner-pressure.py --root .`:`GITEA_RUNNER_PRESSURE_GUARD_OK workflow_files=12 scheduled_workflows=4 auto_branch_events_on_110=0 generic_runner_labels=0`。 +- `git diff --check`:通過。 + +**仍維持**: +- 沒有讀 secret / runner token / `.runner` 內容 / `.env` / raw sessions / SQLite / auth。 +- 沒有使用 GitHub / gh / GitHub API / GitHub Actions。 +- 沒有重啟主機,沒有 Docker / Nginx / K3s / DB / firewall restart,沒有 workflow_dispatch,沒有 DROP / TRUNCATE / restore / prune。 + **下一步**: - amend / push 到 Gitea main 後讀回新的 CD;deploy 後驗證 reboot scorecard 與 priority work-order production API 已出現 `windows99_management_channel` 與 `windows99_remote_execution_channel_ready=false`。 diff --git a/ops/runner/test_cd_controlled_runtime_profile.py b/ops/runner/test_cd_controlled_runtime_profile.py index 33ff23af5..70ed90c1f 100644 --- a/ops/runner/test_cd_controlled_runtime_profile.py +++ b/ops/runner/test_cd_controlled_runtime_profile.py @@ -238,6 +238,18 @@ def test_telegram_alert_ai_automation_matrix_stays_on_controlled_runtime_profile assert source in text +def test_alertmanager_webhook_metrics_stays_on_controlled_runtime_profile() -> None: + text = _workflow_text() + expected_sources = [ + "apps/api/src/api/v1/webhooks.py)", + "apps/api/tests/test_alertmanager_webhook_metrics.py)", + "src/api/v1/webhooks.py", + "tests/test_alertmanager_webhook_metrics.py", + ] + for source in expected_sources: + assert source in text + + def test_cd_requires_production_deploy_readback_after_rollout() -> None: text = _workflow_text() assert "apps/api/tests/test_awoooi_production_deploy_readback_blocker.py)" in text