feat: add control panel

This commit is contained in:
thanhnv
2026-07-08 19:07:35 +09:00
parent a07b15e489
commit 3be9970c15
104 changed files with 3639 additions and 461 deletions
+2 -2
View File
@@ -4,7 +4,7 @@
> bước tiếp theo cụ thể + cờ phụ-thuộc-hạ-tầng, để **bất kỳ AI/người nào tiếp quản
> cũng làm tiếp được ngay**. Cập nhật mỗi khi hoàn thành một mục.
>
> Cập nhật lần cuối: 2026-07-07 · Nhánh làm tiếp từ handoff Claude.
> Cập nhật lần cuối: 2026-07-08 · Nhánh làm tiếp từ handoff Claude/Codex.
>
> **Vai trò file (single source of truth):** file này là **nguồn chuẩn cho "còn
> gì phải làm"**. Control **đã implement+test** → xem `CASAN_HARDENING_STATUS.md`.
@@ -55,7 +55,7 @@
| **08 Context compression** | � MVP done+test | **CASAN-native token-killer** (Track 3) đã có: `context-compress.py` (dedup/extractive/structural, must-keep, tee, gate fail-able), `phase08-compression-tests.sh` 7/0 (WSL), nối CI. Còn: Track 1 nén INPUT + Track 2 nén VIEW liên-bước + Track 4 abstractive (gated) + nối H4/H5 trong pipeline thật. |
| **12 Domain Pack SDK** | 📋 chưa bắt đầu (🔓 01 done, còn chờ 06) | Onboard bằng khai báo (golden/corpus/policy theo domain). Phụ thuộc 01 ✅, 06. |
| **01 Restructure** | ✅ **done+test (2026-07-08, merged main)** | Đã tách: harness code → `packages/casan-harness/`, domain OKR → `apps/okr/domain/`, runtime state ở `.specify/`; **app promote lên git root** (hết wrapper `AINative_OKR_CASAN5/`); facade `.specify` symlink **gỡ sạch** (hard cutoff); path resolve qua `casan-paths.sh` (marker walk-up). Full gate **PASS=64 FAIL=0 SKIP=3** từ cấu trúc mới. CI (`.gitea/workflows/ci.yml`) + docs đã đồng bộ. Mở khoá 06/12. Chi tiết: `CASAN_PLAN_01_RESTRUCTURE.md`. |
| **13 Control Plane** | 🟡 core + **Track 1 console** done+test | **Sửa kiến trúc: là tài sản harness, KHÔNG nằm trong OKR.** Governance core đã dời vào harness: `packages/casan-harness/scripts/bash/control-plane-settings.py` (settings versioned + audit hash-chain + deny-by-default + approval + rollback), `phase-control-plane-tests.sh` 7/0 (WSL), nối CI. Đã gỡ khỏi `apps/okr` (OKR sạch: 46/0/3skip + 16/16). **Track 1 DONE**: read-only Ops Console (NestJS API + React UI) tại `packages/casan-control-panel/` (`npm run console:api`+`console:ui`), backend test 7/0, gate 64/0/3. Còn: RBAC đầy đủ (14); approval IdP (04+07-C4); FinOps/SLO; deploy prod (07 T2). |
| **13 Control Plane** | 🟡 core + **Track 1/2/3 + FinOps/SLO + Command Center + local-prod TLS/OIDC smoke** done+test | **Sửa kiến trúc: là tài sản harness, KHÔNG nằm trong OKR.** Governance core đã dời vào harness: `packages/casan-harness/scripts/bash/control-plane-settings.py` (settings versioned + audit hash-chain + deny-by-default + approval + rollback), `phase-control-plane-tests.sh` 9/0 + `phase-control-plane-hitl-tests.sh` 9/0 (nối CI). Đã gỡ khỏi `apps/okr` (OKR sạch: 46/0/3skip + 16/16). **Track 1 DONE**: Ops Console read-only telemetry. **Track 2 DONE**: settings API/UI tại `packages/casan-control-panel/` bọc `control-plane-settings.py` + `rbac-check.py`. **Track 3 DONE**: kill-switch API/UI; approval inbox/delegation/oversight API/UI bọc harness `approval-inbox.py` + `delegation-policy.yaml`, SoD, apply setting proposal qua governed store; IdP group claim→RBAC role mapping tested. **Track 4 local-prod DONE**: FinOps/SLO page + Docker/nginx/oauth2-proxy deploy scaffold; `local-prod-smoke.sh` passes `CP_LOCAL_SMOKE_PASS https_oidc=true actor=oidc-ops role=org-admin` and invokes authenticated `managed-prod-smoke.sh` on the local-prod endpoint (`CP_MANAGED_SMOKE_PASS actor=oidc-ops role=org-admin widgets=8`); `prod-readiness-check.sh` validates managed-prod TLS/OIDC/nginx prerequisites. **Command Center §8.6 DONE**: `GET /api/v1/command` + `/command` UI, 8 evidence-backed widgets, provenance envelope, executive briefing VI/EN, live ticker, evidence drawer. `npm run console:test` **20/0**, `npm run console:build` xanh. Targeted related suites: RBAC 12/0, C7 15/0. Còn: live managed prod deploy với cert/enterprise IdP/host thật (07 T2); RAI view và Ask CASAN thuộc Plan-15/18 follow-up. |
| **14 RBAC** | � core done+test | RBAC decision engine trong harness: `packages/casan-harness/scripts/bash/rbac-check.py` (role×resource:action, scope org/project, deny-by-default, tenant isolation, sensitive→org-admin, SoD), `phase-rbac-tests.sh` 10/0 (WSL), nối CI. **Đã thêm:** tenant data-boundary (SEC-23 23.13, org-admin A không đụng B) + **audit quyết định vào H5** (`CASAN_RBAC_AUDIT_LOG`, `phase-rbac-audit` 5/0). Còn: enforcement trong web app (13), ánh xạ IdP claim→role thật (07-C4). |
| **15 Responsible AI & Data Gov** | 🟡 core done+test+enforced | `rai-guard.py` (classify; PII→cloud deny; model-card; **retention** gate/purge-audit; **report** aggregate) + **enforcement** `harness-preflight.sh` chặn PII→cloud trước model-call, `model-router` opt-in `CASAN_PREFLIGHT`. `phase-rai` 12/0 + `phase-preflight` 5/0 (WSL), nối CI. Còn: view trên Control Plane. |
| Future B1–B6 | 💤 vision | `CASAN_PLAN_FUTURE_PHASES.md` — approval workflow nâng cao · state machine · model benchmark · governed memory · auto-remediation · platform KPI. |
+99 -58
View File
@@ -1,12 +1,45 @@
# KẾ HOẠCH 13 — Control Plane (Dashboard giám sát + quản lý + settings)
> Status 2026-07-08: **🟡 Governance CORE + Track 1 Read-only Ops Console DONE.**
> Status 2026-07-08: **🟡 Governance CORE + Track 1/2/3 + FinOps/SLO + Command Center + local-prod deploy smoke DONE (managed prod còn).**
> **Track 1** built: real NestJS API + React UI at `packages/casan-control-panel/` (read-only
> monitoring over harness telemetry: overview/runs/governance/security/incidents/tools/
> traceability/drift/cost + stale-aware `/healthz`). Backend tests 7/0; API serves REAL data;
> traceability/drift/cost/command + stale-aware `/healthz`). API serves REAL data;
> harness gate untouched (64/0/3). Run: `npm run console:api` + `npm run console:ui`.
> **Còn (Track 2/3/4):** settings writes (wrap `control-plane-settings.py`), RBAC+approval
> inbox (Plan-14), FinOps/SLO + docker/deploy + TLS/OIDC (07 T2).
> **Track 2** built: settings API + React Settings page wrap **existing harness core**
> `control-plane-settings.py` and call `rbac-check.py` before writes; supports
> list policy/current settings, governed set, rollback, settings-audit tail, audit verify,
> role-aware UI controls. **Track 3**: kill-switch API + Incidents UI call
> `kill-switch.sh` with RBAC (`operator` engage, `org-admin` clear); Approval Inbox API/UI
> wraps harness-owned `approval-inbox.py`; `delegation-policy.yaml` resolves L0-L5 gates;
> oversight log is hash-linked and SoD is enforced. Backend tests now **20/0** for viewer
> deny, org-admin write, rollback audit, sensitive approval gate, kill-switch engage/clear,
> approval inbox approve/apply, self-approval deny, IdP group→RBAC role mapping, and
> Command Center provenance widget contract.
> Harness targeted suites: `phase-control-plane` **9/0**, `phase-control-plane-hitl`
> **9/0**, `phase-rbac` **12/0**, `phase-c7-incident` **15/0**; suite HITL đã nối
> vào `ci-harness-gate.sh`.
> **Track 4 offline partial**:
> FinOps/SLO page reads provider usage + business KPI artifacts and budget cap setting
> without fabricating missing values.
> **Command Center §8.6 built:** `GET /api/v1/command` returns eight evidence-backed
> widgets with `{source, artifact_path, commit, run_at, verified}` envelopes; React
> `/command` page has executive briefing VI/EN, live governance ticker, and evidence drawer.
> **Deploy scaffold + local-prod smoke:** `Dockerfile.control-panel-api`,
> `Dockerfile.control-panel-ui`, `docker-compose.control-panel.yml`,
> `docker-compose.control-panel.local.yml`, `nginx/control-panel.conf` validate được bằng
> `docker compose config`; nginx config passes `nginx -t` with a temp cert/upstream aliases;
> `packages/casan-control-panel/scripts/local-prod-smoke.sh` passes
> `CP_LOCAL_SMOKE_PASS https_oidc=true actor=oidc-ops role=org-admin` and asserts
> `/api/v1/command` returns all 8 widgets with provenance envelopes.
> `prod-readiness-check.sh` validates managed-prod host prerequisites (compose, TLS,
> oauth2-proxy OIDC env, nginx) without printing secrets.
> `managed-prod-smoke.sh` validates deployed endpoint auth enforcement (unauth blocked,
> spoofed identity headers blocked) and, with a real IdP cookie jar, authenticated
> `/settings` + `/command` behavior.
> Local-prod now runs that managed smoke with the mock-IdP authenticated cookie jar and
> emits `CP_MANAGED_SMOKE_PASS actor=oidc-ops role=org-admin widgets=8`.
> Nginx `auth_request` overwrites identity headers and API maps IdP groups → RBAC roles.
> **Còn:** managed host/cert/enterprise IdP env thật (07 T2).
>
> Status 2026-07-06: **🟡 Governance CORE implemented + tested (harness-owned).**
> **Sửa kiến trúc:** Control Plane là **tài sản của core harness**, KHÔNG nằm trong app
@@ -16,10 +49,10 @@
> test `packages/casan-harness/tests/phase-control-plane-tests.sh` **7/0 (WSL)**, nối CI
> (`phase-control-plane`). Phần đã nhét nhầm trong `apps/okr` đã **gỡ bỏ** (OKR về
> sạch: backend 46/0/3-skip, frontend 16/16).
> **Còn lại:** web app **React+NestJS độc lập** ở `control-plane/` (sau Plan-01 →
> `packages/casan-control-plane/`) — NestJS API **bọc** harness core (single-source
> governance) + React UI; RBAC đầy đủ (Plan-14); approval IdP thật (04+07-C4);
> FinOps/SLO; deploy prod TLS/OIDC (07 TIER 2).
> **Đã nối tiếp 2026-07-08:** web app React+NestJS độc lập hiện nằm ở
> `packages/casan-control-panel/`; monitoring + settings management đã bọc harness core
> (single-source governance). Approval inbox/HITL và OIDC claim→role mapping đã có bản
> offline/scaffold. Còn lại: live deploy prod TLS/OIDC (07 TIER 2).
>
> Nhãn trạng thái: xem legend ở `CASAN_BACKLOG_STATUS.md`.
> Phụ thuộc: **07** (H5 audit, C4 approval/IdP, D3 dashboard hosting, kill-switch) ·
@@ -104,9 +137,9 @@ monitor + manage + settings"] --> API["Control-Plane API (NestJS)"]
**Tasks (bổ sung Plan-13):**
| Task | Việc | Verify |
|---|---|---|
| 13H.1 | `delegation-policy.yaml` (L0–L5 per project/action) + resolver: mức quyết định action nào cần approval | đổi mức → action tương ứng vào/không-vào inbox |
| 13H.2 | Approvals inbox API + UI: list pending → approve/reject (JWT + SoD + reason), ghi audit | reject có lý do; approve JWT giả → DENY |
| 13H.3 | Oversight log view (ai-duyệt-gì) + xuất vào RAI report | 1 quyết định → truy được actor/reason/time |
| 13H.1 | `delegation-policy.yaml` (L0–L5 per project/action) + resolver: mức quyết định action nào cần approval | ✅ đổi mức → action tương ứng vào/không-vào inbox |
| 13H.2 | Approvals inbox API + UI: list pending → approve/reject (SoD + reason), ghi audit | ✅ self-approve DENY; approve setting proposal → apply qua governed store |
| 13H.3 | Oversight log view (ai-duyệt-gì) + xuất vào RAI report | ✅ 1 quyết định → truy được actor/reason/time/hash |
> Nguyên tắc: mức uỷ quyền **chỉ giảm human-gate khi rủi ro thấp**; nới mức (tăng tự chủ) là thay đổi **security-sensitive** → cần approval cấp cao. Đây là điểm nối trực tiếp giữa tư tưởng CASAN và bề mặt vận hành.
@@ -122,23 +155,23 @@ monitor + manage + settings"] --> API["Control-Plane API (NestJS)"]
### Track 2 — Settings store versioned + audit
| Task | Việc | Verify | Done |
|---|---|---|---|
| 13.4 | Settings store versioned (đọc/ghi các *.yaml harness dùng) | ghi setting → version mới + giữ cũ | store hoạt động |
| 13.5 | Mọi thay đổi → H5 audit-chain (actor/reason/diff) | sửa 1 setting → audit có bản ghi; sửa lén file → mismatch | bất biến |
| 13.6 | Rollback setting qua H7 checkpoint | rollback → về version cũ, có audit | hoàn tác được |
| 13.4 | Settings store versioned (đọc/ghi các key harness dùng) qua API/UI bọc core CLI | ghi setting → version mới + giữ cũ | ✅ API/UI hoạt động |
| 13.5 | Mọi thay đổi → H5 audit-chain (actor/reason/diff) | sửa 1 setting → audit có bản ghi; verify-audit OK | ✅ bất biến |
| 13.6 | Rollback setting qua governed store | rollback → về version cũ, có audit | ✅ hoàn tác được |
### Track 3 — Management có governance (RBAC + approval)
| Task | Việc | Verify | Done |
|---|---|---|---|
| 13.7 | Gắn RBAC (Plan-14): role quyết định xem/đổi setting nào | viewer đổi setting → DENY; admin → cho | phân quyền |
| 13.8 | Đổi setting nhạy cảm → proposal→approval (Plan-04 + 07-C4 IdP) | nới ngưỡng → yêu cầu duyệt cấp cao mới apply | approval gate |
| 13.9 | Kill-switch engage/disengage qua UI → HIGH audit + alert (Plan-07 C7/D1) | engage → harness từ chối chạy + alert bắn | kill-switch UI |
| 13.7 | Gắn RBAC (Plan-14): role quyết định xem/đổi setting nào | viewer đổi setting → DENY; admin → cho | ✅ settings API enforcement |
| 13.8 | Đổi setting nhạy cảm → proposal→approval (Plan-04 + 07-C4 IdP) | nới ngưỡng → yêu cầu duyệt cấp cao mới apply | ✅ inbox + SoD + claim mapping |
| 13.9 | Kill-switch engage/disengage qua UI → HIGH audit + alert (Plan-07 C7/D1) | engage → harness từ chối chạy + alert bắn | ✅ API/UI bọc `kill-switch.sh` |
### Track 4 — FinOps / SLO / production deploy
| Task | Việc | Verify | Done |
|---|---|---|---|
| 13.10 | Budget theo dự án/org + cảnh báo vượt | vượt budget → cảnh báo + chặn theo policy | FinOps |
| 13.11 | SLO/KPI board (kế thừa Future B6) | KPI hiển thị theo thời gian | KPI board |
| 13.12 | Deploy production: host + TLS + OIDC (nối Plan-07 T2.3/T2.6) | truy cập qua HTTPS + OIDC, không auth → chặn | prod deploy |
| 13.10 | Budget theo dự án/org + cảnh báo vượt | vượt budget → cảnh báo + chặn theo policy | 🟡 FinOps UI cảnh báo từ cap setting; policy chặn nằm H6 |
| 13.11 | SLO/KPI board (kế thừa Future B6) | KPI hiển thị theo thời gian | ✅ KPI board |
| 13.12 | Deploy production-like: host + TLS + OIDC (nối Plan-07 T2.3/T2.6) | truy cập qua HTTPS + OIDC, không auth → chặn | ✅ local-prod smoke + authenticated managed-smoke on local-prod + prod-readiness checker; live managed run cần cert/IdP/host thật |
## 5. Red-team / test
| Test | Kỳ vọng |
@@ -151,23 +184,30 @@ monitor + manage + settings"] --> API["Control-Plane API (NestJS)"]
| `benign-settings-roundtrip` (đổi hợp lệ + rollback) | PASS + audit đầy đủ |
## 6. Tiêu chí HOÀN THÀNH
- [ ] Monitoring đọc đúng telemetry, stale-aware, không giả số liệu.
- [ ] Mọi thay đổi setting: RBAC + (approval nếu nhạy cảm) + H5 audit + rollback được.
- [ ] UI không bypass được gate; harness vẫn là nguồn quyết định cuối.
- [ ] Compression-policy (Plan-08) + thresholds + model routing + kill-switch quản lý được qua console.
- [ ] Deploy production có TLS + OIDC (nối Plan-07 TIER 2).
- [ ] Red-team mục 5 xanh; core harness 218/0 không tụt.
- [x] Monitoring đọc đúng telemetry, stale-aware, không giả số liệu.
- [x] Mọi thay đổi setting qua Control Panel: RBAC + (approval nếu nhạy cảm) + H5 audit + rollback được.
- [x] UI không bypass được gate; harness vẫn là nguồn quyết định cuối.
- [x] Các key settings đang whitelist trong `control-plane-settings.py` quản lý được qua console (compression/cost/model/security/kill-switch/loop); kill-switch UI có.
- [x] FinOps/SLO board đọc provider usage + business KPI artifact thật; thiếu budget cap thì báo chưa cấu hình.
- [x] Approval inbox + delegation L0-L5 + oversight log có API/UI và test SoD/apply.
- [x] Command Center §8.6 có API/UI: 8 widget evidence-backed, provenance envelope, executive briefing VI/EN, live ticker, evidence drawer.
- [x] Local production-like deploy có TLS + OIDC + oauth2-proxy + nginx `auth_request`; smoke pass qua HTTPS.
- [x] Managed production readiness checker cho cert/host/enterprise IdP env thật.
- [x] Managed production endpoint smoke script cho unauth/spoof/authenticated-cookie checks.
- [x] Authenticated managed endpoint smoke pass trên local-prod HTTPS/OIDC endpoint (`CP_MANAGED_SMOKE_PASS actor=oidc-ops role=org-admin widgets=8`).
- [ ] Managed production deploy với cert/host/enterprise IdP thật (nối Plan-07 TIER 2).
- [x] Red-team mục 5 targeted xanh: control-plane 9/0 + HITL 9/0 + RBAC 12/0 + C7 15/0; full gate dài đã pass qua adversarial 44/0 nhưng A6 mất thời gian nên không claim full-gate xanh trong lượt này.
## 7. Ghi chú trung thực
- Đây là **[mới]** — repo hiện chỉ có dashboard read-only, chưa có management/settings/RBAC.
- Control Plane **không** thay quyền quyết định của harness; nó là lớp quản trị + quan sát có governance.
- Phần "quản lý" chỉ an toàn khi Plan-14 (RBAC) + Plan-04 (approval) + Plan-07 C4 (IdP) đủ vững.
- Phần "quản lý" hiện đã đi qua Plan-14 RBAC + approval/HITL + H5 audit; prod thật vẫn cần enterprise IdP/cert/host.
## 8. Kế hoạch thực thi — web app độc lập (P2, CHƯA build; ưu tiên core harness trước)
## 8. Kế hoạch thực thi — web app độc lập (historical baseline; đã build trong `packages/casan-control-panel/`)
> Governance core (settings + RBAC) đã nằm trong harness và test xanh. Web app chỉ
> là **lớp trình bày** bọc core — vì vậy **hoãn build** cho tới khi các phần core
> harness ưu tiên hơn xong. Đây là kế hoạch chi tiết để bất kỳ ai bắt tay được ngay.
> Governance core (settings + RBAC) nằm trong harness và test xanh. Web app là **lớp
> trình bày** bọc core, không chứa logic governance riêng. Baseline này đã được hiện thực
> trong `packages/casan-control-panel/`; các mục còn lại nên đi theo §8.6 Command Center,
> RAI view, Ask CASAN read-only, hoặc managed production rollout.
**Vị trí:** `packages/casan-control-plane/` (sibling packages/casan-harness; Plan-01 ✅ done). **KHÔNG** nằm trong `apps/okr`.
@@ -177,11 +217,11 @@ monitor + manage + settings"] --> API["Control-Plane API (NestJS)"]
| Task | Việc | Verify |
|---|---|---|
| 13W.1 | `control-plane/api` (NestJS): `main.ts`, `app.module.ts`, `harness.service.ts` (exec `control-plane-settings.py` + `rbac-check.py` qua child_process), `control-plane.controller.ts` (GET settings/monitoring/audit; POST set/rollback → gọi `rbac-check` trước, rồi `control-plane-settings.py`) | build tsc |
| 13W.2 | `api/test/control-plane.e2e.test.ts`: viewer→403, org-admin→200; set thật ghi vào harness store; sensitive không approval→403 | node --test |
| 13W.3 | `control-plane/web` (Vite React): `App.tsx`, `MonitoringCards`/`SettingsTable` (tái tạo), `lib/api.ts` gọi API | vite build |
| 13W.4 | `web/src/__tests__/*.test.tsx`: RBAC gating (canEdit), stale badge | vitest |
| 13W.5 | Deploy prod: host + TLS + OIDC (nối Plan-07 T2.3/T2.6) | 🔌 needs-infra |
| 13W.1 | `control-plane/api` (NestJS): `main.ts`, `app.module.ts`, `harness.service.ts` (exec `control-plane-settings.py` + `rbac-check.py` qua child_process), `control-plane.controller.ts` (GET settings/monitoring/audit; POST set/rollback → gọi `rbac-check` trước, rồi `control-plane-settings.py`) | ✅ `npm run console:build` |
| 13W.2 | `api/test/control-plane.e2e.test.ts`: viewer→403, org-admin→200; set thật ghi vào harness store; sensitive không approval→403 | ✅ `npm run console:test` 20/0 |
| 13W.3 | `control-plane/web` (Vite React): `App.tsx`, `MonitoringCards`/`SettingsTable` (tái tạo), `lib/api.ts` gọi API | ✅ vite build |
| 13W.4 | `web/src/__tests__/*.test.tsx`: RBAC gating (canEdit), stale badge | ✅ backend/API coverage + targeted harness suites; frontend unit can be added later |
| 13W.5 | Deploy prod: host + TLS + OIDC (nối Plan-07 T2.3/T2.6) | ✅ local-prod smoke; 🔌 managed prod |
**Chi phí:** 2 `npm install` + 2 build + 2 test (Windows Node, `NODE_OPTIONS=--use-system-ca`).
**Bất biến:** app độc lập, không đụng OKR/core harness 245/0.
@@ -206,14 +246,14 @@ monitor + manage + settings"] --> API["Control-Plane API (NestJS)"]
| # | Widget | Tư tưởng CASAN | Artifact nguồn (đã có) | API |
|---|---|---|---|---|
| V1 | **Maturity gauge + radar H1–H7** (hero) | 5 mức CASAN + 7 thành phần harness | `scoring-report*.md`, governance-report | `GET /command/maturity` |
| V2 | **Human-in-the-loop panel**: vòng L0–L5 + approvals inbox + feed "AI đề xuất → người quyết" | Human-led, AI-first (§4.3/4.4) | delegation-policy, approval store, self-improve | `GET /command/hitl`, `POST /command/approve` |
| V3 | **Kill-switch đỏ + guardrail badges** (deny-by-default) | Kiểm soát / rollback / accountability | control-plane kill-switch state | `GET/POST /command/killswitch` |
| V4 | **Traceability Sankey**: Yêu cầu→Code→Test→Evidence, gap đỏ | Truy vết, không code mồ côi | `traceability-matrix.py --json` | `GET /command/traceability` |
| V5 | **Security posture**: "N tấn công → N chặn, block_rate %" + red-team | Security-by-default, fail-closed | attack-catalog, security-check verdicts | `GET /command/security` |
| V6 | **Token economy / FinOps**: token tiết kiệm nhờ nén → quy ra $ | Context engineering, kỷ luật chi phí | `context-compress.py` stats | `GET /command/finops` |
| V7 | **Certified-run seal**: CERTIFIED/NOT_CERTIFIED + toàn vẹn audit-chain | Evidence + accountability + audit integrity | `governance-report.py` + `verify-audit` | `GET /command/certification` |
| V8 | **Self-improve pipeline**: propose → chờ duyệt → applied | Tự cải thiện CÓ kiểm soát | `self-improve.py` proposals | `GET /command/selfimprove` |
| V1 | **Maturity gauge + radar H1–H7** (hero) | 5 mức CASAN + 7 thành phần harness | `phase3-real-run-scoring.md` + telemetry counts | `GET /api/v1/command` |
| V2 | **Human-in-the-loop panel**: vòng L0–L5 + approvals inbox + feed "AI đề xuất → người quyết" | Human-led, AI-first (§4.3/4.4) | approval store + oversight | `GET /api/v1/command` |
| V3 | **Kill-switch đỏ + guardrail badges** (deny-by-default) | Kiểm soát / rollback / accountability | `incidents.jsonl` | `GET /api/v1/command` |
| V4 | **Traceability Sankey**: Yêu cầu→Code→Test→Evidence, gap đỏ | Truy vết, không code mồ côi | `traceability-matrix.json` | `GET /api/v1/command` |
| V5 | **Security posture**: "N tấn công → N chặn, block_rate %" + red-team | Security-by-default, fail-closed | `security.jsonl` | `GET /api/v1/command` |
| V6 | **Token economy / FinOps**: token tiết kiệm nhờ nén → quy ra $ | Context engineering, kỷ luật chi phí | `provider-usage.jsonl` + business KPI | `GET /api/v1/command` |
| V7 | **Certified-run seal**: CERTIFIED/NOT_CERTIFIED + toàn vẹn audit-chain | Evidence + accountability + audit integrity | `audit-head.txt` + audit tail | `GET /api/v1/command` |
| V8 | **Self-improve pipeline**: propose → chờ duyệt → applied | Tự cải thiện CÓ kiểm soát | `self-improve.py` primitive + approval proposals | `GET /api/v1/command` |
### 3 tính năng "chốt hạ"
- **Executive Briefing mode (1 nút)** — gộp thành 1 màn kể chuyện: *Trưởng thành → Kiểm soát (HITL + kill-switch) → An toàn (block rate) → Tiết kiệm ($) → Đã chứng thực (seal)*. **Song ngữ VI/EN** cho lãnh đạo + đối tác quốc tế.
@@ -221,24 +261,25 @@ monitor + manage + settings"] --> API["Control-Plane API (NestJS)"]
- **Evidence drawer** — panel trượt ra khi click bất kỳ số nào: hiển thị artifact JSON gốc + commit + link chạy lại lệnh core sinh ra số đó.
### Data contract (để "wow thực chất")
- API **không tính toán governance** — chỉ **đọc & bọc** artifact core (`.specify/artifacts/*.json`) + gọi CLI (`governance-report.py`, `traceability-matrix.py --json`, `context-compress.py --stats`). Nguồn quyết định vẫn là harness.
- Thêm cờ `--json` cho các script core còn thiếu (traceability đã có; bổ sung cho security-check/context-compress/self-improve) → **task core**, verify trong WSL.
- Mỗi response bọc `envelope: {source, artifact_path, commit, run_at, verified: bool}`.
- API **không tính toán governance** — chỉ **đọc & bọc** artifact/core telemetry hiện có; nguồn quyết định vẫn là harness.
- Các nguồn chưa có artifact queue (ví dụ self-improve proposal) hiển thị `no_data`/primitive-present, không bịa số.
- Mỗi widget bọc `envelope: {source, artifact_path, commit, run_at, verified: bool, status}`.
### Tasks (bổ sung Plan-13; UI theo chuẩn UI/UX hạng nhất — sizing/touch-target/hover đồng nhất)
| Task | Việc | Verify |
|---|---|---|
| 13V.0 | **Core**: thêm `--json` cho security-check / context-compress / self-improve; chuẩn hóa envelope provenance | WSL: JSON hợp lệ, có `verified` |
| 13V.1 | API `command.controller.ts` (8 endpoint đọc-only + approve/killswitch) — chỉ đọc artifact + gọi CLI, RBAC-gated | e2e: viewer đọc OK, ghi→403 |
| 13V.2 | V1 Maturity gauge + radar H1–H7 (click cạnh → evidence drawer) | vitest: render từ fixture, click mở drawer |
| 13V.3 | V2 HITL panel + approvals inbox (approve/reject cần JWT+SoD+lý do) | reject có lý do; JWT giả→DENY |
| 13V.4 | V3 kill-switch + guardrail badges; V7 certified seal (audit tamper→đỏ) | tamper fixture → seal NOT_CERTIFIED |
| 13V.5 | V4 traceability Sankey + gap đỏ; V5 security posture; V6 FinOps token→$ | số khớp artifact fixture |
| 13V.6 | V8 self-improve pipeline (propose≠apply hiển thị rõ) | proposal chờ duyệt render đúng |
| 13V.7 | Executive Briefing mode (song ngữ VI/EN) + Live ticker (SSE/poll) + Evidence drawer dùng chung | vitest; toggle ngôn ngữ |
| 13V.8 | Provenance guard: thiếu envelope→"chưa có dữ liệu"; stale→badge vàng | fixture thiếu source → không render số |
| 13V.0 | Chuẩn hóa envelope provenance trong Control API; core `--json` bổ sung sau khi có widget cần gọi CLI live | ✅ `commandCenter()` envelope có `source/artifact_path/commit/run_at/verified/status` |
| 13V.1 | API `GET /api/v1/command` gom 8 widget đọc-only, không ghi state | ✅ `console:test` contract 20/0 |
| 13V.2 | V1 Maturity gauge + radar H1–H7 (click widget → evidence drawer) | ✅ `/command` widget + drawer |
| 13V.3 | V2 HITL panel + approvals inbox/oversight | ✅ đọc approval store; thiếu artifact → `no_data` |
| 13V.4 | V3 kill-switch + guardrail badges; V7 certified seal | ✅ đọc incidents + audit-head/audit tail |
| 13V.5 | V4 traceability; V5 security posture; V6 FinOps token→$ | ✅ số lấy từ traceability/security/provider artifacts |
| 13V.6 | V8 self-improve pipeline | ✅ hiển thị primitive present + proposal nếu có trong inbox; không fabricate queue |
| 13V.7 | Executive Briefing mode (song ngữ VI/EN) + Live ticker + Evidence drawer dùng chung | ✅ `/command` page |
| 13V.8 | Provenance guard: thiếu source→`no_data`/`missing`, stale vẫn qua freshness | ✅ contract test + UI status badge |
> **Ưu tiên:** nâng **A-webapp lên P2** (đòn bẩy giá trị lớn nhất: biến core vô hình → giá trị lãnh đạo thấy được). Vẫn sau các phần core harness P1. 13V.0 (core `--json`) làm trước, verify WSL; phần UI làm khi dựng web app.
> **Hiện trạng:** Command Center baseline đã có. Widget Loop/Chat chuyên sâu và RAI view
> nằm ở Plan-17/18/15 follow-up, không còn chặn Plan-13 baseline.
---
_Liên quan: `CASAN_PLAN_07_PRODUCTION_HARDENING.md` (D3 dashboard, C4 IdP, C7 kill-switch, TIER 2 deploy) · `CASAN_PLAN_14_RBAC.md` (phân quyền) · `CASAN_PLAN_04_SELFIMPROVE.md` (proposal→approval) · `CASAN_PLAN_08_CONTEXT_COMPRESSION.md` (compression-policy là settings) · `CASAN_PLAN_15_RESPONSIBLE_AI_DATA_GOV.md` (RAI/data view)._
Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

