KB-1EAB

Opus Review — P2B-P0 Schema Inspection Report

4 min read Revision 1
iu-0pack-2bp2b-p0reviewschema-inspection

Opus Review — P2B-P0 Schema Inspection Report

Date: 2026-05-05 | Reviewer: Opus (phiên Pack 2B) Reviewed: reports/19-p2b-p0-iu-schema-inspection-report.md rev1


Verdict

P2B-P0 PASS. Report hoàn thành 10/10 sections theo prompt rev2. Read-only, không mutation. Chất lượng cao — agent tự extract trigger logic L1/L2 ngoài scope query gốc.


Findings đáng chú ý

1. Circular FK IU↔UV (quan trọng nhất cho P2B-P1)

IU có FK version_anchor_ref → unit_version(id) DEFERRABLE. UV có FK unit_id → information_unit(id) NOT deferrable.

→ P2B-P1 bắt buộc single-transaction flow:

  1. INSERT IU (version_anchor_ref = NULL tạm)
  2. INSERT UV (unit_id = IU.id)
  3. UPDATE IU SET version_anchor_ref = UV.id, content_anchor_ref = UV.id::text
  4. COMMIT → L2 deferred trigger fires, verify anchors

Agent đề xuất CTE pattern gộp bước 1-3 — hợp lý.

2. Vocab blocker (phải resolve trước P2B-P1)

L1 trigger kiểm tra 3 vocab qua dot_config:

  • vocab.unit_kind.<value> — unit_kind phải match
  • vocab.section_type.<value> — primary_section_type_ref phải match
  • vocab.publication_type.<value> — optional nhưng nếu có phải match

→ P2B-P1 preflight cần query:

SELECT key FROM dot_config WHERE key LIKE 'vocab.unit_kind.%';
SELECT key FROM dot_config WHERE key LIKE 'vocab.section_type.%';

Để biết chính xác giá trị nào hợp lệ.

3. Birth trigger timing — OK

trg_birth_information_unit = AFTER INSERT (immediate, không deferred). Fires ngay khi IU row INSERT, trước COMMIT. Đọc identity_profile snapshot tại thời điểm INSERT → profile phải final lúc INSERT, không patch sau.

4. L2 deferred constraint — strict equality

content_anchor_ref PHẢI bằng version_anchor_ref::text. version_anchor_ref PHẢI trỏ đến UV row có unit_id = IU.id. Kiểm tra tại COMMIT time.

5. No RLS, no PROV-HUMAN — clean path

Không có row-level security. description_policy = structured_exempt → không cần description backfill.


Đánh giá schema vs UMC design (file 04)

UMC element Có trên schema thật? Ghi chú
U1 unit_id id uuid auto
U2 canonical_address ✅ text UNIQUE
U3 unit_kind ✅ text, L1 vocab check
U4 lifecycle_status ✅ default 'draft'
U5 content_anchor_ref ✅ text, L2 enforce
U6 version_anchor_ref ✅ uuid FK→UV, DEFERRABLE
U7 owner_ref ✅ text NOT NULL
U8 timestamps ✅ created_at/updated_at/created_by/updated_by
U9 parent_or_container_ref ✅ uuid nullable
U10 conformance_status ✅ default 'open'

10/10 UMC elements có trên schema. Schema khớp design.


Đề xuất P2B-P1

P2B-P1 prompt nên gồm:

  1. Vocab preflight — query dot_config lấy valid unit_kind + section_type values
  2. Build exact payload — dùng CTE pattern agent đề xuất, thay placeholders bằng giá trị thật
  3. Pilot namespacecanonical_address dạng pilot.iu0.test-001 (hoặc format khác nếu GPT/User chỉ định)
  4. Verify birth fire — ngay sau COMMIT, query birth_registry
  5. Verify L2 pass — anchors consistent
  6. Capture baselines — fn hash, trigger count, birth count trước/sau
  7. 1 pilot row trước, verify xong mới xét row 2

Giá trị pilot đề xuất (chờ GPT/User confirm):

Field Giá trị đề xuất Lý do
canonical_address pilot.iu0.test-001 Pilot namespace rõ ràng
unit_kind (cần query vocab) Có thể law_unit nếu đã seed
owner_ref system hoặc pilot Pilot actor
identity_profile.title Pilot IU Test 001 Nhận dạng rõ
body (UV) Pilot content for IU test 001 Nội dung test
content_hash md5 hoặc sha256 của body Computed

Câu hỏi cho GPT/User

  1. P2B-P0 report PASS — đồng ý proceed P2B-P1?
  2. Pilot canonical_address format: pilot.iu0.test-001 hay format khác?
  3. Sau pilot verify thành công: keep rows hay cleanup?

Opus review P2B-P0 | 2026-05-05 | PASS. Vocab blocker cần resolve. Circular FK cần single-tx.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/reviews/opus-review-p2b-p0-schema-inspection-report-2026-05-05.md