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) with metric_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, updates meta_catalog.record_count for 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_definitions row, not write manual counts.
  • Known inconsistencies: trg_auto_sync_registry_counts reportedly 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 by entity_labels junction (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_mode default warning (SOFT); only blocking raises. Kill switch app.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_tools 309 (tier A60/B230/null19; status active291/published16/null2; paired_dot 131/309; operation populated 50/309; coverage_status null 103); dot_iu_command_catalog 54 (100% metadata, mutating 39, reversible 41, no schema/test col); dot_operations 20; dot_domains 46 (no description col); dot_domain_rules 67; dot_coverage_required 11; 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_unit 187 (enacted 146 + draft 41) + design_doc_section 32. Cols incl canonical_address, unit_kind, lifecycle_status, identity_profile, section_type. No ui/surface unit_kind.
  • iu_relation (60) — all contains, 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, normalized edge_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_core schema: staging tables + observability views.

5. Event / Queue (Điều 45)

  • event_outbox 165,403 (99.8% = system/issue_opened firehose; append-only, no status col); event_type_registry 40 (domains iu15/mother8/piece6/staging5/system6); event_subscription 3; iu_outbound_route 15 (target=workflow, all dry_run, fail_closed); job_queue 13; job_dead_letter 0; iu_route_dead_letter 0; event_read 165,042; iu_route_attempt 68. Single substrate confirmed.

6. Approval / Governance spine (Điều 32 / 37)

  • approval_requests 211 (birth_orphan/applied 143 dominant; types incl reclassify, schema_modify, fix_repair_dot, new_dot); apr_approvals 42 (decision uniformly approve; ai_council 28 + human 14; ≥2 cross-sign); apr_request_types 14; apr_action_types 6; workflow_change_requests 3 (dsl_diff); table_proposals 0 (empty, available).

7. Personnel / Role / Agent (Điều 37)

  • directus_users 13 (~6 active), directus_roles 9, directus_policies 8, agents 6 (classification/owner/transport/capabilities), team 0. RBAC = Directus-native; AI actors = agents. No human-org-role table yet (Đ37-H unborn).

8. Trigger (collision flag)

  • trigger_registry 107 = physical DB-trigger catalog (table_name, trigger_type count/label/code/origin/ROW/guard, function_name, all enabled). context_trigger_sources 6. Must NOT be reused for design/business triggersworkflow_trigger_design does 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, has tier); field_type_equivalences 4; forms 0; block_form 0; design_templates 1.

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_registry 10 + 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.
Back to Knowledge Hub knowledge/dev/reports/architecture/law-capability-discovery-official-lists-automation-2026-05-30/04-live-pg-capability-inventory.md