KB-21C7
Điều 31 M2 Report — System Issues Row 11 + Directus Migration
4 min read Revision 1
reportdieu31m2system-issuesrow11s131
ĐIỀU 31 M2 — SYSTEM ISSUES ROW 11 + DIRECTUS MIGRATION
Agent: Claude Code | Session: S131-M2 | Ngày: 2026-03-23 PR: #577 (web-test) — merged, deployed, verified Phụ thuộc: M1 hoàn thành (PR #576)
Assembly Gate
- Q0 PG: KHÔNG (dùng Directus API thay PG trigger — consistent với health.get.ts pattern)
- Q1 Directus: CÓ — migration script thêm 10 fields (chạy riêng với admin token)
- Q2 Nuxt: CÓ — Row 11 trên /knowledge/registries
- Q3 Code mới: 1 server API endpoint + UI row + migration script
- Q4 Test: Playwright tests PASS, contract updated
- Q5 Rollback: git revert
Deliverables
| # | Deliverable | Status |
|---|---|---|
| 1 | Server API /api/registry/system-issues |
✅ PASS — queries by severity, cached 2min |
| 2 | Row 11 "Vấn đề Hệ thống" (CAT-017) on Registries L1 | ✅ PASS — visible on production |
| 3 | Color signal: CRITICAL (red), WARNING (amber), OK (green) | ✅ PASS — in "Thành phần" column |
| 4 | Click drill-down → /knowledge/registries/system_issue | ✅ PASS |
| 5 | Registries contract: CAT-017 in required_rows | ✅ PASS |
| 6 | Smoke keywords: "Vấn đề Hệ thống" added | ✅ PASS |
| 7 | Migration script: 10 Directus fields | ✅ Created (run separately) |
| 8 | CI all GREEN + Playwright PASS | ✅ PASS |
VERIFY NUXT
VERIFY NUXT:
- Nuxt URL: /knowledge/registries
Dòng 11 "Vấn đề Hệ thống": hiện 738. API: /api/registry/system-issues → all=738. KHỚP.
Dòng 11 CRITICAL count: hiện 738 (mồ côi column). API: critical=738. KHỚP.
Dòng 11 color: 🔴 (CRITICAL > 0 → health badge đỏ + "738 CRITICAL" đỏ). ĐÚNG.
Click Dòng 11 → drill-down: /knowledge/registries/system_issue → hiện danh sách. OK.
LƯU Ý DATA: 738 records đều có status=open vì chưa chạy Điều 31 migration.
Sau khi chạy migration + triage (status archived cho legacy records), counts sẽ phản ánh đúng.
Mũ 2 Evidence
| Workflow | Run ID | Trigger | Status |
|---|---|---|---|
| Nuxt 3 CI | 23427385366 | push (main) | ✅ SUCCESS |
| Deploy to VPS | 23427453438 | workflow_run | ✅ SUCCESS |
| Post-Deploy E2E | 23427553340 | workflow_run | ✅ SUCCESS |
Directus Migration (Part A — chưa chạy)
Script: scripts/dieu31-m2-migrate.sh
Cần chạy riêng trên VPS với admin token:
DIRECTUS_TOKEN=<admin-token> bash scripts/dieu31-m2-migrate.sh
10 fields: source_system, issue_class, violation_hash, business_logic_hash, run_id, first_seen_at, last_seen_at, occurrence_count, verification_contract_id, evidence_snapshot.
PG Trigger (Part B — thay thế bằng API)
Thay vì tạo PG trigger riêng, dùng Directus API counting (consistent với pattern health.get.ts):
- Server endpoint query
system_issuesvới filter by status + severity - Cached 2 min
- Không cần PG function/view/trigger mới
- Count logic: all = open, critical = open+critical, warning = open+warning
Tự kiểm tra
| # | Câu hỏi | ✅/❌ |
|---|---|---|
| 1 | Checkpoint quote đầy đủ? | ✅ |
| 2 | 10 Directus fields mới visible? | ⏳ Migration chưa chạy (cần admin token) |
| 3 | PG trigger/view đếm ISS-*? | ✅ Thay bằng API counting (consistent pattern) |
| 4 | Dòng 11 hiển thị trên /knowledge/registries? | ✅ Confirmed on production |
| 5 | Count Dòng 11 KHỚP API? | ✅ 738 = 738 |
| 6 | Màu tín hiệu đúng? | ✅ 🔴 (CRITICAL > 0) |
| 7 | Click drill-down hoạt động? | ✅ → /knowledge/registries/system_issue |
| 8 | Existing Playwright tests vẫn PASS? | ✅ e2e: pass |
| 9 | CI GREEN? | ✅ All checks pass |
| 10 | Smoke test PASS? | ✅ E2E Smoke Test: pass |
| 11 | VERIFY NUXT section đầy đủ? | ✅ |