KB-7807

00 — Overview & Control (P0/P1 Count-Integrity + View Rehearsal)

6 min read Revision 1
registries-pivotcount-integrityrehearsalread-onlybegin-rollbackP0P1M1M22026-05-31control

title: 00 — Overview & Control mission: REGISTRIES_PIVOT_P0_P1_COUNT_INTEGRITY_AND_VIEW_REHEARSAL_MACRO date: 2026-05-31 status: PASS · READ-ONLY proof + BEGIN..ROLLBACK rehearsal · ZERO persistent mutation maps_to: doc-13 next-macro M1 (P0) + M2 (P1) of registries-pivot-os-agency

00 — Overview & Control

This package executes M1 (REGISTRIES_PIVOT_COUNT_INTEGRITY_READONLY_REHEARSAL, =P0) and the M2 (...ADDITIVE_SCHEMA_AND_PIVOTS_DRESS_REHEARSAL, =P1) view/function rehearsal named in knowledge/dev/design/registries-pivot-os-agency/13-next-macro-prompts.md, and confirmed as the required next step by …/reports/architecture/gpt-review-after-registries-pivot-master-design-closeout-2026-05-31.md.

It does not implement production. No COMMIT. No persistent PG/Directus/Qdrant/Nuxt mutation.

Channels used

  • Read: mcp__Incomex_VPS__query_pg (read-only role, READ ONLY tx, statement_timeout 5s, LIMIT 500) + KB MCP + ssh contabo.
  • Apply (rehearsal only): ssh contabo → docker exec -i postgres psql -U workflow_admin -d directus, every statement wrapped in BEGIN; … ROLLBACK; with server-side lock_timeout=3s / statement_timeout=20s / idle_in_transaction_session_timeout=40s and -v ON_ERROR_STOP=1. No COMMIT issued anywhere.

Gate 0 (PASS)

  • Host = contabo VPS (MCP Incomex_VPS); container postgres (postgres:16, healthy 6 weeks); DB = directus.
  • All 18 named substrate tables present in public; v_registry_counts is a BASE TABLE (snapshot), not a view.
  • https://vps.incomexsaigoncorp.vn/knowledge/registries200; …/knowledge/pivot200.
  • workflow_admin BEGIN..ROLLBACK probe: view created in-tx (n=1) → ROLLBACK → gone (n=0), idle in transaction=0.

Entry baseline (read-only, 2026-05-31)

table n table n
meta_catalog 169 label_rules 38
pivot_definitions 37 (35 active) entity_labels 718,744
pivot_results 126 system_issues 179,074
collection_registry 168 event_outbox 170,498
table_registry 21 dot_tools 309
birth_registry 980,378 dot_iu_command_catalog 54
entity_species 42 information_unit 219
species_collection_map 164 iu_relation 60
taxonomy_facets 10 v_registry_counts 169 (base table)
taxonomy 58 v_kg_edges_all 2,259

Append-only tables (birth_registry, system_issues, event_outbox, entity_labels) grow continuously from other system activity; this session wrote to none of them. Structural/registry tables are the mutation guard (must be byte-identical at exit). Exit re-check in doc 13 / final response.

Headline results

  • Leaf-set rule is explicit and data-driven: composition_level<>'meta' AND entity_type NOT LIKE '%_total' AND entity_type<>'all'160 leaf rows (9 rollups excluded). (doc 02)
  • count_integrity_status = FAILED, but leaf-scoping shrinks the picture honestly: unscoped net_gap +200,442 / 10 drift → leaf-scoped +36,783 / 3 drift. The 161 orphans all sit on excluded meta rows. (doc 03)
  • Hidden drift proven: entity_labels stored 690,341 vs live 718,744 (+28,403) and system_issues 171,939 vs 179,074 (+7,135) — invisible to a record-vs-actual check; only record-vs-live-pivot catches them. (doc 03)
  • BEGIN..ROLLBACK rehearsal of all 9 candidate objects = GREEN, rollback clean. A naive pivot LEFT JOIN re-introduced double-count (160→172); the corrected scalar-EXISTS view reproduces the leaf invariant exactly (1,954,686 / 1,917,903 / phantom 36,798). (doc 04)
  • Drill tree is structurally flat today: v_registries_pivot_tree = 37 nodes, 0 with children, 37 roots (all parent_code NULL). Drill works only implicitly via pivot_query grouping pivots (PIV-104 ⊂ PIV-007). (doc 05)
  • Live Đ28 violation still serving: /api/registry/health returns birth_registry gap 985,434 = "ORPHAN", dot_tools noi_sinh 592 = "PHANTOM", totals.totalGap 986,215; /api/registry/counts returns a fourth disagreeing grand total 1,688,702. Hard implementation blocker. (doc 09)
  • Phantom remains LAW_DEFINITION_GAP — and the proposed record>actual operational def is model-dependent and unreliable (model-A surplus = stale actual_count, not phantom; model-B surplus = genuine). (doc 08)

Verdict

Readiness = NOT_READY (RG1 ratification absent; no self-approval). Earliest unlock after human RG1+RG2 = READY_FOR_VIEW_COMMIT (the view layer is rehearsal-proven). Production Nuxt additionally blocked by: live gap-math anti-pattern (retire), parent_code unwired, PIV-500 missing, phantom LAW_DEFINITION_GAP. (doc 11)

Package contents

00 overview · 01 master-design consistency · 02 leaf-set · 03 count-integrity rehearsal · 04 view/function rehearsal · 05 dynamic drilldown contract · 06 label/grouping · 07 pin/ghim · 08 orphan/phantom/notification · 09 no-hardcode acceptance · 10 readiness decision · 11 next-macro pack · 12 SQL appendix/evidence · 13 self-review.

Back to Knowledge Hub knowledge/dev/reports/architecture/registries-pivot-p0-p1-count-integrity-view-rehearsal-2026-05-31/00-overview-control.md