KB-4BFD

P5b — Component/BOM Schema Draft v0.2

28 min read Revision 1
dieu38p5bcomponentbomschematext-as-codeofficial

P5b — Component/BOM Schema Draft v0.2

Loại: Schema design note — Điều 38 Text as Code Phase: P5b (Schema Phase — Component/BOM slice), bổ sung P5 v0.2 Trạng thái: OFFICIAL v0.2 — GPT R1 (18+3) + R2 (12) + FINAL PASS. User PASS. Ngày soạn: 2026-04-26 | Phiên: S181 Agent soạn: Opus 4.6 (Desktop) GPT review: R1 PASS có điều kiện (18+3). R2 PASS có điều kiện nhẹ (12). Final PASS. Inputs: C3 (OFFICIAL v0.1), P5 v0.2, L2, L4, C1, C2, C1A, LSL-01 v0.3/v0.4, Đ24, Đ32, Đ33


1. Mục tiêu

Chuyển C3 operating model thành draft schema cho kho linh kiện Component/BOM — bổ sung P5 v0.2.

Pseudo-DDL = design notation, KHÔNG apply vào production. Mọi DDL thật phải qua gateway/migration approval. CHECK constraints trong pseudo-DDL là notation — production nên dùng FK vocab/config để đúng NT4.


2. Phạm vi / Không làm

2.1 Minimum slice — 10 new tables

  1. component — registry linh kiện
  2. component_version — version content/spec
  3. component_type_vocab — controlled vocabulary
  4. bom_entry — Bill of Materials
  5. reuse_decision — record tìm kiếm + justification
  6. compatibility_rule — requires/conflicts/replaces/forbidden
  7. governance_status_vocab — controlled vocabulary
  8. usage_type_vocab — controlled vocabulary BOM usage
  9. component_pg_ref — read-only PG object references
  10. change_set_subject — generic change subject (extension table liên kết P5 change_set)

Tổng minimum: 10 new tables. P5 existing tables KHÔNG sửa. change_set_subject là extension table liên kết P5.

2.2 Phase 2

  1. golden_path + 12. golden_path_member

2.3 Không làm

  • Không SQL executable / migration / apply production
  • Không DOT/checker (P6) / Qdrant/KG / UI
  • Không sửa P5 v0.2 tables/columns/constraints

3. Nguyên tắc thiết kế

DP-B1: Generic change_set_subject

Tạo change_set_subject table mới link vào P5 change_set (FK). P5 change_set_member giữ nguyên 100% — logical_unit_id NOT NULL không bị relax.

Extensible: thêm subject_type chỉ cần thêm row trong vocab/config, không ALTER table.

DP-B2: BOM uniqueness mặc định (publication_id, component_id)

Policy/config rule, không hard constraint tuyệt đối. Escape hatch: variant, mở rộng key, hoặc component_use_id riêng.

DP-B3: Đ24 entity mapping deferred

Format chờ rà Đ24 entity_code thực tế. component.code là code identity của component catalog, KHÔNG phải Đ24 entity_code. Mapping sang Đ24 deferred (OD-P5b-07).

DP-B4: pg_object_refs = junction table read-only

Không FK trực tiếp vào pg_catalog. Validation via P6 checker. Schema nullable.

DP-B5: Golden path = phase 2

DP-B6: Version sequential, tối đa 1 active per component

DP-B7: Governance status = FK controlled vocabulary table


4. Relationship với P5 v0.2

P5b không thay đổi semantics/invariants của P5 slice. P5b đề xuất backward-compatible bổ sung: 10 new tables, trong đó change_set_subject link vào P5 change_set qua FK. P5 existing tables/rows giữ nguyên.

4.1 change_set_subject

