chore(security): sync with gitea main before reconcile plan [skip ci]
This commit is contained in:
144
docs/LOGBOOK.md
144
docs/LOGBOOK.md
@@ -6379,8 +6379,152 @@ RLS app context:
|
||||
project_context=awoooi total=312 redacted_total=0 envelope_total=0
|
||||
```
|
||||
|
||||
**Migration CI 紅燈修正**:
|
||||
|
||||
- 首次推版後 `run-migration.yml` run `1914` 失敗在 `Seed asset_discovery_run (audit)`:
|
||||
- `psql -c` 不展開 `:'commit_sha'` / `:'files_json'` 變數,造成 syntax error。
|
||||
- 同一 workflow 也把 `_down.sql` 當新增 migration 套用,導致 up migration 後又被 rollback。
|
||||
- 已手動確認 production 欄位曾被 `_down.sql` 移除,並立即重新套回 up migration。
|
||||
- workflow 修正:
|
||||
- `Identify new migrations` 跳過 `*_down.sql` / `*rollback.sql`。
|
||||
- audit SQL 改用 heredoc 餵給 `psql`,讓 `-v` 變數正常展開。
|
||||
|
||||
```text
|
||||
ruby YAML.load_file(".gitea/workflows/run-migration.yml")
|
||||
# yaml ok
|
||||
|
||||
bash -n Identify new migrations / Seed asset_discovery_run extracted scripts
|
||||
# bash syntax ok
|
||||
|
||||
Identify new migrations local dry-run:
|
||||
apps/api/migrations/awooop_phase7_outbound_truth_chain_columns_2026-05-12.sql
|
||||
Rollback/down migrations skipped:
|
||||
apps/api/migrations/awooop_phase7_outbound_truth_chain_columns_2026-05-12_down.sql
|
||||
```
|
||||
|
||||
**下一步**:
|
||||
|
||||
- 推 Gitea main,讓 API image 部署 T1 程式碼。
|
||||
- 部署後用 rollback transaction smoke 驗證新 outbound mirror 會寫入 redacted full content + source envelope,不污染 production DB。
|
||||
- 再更新本 LOGBOOK 的 production smoke 結果。
|
||||
|
||||
**production deploy / smoke 追加(完成)**:
|
||||
|
||||
```text
|
||||
Gitea:
|
||||
1912 CD Pipeline 24b15f4a -> success
|
||||
1913 Code Review 24b15f4a -> success
|
||||
1914 run-migration 24b15f4a -> failure
|
||||
RCA: audit SQL 使用 psql -c + :'commit_sha',且誤套 _down.sql。
|
||||
1916 Code Review f318fd3a -> success
|
||||
修正 run-migration workflow;workflow-only 變更不觸發 runtime CD。
|
||||
|
||||
K8s image:
|
||||
awoooi-api 192.168.0.110:5000/awoooi/api:24b15f4ad2b0898820f8ba723c64ca928b48d471
|
||||
awoooi-worker 192.168.0.110:5000/awoooi/api:24b15f4ad2b0898820f8ba723c64ca928b48d471
|
||||
awoooi-web 192.168.0.110:5000/awoooi/web:24b15f4ad2b0898820f8ba723c64ca928b48d471
|
||||
|
||||
rollout:
|
||||
deployment "awoooi-api" successfully rolled out
|
||||
|
||||
health:
|
||||
http://192.168.0.125:32334/api/v1/health -> 200 healthy
|
||||
pod-local http://127.0.0.1:8000/api/v1/health -> 200 healthy
|
||||
```
|
||||
|
||||
**T1 outbound mirror 實證**:
|
||||
|
||||
```text
|
||||
Rollback transaction smoke:
|
||||
insert_visible=true
|
||||
redaction_version=audit_sink_v1
|
||||
has_content_redacted=True
|
||||
preview_matches_prefix=True
|
||||
token_redacted=True
|
||||
internal_ip_redacted=True
|
||||
envelope_schema=outbound_source_envelope_v1
|
||||
envelope_adapter=codex_smoke
|
||||
envelope_token_blocked=True
|
||||
envelope_has_content_sha=True
|
||||
rollback_triggered=true
|
||||
persisted_after_rollback=0
|
||||
|
||||
Production live rows:
|
||||
project_context=awoooi total=318 redacted_total=2 envelope_total=2
|
||||
latest real rows:
|
||||
message_type=final send_status=sent redaction=audit_sink_v1
|
||||
adapter=legacy_telegram_gateway payload_sha=True content_sha=True
|
||||
|
||||
Truth-chain API:
|
||||
GET /api/v1/platform/truth-chain/5c659c44-9275-5d50-bb40-76f2f00b2d16?project_id=awoooi
|
||||
status=200 found=True source_type=run outbound_visible=1
|
||||
has_content_redacted=True redaction_version=audit_sink_v1
|
||||
envelope_adapter=legacy_telegram_gateway envelope_has_payload_sha=True envelope_has_content_sha=True
|
||||
```
|
||||
|
||||
**進度校準**:
|
||||
|
||||
- T1 Channel Event hardening:已完成 deploy + production smoke。
|
||||
- 仍不能宣稱完整 AI 自動修復閉環已完成;T2 MCP Gateway mandatory audit、T3 Ansible executor、T4 Drift fingerprint FSM、T5 Incident status reconciliation 仍待推進。
|
||||
|
||||
## 2026-05-12(台北)— T2 MCP Gateway mandatory audit:legacy MCP bridge 第一段
|
||||
|
||||
**背景**:
|
||||
|
||||
- T0 truth-chain smoke 顯示 `awooop_mcp_gateway_audit` 仍是 0,但 legacy `mcp_audit_log` 24h 有大量 MCP 呼叫。
|
||||
- 這代表 MCP 能力有被部分使用,卻不是 AwoooP Gateway 單一治理鏈;Telegram / truth-chain 不能完整回答「用了哪些 MCP、自建 MCP、有沒有成功、是否被治理」。
|
||||
- T2 第一段先不改執行語意,避免影響修復行為;先把 legacy direct provider path 橋接到 AwoooP audit。
|
||||
|
||||
**改動**:
|
||||
|
||||
- `mcp_audit_service.record_mcp_call()`:
|
||||
- 保留原本 `mcp_audit_log` 與 `mcp_daily_stats` 寫入。
|
||||
- 對 legacy direct provider path 額外寫一筆 `awooop_mcp_gateway_audit` bridge row。
|
||||
- `gate_result` 明確標示:
|
||||
- `schema_version=legacy_mcp_bridge_v1`
|
||||
- `policy_enforced=false`
|
||||
- `not_used_reason=legacy direct provider path; bridge audit only`
|
||||
- legacy server/tool/flywheel node。
|
||||
- `trace_id` 優先使用 incident_id,讓 truth-chain 可用 incident id 串回 MCP 成敗。
|
||||
- `McpGateway._execute_tool()`:
|
||||
- 真正走 AwoooP Gateway 的 provider 呼叫標記 `gateway_path=awooop_mcp_gateway`,避免 legacy bridge 重複寫。
|
||||
- `test_mcp_audit_service.py` 新增:
|
||||
- legacy direct path 會寫 bridge row。
|
||||
- first-class gateway path 不重複 bridge。
|
||||
|
||||
**本地驗證**:
|
||||
|
||||
```text
|
||||
python -m py_compile \
|
||||
apps/api/src/services/mcp_audit_service.py \
|
||||
apps/api/src/plugins/mcp/gateway.py \
|
||||
apps/api/tests/test_mcp_audit_service.py
|
||||
# OK
|
||||
|
||||
/Users/ogt/awoooi/apps/api/.venv/bin/ruff check --select F,E9 \
|
||||
apps/api/src/services/mcp_audit_service.py \
|
||||
apps/api/src/plugins/mcp/gateway.py \
|
||||
apps/api/tests/test_mcp_audit_service.py
|
||||
# All checks passed
|
||||
|
||||
DATABASE_URL='postgresql+asyncpg://awoooi:awoooi_test_2026@localhost:5432/awoooi_test?ssl=disable' \
|
||||
python -m pytest \
|
||||
apps/api/tests/test_mcp_audit_service.py \
|
||||
apps/api/tests/test_mcp_gateway_audit.py \
|
||||
apps/api/tests/test_mcp_gateway_gate5.py -q
|
||||
# 7 passed
|
||||
|
||||
DATABASE_URL='postgresql+asyncpg://awoooi:awoooi_test_2026@localhost:5432/awoooi_test?ssl=disable' \
|
||||
python -m pytest \
|
||||
apps/api/tests/test_mcp_audit_context.py \
|
||||
apps/api/tests/test_pre_decision_investigator.py \
|
||||
apps/api/tests/test_post_execution_verifier.py \
|
||||
apps/api/tests/test_callback_dispatcher.py \
|
||||
apps/api/tests/test_approval_execution_mcp_audit.py -q
|
||||
# 90 passed
|
||||
```
|
||||
|
||||
**下一步**:
|
||||
|
||||
- 推 Gitea main,等待 CD 部署。
|
||||
- production rollback smoke:呼叫 `record_mcp_call()`,確認同一 transaction 內同時可見 legacy `mcp_audit_log` 與 `awooop_mcp_gateway_audit` bridge row,rollback 後不污染 production。
|
||||
|
||||
@@ -372,6 +372,8 @@ source_event_received
|
||||
|
||||
**T1 first implementation(2026-05-12 23:20 台北)**:開始補 `awooop_outbound_message` 的真相鏈欄位:`content_redacted`、`redaction_version`、`source_envelope`。設計邊界是只保存 redacted rendered card 與 source metadata 摘要;raw Telegram payload、完整 callback data、未遮蔽 token 不入庫。production DB migration 已預套用,API app role 在 `app.project_id=awoooi` 下可讀 outbound rows(`total=312`),代表 T1 的 RLS visibility 紅燈已先驗證可見;新欄位需等 T1 API image 上線後才會產生非空資料。
|
||||
|
||||
**T1 production verified(2026-05-12 23:35 台北)**:API / worker / web 已部署 image `24b15f4a`,CD run `1912` success,health 200。rollback transaction smoke 證明 `record_outbound_message()` 會寫入 `content_redacted`、`redaction_version=audit_sink_v1`、`source_envelope.schema_version=outbound_source_envelope_v1`,且 token / internal IP 會 redacted,transaction rollback 後 `persisted_after_rollback=0`。live production rows 已出現 `redacted_total=2` / `envelope_total=2`,truth-chain API 查 run `5c659c44-9275-5d50-bb40-76f2f00b2d16` 回傳 `has_content_redacted=True` 與 legacy Telegram envelope hash。T1 退出條件中的「RLS 可見性」與「全文 / hash / envelope 可查」已達成。
|
||||
|
||||
---
|
||||
|
||||
## §3 6 大設計維度全展開
|
||||
@@ -1855,12 +1857,34 @@ Phase 6 完成後
|
||||
- truth-chain / router / operator auth / Telegram envelope 測試共 12 passed。
|
||||
- production DB migration 已預套用;`app.project_id=awoooi` 下 `awooop_outbound_message total=312` 可見,舊資料 `redacted_total=0` 合理。
|
||||
|
||||
**production 追加**:
|
||||
- T1 API image 已部署並完成 production smoke;`awooop_outbound_message` 在 `app.project_id=awoooi` 下可見,且新出站 rows 已有 redacted full content 與 source envelope。
|
||||
- `run-migration.yml` 在 24b15f4a 暴露兩個 CI 問題:`psql -c` 不展開 `:'commit_sha'`,且誤套 `_down.sql`。已於 `f318fd3a` 修正為跳過 rollback/down migration,audit SQL 改 heredoc。
|
||||
|
||||
**仍未宣稱完成**:
|
||||
- T1 API image 尚需部署後 smoke,確認新 outbound mirror 實際寫入 `content_redacted` 與 `source_envelope`。
|
||||
- T2 MCP Gateway mandatory audit 未完成,因此不能宣稱所有 MCP / 自建 MCP 都已經過 AwoooP Gateway。
|
||||
|
||||
---
|
||||
|
||||
### 2026-05-12 晚 (台北) — T2 MCP Gateway mandatory audit — legacy MCP bridge 第一段
|
||||
|
||||
**範圍**:
|
||||
- `record_mcp_call()` 保留 legacy `mcp_audit_log` 寫入,同步橋接一筆 `awooop_mcp_gateway_audit`。
|
||||
- bridge row 的 `gate_result` 明確標示 `schema_version=legacy_mcp_bridge_v1`、`policy_enforced=false`、`not_used_reason=legacy direct provider path; bridge audit only`,避免把 legacy direct call 誤認為已完成五閘門治理。
|
||||
- 真正走 `McpGateway` 的 provider 呼叫標記 `gateway_path=awooop_mcp_gateway`,避免重複 bridge。
|
||||
- bridge `trace_id` 優先使用 `incident_id`,讓 truth-chain 可用 incident id 回查 legacy MCP 成敗。
|
||||
|
||||
**已驗證**:
|
||||
- 本地 `py_compile` / `ruff F,E9` 通過。
|
||||
- MCP gateway / audit 聚焦測試 7 passed。
|
||||
- PreDecision / PostExecution / Callback / Approval MCP audit 相鄰流程測試 90 passed。
|
||||
|
||||
**仍未宣稱完成**:
|
||||
- T2 API image 尚需部署後 production rollback smoke。
|
||||
- 這只是 legacy bridge,不是把所有呼叫強制改經 AwoooP Gateway;T2 後續仍要把新 MCP caller 收斂到 first-class Gateway path。
|
||||
|
||||
---
|
||||
|
||||
### 2026-04-20 晚 (台北) — C1-C4 全流程串接 — Playbook 鏈路保護(commit de2d34d)
|
||||
|
||||
**觸發**:統帥全景盤查 AI 自動化節點後,發現 Playbook 自動修復鏈路有 3 個結構性斷點。
|
||||
|
||||
Reference in New Issue
Block a user