KB-7D04 rev 3

Species Taxonomy v1.2 — 3 tầng + Birth Registry + 7 chiều

7 min read Revision 3
speciestaxonomyS157architectureSSOTbirth-registry7-dimensions

SPECIES TAXONOMY — Bảng Phân Loại Loài Đầy Đủ v1.2

v1.2 | 2026-03-21 | S157 v1.2: +Species tree 3 tầng (parent_id + depth). +Birth Registry thay bộ đếm cũ. +Registries UI = 7 chiều (6 lớp + 1 meta-layer species). v1.1: Species ≠ nguyên tử. Species = meta-entity phân loại, đứng NGOÀI 6 lớp cấu tạo. Đọc kèm:

  • search_knowledge("species collection law draft") — Luật Loài v0.5
  • search_knowledge("birth registry law") — Điều 0-G
  • search_knowledge("design feasibility formula") — Công thức thiết kế

I. LỖ HỔNG ĐÃ SỬA (giữ nguyên v1.1)

  • v1.0 gọi "Species = nguyên tử" → SAI. Species = meta-entity, đứng NGOÀI 6 lớp.
  • v1.0 dùng UNION ALL hardcode → SAI. Bộ đếm = Birth Registry (Điều 0-G).

II. ĐỊNH NGHĨA

Species = Meta-entity phân loại (Classification Meta-entity)

  • ĐỨNG NGOÀI 6 lớp cấu tạo (atom→building). Là meta-layer phân loại.
  • KHÔNG CÓ composition_level riêng. Field composition_level trong entity_species = lớp CỦA CÁ THỂ.
  • Tương tự vật lý: "Nguyên tố" trong bảng tuần hoàn ≠ nguyên tử. Hydrogen là LOẠI nguyên tử.
  • Giá trị: Đếm đúng + Chứa đúng + Phát hiện mồ côi + Scale tương lai.

Species Tree 3 Tầng (v1.2)

Khi hệ thống grow lên hàng trăm, hàng ngàn species → cần phân nhóm. Giống sinh vật học: Giới → Bộ → Loài.

Tầng 0 (Nhóm gốc):    Infrastructure    Business Logic    Governance    UI/UX
                            │                  │               │            │
Tầng 1 (Loài chính):   DOT Tool          Workflow        Label Rule     Page
                        Agent             Task            Species        Table UI
                        Collection        Module          Entity Rule    ...
                            │                  │
Tầng 2 (Loài con):     DOT Schema        WF Approval     ...
                        DOT Content       WF Onboarding
                        DOT Inspect       ...

Schema bổ sung entity_species:

ALTER TABLE entity_species ADD COLUMN parent_id integer REFERENCES entity_species(id);
ALTER TABLE entity_species ADD COLUMN depth smallint NOT NULL DEFAULT 1
  CHECK (depth >= 0 AND depth <= 2);
-- depth 0 = nhóm gốc (Infrastructure, Business Logic, Governance, UI/UX)
-- depth 1 = loài chính (DOT Tool, Workflow, Label Rule...)
-- depth 2 = loài con (DOT Schema, DOT Content, WF Approval...)

-- Constraint: root không có parent, non-root phải có parent
ALTER TABLE entity_species ADD CONSTRAINT chk_species_tree
  CHECK (
    (depth = 0 AND parent_id IS NULL) OR
    (depth > 0 AND parent_id IS NOT NULL)
  );

Quy tắc:

  • Hôm nay: 21 species đều ở depth=1 (loài chính). Chưa cần depth 0 và 2.
  • Khi ~10 species cùng nhóm → tạo parent (depth=0). Khi species cần chi tiết → tạo child (depth=2).
  • 3 tầng là ĐỦ. Giống taxonomy (Điều 24) đã chứng minh pattern này.

III. BỘ ĐẾM PHỔ QUÁT = BIRTH REGISTRY (v1.2)

Thay thế hoàn toàn Section III cũ (dynamic function, UNION ALL). Birth Registry đơn giản hơn, mạnh hơn. Chi tiết: search_knowledge("birth registry law") — Điều 0-G

