02 — Candidate Registry Foundation: reuse map + implementation-ready DDL + birth-contract sequence (2026-05-28)
02 — Candidate Registry Foundation
Materially advances Candidate Registries beyond "absent": a live reuse map, implementation-ready DDL for the genuinely-missing families, owner-law + Mother dependency mapping, and the exact birth-contract registration sequence. Live-create is deferred because every registry is a born collection under Điều 0-G/36/37 and requires a Đ32 approval — raw-creating it is the "đẻ rơi" anti-pattern.
1. Live reuse survey (what already exists)
Queried information_schema live. The 6 named families remain ABSENT as named tables, but several de-facto anchors exist:
| Target family | Named table exists? | De-facto reuse anchor (live) | Reuse verdict |
|---|---|---|---|
| field_registry | ❌ | field_type_equivalences (type map only), Directus directus_fields (per-collection field defs) |
partial — directus_fields holds field defs but is Directus-internal; a governed field_registry is still needed for cross-collection field semantics |
| input_form_registry | ❌ | design_templates (config_schema), directus_collections/forms |
absent — needs new |
| output_table_registry | ❌ | table_registry (id,table_id,name,collection,fields,page_url,enable_*,status,module) |
strong reuse — table_registry is a de-facto output-table registry; extend, do not recreate |
| dot_function_registry | ❌ | dot_iu_command_catalog (52), v_dot_iu_command_registry |
strong reuse — catalog is the de-facto DOT function registry; generalize beyond IU |
| task_template_registry | ❌ | tasks, os_project_templates, task_checkpoints |
partial — templates exist for projects/email, not governed task templates |
| workflow_template_registry | ❌ | workflows, workflow_categories, workflow_steps, workflow_step_relations |
strong reuse — workflows machinery exists; add a template layer |
| tier_registry | ❌ | none | absent — needs new |
| ui_product_template_registry (Đ28) | ❌ | design_templates (code,config_schema,component_path,instance_collection,checklist_status,test_results,species_code,composition_level), iu_collection_template_registry, v_iu_product_template |
strong reuse — design_templates IS the Đ28 product template registry; extend |
Net: 3 families need genuinely new tables (field_registry, input_form_registry, tier_registry); 5 should extend/wrap existing (output_table_registry→table_registry, dot_function_registry→dot catalog, task_template_registry→tasks+templates, workflow_template_registry→workflows, ui_product_template_registry→design_templates).
2. Birth-contract registration sequence (mandatory for any new registry collection)
A new base table is NOT lawfully born until ALL of these exist (confirmed live column shapes):
- collection_registry row —
code,name,classification,owner,collection_name,species_code,governance_role,storage_role,source_kind,migration_state,birth_code_strategy,coverage_status,...(168 rows today). - birth_registry row —
entity_code,collection_name,species_code,composition_level,governance_role,inspect_pen,inspect_stamp,inspect_gate,certified,canonical_address,owner,jsonb_profile(876k+ rows; this is the Đ0-G ledger). - governance_registry row —
code,name,gov_type,gov_group,output_target,domain,primary_collection,created_by_law,health_dot,status(5 rows today, all council/system — no factory rows yet). - species map — species_code must resolve in the species taxonomy.
- Đ32 approval binding the creation (review_decision). This is the blocker for live-create.
Because (5) requires a human/council approval that this agent must not self-mint, Branch B is delivered as implementation-ready DDL + the registration rows pre-written, to be applied by the governed birth macro (doc 09 prompt 2).
3. Implementation-ready DDL (the 3 genuinely-new families)
All IF NOT EXISTS, PG-first, additive, reversible (DROP TABLE). Apply only inside the governed birth macro with the §2 rows + Đ32 approval.
-- field_registry: governed cross-collection field semantics (owner law: Điều 36 Collection + layer3-information-law)
CREATE TABLE IF NOT EXISTS public.field_registry (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
code text NOT NULL UNIQUE,
collection_code text NOT NULL, -- FK-intent → collection_registry.code
field_name text NOT NULL,
data_type text NOT NULL,
semantic_type text, -- measurement/identity/temporal/reference/...
is_required boolean NOT NULL DEFAULT false,
validation jsonb, -- declarative constraints
species_code text,
governance_role text,
owner text,
status text NOT NULL DEFAULT 'draft',
created_by_law text NOT NULL DEFAULT 'dieu36',
_dot_origin text,
created_at timestamptz NOT NULL DEFAULT now()
);
-- input_form_registry: governed input surfaces (owner law: Điều 28 template + Điều 36)
CREATE TABLE IF NOT EXISTS public.input_form_registry (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
code text NOT NULL UNIQUE,
name text NOT NULL,
target_collection text NOT NULL,
field_set jsonb NOT NULL DEFAULT '[]'::jsonb, -- ordered field_registry.code list
layout_schema jsonb,
template_ref uuid, -- → design_templates.id
mother_owner text, -- MOW/MOT/MOIT/MOUT
species_code text,
governance_role text,
owner text,
status text NOT NULL DEFAULT 'draft',
created_by_law text NOT NULL DEFAULT 'dieu28',
created_at timestamptz NOT NULL DEFAULT now()
);
-- tier_registry: governed tier/level definitions (owner law: Điều 37 Governance + Điều 5 five-tier architecture axis)
CREATE TABLE IF NOT EXISTS public.tier_registry (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
code text NOT NULL UNIQUE,
name text NOT NULL,
axis text NOT NULL, -- 'architecture' (Tầng1..5) | 'business_operating' (T6..T1)
level_no int NOT NULL,
description text,
depends_on jsonb, -- lower tiers this depends on
governance_role text,
owner text,
status text NOT NULL DEFAULT 'draft',
created_by_law text NOT NULL DEFAULT 'dieu37',
created_at timestamptz NOT NULL DEFAULT now()
);
4. Extend-existing (the 5 reuse families) — non-destructive ALTER intent
- output_table_registry ←
table_registry: addgovernance_role,mother_owner,species_code(nullable) if a governed view over it is insufficient. Prefer a read-only viewv_output_table_registryfirst. - dot_function_registry ←
dot_iu_command_catalog: generalize to non-IU functions via a superset viewv_dot_function_registry(category, mutating, owner_law, function_signature). No table rebuild. - workflow_template_registry ← add
workflow_templatesreferencingworkflows/workflow_stepsas instances; or ais_template boolean+template_ofonworkflows. - task_template_registry ← add
task_templatesreferencingtasksshape; reuseos_project_templatespattern. - ui_product_template_registry ←
design_templatesis already the Đ28 registry; addmother_owner+readinesscolumns; exposev_ui_product_template_registry.
5. Owner-law + Mother dependency matrix
| Family | Owner law | MOW (work) | MOT (task) | MOIT (input) | MOUT (output) |
|---|---|---|---|---|---|
| field_registry | Đ36 + layer3-info | ✓ | ✓ | ✓✓ | ✓ |
| input_form_registry | Đ28 + Đ36 | ✓ | — | ✓✓ | — |
| output_table_registry | Đ36 | ✓ | — | — | ✓✓ |
| dot_function_registry | Đ35 (DOT) | ✓✓ | ✓ | ✓ | ✓ |
| task_template_registry | Đ7 assembly + tasks | ✓ | ✓✓ | — | — |
| workflow_template_registry | Đ7 + Đ45 | ✓✓ | ✓ | — | — |
| tier_registry | Đ37 + Đ5 | ✓ | ✓ | ✓ | ✓ |
| ui_product_template_registry | Đ28 | ✓ | — | ✓ | ✓ |
(✓✓ = primary dependency; the Mother cannot be built without it.)
6. Live-apply vs authority-pack decision
- Authority-pack (all 8): because each is a born governed collection needing Đ32 approval + birth rows. DDL above is ready; apply through the governed birth macro.
- Safe live alternative available now (not applied this run): read-only views over existing anchors (
v_output_table_registry,v_dot_function_registry,v_ui_product_template_registry) are purely additive and could be applied like the KG view — deferred here to keep this run's single live change isolated to KG, but explicitly authorized as the next-safest step.
7. Verdict
Candidate Registry foundation: MATERIALLY ADVANCED — reuse map resolves 5 of 8 to existing anchors; 3 new families have runnable DDL; birth-contract sequence is explicit; live-create correctly deferred to a governed approval. This is enough to start 4 Mothers design-implementation planning (doc 08), not enough to run a Mother (still needs the Đ32 birth approval).