RP Aggregate Pivots — 06 Count Integrity & UI Status Model
06 — Count Integrity Equation & UI Status Model (Workstream E)
Count status taxonomy (the model the UI renders)
| status | meaning | source field | UI render |
|---|---|---|---|
| FINAL | scalar pivot-backed count, live | node contract count_status='pivot_backed' (scalar pivots) |
the number, plain |
| DRILLDOWN | grouped pivot; total = Σ group rows | grouped pivot in pivot_results |
expandable group list |
| CANDIDATE | computable but law not ratified | register aggregate_status='CANDIDATE_REPORT_ONLY' |
number + CANDIDATE badge |
| PIVOT_MISSING | no pivot exists for the concept | node contract count_status='PIVOT_MISSING' / register |
"not yet defined" + propose_pivot |
| LAW_DEFINITION_NEEDED | concept undefined | register aggregate_status='NEEDS_LAW_DEFINITION' |
"not yet ratified", never 0 |
| WARNING_DRILL_MISMATCH | parent ≠ Σ children where a partition law holds | v_rp_drill_reconciliation.drill_status |
warning banner |
| UNVERIFIABLE | grand-total closure impossible | count_integrity_status='unverifiable_at_grand_total' |
equation-incomplete banner |
Did the base view need extending? Yes — two additive read-only views (applied, DROP-reversible)
The base v_registries_pivot_node_contract already exposes count_value, count_status, drift_status, orphan_count, phantom_count, unmanaged_count (NULL), pin_state, warning_flags. It lacked (a) parent↔child drill reconciliation and (b) a candidate/law register. Both were added without touching the base view (so the existing UI contract is byte-identical and stable).
View 1 — v_rp_drill_reconciliation
Compares each parent's scalar count to the sum of its children's group/scalar totals, but only asserts a verdict when a partition law holds: a single, same-source, non-matrix, full-population (same filter) grouped child. Otherwise it is advisory.
parent parent_count n_children children_total partition_defined drill_status
MTX-L1-OVERVIEW 1,132,013 1 2,262,884 f ADVISORY_NO_PARTITION_LAW (matrix = cross-tab, not a partition)
PIV-001 169 3 492 f ADVISORY_NO_PARTITION_LAW (3 facet children, overlap)
PIV-007 309 1 309 t RECONCILES ← DOT drill fixed
PIV-009 168 1 168 t RECONCILES
PIV-016 42 1 42 t RECONCILES
PIV-101 (null) 6 146 f PARENT_NOT_SCALAR
No WARNING_DRILL_MISMATCH remains after the PIV-104 fix. The matrix case was deliberately excluded from the partition law (a matrix sums to ~2× its parent because it counts cells, not a partition) — otherwise it would be a false positive.
View 2 — v_rp_aggregate_candidate_register
The explicit, honest aggregate surface (live counts where a single relation exists):
code concept live_count aggregate_status ui_render
PIV-301 orphan 59 CANDIDATE_REPORT_ONLY CANDIDATE_BADGE
PIV-302 phantom 289 CANDIDATE_REPORT_ONLY CANDIDATE_BADGE
PIV-303 count_drift 3 CANDIDATE_REPORT_ONLY CANDIDATE_BADGE
PIV-312 kg_edges 2,259 NEEDS_LAW_DEFINITION PROPOSE_PIVOT
PIV-304 unmanaged (null) NEEDS_LAW_DEFINITION PROPOSE_PIVOT
PIV-500 grand_total (null) NOT_A_PIVOT_EQUATION_VIEW EQUATION_VIEW
The accounting equation (honest, leaf-scoped)
total_system_objects = counted (FINAL, pivot-backed leaf sum, no Nuxt math)
+ orphan (59, CANDIDATE)
+ phantom (289, CANDIDATE)
+ unmanaged (NULL, LAW_DEFINITION_NEEDED)
From v_count_integrity (160 leaf rows): Σcounted = 2,275,591 · Σactual = 2,254,409 · net record-surplus = 21,197 · drift-flagged rows = 3 · pivot-backed leaves = 21. Because unmanaged is NULL and PIV-500's anchor is unratified, the equation cannot close to one number → count_integrity_status = unverifiable_at_grand_total. This is surfaced as a warning, not a silent green.
UI render rules (no client math, no hardcoded depth)
- Tree/structure — read
parent_code/is_root/has_children/child_pivot_codes/child_layer_kindonly. - Counts — read
count_value(scalar) or the group rows (drilldown). Never compute in Nuxt. - Final counts render plain. Candidate counts render with a badge (from the register). Missing/law render as "not yet defined / ratified", never as 0.
- Drill — read
v_rp_drill_reconciliation.drill_status; show a warning only onWARNING_DRILL_MISMATCH(currently none);ADVISORY_NO_PARTITION_LAWis informational. - Drift — keep showing
drift_statusfrom the node contract (e.g. dot_tools record-surplus 146); it is independent of drill reconciliation. - Grand total — render the equation with the UNVERIFIABLE banner; do not invent a number.
Completion
The UI can represent current truth — final, candidate, missing, law-needed, drill, drift, and unverifiable — without misleading users. ✅