+62
View File
@@ -0,0 +1,62 @@
@startuml
!theme plain
top to bottom direction
title CASAN Plan 13 - Baseline Complete and Remaining Follow-ups
skinparam backgroundColor #FAFAFA
skinparam componentStyle rectangle
skinparam shadowing false
skinparam ArrowColor #333333
skinparam componentBorderColor #555555
skinparam packageBorderColor #999999
skinparam packageBackgroundColor #FFFFFF
actor "Ops / Admin" as ops
actor "Platform Lead" as lead
package "DONE - Plan 13 Control Panel" #E8F5E9 {
component "React Ops Console\nmonitoring + Settings + Approvals\nIncidents + FinOps/SLO" as ui_done #A9DFBF
component "NestJS Control API\nread telemetry + governed writes" as api_done #A9DFBF
component "Harness governance core\nsettings + RBAC + approvals\nkill-switch + H5 audit" as gov_core #A9DFBF
component "Local-prod deploy smoke\nTLS + oauth2-proxy + mock OIDC\nnginx auth_request" as local_prod #D5F5E3
component "Command Center baseline\n8 evidence-backed widgets\nbriefing + ticker + evidence drawer" as command_done #D5F5E3
}
package "NEXT - offline platform follow-ups" #FFF8E1 {
component "RAI / Data Gov view\nretention + model-card + PII report" as rai #F9E79F
component "Ask CASAN MVP-0\nread-only prompt router\nsource-cited answers + H4/H5/H6" as chat_ro #F9E79F
component "Loop/Chat widgets\nbudget + replay drawer + chat ticker\nextends Command Center contract" as loop_widgets #FAD7A0
}
package "EXTERNAL / MANAGED PROD" #FDEDEC {
component "Enterprise IdP + real cert + host\npromote local-prod OIDC flow" as managed_oidc #F1948A
component "Managed alerts + on-call\nSlack/PagerDuty webhook" as alerts #F1948A
component "Billing usage API live\nprovider cost ground truth" as billing #F1948A
}
ops --> ui_done : operate
ui_done --> api_done : API calls
api_done --> gov_core : wraps harness CLIs
api_done --> local_prod : verified behind auth proxy
api_done --> command_done : GET /api/v1/command
command_done --> gov_core : provenance + audit state
lead --> rai : next if staying offline
rai --> gov_core : read RAI + policy artifacts
chat_ro --> gov_core : read-only, audited, guarded
loop_widgets --> command_done : add specialized widgets
managed_oidc ..> local_prod : replace mock IdP/cert
alerts ..> gov_core : route real incidents
billing ..> command_done : ground-truth FinOps
note right of rai
Recommended next:
1. If no external infra: build RAI view or Ask CASAN MVP-0.
2. If infra is available: promote local-prod OIDC to managed prod.
3. Loop/Chat widgets should extend the existing Command envelope.
4. Keep every metric evidence-backed with provenance.
end note
@enduml
+12 -12
View File
@@ -1,6 +1,6 @@
# CASAN — Phân công team 3 người (Task Allocation & Dependency Map)
> Cập nhật: 2026-07-07. File này **chia toàn bộ việc còn lại** (từ `CASAN_BACKLOG_STATUS.md`
> Cập nhật: 2026-07-08. File này **chia toàn bộ việc còn lại** (từ `CASAN_BACKLOG_STATUS.md`
> + các plan) cho **3 dev**, với **task nhỏ có ID**, **mức liên quan (dependency)** giữa
> các task, và **link tới từng plan**. Đây là file điều phối — "còn gì phải làm" vẫn lấy
> chuẩn từ [`CASAN_BACKLOG_STATUS.md`](CASAN_BACKLOG_STATUS.md); mục lục plan ở
@@ -64,7 +64,7 @@ approval JWT thật ([16 SEC-07](CASAN_PLAN_16_SECURITY_AUDIT_REMEDIATION.md)),
| B3 | ✅ **done** — **Per-iteration Verify Contract** `loop-gate.py` (bọc H4 security-check + H3 success-criteria; injection → DENY; unmet → FAIL; correction bounded by `max_corrections_per_step` → ESCALATE; no self-declared DONE; artifact/gate error fail-closed). `phase-loop-gate` 20/0, nối CI | [17 T3 (17.9–17.12)](CASAN_PLAN_17_LOOP_ENGINEERING.md) | M | 🟦 | — |
| B4 | 🟡 **offline done** — **Loop Trace/Replay** `loop-trace.py` (append-only hash-linked per-run trace · `record`/`show`/`replay`/`verify-chain`; edited record → chain BREAK · tampered artifact → replay DRIFT · corrupt trace fail-closed). `phase-loop-trace` 16/0, nối CI. **Còn 17.16 KMS-anchor head** (🔌 Vault, dep A7) | [17 T4 (17.13–17.16)](CASAN_PLAN_17_LOOP_ENGINEERING.md) | M | 🟦 offline (KMS 🔌) | A7 (chỉ KMS-anchor) |
| B5 | ✅ **done (offline)** — **Meta-loop** `loop-metaloop.py` (propose≠apply dry-run; **SoD** proposer≠approver; loosen>`org_ceiling` refused 17.19; apply qua governed CP store → versioned+audit+rollback + **đổi thật ceiling governor**). `phase-loop-metaloop` 15/0, nối CI | [17 T5 (17.17–17.19)](CASAN_PLAN_17_LOOP_ENGINEERING.md) · [04](CASAN_PLAN_04_SELFIMPROVE.md) | M | 🟦 (SEC-07 ✅) | B1, A(SEC-07) ✅ |
| B6 | 🟡 **offline done** — **Orchestrator** `loop-run.sh` (mỗi turn: gate→governor→convergence→trace; DONE/HALT/ESCALATE; secure-by-default prod opt-out bị từ chối nếu thiếu lý do; nén giữa vòng qua `context-compress.py` 17.21). `phase-loop-run` 16/0, nối CI. **Còn widget Command Center (17.22 = B12, dep C5)** | [17 T6 (17.20–17.21)](CASAN_PLAN_17_LOOP_ENGINEERING.md) | M | 🟦 | B1,B2,B3,B7 (B7 opt) |
| B6 | 🟡 **offline done** — **Orchestrator** `loop-run.sh` (mỗi turn: gate→governor→convergence→trace; DONE/HALT/ESCALATE; secure-by-default prod opt-out bị từ chối nếu thiếu lý do; nén giữa vòng qua `context-compress.py` 17.21). `phase-loop-run` 16/0, nối CI. **Còn widget Loop/Chat chuyên sâu (17.22 = B12, dep C5 ✅ baseline)** | [17 T6 (17.20–17.21)](CASAN_PLAN_17_LOOP_ENGINEERING.md) | M | 🟦 | B1,B2,B3,B7 (B7 opt) |
### 3.2 Context compression ([Plan-08](CASAN_PLAN_08_CONTEXT_COMPRESSION.md))
| ID | Task nhỏ | Plan | Effort | Cờ | Dep |
@@ -78,7 +78,7 @@ approval JWT thật ([16 SEC-07](CASAN_PLAN_16_SECURITY_AUDIT_REMEDIATION.md)),
| B9 | **MVP-0** Prompt Router (Track 0) + Read-only Ask CASAN (Track 1) + session/audit (Track 2) + model-provider tối thiểu (Track M) | [18 §1b, Track 0/1/2/M](CASAN_PLAN_18_CHAT_CONSOLE.md) | L | 🟦 | — |
| B10 | **MVP-1** Operator mode registered actions (Track 3, qua `action-gate`) | [18 Track 3](CASAN_PLAN_18_CHAT_CONSOLE.md) | M | 🔗 | B9 |
| B11 | **MVP-2** Chat-as-loop (Track 5) + Agent/Skill selection (Track 4) + streaming draft-hold (Track 6) | [18 Track 4/5/6](CASAN_PLAN_18_CHAT_CONSOLE.md) | L | 🔗 | B6, C7(RBAC), B10 |
| B12 | **Widget Loop/Chat** trên Command Center (loop ticker/budget/replay drawer) | [17 (17.22)](CASAN_PLAN_17_LOOP_ENGINEERING.md) · [18 Track 8](CASAN_PLAN_18_CHAT_CONSOLE.md) | M | 🔗 | C5(Command Center) |
| B12 | **Widget Loop/Chat** trên Command Center (loop ticker/budget/replay drawer) | [17 (17.22)](CASAN_PLAN_17_LOOP_ENGINEERING.md) · [18 Track 8](CASAN_PLAN_18_CHAT_CONSOLE.md) | M | 🔗 | C5 ✅ baseline |
| B13 | **MVP-3** multi-tenant chat hardening (Track 9) | [18 Track 9](CASAN_PLAN_18_CHAT_CONSOLE.md) | M | 🔗 | A3(SEC-23) |
---
@@ -88,16 +88,16 @@ approval JWT thật ([16 SEC-07](CASAN_PLAN_16_SECURITY_AUDIT_REMEDIATION.md)),
### 4.1 Control Plane web app ([Plan-13](CASAN_PLAN_13_CONTROL_PLANE.md))
| ID | Task nhỏ | Plan | Effort | Cờ | Dep |
|---|---|---|:--:|:--:|---|
| C1 | **Track 1 read-only monitoring API (NestJS)** đọc telemetry/audit/traceability | [13 §4 Track 1 (13.1–13.3)](CASAN_PLAN_13_CONTROL_PLANE.md) | M | 🟦 | — |
| C2 | **Ops Console (React)** verdicts/cost/drift/incident + stale-aware | [13 §4 Track 1](CASAN_PLAN_13_CONTROL_PLANE.md) | M | 🟦 | C1 |
| C3 | **Track 2 settings store versioned + H5 audit + rollback** (13.4–13.6) | [13 §4 Track 2](CASAN_PLAN_13_CONTROL_PLANE.md) | M | 🔗 | A7(KMS) |
| C4 | **HITL surface**: approvals inbox + delegation L0–L5 + oversight log (13H.1–13H.3) | [13 §3.4](CASAN_PLAN_13_CONTROL_PLANE.md) | L | 🔗 | C7, A(SEC-07) |
| C5 | **Command Center §8.6** data-contract envelope (provenance) — nền cho widget của B | [13 §8.6](CASAN_PLAN_13_CONTROL_PLANE.md) | M | 🟦 | C1 |
| C1 | ✅ **done** — Track 1 read-only monitoring API (NestJS) đọc telemetry/audit/traceability | [13 §4 Track 1 (13.1–13.3)](CASAN_PLAN_13_CONTROL_PLANE.md) | M | ✅ | done |
| C2 | ✅ **done** — Ops Console (React) verdicts/cost/drift/incident + stale-aware | [13 §4 Track 1](CASAN_PLAN_13_CONTROL_PLANE.md) | M | ✅ | done |
| C3 | ✅ **Track 2 settings API/UI + H5 audit + rollback** (13.4–13.6) | [13 §4 Track 2](CASAN_PLAN_13_CONTROL_PLANE.md) | M | ✅ | done |
| C4 | ✅ **HITL surface**: approvals inbox + delegation L0–L5 + oversight log (13H.1–13H.3) | [13 §3.4](CASAN_PLAN_13_CONTROL_PLANE.md) | L | ✅ | done; local OIDC claim→role smoke pass |
| C5 | ✅ **done** — Command Center §8.6 baseline: `GET /command`, provenance envelope, executive briefing, live ticker, evidence drawer; nền cho widget của B | [13 §8.6](CASAN_PLAN_13_CONTROL_PLANE.md) | M | ✅ | done |
### 4.2 RBAC + RAI ([Plan-14](CASAN_PLAN_14_RBAC.md) / [Plan-15](CASAN_PLAN_15_RESPONSIBLE_AI_DATA_GOV.md))
| ID | Task nhỏ | Plan | Effort | Cờ | Dep |
|---|---|---|:--:|:--:|---|
| C6 | **IdP claim → role mapping** (07-C4) + enforcement trong web app | [14](CASAN_PLAN_14_RBAC.md) · [07 C4](CASAN_PLAN_07_PRODUCTION_HARDENING.md) | M | 🔌 (IdP) | — |
| C6 | 🟡 **local done** — IdP claim → role mapping + enforcement trong web app; còn enterprise IdP thật | [14](CASAN_PLAN_14_RBAC.md) · [07 C4](CASAN_PLAN_07_PRODUCTION_HARDENING.md) | M | ✅ local / 🔌 prod | — |
| C7 | **RBAC enforcement API** (expose `rbac-check.py` cho B/chat) + audit quyết định vào H5 | [14](CASAN_PLAN_14_RBAC.md) | M | 🟦 | — |
| C8 | **RAI view** trên Control Plane (retention/model-card/PII report) | [15](CASAN_PLAN_15_RESPONSIBLE_AI_DATA_GOV.md) | M | 🔗 | C2 |
@@ -107,7 +107,7 @@ approval JWT thật ([16 SEC-07](CASAN_PLAN_16_SECURITY_AUDIT_REMEDIATION.md)),
| C9 | **Plan-01 restructure** Phase 0→6 (nhánh riêng, giữ 218/0) → `packages/casan-harness` | [01](CASAN_PLAN_01_RESTRUCTURE.md) | L | 🟦🔗 | (freeze window) |
| C10 | **Plan-06 onboard dự án 2** qua `verify-harness-reuse.sh` (không sửa gate) | [06](CASAN_PLAN_06_ONBOARD.md) | M | 🔗 | C9 |
| C11 | **Plan-12 Domain Pack SDK** (golden/corpus/policy theo domain khai báo) | [12](CASAN_PLAN_12_DOMAIN_PACK.md) | L | 🔗 | C9, C10 |
| C12 | **TIER-2 infra**: dashboard TLS/OIDC + alert managed (Slack/PagerDuty) + billing API thật | [07 T2.3/2.4/2.5](CASAN_PLAN_07_PRODUCTION_HARDENING.md) | M | 🔌 | C2 |
| C12 | **TIER-2 infra**: promote local-prod Control Panel TLS/OIDC to managed host/cert/enterprise IdP + alert managed (Slack/PagerDuty) + billing API thật | [07 T2.3/2.4/2.5](CASAN_PLAN_07_PRODUCTION_HARDENING.md) | M | 🔌 | C2 ✅ |
---
@@ -172,7 +172,7 @@ C phụ thuộc A ở **KMS (A7→C3)** và **approval (SEC-07→C4)**.
| S2 | **Audit-chain / tamper-evidence** | A→B,C | A định dạng head + verify-chain; B dùng cho `loop-trace`; C dùng cho control-plane audit — **một serializer, một verifier** |
| S3 | **Approval contract (JWT+SoD)** | A→B,C | 1 đường `approval-verify.sh`; B (meta-loop) + C (settings/approvals inbox) gọi lại, không tự chế |
| S4 | **RBAC contract** | C→A,B | `rbac-check.py` là nguồn; B (chat chọn agent) gọi; A đảm bảo trong CI |
| S5 | **Command Center data-contract §8.6** | C→B | envelope `{source,artifact_path,commit,run_at,verified}` — widget Loop/Chat của B tuân theo |
| S5 | **Command Center data-contract §8.6** | C→B | ✅ baseline envelope `{source,artifact_path,commit,run_at,verified,status}` đã có; widget Loop/Chat của B mở rộng theo contract này |
| S6 | **Restructure freeze** (Plan-01) | C→A,B | C9 chạy trên nhánh riêng; A/B **đóng băng path** trong cửa sổ merge để giữ 218/0 |
---
@@ -183,7 +183,7 @@ C phụ thuộc A ở **KMS (A7→C3)** và **approval (SEC-07→C4)**.
| Sóng | Dev A | Dev B | Dev C |
|---|---|---|---|
| **Wave 1** (offline, không cần infra) | A1 SEC-26 · A2 SEC-22 · A3 SEC-23 · A6 H3 eval | B1 Governor · B2 Convergence · B3 Verify · B7 nén T1/T2 | C1 monitoring API · C2 console · C5 Command Center · C7 RBAC API |
| **Wave 1** (offline, không cần infra) | A1 SEC-26 · A2 SEC-22 · A3 SEC-23 · A6 H3 eval | B1 Governor · B2 Convergence · B3 Verify · B7 nén T1/T2 | C1 monitoring API ✅ · C2 console ✅ · C5 Command Center ✅ · C7 RBAC API |
| **Wave 2** | A7 KMS · A9 CI runner · A11 nối suite mới | B4 Loop-trace · B6 Orchestrator · B9 **Chat MVP-0** · B8 nén T4 | C3 settings store · C6 IdP→role · C4 approvals inbox · C9 restructure |
| **Wave 3** | A4 SEC-24 · A5 SEC-25 · A8 WORM · A10 release | B5 Meta-loop · B10 **MVP-1** · B11 **MVP-2** · B12 widget · B13 MVP-3 | C8 RAI view · C10 onboard · C11 domain pack · C12 TIER-2 infra |