-- PSEUDO-DDL — DESIGN NOTATION
CREATE TABLE change_set_subject (
    id                UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    change_set_id     UUID NOT NULL REFERENCES change_set(id),
    
    -- Subject type (extensible via vocab/config — NT4)
    subject_type      TEXT NOT NULL,
        -- Values: 'component', 'component_version', 'bom_entry', 
        -- 'compatibility_rule'. Production: FK change_subject_type_vocab
        -- hoặc config registry. CHECK trong DDL chỉ là notation.
    
    -- Subject references (nullable per subject_type)
    component_id          UUID REFERENCES component(id),
    component_version_id  UUID REFERENCES component_version(id),
    bom_entry_id          UUID REFERENCES bom_entry(id),
    compatibility_rule_id UUID REFERENCES compatibility_rule(id),
    
    -- Change details
    change_action     TEXT NOT NULL,
        -- 'create', 'update', 'retire', 'activate', 'deprecate'.
        -- Production: FK vocab hoặc config.
    
    -- Snapshot (C1 I9)
    snapshot_data     JSONB,
    
    created_at        TIMESTAMPTZ NOT NULL DEFAULT now(),
    
    -- INV-CSM-SINGLE-FK: Exactly one relevant subject FK populated
    -- per subject_type. Others NULL. Trigger/app enforce:
    --   subject_type='component' → component_id NOT NULL, rest NULL.
    --   subject_type='bom_entry' → bom_entry_id NOT NULL, rest NULL.
    --   subject_type='component_version' → component_version_id NOT NULL
    --     + component_id NOT NULL (consistency).
);

5. Entity map

P5 (KHÔNG sửa):                    P5b (10 minimum + 2 phase 2):
┌──────────────┐                    ┌──────────────┐
│ publication  │◄───────────────────│ bom_entry    │
│ (P5)         │                    └──────┬───────┘
└──────────────┘                           │ FK
┌──────────────┐     FK             ┌──────▼───────┐  1:N  ┌─────────────────┐
│ change_set   │◄───────────────────│ component    │──────▶│component_version│
│ (P5)         │  change_set_subject│              │       └─────────────────┘
└──────────────┘                    │ code UNIQUE  │
                                    │ base_comp_ref│──self
                                    │ reuse_dec_id │──▶ reuse_decision
                                    └──────┬───────┘
                                           │
                          ┌────────────────┼────────────────┐
                          ▼                ▼                ▼
                   component_pg_ref  compatibility_rule  entity_labels(Đ24)

Vocab: component_type_vocab, governance_status_vocab, usage_type_vocab
Phase 2: golden_path + golden_path_member

6. Draft table/concept model

CẢNH BÁO: Pseudo-DDL = design notation. CHECK constraints = notation, production dùng FK vocab/config (NT4).

6.1 component

