KB-3B07 rev 28

Handoff S141 — FINAL (5 Missions Done, Pivot LIVE, Chuyển phiên)

8 min read Revision 28
handoffs141dieu26v3.5finalpivot-live

Handoff S141 → Phiên tiếp — FINAL

Ngày: 2026-03-28 | OR: v5.6 | Hiến pháp: v3.9 Phiên mới chỉ cần: search_knowledge("handoff S141") → đọc file này → làm ngay. KHÔNG cần hỏi user "giờ làm gì?" — đọc mục VIỆC TIẾP THEO bên dưới.


S141 ĐÃ LÀM GÌ — TÓM TẮT 1 DÒNG

Viết + ban hành Điều 26 v3.5 (Luật Registries & Đếm) qua 2 vòng hội đồng AI, rồi triển khai 5 missions: pivot_count() LIVE trên production, 30 triggers loại bỏ, thêm collection = 1 INSERT.


5 MISSIONS ĐÃ HOÀN THÀNH

Mission PR Nội dung Status
0.5 — (SQL) Fix 3 production blockers (TRUNCATE, count_material, code sync). 8/8 tests PASS.
1 #640 pivot_definitions (21 rows) + pivot_count() PG function + 30 triggers #DISABLED + Nuxt sửa
2 #641 DOT-113 dot-pivot-declare + DOT-114 dot-pivot-health. 6/7 PASS.
2.5 #642 Fix kiến trúc: pivot_definitions→Directus (18 fields, CAT-024). refresh_meta_catalog_from_pivot(). Luồng PG→Directus→Nuxt verified.

VIỆC TIẾP THEO — THỨ TỰ ƯU TIÊN (orchestrator tự quyết, KHÔNG hỏi user)

🔴 #1: Mission 3 — VIEW Cross-Table (~200 dòng, PHỨC TẠP)

Giao: Claude Code CLI (claude-go) — task phức tạp, KHÔNG giao Desktop.

Nội dung: Tạo ~35 VIEW templates từ pivot_definitions. Mỗi template = 1 PG VIEW trả kết quả GROUP BY N chiều. Điều 26 v3.5 §II BT2 + §VII Mission 3.

Ràng buộc quan trọng:

  • §0-AV: VIEWs PHẢI register Directus. PG→Directus→Nuxt. KHÔNG bypass.
  • §0-AU: Templates derive từ pivot_definitions. KHÔNG hardcode.
  • template_scope + template_anti_scope (GPT R2 Q7): AI chỉ chọn template đúng loại câu hỏi.

Đọc trước khi soạn prompt:

search_knowledge("Điều 26 mới pivot table")    → v3.5, §II BT2 templates, §VII Mission 3
search_knowledge("operating rules SSOT")        → v5.6, §0-AV + §0-AU
search_knowledge("mission template")            → Step 0 S135H pattern

Soạn prompt ra ARTIFACT (không upload Agent Data — tiết kiệm context).

🟡 #2: Điều tra TD-398~402 — Sync Blind Spots (7 lỗ hổng đồng bộ)

Giao: Claude Code CLI — ĐIỀU TRA LỚN, KHÔNG Desktop.

Đặc biệt nghiêm trọng: TD-400 Content sync: Agent Data 595 docs vs Directus 382 = 213 drift!

Nội dung: SSH verify 7 blind spots, đề xuất fix plan. KHÔNG fix code — chỉ điều tra + report.

search_knowledge("sync blind spots TD-398")
search_knowledge("sync governance đồng bộ")

🟡 #3: Backlog — xử lý dần

TD Mô tả Khi nào
TD-408 Scanner hardcode 5/20 tables → meta-driven Sau Mission 3
TD-409~411 CI guard/smoke test/DOT origin hardcode Sau Mission 3
TD-359 Điều 31+ Gương Soi TBD

TRẠNG THÁI HỆ THỐNG — SNAPSHOT 2026-03-28

✅ ĐANG CHẠY TỐT

Thành phần Chi tiết
PG Guards fn_guard_*, fn_validate_dot_origin
Điều 30 guard 23 protected files
Cron 3 entries (runner, refresh, health)
Điều 31 runner/watchdog Contracts 100%
Birth registry 15,307+ births, Gap=0
status field 66/66 tables (birth_registry.status='born')
pivot_definitions 21 rows, Directus registered (18 fields, CAT-024, public read)
pivot_count() LIVE, 20 active rows, real counts
refresh_meta_catalog_from_pivot() LIVE, populate meta_catalog.record_count từ pivot
DOT-113 dot-pivot-declare Single + batch mode (--auto-from-meta-catalog)
DOT-114 dot-pivot-health 7 checks, 6/7 PASS (1 expected WARNING: CAT-999)
v_registry_counts Compat alias, backward compat
Contract tests 8/8 PASS

