KB-1DAD

Opus Review — 22-P0 Inspection + P1 Proposal

4 min read Revision 1
pack-22p0reviewp1proposalopus

Opus Review — 22-P0 Inspection Report + P1 Proposal

Date: 2026-05-06 | Reviewer: Opus 4.6 Reviewed: knowledge/dev/laws/dieu44-trien-khai/reports/22-p0-iu-native-create-contract-inspection-report.md For: GPT/User approve P1 + quyết định defaults/hash reuse


Verdict

P0 PASS. Không blocker. Sẵn sàng P1.


Key Findings

Item Result Impact on P1
Existing fn_iu_create None → tạo mới No conflict
Contract columns (16/16) All present Function can proceed
Deferrable FK Exactly 1: fk_iu_version_anchor, INITIALLY DEFERRED Không cần SET CONSTRAINTS — đã deferred by default
Triggers (4/4) All enabled L1, L2, birth, updated_at đều active
Unique constraint information_unit_canonical_address_key Idempotency guard confirmed
Adapter role directus (owner + only INSERT holder) GRANT target
digest + gen_random_uuid Available Hash + UUID ready
fn_sbx_compute_content_hash Exists (4 args) Cần inspect signature → có thể reuse thay vì tạo fn_content_hash mới
iu_create.* defaults Absent Cần quyết: seed hay require explicit
Pilot IU 1 row (pilot.iu0.test-001) Cleanup optional

Phát hiện quan trọng: FK đã INITIALLY DEFERRED

P0 xác nhận fk_iu_version_anchorDEFERRABLE INITIALLY DEFERRED. Nghĩa là mặc định đã deferred — function không cần SET CONSTRAINTS ... DEFERRED nữa. Rev6 design đã plan dynamic discovery cho constraint name, nhưng thực tế không cần defer gì thêm.

L2 gate cũng là constraint trigger INITIALLY DEFERRED → fires at COMMIT.

Flow đúng: function INSERT IU → INSERT UV → UPDATE anchors → RETURN. COMMIT xảy ra ngoài function (autocommit). Tại COMMIT: FK check + L2 check both pass.

Đề xuất P1: bỏ SET CONSTRAINTS dynamic discovery. Thay bằng: preflight verify FK is INITIALLY DEFERRED (nếu không → EXCEPTION). Đơn giản hơn, ít code hơn, ít rủi ro hơn.


3 Decisions cần GPT/User trước P1

D1: fn_sbx_compute_content_hash — reuse hay tạo mới?

P0 phát hiện fn_sbx_compute_content_hash(4 args) đã tồn tại. P1 cần inspect signature:

  • Nếu compatible (accepts text body, returns sha256 hex) → reuse, không tạo fn_content_hash
  • Nếu sandbox-specific → tạo fn_content_hash mới

Đề xuất: P1 inspect signature trước, quyết tại chỗ. Nếu reuse → alias hoặc call trực tiếp.

D2: iu_create.* defaults — seed gì?

Vocab hiện có:

  • vocab.unit_kind.design_doc_section
  • vocab.section_type.section
  • vocab.publication_type.design_doc

Chỉ có 1 giá trị mỗi loại → default unambiguous. Nhưng theo rev6 policy: không seed mù, GPT/User approve.

Đề xuất: Chưa seed defaults trong P1. Caller phải explicit. Seed defaults khi có nhiều vocab values và rõ use case. Hiện tại 1 value/loại → caller nhớ dễ.

D3: Pilot IU cleanup?

pilot.iu0.test-001 còn tồn tại. Cleanup trước P4 (pilot mới) hay giữ?

Đề xuất: Giữ. P4 pilot dùng address khác (pilot.rev6.001). Cleanup riêng nếu cần.


P1 Scope đề xuất

  1. Inspect fn_sbx_compute_content_hash signature → decide reuse
  2. CREATE helpers: fn_content_hash (hoặc alias), fn_iu_resolve_default, fn_iu_classify_existing, fn_iu_create_preflight
  3. Preflight verify FK INITIALLY DEFERRED (thay vì dynamic SET CONSTRAINTS)
  4. No IU rows. No defaults seeding. No adapter.
  5. Report

Opus Review 22-P0 | 2026-05-06 | PASS. 3 decisions for GPT. Ready for P1.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/reviews/opus-review-22-p0-inspection-and-p1-proposal-2026-05-06.md