-- PSEUDO-DDL — DESIGN NOTATION
CREATE TABLE component (
    id                UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    code              TEXT NOT NULL UNIQUE,
        -- Code identity của component catalog.
        -- KHÔNG phải Đ24 entity_code. Mapping sang Đ24 deferred (OD-P5b-07).
        -- Format convention: lowercase-kebab. Enforce: birth gate (P6).
    
    name              TEXT NOT NULL,
    component_type    TEXT NOT NULL REFERENCES component_type_vocab(code),
    
    owner             TEXT NOT NULL,
    description       TEXT,
        -- Required per component_type config.
    spec_summary      TEXT NOT NULL,
    interface_summary TEXT,
        -- Required per component_type config.
    
    -- Lifecycle (Đ4)
    lifecycle_status  TEXT NOT NULL DEFAULT 'draft',
        -- Values: draft, active, deprecated, superseded, retired.
        -- Production: FK lifecycle_status_vocab hoặc config.
        -- component.superseded = component/base KHÁC thay thế toàn bộ
        --   (architectural replacement, new base).
        -- Phân biệt: component_version.superseded = version mới thay cũ
        --   trong CÙNG component.
    
    -- Governance status
    governance_status TEXT NOT NULL DEFAULT 'experimental'
        REFERENCES governance_status_vocab(code),
        -- INV-LIFECYCLE-GOV-CONSISTENT.
    
    -- Variant
    base_component_id UUID REFERENCES component(id),
        -- NULL = base. NOT NULL = variant → lineage/trace, KHÔNG tree.
    
    -- Reuse decision
    reuse_decision_id UUID REFERENCES reuse_decision(id),
        -- Birth flow: reuse_decision tạo TRƯỚC → component trỏ tới.
        -- Required khi tạo mới (④) / variant / base mới.
    
    identity_profile  JSONB DEFAULT '{}',
    created_at        TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at        TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX idx_comp_type ON component(component_type);
CREATE INDEX idx_comp_lifecycle ON component(lifecycle_status);
CREATE INDEX idx_comp_gov ON component(governance_status);
CREATE INDEX idx_comp_base ON component(base_component_id) WHERE base_component_id IS NOT NULL;

6.2 component_version

-- PSEUDO-DDL — DESIGN NOTATION
CREATE TABLE component_version (
    id                UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    component_id      UUID NOT NULL REFERENCES component(id),
    version_number    INTEGER NOT NULL DEFAULT 1,
    
    spec_detail       TEXT NOT NULL,
    implementation_ref TEXT,
    changelog_summary TEXT NOT NULL,
    
    lifecycle_status  TEXT NOT NULL DEFAULT 'draft',
        -- Values: draft, active, deprecated, superseded, retired.
        -- version.superseded = version cũ khi version mới active CÙNG component.
        -- INV-COMP-SINGLE-ACTIVE, INV-COMP-RETIRED-NO-ACTIVE.
    
    review_state      TEXT DEFAULT 'unreviewed',
        -- Values: unreviewed, in_review, review_passed, review_failed, needs_re_review.
    
    content_hash      TEXT,
        -- Derived: spec_detail + implementation_ref + changelog_summary + content_profile.
    
    content_profile   JSONB DEFAULT '{}',
    
    -- Vector projection hooks
    vector_sync_status TEXT DEFAULT 'pending',
        -- Values: pending, synced, stale, error, skip.
        -- skip = spec quá ngắn. INV-COMP-CHUNK-SINGLE-CV.
    vector_synced_at   TIMESTAMPTZ,
    vector_chunk_count INTEGER DEFAULT 0,
    
    created_at        TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at        TIMESTAMPTZ NOT NULL DEFAULT now(),
    activated_at      TIMESTAMPTZ,
    
    UNIQUE (component_id, version_number)
);

CREATE INDEX idx_cv_component ON component_version(component_id);
CREATE INDEX idx_cv_lifecycle ON component_version(lifecycle_status);

6.3 bom_entry

-- PSEUDO-DDL — DESIGN NOTATION
CREATE TABLE bom_entry (
    id                    UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    publication_id        UUID NOT NULL REFERENCES publication(id),
    component_id          UUID NOT NULL REFERENCES component(id),
    component_version_id  UUID NOT NULL REFERENCES component_version(id),
    
    usage_type            TEXT NOT NULL REFERENCES usage_type_vocab(code),
    config_override       JSONB DEFAULT '{}',
    
    created_at            TIMESTAMPTZ NOT NULL DEFAULT now(),
    
    UNIQUE (publication_id, component_id),
        -- Policy/config mặc định. Escape hatch: variant, mở rộng key,
        -- hoặc component_use_id riêng.
    
    -- BOM KHÔNG có lifecycle riêng. Status derived từ publication:
    --   proposed → mutable
    --   enacted → LOCKED (INV-BOM-ENACTED-LOCK)
    --   superseded/retired → immutable snapshot
    
    -- Business rules (trigger/app):
    -- 1. CONSISTENCY: component_version.component_id = bom_entry.component_id.
    -- 2. Enacted lock: 2 giai đoạn:
    --    a. Khi proposed pub chuyển enacted → GATE kiểm toàn BOM:
    --       component_version.lifecycle = 'active' AND
    --       component.lifecycle = 'active' AND
    --       component.governance_status cho phép.
    --    b. Sau enacted → LOCK: block INSERT/UPDATE/DELETE trên bom_entry.
    -- 3. Proposed publication → mutable, MAY reference draft.
);

CREATE INDEX idx_bom_pub ON bom_entry(publication_id);
CREATE INDEX idx_bom_comp ON bom_entry(component_id);

6.4 reuse_decision

-- PSEUDO-DDL — DESIGN NOTATION
CREATE TABLE reuse_decision (
    id                UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    
    decision_type     TEXT NOT NULL,
        -- Values: reuse_as_is, reuse_with_config, extend_variant, create_new.
        -- Production: FK vocab.
    
    -- Search evidence
    search_performed  BOOLEAN NOT NULL DEFAULT TRUE,
    search_result     TEXT,
    search_evidence   JSONB DEFAULT '{}',
        -- {"considered": [{"code": "guard-x", "reason": "incompatible"}]}
    justification     TEXT NOT NULL,
    
    -- References to existing components
    target_component_id UUID REFERENCES component(id),
        -- Chỉ trỏ component ĐÃ TỒN TẠI:
        --   reuse_as_is / reuse_with_config: component được reuse.
        --   extend_variant: base component đang extend.
        --   create_new: NULL (component chưa tồn tại).
    considered_components JSONB DEFAULT '[]',
        -- Array of component evidence (code/id/reason), không chỉ ids.
    
    -- Approval
    decided_by        TEXT NOT NULL,
    decided_at        TIMESTAMPTZ NOT NULL DEFAULT now(),
    approval_ref      TEXT,
        -- Opaque reference tới APR.
        -- REQUIRED cho create_new (④) và extend_variant (③).
        -- Nullable cho reuse_as_is (①) / reuse_with_config (②) theo policy.
    
    created_at        TIMESTAMPTZ NOT NULL DEFAULT now()
    
    -- Birth flow: reuse_decision tạo TRƯỚC component.
    -- component.reuse_decision_id trỏ tới đây. Không circular.
);

6.5 compatibility_rule

-- PSEUDO-DDL — DESIGN NOTATION
CREATE TABLE compatibility_rule (
    id                UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    
    component_a_id    UUID NOT NULL REFERENCES component(id),
    component_b_id    UUID NOT NULL REFERENCES component(id),
    
    rule_type         TEXT NOT NULL,
        -- Values: requires, conflicts, replaces, compatible_with, forbidden.
        -- Production: FK vocab.
    
    -- Enforcement level
    is_enforced       BOOLEAN NOT NULL DEFAULT FALSE,
        -- DEFAULT FALSE = advisory/knowledge.
        -- TRUE = DOT checker treat as ERROR.
        -- Anti-pattern chưa authority approve → is_enforced=FALSE (advisory).
        -- Sau authority approve → is_enforced=TRUE + authority_ref required.
        -- Enforced cần explicit enforcement decision, không vô tình enforce.
    
    -- Version specificity: hiện component-level.
    -- Version-specific: deferred (OD-P5b-05).
    
    description       TEXT,
    authority_ref     TEXT,
        -- Opaque reference. Bắt buộc khi is_enforced=TRUE + rule_type='forbidden'.
    lifecycle_status  TEXT NOT NULL DEFAULT 'active',
    
    created_at        TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at        TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX idx_compat_a ON compatibility_rule(component_a_id);
CREATE INDEX idx_compat_b ON compatibility_rule(component_b_id);

6.6 component_pg_ref

-- PSEUDO-DDL — DESIGN NOTATION
-- Read-only ref → PG objects. NT11: chỉ trỏ, không khai lại.
-- KHÔNG FK vào pg_catalog. Validation: P6 checker.
CREATE TABLE component_pg_ref (
    id                UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    component_id      UUID NOT NULL REFERENCES component(id),
    
    pg_object_type    TEXT NOT NULL,
        -- Values: function, trigger, table, view, index, type.
    pg_object_schema  TEXT,
        -- Nullable. Default per deployment config, không hardcode.
    pg_object_name    TEXT NOT NULL,
    
    description       TEXT,
    created_at        TIMESTAMPTZ NOT NULL DEFAULT now(),
    
    UNIQUE (component_id, pg_object_type, pg_object_schema, pg_object_name)
);

6.7–6.9 Vocabulary tables

-- PSEUDO-DDL — DESIGN NOTATION
-- Tất cả vocab tables: config/governance data (NT4).
-- KHÔNG thay thế Đ24. Seed values = initial, không hardcode vĩnh viễn.
-- Mở rộng qua catalog governance/approval.

CREATE TABLE component_type_vocab (
    code TEXT PRIMARY KEY,
        -- Initial seed: pattern, template, guard, config_rule, workflow_step, function.
    name TEXT NOT NULL,
    description TEXT,
    lifecycle_status TEXT NOT NULL DEFAULT 'active',
    description_required BOOLEAN DEFAULT TRUE,
    interface_required BOOLEAN DEFAULT TRUE,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE TABLE governance_status_vocab (
    code TEXT PRIMARY KEY,
        -- Initial seed: approved_for_reuse, experimental, restricted,
        -- deprecated_but_allowed, forbidden_for_new.
    name TEXT NOT NULL,
    description TEXT,
    lifecycle_status TEXT NOT NULL DEFAULT 'active',
    allows_new_bom_entry BOOLEAN NOT NULL DEFAULT TRUE,
        -- FALSE cho forbidden_for_new.
    requires_approval BOOLEAN NOT NULL DEFAULT FALSE,
        -- TRUE cho restricted, deprecated_but_allowed — 
        -- add vào BOM cần approval riêng.
        -- Allowed scope/conditions: deferred cho P6 hoặc JSONB extension.
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE TABLE usage_type_vocab (
    code TEXT PRIMARY KEY,
        -- Initial seed: required, optional, reference, alternative.
    name TEXT NOT NULL,
    description TEXT,
    lifecycle_status TEXT NOT NULL DEFAULT 'active',
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

6.10 Phase 2: golden_path + golden_path_member

-- PSEUDO-DDL — DESIGN NOTATION — PHASE 2 (DP-B5)
CREATE TABLE golden_path (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name TEXT NOT NULL,
    problem_type TEXT NOT NULL,
    description TEXT,
    lifecycle_status TEXT NOT NULL DEFAULT 'draft',
    authority_ref TEXT,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE TABLE golden_path_member (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    golden_path_id UUID NOT NULL REFERENCES golden_path(id),
    component_id UUID NOT NULL REFERENCES component(id),
    component_version_id UUID REFERENCES component_version(id),
        -- Draft/proposed GP: NULL = latest active OK.
        -- Active/approved GP: PHẢI lock explicit version_id
        --   (INV-GOLDEN-PATH-VERSION-LOCK).
    sort_order INTEGER NOT NULL DEFAULT 0,
    is_required BOOLEAN NOT NULL DEFAULT TRUE,
    assembly_notes TEXT,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    UNIQUE (golden_path_id, component_id)
);

7. Component lifecycle / versioning

7.1 Component lifecycle

draft ──▶ active ──▶ deprecated ──▶ retired
                 │
                 └──▶ superseded
  • component.superseded = component/base KHÁC thay thế toàn bộ (architectural replacement).
  • component_version.superseded = version cũ khi version mới active CÙNG component.

7.2 Component version lifecycle

  • Tối đa 1 active per component (INV-COMP-SINGLE-ACTIVE).
  • Component retired → active/current version → retired. Historical superseded versions giữ nguyên superseded status cho audit. KHÔNG tất cả versions → retired.
  • Version mới active → version cũ superseded (auto).

7.3 Lifecycle vs governance_status

  • lifecycle = trạng thái tồn tại.
  • governance_status = policy sử dụng.
  • Ràng buộc: retired → NOT approved/experimental (INV-LIFECYCLE-GOV-CONSISTENT). approved_for_reuse chỉ khi active.

8. BOM lifecycle / snapshot rules

8.1 BOM lifecycle derived từ publication

BOM entry KHÔNG có lifecycle riêng. Status derived:

Publication BOM Mutable?
proposed Mutable Yes
enacted LOCKED No
superseded/retired Immutable snapshot No

8.2 Enacted BOM — 2 giai đoạn

Giai đoạn 1 — GATE (khi proposed → enacted): Kiểm toàn BOM:

  • component_version.lifecycle_status = 'active'
  • component.lifecycle_status = 'active'
  • component.governance_status cho phép (allows_new_bom_entry=TRUE, hoặc requires_approval=TRUE + có approval)

Giai đoạn 2 — LOCK (sau enacted): Block INSERT/UPDATE/DELETE trên bom_entry cho publication đó.

8.3 BOM version mismatch + consistency

  • BOM ghi version tại thời điểm add. Bump → BOM không tự đổi → DOT WARN.
  • component_version.component_id PHẢI = bom_entry.component_id (INV-BOM-CONSISTENCY).

9–11. Variant / Reuse / Compatibility

Variant: base_component_id self-ref. Lineage/trace, KHÔNG tree. Variant retired ≠ base retired.

Reuse flow: reuse_decision tạo TRƯỚC → component trỏ tới. target_component_id rules per decision_type (§6.4). approval_ref required cho ③④, nullable cho ①② theo policy.

Compatibility: is_enforced DEFAULT FALSE. Enforced cần authority_ref. Version-specific: deferred (OD-P5b-05).


12. Label integration with Đ24

  • Labels dùng Đ24 entity_labels hoặc mapping tương thích. Format deferred (OD-P5b-07).
  • component.code là code identity catalog, KHÔNG phải Đ24 entity_code.
  • Vocab tables = structural/governance, KHÔNG thay thế Đ24.

13. Change-set / APR integration

  • change_set_subject link P5 change_set. P5 change_set_member giữ nguyên.
  • INV-CSM-SINGLE-FK: Exactly one relevant FK per subject_type.
  • APR: authority_ref/approval_ref opaque. Required rules per decision_type.
  • Snapshot bất biến khi submitted (C1 I9).

14. Birth gate readiness

14.1 Component birth

Check Enforcement
code UNIQUE (catalog identity, ≠ Đ24 entity_code) BLOCK
name, spec_summary NOT NULL BLOCK
component_type FK active vocab BLOCK
owner NOT NULL BLOCK
description per component_type config BLOCK/WARN
interface per component_type config BLOCK/WARN
base_component_id valid (variant) BLOCK
reuse_decision_id (④/variant/base mới): required + approval_ref BLOCK
lifecycle default 'draft' SYSTEM AUTO
governance default 'experimental' SYSTEM AUTO

14.2 Component version birth

Check Enforcement
component_id FK valid BLOCK
version_number auto-increment SYSTEM AUTO
spec_detail, changelog_summary NOT NULL BLOCK
lifecycle default 'draft' SYSTEM AUTO
content_hash computed SYSTEM AUTO

14.3 BOM entry birth

Check Enforcement
publication_id, component_id, component_version_id FK valid BLOCK
component_version.component_id = bom_entry.component_id BLOCK
Component version active + component active + governance per rule BLOCK/WARN
usage_type FK active vocab BLOCK
UNIQUE (publication_id, component_id) BLOCK
Publication not enacted (enacted → locked) BLOCK

15. Vector / KG projection hooks

  • Chỉ spec text dài mới có vector projection. skip cho spec ngắn.
  • INV-COMP-CHUNK-SINGLE-CV: chunk trong đúng 1 component_version. Manifest thuộc P6.
  • KG/Qdrant = projection-only (INV-KG-PROJECTION-ONLY). PG = SoT.

16. P6 checker implications

16.1 Minimum slice

Check Severity Trigger
BOM version mismatch WARN DOT daily
BOM component/version/governance status ERROR DOT daily
Compatibility violation (enforced) ERROR DOT daily
Compatibility advisory (not enforced) WARN DOT daily
Reuse decision completeness ERROR Birth + DOT
Variant base valid ERROR Birth + DOT
Component version single-active ERROR DOT daily
Component retired + active version ERROR DOT daily
Lifecycle-governance consistency ERROR DOT daily
BOM consistency (version↔entry component_id) ERROR Birth + DOT
Component orphan INFO DOT weekly
component_pg_ref validity (query pg_catalog) WARN DOT daily
change_set_subject FK exclusivity ERROR DOT daily

16.2 Phase 2

Check Severity
Golden path adherence WARN
Golden path version lock (active GP, NULL version) ERROR

17. Open decisions

Code Câu hỏi Đề xuất Phase
OD-P5b-01 BOM cho non-publication assembly Phase 2. golden_path_member = BOM. Phase 2
OD-P5b-02 component.code format enforce kebab-case regex at birth P6
OD-P5b-03 component_pg_ref validate PG object exists P6 checker query pg_catalog P6
OD-P5b-04 BOM entry cho non-publication Phase 2 Phase 2
OD-P5b-05 Version-specific compatibility Deferred. Optional FK. P5b v1/P6
OD-P5b-06 Semantic versioning option Sequential default. Semantic per config. P6
OD-P5b-07 Đ24 entity_code mapping Deferred cho P6 rà Đ24 format. P6

18. Constitutional / Cross-law check

Nguyên tắc / Luật Verdict Ghi chú
NT1 / NT13 — PG SoT PASS Component/BOM/reuse trong PG. KG/Qdrant projection-only.
NT2 — Cơ chế máy PASS có điều kiện Birth/reuse/compatibility/BOM lock → P6 implement.
NT4 — Config path PASS có điều kiện 3 vocab + rules + reuse = config/governance. CHECK = notation, production FK vocab. Seed = initial.
NT8 — Assembly First PASS BOM + golden path.
NT11 — Khai tối thiểu PASS pg_ref read-only. Vocab ≠ Đ24.
Đ24 PASS Labels qua entity_labels. Mapping deferred. component.code ≠ Đ24 entity_code.
Đ32 PASS authority_ref/approval_ref opaque. Required rules per decision_type.
Đ33 PASS Pseudo-DDL = design notation. Mọi DDL thật qua gateway/migration approval.
L2/L4/C3/P5 PASS Backward-compatible bổ sung. P5 tables KHÔNG sửa.

19. PASS criteria

# Criterion Status
1 10 new tables minimum + 2 phase 2
2 P5 backward-compatible bổ sung, KHÔNG sửa P5 tables
3 change_set_subject generic, INV-CSM-SINGLE-FK
4 BOM ≠ publication_member
5 Component ≠ text unit
6 pg_ref read-only, no pg_catalog FK
7 Reuse decision flow: no circular, approval_ref rules
8 Labels dùng Đ24, vocab ≠ Đ24, code ≠ entity_code
9 Lifecycle vs governance + invariant
10 Superseded phân biệt component vs version
11 BOM enacted: GATE then LOCK
12 is_enforced DEFAULT FALSE
13 authority_ref opaque
14 Pseudo-DDL = notation, DDL qua gateway
15 19 invariants bảo toàn
16 Constitutional PASS
17 GPT + User duyệt

20. Invariants

Code Statement Enforce Nguồn
INV-COMP-NEQ-UNIT Component ≠ text unit Architecture C3, L2
INV-CATALOG-NEQ-PG pg_ref read-only, not duplicate Design NT11
INV-BOM-NEQ-MEMBER BOM ≠ publication_member Table design C3, L2
INV-BOM-NEQ-REF BOM (pub) ≠ ref edge (unit) Table design C3, L2
INV-REUSE-FIRST Reuse trước tạo mới Birth gate L2
INV-COMP-NO-AUTH Component ≠ text authority Governance L2
INV-VARIANT-BASE Variant → base tồn tại FK + birth L2
INV-COMP-NO-TREE No parent-child tree Architecture C3
INV-BOM-ENACTED-LOCK Enacted pub → BOM locked Trigger/app C3
INV-GOLDEN-PG Golden path = PG data (phase 2) Design L2
INV-COMP-LABEL-D24 Labels Đ24 hoặc mapping tương thích Architecture CI-9
INV-COMP-SINGLE-ACTIVE Max 1 active version per component Trigger/app C3
INV-COMP-RETIRED-NO-ACTIVE Retired → active/current version retired; historical superseded giữ audit Trigger/app C3
INV-LIFECYCLE-GOV-CONSISTENT retired → NOT approved/experimental DOT C3
INV-KG-PROJECTION-ONLY KG/Qdrant projection-only Architecture NT1
INV-BOM-CONSISTENCY comp_version.component_id = bom_entry.component_id Trigger/app R1
INV-COMP-CHUNK-SINGLE-CV Chunk trong đúng 1 component_version P6 manifest P5 analog
INV-GOLDEN-PATH-VERSION-LOCK Active GP lock explicit version_id Trigger/app R1
INV-CSM-SINGLE-FK Exactly one subject FK per subject_type Trigger/app R2

P5b có yêu cầu sửa P5 v0.2 không?

KHÔNG sửa P5 v0.2 tables/columns/constraints. P5b chỉ backward-compatible bổ sung: 10 new tables (minimum) + change_set_subject link P5 change_set qua FK. P5 existing rows, constraints, 15 invariants giữ nguyên.


P5b v0.2 | OFFICIAL | S181 | 2026-04-26 | Opus 4.6 GPT: R1 (18+3) + R2 (12) + FINAL PASS | User: PASS