feat(governance): 新增操作類別權限模型
All checks were successful
Code Review / ai-code-review (push) Successful in 16s
CD Pipeline / tests (push) Successful in 1m24s
CD Pipeline / build-and-deploy (push) Successful in 4m45s
CD Pipeline / post-deploy-checks (push) Successful in 1m46s

This commit is contained in:
Your Name
2026-06-12 15:04:51 +08:00
parent b5112ccf65
commit 7c8bb3645b
14 changed files with 1994 additions and 10 deletions

View File

@@ -1,3 +1,31 @@
## 2026-06-12P2-101 操作類別權限模型
**背景**P2-404 已把 fixture/readback/verifier dry-run promotion 成 runtime worker shadow / no-write execution evidence gate統帥指出 TG 批准後仍沒有真正自動化也沒有產生可操作的人工下一步。P2-101 先把每一類操作的權限、風險、Agent 責任、下一個 gate 與人工處置模板固定成可查模型,避免批准後落到 `learning_recorded``manual_review` 但沒有 SOP。
**完成(本地)**
- 新增 `ai_agent_operation_permission_model_v1` schema、committed snapshot 與 backend loader強制 runtime execution、Gateway queue write、Telegram send、Bot API、delivery receipt、AI runtime worker、中低風險 auto worker、verifier live readback、production write、secret value read、paid provider call、host / cluster command 與 destructive action 全部維持 `false / 0`
- 新增 `GET /api/v1/agents/agent-operation-permission-model` 只讀 API 與測試API 只回傳 permission lane、operation category、Agent responsibility、gate transition 與 operator decision template不寫 queue、不送 Telegram、不啟動 worker。
- 治理頁 `/zh-TW/governance?tab=automation-inventory` 新增 P2-101 區塊,顯示 5 條 permission lane、13 類 operation category、3 個 Agent permission role、8 個 gate transition 與 5 個人工操作模板。
- 更新 `AI_AGENT_AUTOMATION_WORKLIST_2026-06-04.md``AI_AGENT_INTERACTION_LEARNING_PROOF_2026-06-11.md` 與 MASTER §3.2 / §5將 P2-101 標記為完成,下一步改為 `P2-102` 候選操作 dry-run 證據。
**驗證(本地)**
- `python3 -m json.tool` 檢查 P2-101 snapshot / schema / `zh-TW.json` / `en.json` 通過。
- `python3 -m py_compile apps/api/src/services/ai_agent_operation_permission_model.py apps/api/src/api/v1/agents.py` 通過。
- `DATABASE_URL='postgresql+asyncpg://test:test@localhost/test' PYTHONPATH=apps/api pytest -q apps/api/tests/test_ai_agent_operation_permission_model.py apps/api/tests/test_ai_agent_operation_permission_model_api.py``10 passed`
- `cmp -s apps/web/messages/zh-TW.json apps/web/messages/en.json` 通過,兩份訊息檔維持繁體中文鏡像。
- `pnpm --filter @awoooi/web typecheck` 通過。
- `NEXT_PUBLIC_API_URL=https://awoooi.wooo.work NEXT_PRIVATE_BUILD_WORKER_COUNT=1 SENTRY_SUPPRESS_GLOBAL_ERROR_HANDLER_FILE_WARNING=1 pnpm --filter @awoooi/web build`Next compile / static page generation 通過standalone copy 階段因本機磁碟只剩約 `127MiB` 觸發 `ENOSPC`,已清除本輪忽略產物 `apps/web/.next`,等待 Gitea CD runner 重新 build 作正式部署依據。
**完成度同步**
- P2-101本地完成度 `97%`permission lane `5`、operation category `13`、Agent permission role `3`、gate transition `8`、operator decision template `5`
- runtime execution、Gateway queue write、Telegram send、Telegram Bot API、delivery receipt write、AI runtime worker、中低風險 auto worker、verifier live readback、production write、secret value read、paid provider call、host / cluster command、destructive action全部仍為 `0`
- P2-102下一步要讓所有候選操作具備 dry-run 證據、side-effect count、evidence hash 與 verifier plan完成前不得 live worker、queue write、Telegram send、production write 或 verifier live readback。
**邊界**:本段不送 Telegram、不寫 Gateway queue、不呼叫 Bot API、不寫 delivery receipt、不啟動 live AI runtime worker、不啟動中低風險 auto worker、不跑 verifier live readback、不讀 secret、不呼叫付費 provider、不執行 host / cluster / destructive action、不顯示內部對話內容、不提供前端批准 / 執行 / 發送按鈕;不得把 operation permission model 解讀成 runtime loop 已運作。
## 2026-06-12P2-404 runtime worker shadow / no-write execution evidence gate
**背景**P2-403N 已把報表 dry-run 草案提升到 fixture smoke、queue preview readback 與 verifier dry-run統帥要求不要停在報表與 UI而要往真正 AI Agent 自動化流程推進。本段將 P2-403N 的 promotion 轉成 runtime worker shadow / no-write execution evidence gate但仍不啟動 live worker 或任何 production write。