KB-F4AD
RE-AUDIT REPORT — Codex — 2026-03-15
12 min read Revision 1
RE-AUDIT REPORT — Codex — 2026-03-15
TÓM TẮT
- 🔴 Critical: 8 vấn đề
- 🟡 Warning: 10 vấn đề
- 🟢 OK: 6 lĩnh vực
- ✅ S124 fixes verified: 6/13 (1 mục không thể test do yêu cầu read-only)
I. NHẤT QUÁN TÀI LIỆU
Kết quả chính
- Hiến pháp v3.5 + OR v4.24 + Label Law v1.3 nhìn chung nhất quán ở nguyên tắc (Registry-First, Assembly-First, DOT-first, Fix Gốc).
- Có lệch giữa tài liệu/claim và production ở các điểm vận hành quan trọng.
Findings + Evidence
- Lệch endpoint registries giữa checklist và production (🟡)
- Expected:
/registrieshoạt động. - Actual:
curl -s https://vps.incomexsaigoncorp.vn/registries | head -100→ JSON404 Page Not Found.curl -sI https://vps.incomexsaigoncorp.vn/knowledge/registries | head -5→HTTP/1.1 200 OK.
- Kết luận: route chuẩn production là
/knowledge/registries.
- Claim CHECK 9/9 GREEN trong S124 không còn chứng cứ vận hành hiện tại (🔴)
- Expected: có workflow/monitor thể hiện CHECK 9 registry integrity đang chạy.
- Actual:
gh run list --limit 20 --json status,conclusion,name,createdAtchỉ thấyArtifact Audit (Monitor),Secrets Audit (Monitor),Data Lifecycle, không thấy workflow “Health Check”/“CHECK 9”..github/workflows/data-lifecycle.yml,artifact-audit.yml,secrets-audit.ymlhiện rất tối giản (monitor placeholder/single check script).
- Kết luận: không chứng minh được CHECK 9 đang vận hành như mô tả.
- Số liệu count bị drift giữa metadata và counter runtime (🟡)
- Actual:
SELECT code,record_count,actual_count FROM meta_catalogcho CAT-016=1376, CAT-017=738.SELECT cat_code,record_count FROM v_registry_counts WHERE cat_code IN ('CAT-016','CAT-017')cho CAT-016=1382, CAT-017=707.
- Kết luận: tài liệu “đã ổn định count” chưa phản ánh drift đang tồn tại.
II. LỖ HỔNG KIẾN TRÚC
- Integrity gate hiện tại không bao quát đủ thực tế quan hệ (🔴)
- Actual:
SELECT COUNT(*) FROM verify_counts() WHERE status <> 'OK'→ 0.SELECT severity, COUNT(*) FROM audit_dead_links() GROUP BY severity→error=119.SELECT severity, COUNT(*) FROM audit_relationships() GROUP BY severity→warning=602.
- Kết luận: hệ thống có “xanh đếm” nhưng vẫn nhiều vấn đề quan hệ/link.
- entity_dependencies đang trộn nhiều kiểu identifier, gây scanner báo lỗi hàng loạt (🔴)
- Actual:
SELECT COUNT(*) ... non_prefix_style_links FROM entity_dependencies→170/254không theo PREFIX chuẩn.- Sample chứa
workflow_steps.checkpoint_set_id -> checkpoint_sets,COL-052 -> meta_catalog,... -> tasks/workflows.
- Kết luận: scanner hiện tại xem nhiều link kỹ thuật/semantic như dead-link nghiệp vụ.
- check_registry_coverage() không phát hiện “coverage thật” của toàn bộ collections (🟡)
- Actual:
SELECT * FROM check_registry_coverage()→ 0 rows.SELECT COUNT(*) untracked FROM directus_collections LEFT JOIN collection_registry ...→ 18 untracked collections.
- Kết luận: coverage check hiện chỉ kiểm một lát cắt (counter/trigger), chưa kiểm full registry completeness.
- DOT registry và DOT runtime lệch (🔴)
- Actual:
- DB:
SELECT COUNT(*) FROM dot_tools→ 112. - Files:
/opt/incomex/dot/bincó 75 scripts; 3 thư mụcdot/binunique names = 121. - 4 tools mới trong S124 có record DB nhưng file thiếu hoàn toàn:
DOT-109 dot-production-truth-gateDOT-110 dot-coverage-inspectorDOT-111 dot-entity-deprecateDOT-112 dot-entity-retire
- DB:
- Kết luận: registry không phản ánh executable reality.
III. LỖI MÃ NGUỒN
- Nuxt registries page gọi field không tồn tại trong
v_registry_counts(🔴)
- Code:
pages/knowledge/registries/index.vueđọc fieldscount_b,count_c,cross_check. - DB schema thực tế
v_registry_countschỉ có:id, cat_code, entity_type, record_count, orphan_count, composition_level, code_column, prev_count. - Ảnh hưởng: block cross-check UI luôn rơi vào fallback/catch, tạo cảm giác “không lỗi” nhưng mất kiểm chứng thật.
- Nuxt entity issues filter sai enum status (🔴)
- Code:
pages/knowledge/registries/[entityType]/index.vuefilterstatus in ['mở','đang_xử_lý']. - DB thực tế:
SELECT status, COUNT(*) FROM system_issueschoopen,archived. - Ảnh hưởng: panel issues theo entity có thể rỗng giả dù DB có dữ liệu.
- Agent Data endpoint nhạy cảm đang mở không cần API key (🔴)
- Probe:
POST /api/chatkhông key → HTTP 400 (Query text must not be empty) thay vì 401.POST /api/ingestkhông key → HTTP 500 (Missing text in request body) thay vì 401.GET /api/kb/listkhông key → HTTP 200 và trả dữ liệu thật.
- Ảnh hưởng: bề mặt tấn công/cost abuse cao.
- Workflow monitor “xanh giả” (🟡)
.github/workflows/artifact-audit.ymlvàsecrets-audit.ymlhiện chủ yếuechoplaceholder.- Ảnh hưởng: CI GREEN không đồng nghĩa có giám sát chiều sâu.
IV. NỢ KỸ THUẬT
TDs đã resolve — verify lại
- TD-174 (fn_auto_label_assignment data-driven): PASS
- Evidence:
pg_get_functiondef(fn_auto_label_assignment)có đoạnSELECT vrc.code_column ... JOIN meta_catalog ....
- Evidence:
- TD-167 (system_issues triage): PASS một phần
SELECT status,COUNT(*) FROM system_issues→open=707,archived=31.
- TD-175b (CAT-016/017 orphan): PASS theo v_registry_counts
- CAT-016 orphan=0, CAT-017 orphan=0.
- TD-LIFECYCLE: PARTIAL
- DB functions
deprecate_entity,retire_entitycó tồn tại. - Nhưng DOT wrappers tương ứng thiếu file runtime (DOT-111/112).
- DB functions
- TD-179 (CHECK 9 monitoring): FAIL to verify
- Không tìm thấy workflow/check đang chạy như mô tả.
TD mới phát hiện
- Public exposure của Directus Flow + Agent Data endpoints (P0).
- DOT registry-runtime mismatch (record có, script thiếu) (P0).
- UI cross-check/issue panel drift với schema & enum thực tế (P1).
- Coverage check blind spot (0-row nhưng vẫn có untracked collections) (P1).
V. AUTOMATION GAPS
- Self-healing loop chưa khép kín thực tế vận hành (🔴)
- Dù nhiều checker tồn tại, runtime còn dead-links/errors lớn và monitor CI hiện mỏng.
- Flow sync direction nhất quán với S124 nhưng đang inactive có chủ đích (🟢)
directus_flowscho thấy:[DOT] Knowledge Sync to Agent Data= inactive[DOT] Knowledge Delete from Agent Data= inactiveCache Invalidation — Knowledge Update= inactive
- Điều này phù hợp claim “AD là SSOT cho knowledge”, nhưng cần guardrail rõ để tránh hiểu sai.
- CHECK xanh chưa đo đúng thứ cần đo (🟡)
check_registry_coverage()trả 0 rows nhưng vẫn có 18 untracked collections.verify_counts()mismatch=0 nhưng quan hệ/link audit vẫn báo lớn.
VI. BẢO MẬT & HIỆU NĂNG
- Directus public role đang quá rộng (🔴)
public_permissions_via_policycho thấy Public có:directus_flowsread+executedirectus_flow_runscreate+readsystem_issues/knowledge_documentscó thể đọc qua public API probe.
- Đây là bề mặt rủi ro cao.
- Directus rate limiter đang tắt (🟡)
docker-compose.yml:RATE_LIMITER_ENABLED: "false".- Nginx chỉ rate-limit
/ops/*, không limit/directus/*hoặc/api/*chung.
- Agent Data API exposure (🔴)
/api/chat,/api/ingest,/api/kb/listcallable không key (probe thực tế).
- PG role hardening cần rà lại (🟡)
pg_roles: cóworkflow_adminlàrolsuper=true,rolcanlogin=true.- Chưa thấy bằng chứng cần thiết trong luồng hiện tại.
- Performance baseline hiện chấp nhận được nhưng có điểm cần theo dõi (🟡)
pg_stat_user_tables:system_issuesseq_scan=1751,taxonomyseq_scan=12681.- Dữ liệu còn nhỏ, nhưng khi 10x sẽ cần tối ưu query pattern/index usage.
VII. S124 FIXES VERIFICATION
| # | Hạng mục | Kết quả | Evidence |
|---|---|---|---|
| 1 | verify_counts() = 0 mismatch | PASS | SELECT COUNT(*) FROM verify_counts() WHERE status<>'OK' → 0 |
| 2 | Orphan CAT-016 = 0 | PASS | v_registry_counts CAT-016 orphan=0 |
| 3 | Orphan CAT-017 = 0 | PASS | v_registry_counts CAT-017 orphan=0 |
| 4 | Health Check GH CHECK 9 GREEN | FAIL | Không thấy workflow/check tương ứng trong gh run list + workflows hiện tại |
| 5 | fn_auto_label_assignment đọc code_column | PASS | pg_get_functiondef có vrc.code_column join meta_catalog |
| 6 | dot-entity-deprecate hoạt động khi gọi | FAIL | Script file không tồn tại trên VPS |
| 7 | dot-entity-retire hoạt động khi gọi | FAIL | Script file không tồn tại trên VPS |
| 8 | truth-gate hoạt động khi gọi | FAIL | Script file không tồn tại trên VPS |
| 9 | coverage-inspector hoạt động khi gọi | FAIL | Script file không tồn tại trên VPS |
| 10 | Checklist 8 bước (test tạo collection) | NOT TESTED | Nhiệm vụ yêu cầu read-only, không được tạo mới |
| 11 | ISS-xxx auto-generate | PASS | invalid_code_count=0, range ISS-0001..ISS-0738 |
| 12 | Auto-ID BEFORE INSERT triggers | PASS | trg_auto_code_*: 16/16 là BEFORE INSERT |
| 13 | Monitoring CHECK 9 chạy đúng | FAIL | Không có evidence workflow/check đang chạy |
TOP 10 KIẾN NGHỊ (xếp theo ưu tiên)
| # | Kiến nghị | Lý do | Mức |
|---|---|---|---|
| 1 | Đóng public access cho directus_flows execute + flow_runs create/read |
Rủi ro bảo mật rất cao | 🔴 |
| 2 | Bắt buộc API key cho /api/chat, /api/ingest, /api/kb/list (hoặc tách public-private rõ) |
Tránh abuse chi phí/dữ liệu | 🔴 |
| 3 | Khôi phục hoặc xoá claims về DOT-109..112: record chỉ giữ khi script có thật | Tránh “registry giả” | 🔴 |
| 4 | Thiết kế lại integrity gate: gộp verify_counts + dead_links + relationship quality thành một gate có severity rõ |
Tránh xanh giả | 🔴 |
| 5 | Sửa Nuxt registries cross-check theo schema thực tế v_registry_counts |
Hiện tại cross-check fallback im lặng | 🔴 |
| 6 | Sửa filter status system_issues trong page entity (open/resolved/archived) |
Tránh panel rỗng giả | 🟡 |
| 7 | Khôi phục monitoring CHECK 9 thực sự (không placeholder), và publish evidence run cố định | Đảm bảo S124 fix còn sống | 🟡 |
| 8 | Đồng bộ semantics count giữa meta_catalog và v_registry_counts (hoặc ghi rõ mỗi bảng đo cái gì) |
Tránh drift dữ liệu vận hành | 🟡 |
| 9 | Thêm check “untracked directus_collections” vào CI/health gate | check_registry_coverage() hiện không phát hiện |
🟡 |
| 10 | Rà soát role workflow_admin superuser + bật rate limiting phù hợp cho Directus/API |
Harden bảo mật và scale | 🟡 |
Raw Evidence Snapshot (tóm tắt)
- PostgreSQL:
verify_counts()mismatch = 0check_registry_coverage()= 0 rowsaudit_dead_links()= 119 errorsaudit_relationships()= 602 warningsv_all_entity_codes= 1473entity_labels= 1912system_issues: archived=31, open=707
- Directus:
- API auth count: collections=151, flows=127 (
limit=500) - DB count: directus_collections=124, directus_flows active=123/inactive=4
- API auth count: collections=151, flows=127 (
- Production:
https://vps.incomexsaigoncorp.vn/= HTTP 200/registries= 404;/knowledge/registries= 200
- GitHub Actions:
- Recent runs chủ yếu
Artifact Audit,Secrets Audit,Data Lifecycle; không thấy health-check/check9 workflow tương ứng.
- Recent runs chủ yếu