KB-1659

Handoff S178 Fix 30 → Fix 31

8 min read Revision 1
handoffs178fix30enrichmentdescriptiongen-code

Handoff S178 Fix 30 → Fix 31

Phiên: S178 Fix 30 | Ngày: 2026-04-23 HP: v4.6.3 (14 NT) | Đ22: v1.2 Fix 29 (rev 22) | Đ3: rev 6 | Đ2: rev 2


§0. TÓM TẮT 1 CÂU

gen_code adaptive width (19 function + 19 seq), severity normalize (8→3 + constraint), heartbeat wiring, H11b scope fix (1412→364), luật Đ2/Đ3/Đ22 amend, hướng dẫn enrichment v1.0. Sẵn sàng pilot enrichment 364 entity.


§1. ĐÃ LÀM

# Việc Status Commits
1 gen_code adaptive width: 19 functions lpad cố định → GREATEST(min,len) main 918cf54, dot 4f8e267
2 Sequence align: 19 seq → diff=0 (cùng commit trên)
3 TD-S178-20/21/22 CLOSED tech-debt.md updated
4 Amend Đ2 §5: "3 chữ số" → "tự giãn, CẤM lpad cố định" KB rev 2
5 Reclassify 58 issues source='dot-hc-executor' → check_code cụ thể main 44923be
6 resolved_at timestamp → timestamptz (cùng commit)
7 Đ22 §4.3 trùng số → §4.5 Retrofit clause KB rev 22
8 Heartbeat: executor ghi dot_config.hc_executor_last_run dot fa99476, main ff174e9
9 Severity normalize: 8 giá trị → 3 (critical/warning/info) + CHECK constraint (cùng commit)
10 fn_log_issue normalize severity đầu vào legacy (cùng commit)
11 H11a auto-close: 6 issues resolved executor auto
12 Verify 3 probe PASS (heartbeat/coverage/lockfile) evidence in report
13 Đ3 §2.5: +clause phân biệt thực thể kiến trúc vs bản ghi vận hành KB rev 6
14 Phụ lục Đ3 §A.3: +scope note loại trừ system_issue KB rev 3
15 H11b query .sql: +species filter via dot_config KB rev 2
16 dot_config seed h11b_exclude_species = ["system_issue"] main dafed04
17 H11b scope: 1412 → 364 (loại 1048 system_issues) verified production
18 Hướng dẫn viết Description v1.0 upload KB knowledge/dev/guides/description-enrichment-guide.md

§2. QUYẾT ĐỊNH KỸ THUẬT

# Quyết định Lý do
1 GREATEST(min_width, length(n)) thay vì nâng lpad cố định NT4 — tự giãn vĩnh viễn, không hardcode mới
2 Severity 3 giá trị lowercase + CHECK constraint Chuông rung đúng tần số, bộ lọc không điếc
3 system_issues giữ governed, chỉ loại enrichment scope Cần lifecycle (auto-close, ISS-code), không cần AI viết mô tả
4 h11b_exclude_species config thay vì hardcode species trong query NT4+NT13 — thêm species = UPDATE config
5 Hướng dẫn enrichment = file riêng, không nhúng trong luật Agent đọc 1 file, không cần đọc 5 luật

§3. LUẬT SỬA TRONG PHIÊN

Luật Version Thay đổi KB rev
Đ2 rev 2 §5: "tự giãn", CẤM lpad cố định, PG SEQUENCE 2
Đ3 rev 6 §2.5: +phân biệt thực thể kiến trúc vs bản ghi vận hành 6
Đ22 rev 22 §4.3→§4.5 Retrofit clause (fix trùng số) 22
Phụ lục Đ3 rev 3 +§A.3 template enrichment + scope note 3

§4. SỐ LIỆU PRODUCTION

gen_code: 19 functions adaptive, 19 seq aligned diff=0
severity: critical=312, warning=1757, info=5
heartbeat: hc_executor_last_run = 2026-04-23T04:01:05+00:00
verify: 3/3 probe PASS
H11a: findings=0, issues open=0, resolved=6
H11b: findings=364 (was 1412), scope fix = -1048
enrichment: 364 entity across 8 tables
executor: v1.5.0, cron 3h, RC=1 (unrelated HC failures)

§5. PHIÊN SAU CẦN LÀM

