KB-6E8C

10 — Dress Rehearsal Plan (design only)

3 min read Revision 1
architecturedress-rehearsalviewsfunctionsapinuxtrollbackdieu302026-05-30

title: 10 — Dress Rehearsal Plan (design only, no execution) date: 2026-05-30

10 — Dress Rehearsal Plan (DESIGN ONLY — nothing executed this session)

No PG/Directus/Qdrant mutation occurred. SQL below = a rehearsal plan for a FUTURE Điều 32-gated session inside BEGIN … ROLLBACK (compile then ROLLBACK; COMMIT only after approval).

1. Backend views/functions (additive, reversible)

  • v_living_lists (view) → (pivot_code,name,source_object,total,child_pivots[],record_count,actual_count,drift,needs_refresh,refreshed_at,governance_owner): one row/active list, pivot-backed (pivot_definitions JOIN LATERAL pivot_count + meta_catalog + pivot_results). Rollback DROP VIEW.
  • v_registries_pivot_tree (recursive/lazy view) (parent_id)→node rows (doc 07): resolves has_children/child_layer_kind/next_pivot_code from pivot_definitions group_spec matched on source_object. Rollback DROP.
  • v_count_drift (view) → (cat_code,source_object,record_count,pivot_count,delta) (PM4). DROP.
  • test_counting_contract() (read-only STABLE) → (cat_code,stored,pivot,ok): assert pivot==stored, log mismatch. DROP.
  • fn_node_substrate(p_source,p_pk) (read-only) → jsonb (doc 07§D). DROP.

SQL safety: SELECT-only / SECURITY INVOKER / STABLE; no DDL on existing objects; statement_timeout; recursion bounded by count≤1 leaf. No-hardcode tests: tree view has NO literal category/species/layer lists, NO count literals (every count via pivot_count, every grouping via group_spec).

2. API/Directus (reuse, no business logic)

Directus read of v_living_lists / v_registries_pivot_tree (pure SELECT … WHERE parent_id=:id), or thin diServer /api/registries-pivot/tree?parent= doing only SELECT (zero aggregation — contrast current /api/registry/health gap math). Evidence reuses pivot_query(:code).

3. Nuxt render-shell

Components: RegistriesPivotPage (summary+breadcrumb), DrillLayer (renders one backend-declared layer; recursion = nested DrillLayer fed by drilldown_query_ref), NodeRow (label+count chip+child-summary+badges), SubstratePanel (leaf §D). Props only; no count logic, no category arrays, no depth constants. has_children toggles expander; next_pivot_code/drilldown_query_ref drive next fetch.

4. Rehearsal procedure (future, gated)

BEGIN;
  CREATE VIEW v_living_lists AS …;
  CREATE VIEW v_count_drift AS …;
  CREATE FUNCTION test_counting_contract() …;
  CREATE VIEW v_registries_pivot_tree AS …;
  CREATE FUNCTION fn_node_substrate(text,text) …;
  -- smoke selects (doc 11)
ROLLBACK;  -- prove-and-revert; COMMIT only after Điều 32

Committed-deploy reversal = the DROP statements (Điều 30, forward-only).

Back to Knowledge Hub knowledge/dev/reports/architecture/registries-pivot-os-agency-surface-master-design-2026-05-30/10-dress-rehearsal-plan.md