06 — Count Integrity and Accounting Equation
06 — Count Integrity and Accounting Equation
Count integrity (live, post-commit)
From v_count_integrity (160 leaf rows):
| metric | value |
|---|---|
| Σ counted | 2,275,591 |
| Σ actual | 2,254,409 |
| Σ orphan (leaf-grain) | 0 |
| net record-surplus | 21,197 |
| drift-flagged rows | 3 |
| pivot-backed leaves | 21 |
Safety-net (birth-grain) counts: orphan v_birth_orphan=59, phantom v_birth_phantom=289, IU=219, KG edges=2,259, system_issues(open)=207,940.
No Nuxt math required
Every L1 and wired-layer count is pivot-backed (v_registries_pivot_node_contract.count_value). The UI renders values verbatim. The backend contract needs no client-side arithmetic.
The accounting equation (explicit, leaf-scoped, honest)
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 the leaf set (composition_level<>'meta', not a
_total/allrollup) — never a blind SUM of meta+rollup rows. - orphan = 59 (
v_birth_orphan, birth-grain) — CANDIDATE (not legally stable at RP grain). - phantom = 289 (
v_birth_phantom, birth-grain) — CANDIDATE. - unmanaged = NULL / CANDIDATE — no ratified definition; surfaced as
unmanaged_count=NULL, never faked. - cross-check anchor = PIV-500 grand total = PIVOT_MISSING ⇒
count_integrity_status = unverifiable_at_grand_total.
Which terms are FINAL vs CANDIDATE
| term | status |
|---|---|
| per-leaf counted (L1 totals, wired layers) | FINAL — pivot-backed, live |
| orphan (59) | CANDIDATE (birth-grain; RP-grain law not ratified) |
| phantom (289) | CANDIDATE |
| unmanaged | CANDIDATE (undefined) |
| grand total / equation closure | UNVERIFIABLE until PIV-500 ratified |
Warning, not silent green
Because the grand-total anchor (PIV-500) is missing and orphan/phantom/unmanaged are CANDIDATE, the equation cannot be closed to a single number. The contract surfaces this honestly: count_status=PIVOT_MISSING on the missing aggregates, unmanaged_count=NULL, and count_integrity_status=unverifiable_at_grand_total. A mismatched equation raises a warning state — it does not silently pass.
DOT-category drill discrepancy (surfaced drift flag)
PIV-104 (status='published' only) child Σ = 16 (pivot 8 / uncategorised 4 / Vòng đời 2 / Giám sát 2) ≠ parent PIV-007 = 309 (all dot_tools). This is a real published-only drill-integrity gap — documented, not silently reconciled. Fix (owner decision): drop the published filter or add a status sub-axis so child Σ reconciles to parent.