KB-12AD
IU Core First Durable Structure Op — 02 Execution layer package (migration 010)
4 min read Revision 1
dieu44iu-core-mvpstructure-opexecution-layermigration-010v0.62026-05-21
02 — Structure-op Execution Layer Package (migration 010)
The SQL-backed live counterpart of the Python StructureOpsWorkflow /
InMemoryStructureStore seam. Additive only — no ALTER, no DROP.
Objects (all in sql/iu-core/010_structure_op_execution.sql)
| Object | Role |
|---|---|
fn_iu_structure_ops_enabled() |
dedicated kill-switch; fail-closed (missing key => false) |
fn_iu_tree_path_refresh(uuid[]) |
rebuild iu_tree_path for the given units + subtrees from v_iu_tree |
fn_iu_structure_op_plan(...) |
phase 1 — record a planned envelope; idempotent on a deterministic key; mutates no tree |
fn_iu_structure_op_apply(uuid) |
phase 2 — gated durable apply (reparent_piece); snapshots compensation into impact_summary |
fn_iu_structure_op_verify(uuid) |
phase 3 — read-only invariant verdict |
fn_iu_structure_op_rollback(uuid) |
phase 4 — gated compensation; retains enacted_at (H4) |
v_iu_structure_operation_log |
observability — one row per op + lineage-edge count |
Safety contract
- Fail-closed gate:
apply/rollbackRAISE insufficient_privilegeunlessdot_config 'iu_core.structure_ops_enabled' = 'true'. The gate is registered CLOSED byruntime/120and only opened inside the single transaction ofruntime/140. - Bounded impact:
applytouches exactly oneinformation_unitadjacency pointer and theiu_tree_pathrows of that unit's subtree. - Reversible: the compensation snapshot (
prior_parent,relation_written,relation_retired) lives inimpact_summary;rollbackis a pure inverse needing no external input. - Idempotent:
plandedupes onidempotency_key;applyon anenactedop androllbackon arolled_backop are no-ops. - MVP scope:
apply/rollbackimplementreparent_piece; the other fiveoperation_typesRAISE feature_not_supported— fail-closed and honest. - IU Gateway integration:
apply/rollbackdiscover the gateway marker key fromdot_configandset_config(marker_key,'fn_iu_structure_op',true)(transaction-local) before their singleinformation_unitwrite.runtime/120registersfn_iu_structure_opin the gateway allowlist; without that registrationapplystill fails closed at the guard.
Activation / verification / disable
| File | Purpose |
|---|---|
runtime/120_structure_ops_register.sql |
gate registered CLOSED + gateway-writer registered (idempotent) |
runtime/rollback/120_...rollback.sql |
gate => false + gateway-writer de-registered |
runtime/130_structure_op_verification.sql |
read-only S1–S9 verification |
sandbox/050_structure_op_probe.sql |
BEGIN...ROLLBACK full-envelope proof, safe on production |
rollback/010_structure_op_execution.rollback.sql |
drop the layer; refuses while any op is enacted |
Install evidence (production)
010applied — no error.runtime/120applied — gatefalse, allowlist nowfn_iu_create,fn_iu_apply_edit_draft,fn_iu_enact,fn_iu_structure_op.runtime/130— S1 6/6 functions present, S2 view present, S3 gatefalse, S4 fail-closedtrue, S6 tree consistency158=158=158, S8 0 stranded.runtime/110DOT scan — D9 41/41, every classok=true, D8 0 drift.sandbox/050— P1 planned, P2 applyok, P3 move shown, P4 verifyok, P5 rollbackok, P6 fully restored, P7 verifyok, P8enacted_atretained. Zero durable rows.