S161D — Investigation & Classification Report: Layer 3 Điều 31
S161D — Investigation & Classification Report
Agent: Claude Code (CLI) | Ngày: 2026-03-25 Scope: Investigation only — NO code, NO PR, NO deploy
1. render_fault (135) — Chi tiết
Sub-patterns (dot-scanner, 121 archived):
| Sub-pattern | Count | Root Cause |
|---|---|---|
broken_relation_target |
110 | entity_dependencies points to entity that doesn't exist in target collection |
broken_relation_source |
9 | Source entity referenced in relation doesn't exist |
missing_l2_config |
2 | CAT-999 (Chưa phân loại) — Layer 2 missing registry table config |
+ 14 runner issues (archived S161B) — old data-testid contract checks
Entity type distribution:
- collection: 103 (entities in collection_registry with broken links)
- wcr: 5, workflow: 5, task: 3, workflow_step: 2, etc.
Analysis:
The 119 "link_hỏng" are broken entity_dependency records where the source or target entity no longer exists. These are orphaned relationship records, NOT broken UI links. The root cause is: entities were deleted but their dependency records in entity_dependencies table were not cleaned up.
Natural Layer 3 groups:
orphan_dependency_target(110) — dependency target doesn't existorphan_dependency_source(9) — dependency source doesn't existmissing_registry_config(2) — collection lacks Layer 2 table definition
2. data_fault (615) — Chi tiết
Sub-patterns:
| Sub-pattern | Count | Root Cause |
|---|---|---|
no_relation_data |
588 | Entity has 0 rows in entity_dependencies. DOT scan flagged "Chưa có dữ liệu quan hệ" |
no_entity_dependencies |
18 | Catalog entries (CAT-xxx) missing entity_dependencies completely |
missing_identifier |
9 | Entities lack code/identifier field (e.g., "Chỉ 0% items có mã định danh") |
Entity type distribution:
- entity_dependency: 256 (individual dep records flagged)
- collection: 99, dot_tool: 89, checkpoint_instance: 46, page: 39
- checkpoint_type: 25, catalog: 19, task: 10, agent: 8, module: 6
Key stats:
- 597 unique entity_codes affected
- Average 1.03 issues per entity (mostly 1:1)
Analysis:
The dominant pattern (588) is: DOT scan found entities with ZERO relationships in entity_dependencies. This is the "thiếu quan hệ" (missing relationship) issue type. It means most entities in the system have not been linked to other entities via the dependency graph.
Natural Layer 3 groups:
no_dependencies(588) — entity not linked in dependency graphcatalog_no_deps(18) — catalog categories without dependency datamissing_code(9) — entities without identifier codes
3. Nuxt 1543 vs PG 17408 — Root Cause
Finding: "1543" NOT found in current production
- Registries page SSR HTML does NOT contain "1543"
- The number is likely from a cached/stale observation or a different page view
- Current actual values:
| Source | Value | What it represents |
|---|---|---|
| CAT-ALL record_count | 17426 | SUM of managed record_counts |
| /api/registry/counts | 17426 | Same (SUM managed) |
| /api/registry/raw-counts total_records | 22272 | SUM managed + log collections |
Possible origin of "1543":
The number 1543 could be from a PREVIOUS state of CAT-ALL (before M5B updated record_counts for 4 collections). Or it could be active_count (currently 849) or a UI computation that sums only "small" collections excluding birth_registry.
Verdict: Cannot reproduce "1543" on current production. Numbers are consistent across PG and Nuxt APIs.
4. BẢNG PHÂN LOẠI LAYER 3 ĐỀ XUẤT
| Layer 2 | Layer 3 (sub_class) | Count | Root Cause | Fixable? | Fix Method |
|---|---|---|---|---|---|
| render_fault | orphan_dep_target |
110 | Dependency target entity deleted, dep record remains | YES | DELETE orphan entity_dependencies rows |
| render_fault | orphan_dep_source |
9 | Dependency source entity deleted | YES | DELETE orphan rows |
| render_fault | missing_l2_config |
2 | Collection lacks Layer 2 config | YES | Add registry table config for CAT-999 |
| data_fault | no_dependencies |
588 | Entity has 0 relationships in dependency graph | PARTIAL | Backfill deps for key entities; accept 0 for minor entities |
| data_fault | catalog_no_deps |
18 | Catalog entry without dependency metadata | YES | Register dependencies for each catalog entry |
| data_fault | missing_code |
9 | Entity lacks identifier code | YES | Generate codes per naming convention |
| sync_fault | count_drift |
2 | meta_catalog count drifted from actual | ALREADY FIXED | Refresh mechanism now works |
| contract_fault | cascade_stale |
1 | Old cascade issue from v1.0 contracts | ARCHIVED | S161B cleaned |
| watchdog_fault | runner_liveness |
1 | WATCHDOG — active, legitimate | KEEP | Normal operation |
5. DỰ THẢO BỔ SUNG ĐIỀU 31 §IV.6-B
§IV.6-B: Layer 3 — Phân loại chi tiết (sub_class)
Nguyên tắc phân loại:
- Phân theo ROOT CAUSE, không theo triệu chứng
- Nhóm > 100 issues → tách thành sub_class
- Nhóm < 5 issues → xem xét gộp vào nhóm cha
- Mỗi sub_class PHẢI có hành động fix rõ ràng
- sub_class là field mới trong system_issues (nullable, string)
Bảng phân loại chuẩn:
| issue_class (L2) | sub_class (L3) | Mô tả | Severity | Hành động |
|---|---|---|---|---|
| render_fault | orphan_dep_target | Dependency trỏ đến entity đã xoá (target) | CRITICAL | Xoá dependency record orphan |
| render_fault | orphan_dep_source | Dependency từ entity đã xoá (source) | CRITICAL | Xoá dependency record orphan |
| render_fault | missing_l2_config | Collection thiếu Layer 2 registry table config | WARNING | Thêm config vào collection |
| data_fault | no_dependencies | Entity chưa có quan hệ trong dependency graph | WARNING | Backfill cho key entities |
| data_fault | catalog_no_deps | Catalog entry chưa khai báo dependencies | WARNING | Register deps cho catalog |
| data_fault | missing_code | Entity thiếu mã định danh | WARNING | Generate code theo convention |
| sync_fault | count_drift | meta_catalog count lệch với thực tế | WARNING | Chạy refresh_registry_counts() |
| watchdog_fault | runner_liveness | WATCHDOG check — runner đang sống | CRITICAL | Bình thường, không cần fix |
Layer 4 — Địa chỉ lỗi: Mỗi issue ở Layer 4 hiển thị:
entity_code: Mã entity bị ảnh hưởngentity_type: Loại entityaffected_url: Link trực tiếp đến entity trong Directusdescription: Mô tả chi tiết vấn đề cụ thể
6. ĐỀ XUẤT XỬ LÝ
P0 — Đã xong (S161B/C):
- 15 stale runner issues → archived ✓
- CAT-ALL refresh → fixed ✓
P1 — Fix tiếp (ưu tiên cao):
- orphan_dep_target (110): DELETE orphan entity_dependencies WHERE target doesn't exist. Safe, data cleanup.
- orphan_dep_source (9): Same approach.
- Total: 119 issues resolvable by data cleanup
P2 — Fix trung bình:
- catalog_no_deps (18): Register catalog dependencies
- missing_code (9): Generate identifiers
- missing_l2_config (2): Add config for CAT-999
P3 — Để lại (cần chiến lược):
- no_dependencies (588): Largest group. Most entities genuinely have 0 dependencies because dependency graph was never populated systematically. This is a FEATURE GAP not a BUG. Fixing requires: mass-scan all entities → auto-detect relationships → backfill. Scope: separate project, not hotfix.
Summary Impact:
| Priority | Issues | After fix |
|---|---|---|
| P0 (done) | 16 | ✓ 15 archived + 1 WATCHDOG |
| P1 | 119 | DELETE orphan deps → 119 issues auto-resolvable |
| P2 | 29 | Data backfill → 29 issues resolvable |
| P3 | 588 | Dependency graph population — separate project |
| Total fixable now | 148 of 754 (20%) | Remaining: 606 (all archived, low severity) |