05 — Missing Pivots and Count Contract
05 — Missing Pivots and Count Contract
Pivot-only counting — what is backed today (LIVE)
Every L1 registry total is pivot-backed (pivot_results.group_values='{}'): PIV-001=169, PIV-002=21, PIV-003=5, PIV-004=2, PIV-005=70, PIV-006=3, PIV-007=309, PIV-008=37, PIV-009=168, PIV-010=10, PIV-011=6, PIV-012=31, PIV-013=2, PIV-014=142, PIV-016=42, … (rendered by v_registries_pivot_node_contract.count_value). No Nuxt math is required for any L1 or wired-layer count.
PIVOT_MISSING ledger (surfaced, never hidden)
| Proposed pivot | Count meaning | Live source / value | Definability today |
|---|---|---|---|
| PIV-500 | grand total total_system_objects |
cross-table anchor (≠ single source_object) | NOT expressible in current pivot_definitions schema (GROUP BY one source_object). Needs engine extension (view-backed pivot). HELD. |
| PIV-301 | orphan total | v_birth_orphan = 59 |
definable as view-backed pivot |
| PIV-302 | phantom total | v_birth_phantom = 289 |
definable |
| PIV-303 | count-integrity / drift total | v_count_drift = 3 rows; net record-surplus 21,182 |
definable |
| PIV-304 | unmanaged / unknown | needs law definition (see invariant) | needs ratified definition |
| PIV-311 | IU total | information_unit = 219 |
definable |
| PIV-312 | KG edge total | v_kg_edges_all = 2,259 |
definable |
| PIV-313 | system_issues open | system_issues WHERE status='open' = 207,940 |
definable |
Until each exists, v_registries_pivot_node_contract.count_status='PIVOT_MISSING' and unmanaged_count=NULL (explicit). The UI renders a PIVOT_MISSING badge + next_action=propose_pivot. |
Why PIV-30x/31x are HELD (not applied this macro)
- Each requires
pivot_definitionsto support a view-backed / expression count (not justGROUP BY source_object). The current engine +fn_birth_registry_autobirth path assume a real source table. Adding them = new pivot semantics + births → owner-gated (and births can hit the knownbirth_registry UNIQUE(entity_code)composite defect — Track B). - PIV-304 unmanaged and the orphan/phantom law definitions are not yet ratified at the grain RP needs. Faking them is forbidden (§13). They stay CANDIDATE.
The accounting invariant (explicit, leaf-scoped)
total_system_objects = counted_in_registries_pivot
+ orphan (unborn / missing-birth)
+ phantom (registered-but-absent / stranded)
+ unmanaged (no registry / unknown)
- counted = Σ pivot-backed leaf counts over
v_registry_leaf_set(composition_level<>'meta', entity_type not '%_total'/'all') — never blind-SUM of meta+rollup rows (the §28 disguised-math trap). - orphan =
v_birth_orphan(59), phantom =v_birth_phantom(289), both birth-grain — NOT the leaf-grainorphan_count(which is 0). - Cross-check anchor = PIV-500 (PIVOT_MISSING ⇒ invariant currently
count_integrity_status = unverifiable_at_grand_total, surfaced honestly). - Stability: orphan/phantom/unmanaged definitions are CANDIDATE (not legally stable at RP grain) → marked CANDIDATE, not final.
DOT-category drill discrepancy (count-integrity flag)
PIV-104 (v_pivot_dot_by_category) filters status='published' → children sum = 16 (pivot 8, uncategorized 4, Giám sát 2, Vòng đời 2). Parent PIV-007 counts all dot_tools = 309. Child Σ (16) ≠ parent (309) → this is a real drill-integrity gap to surface (the category drill is published-only). Fix = align the filter or add a status dimension; documented, not silently reconciled.