KB-4028
S159 Health System Report — Đếm 2 Nơi + Registries Dòng 8-10
6 min read Revision 1
reports159healthdem-2-noiregistriescomplete
S159 Health System Report — Đếm 2 Nơi + Registries Dòng 8-10
Session: S159 | Date: 2026-03-21 | Status: COMPLETE PRs: #563 (main), #564 (count fix) | All merged
Assembly Gate
- Q0: YES — PG function fn_registry_health() dynamic SQL. Đếm = database job.
- Q1: YES — birth_registry, collection_registry sẵn có.
- Q2: CẦN — rows 8-10 + server API + detail pages. Assembly: UTable + UBadge.
- Q3: PG function + 2 server APIs + registries index update + 2 detail pages.
- Q4: PG: gap = 0 per collection. Nuxt: numbers match.
- Q5: DROP FUNCTION + git revert.
4 Yếu Tố Khả Thi
| # | Yếu tố | Trạng thái |
|---|---|---|
| 1 | Mô hình: PG function tự so sánh source vs birth per collection. Metadata-driven. | PASS |
| 2 | Quy trình: INSERT → trigger → birth → VIEW auto update → UI hiển thị → gap > 0 → investigate | PASS |
| 3 | Công cụ: PG function (đếm), server API (serve), UTable (hiển thị) | PASS |
| 4 | Môi trường: birth_registry + species_collection_map + collection_registry = sẵn có | PASS |
Changes — 5 files + 1 PG function
| File | Type | Description |
|---|---|---|
| fn_registry_health() | PG | Metadata-driven source vs birth counting per governed collection |
| server/api/registry/health.get.ts | NEW | Server API: source vs birth counts, 2min cache |
| server/api/registry/unmanaged.get.ts | NEW | Server API: observed + excluded counts, 5min cache |
| pages/registries/index.vue | MODIFIED | +rows 8-10 (orphan/phantom/unmanaged) + health/info level configs |
| pages/registries/health/index.vue | NEW | Detail page: per-collection gap table with summary cards |
| pages/registries/unmanaged/index.vue | NEW | Detail page: observed + excluded collection list |
So Sánh Nơi Chứa vs Nơi Sinh
/api/registry/health → 18 collections, ALL KHỚP
collection_name | noi_chua | noi_sinh | gap | status
-------------------------|----------|----------|-----|-------
agents | 6 | 6 | 0 | KHOP
checkpoint_sets | 2 | 2 | 0 | KHOP
checkpoint_types | 31 | 31 | 0 | KHOP
collection_registry | 138 | 138 | 0 | KHOP
dot_tools | 112 | 112 | 0 | KHOP
entity_dependencies | 141 | 141 | 0 | KHOP
entity_species | 21 | 21 | 0 | KHOP
meta_catalog | 33 | 33 | 0 | KHOP
modules | 4 | 4 | 0 | KHOP
system_issues | 738 | 738 | 0 | KHOP
table_registry | 20 | 20 | 0 | KHOP
tasks | 6 | 6 | 0 | KHOP
taxonomy | 55 | 55 | 0 | KHOP
taxonomy_facets | 6 | 6 | 0 | KHOP
ui_pages | 37 | 37 | 0 | KHOP
workflow_change_requests | 3 | 3 | 0 | KHOP
workflows | 2 | 2 | 0 | KHOP
workflow_steps | 70 | 70 | 0 | KHOP
Totals: khop=18, orphan=0, phantom=0, totalGap=0
CHECKPOINT TIN CẬY
Q: SỐ ĐÃ TIN CẬY CHƯA? A: CÓ. Nơi chứa = 1425. Nơi sinh = 1425. Gap = 0.
- 18/18 governed collections KHỚP.
- 0 orphan (entity có trong source nhưng không có birth record).
- 0 phantom (birth record không có entity tương ứng).
- Adding new collection = add species_collection_map record → auto detected. No code change.
Unmanaged Collections
observed: 43 collections
excluded: 77 collections
total: 120 collections (không quản trị)
VERIFY NUXT
- Nuxt URL: /knowledge/registries
- Dòng 7 (Phân loại loài): 20 loài, 1425 governed. PG: 1425. KHỚP.
- Dòng 8 (Mồ côi): 0 orphan. PG: 0. KHỚP. Badge: info (xám = 0).
- Dòng 9 (Phantom): 0 phantom. PG: 0. KHỚP. Badge: info (xám = 0).
- Dòng 10 (Không quản trị): 120. PG: 120. KHỚP.
- Click dòng 8/9 → /registries/health: 200 OK. 18 collections, summary cards (18 KHỚP, 0 orphan, 0 phantom). PASS.
- Click dòng 10 → /registries/unmanaged: 200 OK. 120 collections listed. PASS.
Issues Encountered
- entity_labels misclassified — was governed but is a junction table with no
codecolumn. Fixed: set toexcluded, removed species mapping. Fixed gap went from PHANTOM to clean. - Directus aggregate API —
aggregate[count]=*not reliably parsed via$fetch. Fixed: usemeta=total_count&limit=0pattern (same as other Directus queries). - 2 PRs — #563 (main), #564 (count fix). Could have been 1 PR.
Tự Kiểm Tra
| # | Câu hỏi | Kết quả |
|---|---|---|
| 1 | Đã đọc SSOT + quote §0-J + §0-K? | ĐẠT |
| 2 | Đã đọc Điều 0-G §II.5 (orphan/phantom queries)? | ĐẠT |
| 3 | Bảng 4 yếu tố khả thi pass 4/4? | ĐẠT |
| 4 | PG function fn_registry_health tạo? Tự đếm? | ĐẠT (metadata-driven, no code change) |
| 5 | Registries dòng 8 (mồ côi) hiển thị? Auto color? | ĐẠT (info/gray khi 0) |
| 6 | Registries dòng 9 (phantom) hiển thị? | ĐẠT |
| 7 | Registries dòng 10 (không quản trị) + layer 2? | ĐẠT |
| 8 | CI GREEN? Smoke PASS? | ĐẠT |
| 9 | VERIFY NUXT đầy đủ? | ĐẠT |
| 10 | CHECKPOINT TIN CẬY trả lời? | ĐẠT (gap=0, 18/18 KHỚP) |
| 11 | Report đúng path? | ĐẠT |
S159 COMPLETE. Hệ thống đếm tin cậy hoạt động. 18/18 KHỚP. Gap = 0.
S159 | 2026-03-21 | PRs #563-564 merged | 18/18 KHỚP | Gap=0 | Đếm 2 nơi tin cậy