KB-4537
04 — Live PG Capability Inventory
8 min read Revision 1
architecturediscoverypostgrespivotdotbirthiu-kgread-only
04 — Live PG Capability Inventory
All counts live from directus DB, 2026-05-30. 274 tables in public + 4 objects in iu_core. 200 pg_proc functions matched the discovery patterns.
1. Pivot / Counting subsystem (Điều 26) — the auto-count engine
pivot_definitions(37) — declarative spec in jsonb (filter_spec,group_spec,metric_spec,source_object,registry_group,cache_tier). NOT axis-columns.pivot_results(126) — UPSERT cache(pivot_code, source_object, group_values)withmetric_values,refreshed_at,needs_refresh.- Functions (definitions read, never executed):
pivot_count(p_code)total-only;pivot_query(p_code)grouped (whitelisted ops/funcs, dynamic SQL);pivot_matrix(...);refresh_pivot_results()(loops active defs → UPSERT);refresh_meta_catalog_from_pivot()(SECURITY DEFINER, advisory-locked, updatesmeta_catalog.record_countfor pure-total pivots only);test_counting_contract()(8-test harness T1–T8). - Views:
v_registry_counts(per-CAT record/active/count_b/prev/cross_check),v_registry_summary(totals: total_atoms 1,930,183; total_orphans 161). - What pivots already count (selected): PIV-001 meta_catalog 169 · PIV-002 table_registry 21 · PIV-004 workflows 2 · PIV-005 workflow_steps 70 · PIV-007 dot_tools 309 · PIV-008 ui_pages 37 · PIV-009 collection_registry 168 · PIV-010 tasks 10 · PIV-011 agents 6 · PIV-015 trigger_registry 107 · PIV-016 entity_species 42 · PIV-019 birth_registry 954,161 · PIV-207 approval_requests 211. Plus cross-table (PIV-101..106), L2-drill (PIV-201..206), and matrix (MTX-L1-OVERVIEW, MTX-L2-ATOM).
- KEY: almost every official list already has a pivot. Adding a new list = add a
pivot_definitionsrow, not write manual counts. - Known inconsistencies:
trg_auto_sync_registry_countsreportedly DISABLED (v_registry_counts may lag); cross_check LỆCH on CAT-006 (309 vs count_b 163), CAT-007, CAT-ALL, CAT-MOL, CAT-CMP, CAT-MAT, CAT-023.
2. Birth / Collection / Meta / Table (Điều 0-G / 36 / 29)
birth_registry(954,161) — 22 cols. Dominated byentity_labelsjunction (698,560, governance_role=excluded) +system_issues(174,109) +registry_changelog(66,338). By composition_level: atom 953,046 / molecule 925 / compound 145 / meta 45. Only 1,402 certified (birth ≠ certification).fn_pre_birth_check(p_collection,p_code,p_name,p_dot_origin)— 5 checks: managed in meta_catalog; non-empty_dot_origin; code regex^[A-Z]+-[0-9]+$; name not dup; code not dup.fn_birth_gate()— trigger wrapper;app.birth_gate_modedefaultwarning(SOFT); onlyblockingraises. Kill switchapp.bypass_birth_gate.meta_catalog(169) = SoT "list of lists." Denormalized counts:record_count,actual_count,orphan_count,baseline_count,active_count,species_count,last_scan_date. Meta-rows point at other registries (CAT-008→collection_registry, CAT-023→birth_registry, CAT-006/CAT-DOT→dot_tools, roll-ups CAT-ALL/COL/MOL/CMP).collection_registry(168) — physical Directus collections;governance_role× status: observed 64, excluded 60, governed 28+8, locked 3, law_artifact 2.table_registry(21) — UI table-definition registry (tbl_*→ page_url, fields JSON), NOT a data SoT.entity_species(42) — species/composition classification.
3. DOT governance (Điều 23 / 35) — see pilot doc 08
dot_tools309 (tier A60/B230/null19; status active291/published16/null2; paired_dot 131/309;operationpopulated 50/309;coverage_statusnull 103);dot_iu_command_catalog54 (100% metadata, mutating 39, reversible 41, no schema/test col);dot_operations20;dot_domains46 (no description col);dot_domain_rules67;dot_coverage_required11;dot_config. Scanners:fn_refresh_dot_count(→CAT-DOT),fn_refresh_orphan_dot(→CAT-DOT),fn_validate_dot_origin,fn_enforcement_validate_dot,fn_dot_iu_command_log(fail-closed).
4. IU / KG (Điều 38 / 39 / 44)
information_unit(219) =law_unit187 (enacted 146 + draft 41) +design_doc_section32. Cols inclcanonical_address,unit_kind,lifecycle_status,identity_profile,section_type. Noui/surface unit_kind.iu_relation(60) — allcontains, UUID-keyed (IU containment tree). Enriched with provenance/confidence/assertion_mode.universal_edges(2199) — integer-keyed structural graph: USES 1486 / BELONGS_TO 431 / CONTAINS 282. Top: dot_tools→taxonomy 469, trigger_registry→taxonomy 354.v_kg_edges_all(VIEW, 2259) = UNION of both layers, normalizededge_source/source_ref/target_ref, read-only projection (no hidden 2nd SoT, vector OFF).- ~150
fn_iu_*functions (create/edit/compose/cut/enact/split/merge/route/gate/notify/vector/three-axis-envelope).iu_coreschema: staging tables + observability views.
5. Event / Queue (Điều 45)
event_outbox165,403 (99.8% = system/issue_opened firehose; append-only, no status col);event_type_registry40 (domains iu15/mother8/piece6/staging5/system6);event_subscription3;iu_outbound_route15 (target=workflow, all dry_run, fail_closed);job_queue13;job_dead_letter0;iu_route_dead_letter0;event_read165,042;iu_route_attempt68. Single substrate confirmed.
6. Approval / Governance spine (Điều 32 / 37)
approval_requests211 (birth_orphan/applied 143 dominant; types incl reclassify, schema_modify, fix_repair_dot, new_dot);apr_approvals42 (decision uniformly approve; ai_council 28 + human 14; ≥2 cross-sign);apr_request_types14;apr_action_types6;workflow_change_requests3 (dsl_diff);table_proposals0 (empty, available).
7. Personnel / Role / Agent (Điều 37)
directus_users13 (~6 active),directus_roles9,directus_policies8,agents6 (classification/owner/transport/capabilities),team0. RBAC = Directus-native; AI actors =agents. No human-org-role table yet (Đ37-H unborn).
8. Trigger (collision flag)
trigger_registry107 = physical DB-trigger catalog (table_name,trigger_typecount/label/code/origin/ROW/guard,function_name, all enabled).context_trigger_sources6. Must NOT be reused for design/business triggers —workflow_trigger_designdoes not exist.
9. Field / Form / Output (mostly unborn)
- ABSENT:
field_registry,input_form_registry,tier_registry,workflow_trigger_design. - Live field truth =
directus_fields(1,482); governance overlay =collection_field_standards(11, hastier);field_type_equivalences4;forms0;block_form0;design_templates1.
10. Scanner / detector / reconciler
- Scanners:
fn_birth_onboarding_full_scan(+_hc),fn_admin_fallback_overdue_scan,check_registry_coverage,run_audit_to_issues,audit_dead_links,audit_relationships,fn_refresh_orphan_dot;universal_rule_registry10 + runs/results/violations. - Reconcilers:
fn_reconcile_fk_vs_edges,fn_reconcile_rules_vs_views,fn_reconcile_all_labels. - Health:
system_health_checks,fn_registry_health,fn_iu_collection_healthcheck,fn_phase0_cockpit.