Mọi entity sinh ra → PG trigger → INSERT vào birth_registry. Đếm = COUNT trên birth_registry.

-- Đếm per species — 1 câu, KHÔNG BAO GIỜ SỬA
SELECT species_code, COUNT(*) FROM birth_registry 
WHERE governance_role = 'governed' GROUP BY species_code;

-- Đếm per composition_level
SELECT composition_level, COUNT(*) FROM birth_registry 
WHERE governance_role = 'governed' GROUP BY composition_level;

-- Thêm species/collection mới → KHÔNG SỬA QUERY

Ưu thế so với cách cũ:

  • Không UNION ALL, không dynamic function, không hardcode
  • 1 collection duy nhất cho đếm + orphan + inspection
  • Thêm entity type = thêm metadata record, code bất biến

IV. BẢNG 21 SPECIES HIỆN TẠI (snapshot, SẼ TĂNG)

Nhóm A: 14 loài entity đã quản trị

# code species_code display_name cá thể thuộc lớp management_mode prefix
1 SPE-CAT catalog Danh mục hệ thống atom governed CAT
2 SPE-TBL table_ui Bảng UI molecule governed TBL
3 SPE-MOD module Module compound governed M
4 SPE-WKF workflow Quy trình compound governed WF
5 SPE-WFS workflow_step Bước quy trình molecule governed ND
6 SPE-WCR wcr Đề xuất thay đổi compound governed WCR
7 SPE-DOT dot_tool DOT Tool atom governed DOT
8 SPE-PGE page Trang UI molecule governed PG
9 SPE-COL collection Collection molecule governed COL
10 SPE-TSK task Nhiệm vụ compound governed TSK
11 SPE-AGT agent Agent atom governed AGT
12 SPE-CPT checkpoint_type Loại checkpoint atom governed CP
13 SPE-CPS checkpoint_set Bộ checkpoint molecule governed CPS
14 SPE-DEP dependency Phụ thuộc atom governed DEP

Nhóm B: 6 loài governance

# code species_code display_name cá thể thuộc lớp management_mode prefix
15 SPE-LBL label Nhãn phân loại atom governed
16 SPE-FAC label_facet Chiều phân loại atom governed FAC
17 SPE-LBR label_rule Quy tắc gán nhãn atom governed
18 SPE-SPE species Loài meta governed SPE
19 SPE-ERL entity_rule Quy tắc thực thể atom governed
20 SPE-ISS system_issue Vấn đề hệ thống atom governed

Nhóm C: Native-managed

# code species_code display_name cá thể thuộc lớp management_mode prefix
21 SPE-DXF directus_field Trường Directus atom observed

V. REGISTRIES UI = 7 CHIỀU (v1.2)

Trước: 6 lớp cấu tạo. Giờ: 6 + 1 meta-layer species.

Chiều Nhìn vào Câu hỏi Ví dụ
1-6 6 lớp cấu tạo (atom→building) "Thứ này CẤU TẠO từ gì?" DOT-042 = atom, WF-001 = compound
7 Species meta-layer (tree 3 tầng) "Thứ này thuộc LOÀI gì?" DOT-042 thuộc SPE-DOT, WF-001 thuộc SPE-WKF

Browse theo species: Click SPE-DOT → thấy 97 DOT tools + composition_level + governance + inspection status.


VI. QUY TẮC CHO TƯƠNG LAI (giữ nguyên v1.1 + bổ sung)

Khi entity/species/collection mới sinh ra:

  1. Birth Registry auto capture (PG trigger) → KHÔNG VÔ HÌNH
  2. collection_registry auto detect (PG event trigger)
  3. Species mapping: governed → bắt buộc. Observed/excluded → không cần.
  4. Inspectors kiểm tra → certified
  5. KHÔNG SỬA CODE. Thêm metadata = xong.

v1.2 | 2026-03-21 | +Species tree 3 tầng. +Birth Registry thay bộ đếm. +Registries 7 chiều. v1.1 | 2026-03-20 | Species ≠ nguyên tử. Meta-entity. Bộ đếm metadata-driven. v1.0 | 2026-03-20 | Bản đầu (lỗ hổng đã sửa).