⚠️ CẦN CHÚ Ý

Thành phần Chi tiết
entity_dependencies 141 records, chưa đầy đủ
universal_edges 2039 records, chưa đầy đủ
30 counting triggers #DISABLED (comment out, KHÔNG xoá)
TD-398~402 7 sync blind spots 🔴🔴 — chưa fix
TD-408~411 4 hardcode debts §0-AU — chưa fix

❌ CHƯA TRIỂN KHAI

Thành phần Chi tiết
entity_labels Chưa deploy (Điều 24 Label Law)
VIEW cross-table templates Chưa tạo → Mission 3
AI guardrails B1.5 Chưa triển khai → Mission 6
Performance hot/warm/cold Chưa cần (< 5K definitions)

TÀI LIỆU SSOT — ĐỌC KHI CẦN

Tài liệu Path Dùng khi
Điều 26 v3.5 search_knowledge("Điều 26 mới pivot table") Soạn Mission 3+
OR v5.6 search_knowledge("operating rules SSOT") Mỗi mission
Tech Debt search_knowledge("nợ kỹ thuật tech debt") Rà soát priorities
Hiến pháp v3.9 search_knowledge("hiến pháp kiến trúc") Khi cần nguyên tắc gốc
Mission template search_knowledge("mission template") Soạn mọi prompt
Roadmap search_knowledge("roadmap triển khai điều 26") Xem tổng thể
Mission 0.5 report knowledge/current-state/reports/mission-05-blockers-fix Tham khảo
Mission 1 report knowledge/current-state/reports/mission-1-pivot-chay Tham khảo
Mission 2 report knowledge/current-state/reports/mission-2-dot-pivot Tham khảo
Mission 2.5 report knowledge/current-state/reports/mission-25-fix-architecture Tham khảo

NGUYÊN TẮC CỐT LÕI — NHẮC MỖI PHIÊN

  1. §0-AV: PG → Directus → Nuxt. KHÔNG bypass. Mỗi mission check: "Có component nào bypass Directus?"
  2. §0-AU: CẤM hardcode. Thêm collection = 1 INSERT. Hệ thống TỰ BIẾT.
  3. Assembly First (Điều 7): PG VIEW/TRIGGER/CTE trước → Directus → Nuxt → Code mới CUỐI CÙNG.
  4. 3 bài toán đơn giản: M2M + Pivot + Dây điện. KHÔNG over-engineer.
  5. filter = JSON spec. Whitelist phổ quát: filter + group + metric.
  6. #DISABLE không xoá. Dependency audit trước. Alias shim nếu cần.
  7. Nguyên tắc vàng: Chạy rồi KHÔNG SỬA CODE. Thay đổi = metadata.
  8. Prompt giao agent ra ARTIFACT — KHÔNG upload Agent Data (tiết kiệm context + token).
  9. Desktop = tác vụ nhỏ. Điều tra lớn / mission phức tạp → Claude CLI hoặc Codex.
  10. Agent tự lập báo cáo tại knowledge/current-state/reports/.

BÀI HỌC S141 — KHÔNG LẶP LẠI

  1. Kiểm tra kiến trúc, không chỉ kiểm tra số. Mission 1 số đúng nhưng bypass Directus → mất thêm Mission 2.5 để fix.
  2. Mỗi mission thêm check: "Luồng PG→Directus→Nuxt đúng? Có PG table chưa register Directus?"
  3. Orchestrator phải chặn trước khi agent sai, không để agent làm xong rồi mới fix. Phòng ngừa > sửa chữa.
  4. Prompt phải ghi rõ ràng buộc kiến trúc, không chỉ ghi mục tiêu chức năng.

PHIÊN MỚI BẮT ĐẦU NHƯ SAU

1. search_knowledge("handoff S141") → đọc file này
2. Xác nhận: "S141 DONE. 5 missions. Tiếp Mission 3."
3. Đọc: search_knowledge("Điều 26 mới pivot table") → v3.5 §VII Mission 3
4. Đọc: search_knowledge("operating rules SSOT") → v5.6
5. Đọc: search_knowledge("mission template") → S135H pattern
6. Soạn Mission 3 prompt ra ARTIFACT → giao user copy cho claude-go
7. Cập nhật OR + Tech Debt + Handoff sau mission xong

KHÔNG hỏi user "giờ làm gì?" — đọc handoff là biết.


S141 FINAL | 5 missions | 3 PRs (#640-#642) | Điều 26 v3.5 BAN HÀNH | Hiến pháp v3.9 | OR v5.6 | pivot_count() LIVE