11 — Next Macro Pack (Branch K, 10 paste-ready prompts)
title: 11 — Next Macro Pack (Branch K) date: 2026-05-31 note: each prompt is self-contained; standing header applies to all
11 — Next Macro Pack (Branch K)
Standing header (prepend to every prompt): Host = contabo VPS. DB = directus on docker container postgres. Read channel = query_pg (read-only) + KB + ssh contabo. Apply channel = ssh contabo → docker exec -i postgres psql -U workflow_admin -d directus, BEGIN..ROLLBACK only until the named gate passes, server-side lock_timeout/statement_timeout/idle_in_transaction_session_timeout + ON_ERROR_STOP=1. Forbidden (all): COMMIT before the stated gate; persistent PG/Directus/Qdrant/Nuxt mutation; route build before RG6; self-approval; frontend business/count logic; hardcoded counts/categories/species/layers/labels/pins/thresholds; any count not pivot-backed or PIVOT_MISSING; event/job execution; notification emit. Always: check live before action; do not ask the user; additive + reversible; live verification beats old report; confirm entry==exit baseline.
P1 — REGISTRIES_PIVOT_VIEW_COMMIT_AFTER_RATIFY (gate: RG1+RG2 human-accepted)
Goal: COMMIT the corrected, fan-out-free additive views/fn from this rehearsal — v_registry_leaf_set, v_count_integrity (scalar-EXISTS form), v_count_drift, fn_registries_pivot_node_substrate — plus EXTEND meta_catalog.phantom_count and a meta_catalog.pivot_code mapping column. Re-run the doc-04 rehearsal BEGIN..ROLLBACK, confirm the invariant reproduces (160 / 1,954,686 / 1,917,903 / phantom 36,798), THEN COMMIT off-peak only. Evidence: post-COMMIT \d+ of each object; SELECT count(*) FROM v_count_integrity=160; reversal script (DROP …) attached.
P2 — REGISTRIES_PIVOT_DIRECTUS_API_EXPOSURE (gate: P1 committed; design-only first)
Goal: design + rehearse how v_count_integrity/v_living_lists/pivot_count/pivot_query reach the doc-03 contract via a Directus collection or /api/registries-pivot/* endpoint. Map every doc-03 field → its pivot/view source; list PIVOT_MISSING cells explicitly; reuse Đ33 read tiers. The shaper does NO counting. Evidence: field→source table; read-grant plan; assembly PG→Directus→Nuxt (no direct PG from Nuxt).
P3 — REGISTRIES_PIVOT_UI_PREVIEW_STATIC (gate: RG6)
Goal: static preview at /ui-preview/registries-pivot/v1/ (additive nginx mount, reuse existing location /ui-preview/) rendering a mock contract matching doc 03 (L1 9-row + drill + child-summary + traffic-lights + columns). Every count PIVOT_MISSING unless a real pivot exists. Forbidden: production Nuxt; DB mutation; fabricated counts; hardcoded layer/species/label arrays. Evidence: HTTP 200; Đ28 template-registration spec; no literal arrays.
P4 — REGISTRIES_PIVOT_NUXT_RENDER_SHELL (gate: ALL RG1–RG8 + P1/P2 live)
Goal: implement the converged /knowledge/registries-pivot render-shell (reuse /knowledge/pivot pattern + registered Đ28 templates); retire /api/registry/health gap-math behind live pivot replacements (retire-after-replace). Run doc-09 tests (Truth-Check 100%, coverage 100%, 0 hardcode_violation, contract). Evidence: parity report; coverage scan; the gap-math endpoint no longer count-authoritative.
P5 — REGISTRIES_PIVOT_COUNT_DRIFT_RECONCILE (gate: P1 committed)
Goal: create the missing pivots PIV-500 (grand-total over the universal substrate), PIV-30x (orphan/phantom/drift totals), PIV-31x (label-by-facet — also fixes CAT-068 hidden drift), and a system_issues-total pivot (fixes CAT-017 hidden drift). BEGIN..ROLLBACK INSERT into pivot_definitions first; then refresh_meta_catalog_from_pivot; reconcile CAT-006↔CAT-DOT to one canonical CAT + one pivot (PIV-007). Evidence: pivot_count('PIV-500') exists and the four disagreeing totals (1,688,702 / 1,682,270 / 1,919,748 / 1,954,686) collapse to one explained anchor.
P6 — REGISTRIES_PIVOT_PHANTOM_LAW_PATCH (gate: council / Đ32)
Goal: author the council packet defining phantom as "a counted unit whose substrate cannot be located by the source's own scanner", with per-source_model detection (model-B = file-existence; model-A = live-pivot reconciliation) — explicitly rejecting blind record−actual. Register count_integrity_phantom. Reuse approval_requests/apr_approvals. Forbidden: self-approval; enacting without council. Evidence: APR package; until ratified phantom stays LAW_DEFINITION_GAP and renders PIVOT_MISSING.
P7 — REGISTRIES_PIVOT_THRESHOLD_AND_LABEL_REGISTRY_EXTEND (gate: RG5)
Goal: add a per-species ungrouped-display threshold home (new meta_catalog/entity_species.max_ungrouped_threshold column OR display_policy(species_code,max_ungrouped default 50) table — born+registered), so the 50 ceiling is PG data not a constant. Wire v_registry_label_grouping_required to read it; PIV-31x for label counts. BEGIN..ROLLBACK first. Evidence: 27 currently-over-50 leaves resolve a threshold from PG; zero literal 50 in any view/Nuxt.
P8 — REGISTRIES_PIVOT_PIN_REGISTRY_BIRTH (gate: RG5 + Đ32 approval)
Goal: birth registry_pin (Đ0-G) using the rehearsed shape (doc 07), register in meta_catalog, add PIV-32x, register pin.created/pin.removed in event_type_registry (before emit). BEGIN..ROLLBACK first. Forbidden: implement without approval; frontend pin state. Evidence: pin row counted by PIV-32x; T-SELF-1 passes (pin table itself registered).
P9 — REGISTRIES_PIVOT_NOTIFICATION_CLEANUP_INTEGRATION (gate: P4 + P6 ratified)
Goal: wire doc-08 contract live — fn_count_integrity_check() writes idempotent system_issues (coalesce_key, reuse types + the 3 new) and emits signal-only event_outbox events (register-before-emit); governed cleanup workflows consume per issue_type (Đ45 MOT-not-executor); register the check as an Đ31 self-verification contract + watchdog. Forbidden: scanner self-executing cleanup; data-in-queue; emit before type registered. Evidence: occurrence_count bumps (no dup); events signal-only.
P10 — REGISTRIES_PIVOT_NO_HARDCODE_CI (gate: P2; runs continuously)
Goal: add a CI/static check over the web source repo (not the built bundle) that greps for literal CAT-*/label arrays, reduce/Math.abs on counts, hardcoded 50/thresholds, level === N depth branching, localStorage pin arrays → write hardcode_violation/hc_finding_* to system_issues (types exist) + Đ28 Test-4 runtime parity + DOT-template-coverage (0 outside registry). Evidence: CI job; baseline = the live /api/registry/health gap-math flagged.
Ordering
RG1 ratify → P1 (view commit) → P5 (pivots/drift) ∥ P7 (threshold) → P2 (API) → P6 (phantom council) → P3 (UI preview) ∥ P8 (pin, after approval) → P4 (Nuxt, after all RG) → P9 (notification) ; P10 runs from P2 onward. DEFER: ghost (Qdrant), IU/KG pivots.