# Việc Effort Ghi chú
1 Pilot enrichment: entity_species (23) Medium Gemini CLI. Đọc hướng dẫn knowledge/dev/guides/description-enrichment-guide.md
2 Đợt 1: dot_tools (10) + agents (6) + tasks (3) Medium Gemini CLI. Sau pilot OK
3 Đợt 2: meta_catalog (130) + ui_pages (37) + workflow_steps (8) High Chia batch ≤30
4 Đợt 3: collection_registry (147) High Chia batch ≤30
5 A11 DROP bảng cũ Low Gate 48h — kiểm tra lại deadline
6 APR id=22 retroactive Low Deadline 2026-04-24

TD mới phát hiện Fix 30:

TD Mô tả Priority
TD-FIX30-01 7 table_registry entities thiếu species mapping (species_code NULL) → lọt H11b do NOT IN NULL behavior 🟡
TD-FIX30-02 Đ43 §9.1 H11b text chưa mention loại trừ species vận hành — cần thêm note viện dẫn Đ3 §2.5 🟢
TD-FIX30-03 Đ2 §4 bảng prefix lạc hậu (19 thực tế vs 14+2 trong luật: MOD≠M, thiếu ISS/LBL/TRG) 🟡
TD-FIX30-04 gen_code _min_width:=3 hardcode trong function body → nên đọc dot_config (NT13) 🟢

§6. BÀI HỌC

# Bài học
1 system_issues ≠ thực thể: 1,040/1,411 PROV-DOT là data vận hành. Nếu không phân biệt → enrichment vô nghĩa 74% effort. Phải hỏi "cái này là thiết kế hay runtime?" TRƯỚC khi lập kế hoạch.
2 Severity lộn xộn = chuông điếc: 8 giá trị thay vì 3. Query WHERE severity='critical' bỏ sót 27 rows CRITICAL. CHECK constraint phải đi kèm normalize.
3 Heartbeat missing = y tá mù: Executor chạy 3h/lần nhưng không ai biết. Tầng giám sát đủ 4 tầng nhưng dây nối đứt = vô nghĩa.
4 Hướng dẫn ≠ luật: Agent đọc luật = chậm + dễ nhầm. 1 file hướng dẫn thực hành = tiết kiệm 80% thời gian đọc. Luật là nền tảng, hướng dẫn là công cụ.

§7. FILE THAY ĐỔI

VPS commits

Repo Commit Nội dung
/opt/incomex 918cf54 gen_code adaptive + seq align
/opt/incomex 44923be reclassify 58 issues + resolved_at
/opt/incomex ff174e9 severity constraint + heartbeat seed
/opt/incomex dafed04 H11b exclude species config
/opt/incomex/dot 4f8e267 gen_code adaptive
/opt/incomex/dot fa99476 heartbeat + severity wiring

KB

Path Rev Nội dung
knowledge/dev/laws/law-02-registry.md 2 §5 tự giãn
knowledge/dev/laws/law-03-metadata.md 6 §2.5 thực thể vs vận hành
knowledge/dev/laws/law-22-self-healing.md 22 §4.3→§4.5
knowledge/dev/laws/dieu3-phu-luc-description-templates.md 3 §A.3 + scope note
knowledge/current-state/queries/h11b-description-detail-missing.sql 2 +species filter
knowledge/dev/guides/description-enrichment-guide.md 1 NEW — hướng dẫn enrichment
knowledge/dev/ssot/tech-debt.md updated TD-S178-20/21/22 closed

Reports Fix 30

Path Nội dung
reports/s178-fix30-gen-code-adaptive-report.md gen_code trước/sau
reports/s178-fix30-description-investigation.md H11a/H11b coverage
reports/s178-fix30-wiring-fix.md heartbeat + severity + auto-close
reports/s178-fix30-h11b-scope-fix.md H11b scope fix
reports/s178-fix30-prov-dot-breakdown.md PROV-DOT per table
reports/s178-fix30-backfill-stats.md 364 enrichment stats

§8. ĐỌC PHIÊN SAU

search_knowledge("handoff fix30")
search_knowledge("description enrichment guide agent")
search_knowledge("H11b scope fix system_issue exclude")
search_knowledge("gen_code adaptive fix30")

Handoff Fix 30 → Fix 31 | 2026-04-23 | 18 việc DONE, 4 luật amend, 6 commits, 6 reports, 1 guide mới