feat(governance): archive duplicate km review drafts
All checks were successful
Code Review / ai-code-review (push) Successful in 10s
Type Sync Check / check-type-sync (push) Successful in 33s
CD Pipeline / tests (push) Successful in 3m31s
CD Pipeline / build-and-deploy (push) Successful in 4m41s
CD Pipeline / post-deploy-checks (push) Successful in 1m53s
All checks were successful
Code Review / ai-code-review (push) Successful in 10s
Type Sync Check / check-type-sync (push) Successful in 33s
CD Pipeline / tests (push) Successful in 3m31s
CD Pipeline / build-and-deploy (push) Successful in 4m41s
CD Pipeline / post-deploy-checks (push) Successful in 1m53s
This commit is contained in:
@@ -1,3 +1,61 @@
|
||||
## 2026-05-20|T93 KM duplicate drafts owner archive action
|
||||
|
||||
**觸發**:
|
||||
|
||||
- T92 已把 Hermes KM healthcheck review drafts 做成後端 read-only dedupe plan,Work Items 可看到 canonical / duplicates / owner action。
|
||||
- 但 Operator 仍只能「看見封存候選」,不能在 AwoooP 內完成 owner 審核後的可稽核封存;舊 duplicate drafts 仍會讓 KM governance 畫面長期顯示髒資料。
|
||||
|
||||
**修正**:
|
||||
|
||||
- 新增 owner-approved write API:`POST /api/v1/ai/governance/km-review-drafts/dedupe/{governance_event_id}/archive-duplicates`
|
||||
- request 必須帶 `canonical_entry_id`、`duplicate_entry_ids`、`owner_approved=true`。
|
||||
- 後端會重新查最新 dedupe plan;canonical 或 duplicate list 與最新 plan 不一致時回 `409`,避免前端 stale click 封存錯資料。
|
||||
- 實際寫入只做 `KnowledgeEntry.status=archived` soft archive,不刪除 KM。
|
||||
- duplicate row 會追加 `archived_by:km_review_dedupe`、`dedupe_canonical:*`、`dedupe_owner:*`、`archived_at:*` 等追蹤 tags。
|
||||
- 成功封存後新增一筆 terminal `governance_remediation_dispatch` audit row:`executor_type=hermes_km_review_dedupe_owner_archive`、`dispatch_status=succeeded`。
|
||||
- double-click / retry 若已由同 canonical 封存過,回 `noop_already_archived`,不重複寫入。
|
||||
- `/awooop/work-items` 的 KM 草稿去重視圖新增 owner action button:
|
||||
- 按下後送出 canonical + duplicates + owner approval。
|
||||
- 成功後重新整理 telemetry,讓 draft / duplicate count 回到 production truth。
|
||||
- UI 全部走 i18n,icon 使用 Lucide `Archive`,不使用 emoji。
|
||||
|
||||
**Local verification**:
|
||||
|
||||
```text
|
||||
python3 -m py_compile apps/api/src/models/governance.py apps/api/src/api/v1/ai_governance.py apps/api/src/services/governance_query_service.py apps/api/src/services/governance_km_review_service.py
|
||||
-> ok
|
||||
DATABASE_URL=postgresql+asyncpg://test:test@localhost:5432/test /Users/ogt/awoooi/apps/api/.venv/bin/python -m pytest apps/api/tests/test_ai_governance_endpoints.py apps/api/tests/test_governance_dispatcher.py apps/api/tests/test_hermes_kb_growth_worker.py -q
|
||||
-> 59 passed
|
||||
pnpm --dir apps/web exec next lint --file 'src/app/[locale]/awooop/work-items/page.tsx'
|
||||
-> No ESLint warnings or errors
|
||||
pnpm --dir apps/web exec tsc --noEmit --pretty false
|
||||
-> ok
|
||||
/Users/ogt/awoooi/apps/api/.venv/bin/python -m ruff check apps/api/src/api/v1/ai_governance.py apps/api/src/models/governance.py apps/api/src/services/governance_km_review_service.py apps/api/tests/test_ai_governance_endpoints.py
|
||||
-> All checks passed
|
||||
cd apps/api && /Users/ogt/awoooi/apps/api/.venv/bin/python ../../scripts/generate-schemas.py && cd ../../packages/shared-types && pnpm generate:types
|
||||
-> packages/shared-types 無 diff
|
||||
git diff --check
|
||||
-> pass
|
||||
```
|
||||
|
||||
**待 production deploy / smoke**:
|
||||
|
||||
- 推 Gitea main 後確認 CD / Code Review / Type Sync / E2E Health 全綠。
|
||||
- `GET /api/v1/ai/governance/km-review-drafts/dedupe?limit=100` 應仍回目前 duplicate plan。
|
||||
- 對第一組 duplicate plan 呼叫 archive endpoint 的 `dry_run=true`,確認 `status=dry_run`、`would_archive_entry_ids` 不為空、`writes_km=false`。
|
||||
- Work Items production smoke 要看到「封存重複草稿」按鈕與 owner action 結果區,且無 console/page error。
|
||||
|
||||
**目前整體進度**:
|
||||
|
||||
- AwoooP 告警可觀測鏈:約 99.1%。
|
||||
- 低風險自動修復閉環:約 95%。
|
||||
- 前端 AI 自動化管理介面同步:約 97.4%。
|
||||
- 治理告警可讀性 / 可處置性:約 97.8%。
|
||||
- AI Agent ownership 可追溯性:約 96.3%。
|
||||
- KM healthcheck 派工可追蹤性:約 99%。
|
||||
- Hermes KB growth 草稿 / owner review 閉環:約 98.2%。
|
||||
- 完整 AI 自動化管理產品化:約 95.6%。
|
||||
|
||||
## 2026-05-19|T92 KM review drafts owner dedupe plan
|
||||
|
||||
**觸發**:
|
||||
|
||||
@@ -2313,6 +2313,15 @@ Phase 6 完成後
|
||||
- 邊界:T89 補齊 detail/history read model 的 dispatch id 鏈路,不代表 Hermes KB growth worker 已執行草稿、owner review 或 KM writeback;下一段仍需實作 worker 消費 pending dispatch 並推進狀態。
|
||||
- 目前進度更新:治理告警可讀性 / 可處置性約 96%;AI Agent ownership 可追溯性約 94.5%;KM healthcheck 派工可追蹤性約 92%;詳情 / 歷史 dispatch read model 約 93%;完整 AI 自動化管理產品化約 92.8%。
|
||||
|
||||
**T93 KM duplicate drafts owner archive action(2026-05-20 台北)**:
|
||||
- 觸發:T90-T92 已讓 `knowledge_degradation` → Hermes KB growth → KM review draft → dedupe plan 在 Work Items 可見,但 Operator 仍只能看到封存候選,不能在 AwoooP 內完成 owner 審核後的可稽核封存。
|
||||
- 修正:新增 owner-approved write API `POST /api/v1/ai/governance/km-review-drafts/dedupe/{governance_event_id}/archive-duplicates`。寫入前重新查最新 dedupe plan,canonical 或 duplicate list 不一致即 `409`;未傳 `owner_approved=true` 即拒絕;實際動作只將 duplicate `KnowledgeEntry.status` 改為 `archived`,不刪除 KM。
|
||||
- Audit:成功封存時會新增 terminal `governance_remediation_dispatch` row,`executor_type=hermes_km_review_dedupe_owner_archive`、`dispatch_status=succeeded`,`decision_context.workflow.current_stage=km_duplicate_archive_after_owner_approval`,並記錄 canonical / archived ids / owner / next_action=`stale_ratio_recheck`。
|
||||
- UI:`/awooop/work-items` 的 KM 草稿去重視圖新增 Lucide `Archive` owner action button,按下後送 canonical + duplicates + owner approval,成功後重新抓 production telemetry。UI copy 全部走 i18n。
|
||||
- 邊界:T93 打通 owner 審核後的 duplicate soft-archive 操作,不代表 AI 可自動封存高影響 KM;高影響知識仍需 owner review,AI 只能產生草稿、dedupe plan 與可稽核建議。
|
||||
- Local verification:`py_compile` ok;治理 endpoint / dispatcher / Hermes worker tests `59 passed`;Work Items Next lint ok;`tsc --noEmit` ok;ruff ok;shared-types regenerate 後無 diff;`git diff --check` pass。
|
||||
- 目前進度更新:治理告警可讀性 / 可處置性約 97.8%;AI Agent ownership 可追溯性約 96.3%;KM healthcheck 派工可追蹤性約 99%;Hermes KB growth 草稿 / owner review 閉環約 98.2%;完整 AI 自動化管理產品化約 95.6%。
|
||||
|
||||
---
|
||||
|
||||
### 2026-04-20 晚 (台北) — C1-C4 全流程串接 — Playbook 鏈路保護(commit de2d34d)
|
||||
|
||||
Reference in New Issue
Block a user