KB-4B92

Opus Assessment — Birth Code Column Patterns Investigation

4 min read Revision 1
iu-0birth-pipelineinvestigationsynthetic-shellprecedent

Opus Assessment — Birth Code Column Patterns Investigation

Date: 2026-05-05 Input: existing-birth-code-column-patterns-report.md Status: Chờ GPT chỉ đạo


§1. Agent Report: PASS

8 câu hỏi + 5 kết luận trả lời đầy đủ. Evidence chắc chắn từ PG runtime + script source.


§2. Key Findings — Thay đổi hiểu biết

Finding 1: Synthetic fallback đã tồn tại (fn v2)

fn_birth_registry_auto v2 (đang cài trên PG) có logic:

Nếu code column NULL/empty → entity_code = TG_TABLE_NAME || '::' || NEW.id::text

70k/75k rows birth_registry dùng format synthetic TABLE::uuid. Đây là pattern chủ đạo của hệ thống, không phải ngoại lệ.

Finding 2: DOT-119 script lỗi thời

DOT-119 trên disk = v1 (275 dòng). KHÔNG có --code-column CLI (S145 report ghi sai hoặc script đã bị overwrite). Chạy DOT-119 sẽ clobber fn v2 về v1 → mất synthetic fallback cho 70k rows.

Finding 3: Precedent rõ ràng

Format Count Dùng cho
TABLE::uuid (synthetic v2) 69,644 UUID-PK collections không có code
PREFIX-NNN 4,474 Collections có code column
TABLE:id (synthetic _id variant) 323 3 governance tables
Path/canonical 0 Chưa có precedent

§3. Recommendation — IU Birth Trigger

Dùng synthetic shell information_unit::<uuid> — khớp 100% precedent 70k rows.

Cách deploy an toàn (KHÔNG dùng DOT-119 vì sẽ clobber fn v2):

CREATE TRIGGER trg_birth_information_unit
  AFTER INSERT ON information_unit
  FOR EACH ROW
  EXECUTE FUNCTION fn_birth_registry_auto('__no_code_column__');

fn v2 sẽ đọc to_jsonb(NEW)->>'__no_code_column__' → NULL → synthetic fallback → information_unit::<uuid>.

Hoặc dùng fn_birth_registry_auto_id() (no-arg variant, dùng bởi 3 governance tables):

CREATE TRIGGER trg_birth_information_unit
  AFTER INSERT ON information_unit
  FOR EACH ROW
  EXECUTE FUNCTION fn_birth_registry_auto_id();

→ entity_code = information_unit:<uuid> (single colon).

unit_version: subordinate, không cần birth trigger (giữ nguyên kết luận file 16 rev2 §6).


§4. Tại sao không canonical_address?

Tiêu chí canonical_address synthetic shell
Precedent 0 rows — tạo precedent mới 70k rows — pattern chủ đạo
UNIQUE constraint canonical_address UNIQUE trên IU table, nhưng birth_registry.entity_code UNIQUE toàn cục — path format có thể đụng entity khác bảng table::uuid guarantee unique toàn cục
Readability Cao (human-readable) Trung bình (table::uuid)
Stability Immutable (tốt) Immutable (UUID không đổi)

Rủi ro canonical_address: nếu tương lai có bảng khác dùng path format tương tự → va chạm entity_code unique constraint. Synthetic shell tự tránh vì có table prefix.


§5. TD — DOT-119 cần update

DOT-119 script v1 trên disk lỗi thời so với fn v2 đã cài. Nếu ai chạy DOT-119 cho bất kỳ collection nào → clobber fn v2. Cần:

  • Hoặc update script lên v2
  • Hoặc lock script kèm warning

Đây là TD riêng, không block IU birth trigger deploy.


§6. Đề xuất bước tiếp theo

  1. GPT chốt: synthetic shell (fn v2 fallback) hay fn_birth_registry_auto_id() hay canonical_address.
  2. Opus soạn execution prompt ngắn (1 CREATE TRIGGER + verify).
  3. Deploy + test INSERT 1 IU pilot row → verify birth_registry entry.
  4. F6 RESOLVED.
  5. Pack 2B UNBLOCKED.

Opus Assessment | 2026-05-05 | Investigation PASS. Synthetic shell information_unit::<uuid> khớp 70k precedent. Deploy 1 trigger SQL trực tiếp. Chờ GPT chốt.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/reviews/opus-assessment-birth-code-patterns-investigation-2026-05-05.md