KB-7BA7
06 — Backend View/Function Contract
3 min read Revision 1
registries-pivotbackend-contractviewnode-contract2026-06-03
06 — Backend View / Function Contract
Status: LIVE (existing + 1 new applied this macro)
Already-live (verified, REUSE — not rebuilt)
| Object | Role | Note |
|---|---|---|
v_registries_pivot_tree |
tree skeleton: node_code, parent_code, is_root, has_children | correct; flat only because parent_code NULL |
v_living_lists |
leaf lists: list_count, count_source, pivot_code, pivot_backed | reads v_registry_leaf_set |
v_count_integrity |
per-leaf counted/actual/orphan/surplus/drift/status/classification | 160 rows |
v_count_drift |
drift subset of v_count_integrity | 3 rows |
fn_registries_pivot_node_substrate(code) |
leaf → meta_catalog substrate + pivot | the L4 "DB về chính nó" |
pivot_count/query/matrix |
the only counting methods | Điều 26 |
NEW — applied LIVE this macro (additive, reversible by DROP)
v_registries_pivot_node_contract — the §8 node contract, 26 columns, rendered verbatim by Nuxt:
node_code, node_type, label, parent_code, is_root, source_object, composition_level,
species, registry_group, display_order, is_active,
count_value, count_pivot_code, count_status('pivot_backed'|'PIVOT_MISSING'),
has_children, child_pivot_codes[], child_layer_kind, final_substrate_ref,
detail_route, drilldown_query_ref,
orphan_count, phantom_count, unmanaged_count(NULL=PIVOT_MISSING), drift_status,
pin_state('PIN_REGISTRY_MISSING'), warning_flags(jsonb)
Sources: pivot_definitions (graph) + pivot_results (count) + v_rp_classification_governance_map (warnings) + v_count_integrity joined by source_object (orphan/phantom/drift). No depth logic, no count math — Nuxt cannot derive any of it.
Validation evidence (in-txn select)
26 columns; PIV-001=169/pivot_backed, PIV-007=309/drift, PIV-008=37/drift; final_substrate_ref resolves to the source table for leaves. Created + committed; pivot_definitions byte-identical after (pd_hash unchanged).
Behavior across the two graph states
- Today (parent_code NULL):
has_children=falsefor all → contract is honest-flat; every node still carries count + warnings + substrate ref. - After operator commits wiring (doc 10): the SAME view immediately reports
has_children=truefor the 6 parents,child_pivot_codespopulated,final_substrate_ref=NULLfor parents — zero UI or view change needed. This is the data-driven, no-hardcode-depth contract working as designed.
Not built here (held, with reason)
v_pivot_missing(enumerates PIV-500/30x/31x) — would name not-yet-born codes; delivered as apply-packet text (doc 10) to avoid a code-list view; the live contract already exposes per-nodecount_status=PIVOT_MISSING.- PIV-30x/31x pivot rows — held (doc 05).