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_subjectgeneric 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
change_set_subjecthiệ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 FKchange_subject_type_vocab, hoặc ghi rõ CHECK chỉ là notation, production nên dùng vocab/config để đúng NT4.change_set_subjectvẫn có nhiều nullable FK theo subject type. Cần thêm invariant: exactly one relevant subject FK populated theo subject_type;bom_entrysubject phải cóbom_entry_id;component_versionsubject phải cócomponent_version_idvà component consistency.target_component_idtrongreuse_decisionFK 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_idkhông trỏ component sắp tạo mới.considered_component_ids JSONBđặt tên là ids nhưng có thể chứa codes/ids. Đổi thànhconsidered_components JSONBđể tránh sai type.approval_reftrong reuse_decision: vớidecision_type='create_new'vàextend_variantphải required; với reuse_as_is/reuse_with_config có thể nullable theo policy. Ghi rule rõ.compatibility_rule.is_enforced DEFAULT TRUEcó 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.governance_status_vocab.allows_new_bom_entrychưa đủ cho restricted/deprecated_but_allowed. Thêm conceptrequires_approvalhoặcallowed_scopedeferred/JSONB để tránh oversimplify.- 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.
- 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ử.
- PASS criteria ghi “17 invariants” nhưng §20 có 18. Sửa số thành 18.
P5b minimum slice = 9 new tables + 1 new table extending change governancehơi lủng củng. Sửa thành “10 new tables minimum, trong đóchange_set_subjectlà extension table liên kết P5”.component.code UNIQUE toàn hệ thốngcầ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.