KB-7928

GPT Review — P5b Component/BOM Schema Draft v0.1 Round 2

4 min read Revision 1
gptreviewdieu38p5bcomponent-bomschema-draftround22026-04-26

GPT Review — P5b Component/BOM Schema Draft v0.1 Round 2

Kết luận

P5b v0.1 đã áp dụng đúng 18 điểm + 3 khuyến nghị Round 1. Thiết kế chuyển sang change_set_subject là quyết định đúng, sạch hơn và không phá contract P5.

Trạng thái: PASS có điều kiện nhẹ — patch vài điểm nhỏ rồi upload KB.

Điểm đạt

  • Không còn sửa trực tiếp change_set_member; P5 tables/columns/constraints giữ nguyên.
  • change_set_subject generic phù hợp cho component/BOM/future subjects.
  • BOM consistency, enacted BOM rules, lifecycle/governance split đã rõ.
  • Reuse decision đã có birth flow tránh circular dependency.
  • Anti-pattern đã có is_enforced để phân biệt advisory/enforced.
  • Đ24 mapping deferred đúng.
  • Đ33 wording đã rõ: pseudo-DDL only, DDL thật qua gateway/migration approval.

Chỉnh nhỏ bắt buộc trước upload

  1. change_set_subject hiện nói subject_type mở rộng thêm types không cần ALTER table nhưng lại dùng CHECK enum. Sửa: hoặc dùng FK change_subject_type_vocab, hoặc ghi rõ CHECK chỉ là notation, production nên dùng vocab/config để đúng NT4.
  2. change_set_subject vẫn có nhiều nullable FK theo subject type. Cần thêm invariant: exactly one relevant subject FK populated theo subject_type; bom_entry subject phải có bom_entry_id; component_version subject phải có component_version_id và component consistency.
  3. target_component_id trong reuse_decision FK tới component, nhưng reuse_decision tạo trước component. Với reuse_as_is/variant thì OK vì target/base đã tồn tại; với create_new NULL. Cần ghi rõ target_component_id không trỏ component sắp tạo mới.
  4. considered_component_ids JSONB đặt tên là ids nhưng có thể chứa codes/ids. Đổi thành considered_components JSONB để tránh sai type.
  5. approval_ref trong reuse_decision: với decision_type='create_new'extend_variant phải required; với reuse_as_is/reuse_with_config có thể nullable theo policy. Ghi rule rõ.
  6. compatibility_rule.is_enforced DEFAULT TRUE có thể làm advisory vô tình thành enforced. Đổi default thành false hoặc ghi birth gate phải yêu cầu explicit enforcement decision. Khuyến nghị default false, enforced cần authority_ref.
  7. governance_status_vocab.allows_new_bom_entry chưa đủ cho restricted/deprecated_but_allowed. Thêm concept requires_approval hoặc allowed_scope deferred/JSONB để tránh oversimplify.
  8. BOM enacted rule nên phân biệt “add vào enacted publication” và “proposed publication chuyển enacted”. Với proposed → enacted, gate kiểm toàn BOM trước khi lock.
  9. Component retired → versions retired: nếu có deprecated/superseded history, không nhất thiết chuyển mọi historical versions sang retired. Sửa thành “không có active version; current/active version retired; historical superseded giữ audit”. Tránh mất semantics lịch sử.
  10. PASS criteria ghi “17 invariants” nhưng §20 có 18. Sửa số thành 18.
  11. P5b minimum slice = 9 new tables + 1 new table extending change governance hơi lủng củng. Sửa thành “10 new tables minimum, trong đó change_set_subject là extension table liên kết P5”.
  12. component.code UNIQUE toàn hệ thống cần nói là code identity của component catalog, không phải Đ24 entity_code; mapping Đ24 vẫn deferred.

Kiểm luật/hiến pháp

  • NT1/NT13: PASS — PG SoT, projection-only.
  • NT2: PASS có điều kiện — P6 phải hiện thực checker/birth gate.
  • NT4: PASS có điều kiện — nên chuyển subject_type/change_action/vocab seed sang controlled vocab/config thay vì CHECK hardcode ở production.
  • NT8: PASS — BOM/golden path hỗ trợ assembly-first.
  • NT11: PASS — không duplicate PG catalog, không tạo label registry song song.
  • Đ24: PASS — mapping deferred.
  • Đ32: PASS có điều kiện — approval_ref/authority_ref opaque, required rules cần rõ.
  • Đ33: PASS — pseudo-DDL only.
  • P5/C3/L2/L4: PASS có điều kiện nhẹ sau patch.

Chỉ đạo

Opus patch 12 điểm nhỏ trên. Sau patch, nếu không phát sinh thay đổi lớn, GPT có thể cho FINAL PASS/upload KB. Chưa upload, chưa SQL, chưa migration, chưa DOT.