IU Core Event Worker — 06 Structure-ops production workflow package
IU Core Event Worker — 06 Structure-ops production workflow package
Design package (not built this macro). The substrate already exists; this specifies the workflow that exercises it.
Substrate in place
iu_structure_operation— governed envelope per op (004; H4-fixed006).iu_relation— typed lineage edges;uq_iu_relation_one_active_parent.iu_tree_path— materialised tree (158 rows);v_iu_tree— live recursive projection.- Helpers
fn_iu_tree_assert_acyclic,fn_iu_tree_is_descendant(005). - Python:
structure_ops.py(6 operation types, status transitions,STRUCTURE_OP_EVENTS),tree.py(cycle logic),idempotency.py(structure_operation_key).
Command contract — plan → apply → verify → rollback
One verb per operation type (add_new_piece, split_large_piece,
merge_small_pieces, deprecate_piece, replace_piece, reparent_piece),
each a four-phase governed envelope keyed by structure_operation_key:
- plan (dry-run) — create
iu_structure_operationdraft→planned; computeimpact_summary(affected IUs,iu_tree_pathrows that change,iu_sql_linkrows hit) without mutating. Idempotent on the key. - apply —
planned→enacted(setsenacted_at). Mutateinformation_unit.parent_or_container_ref/ create IUs via the birth gate / setlifecycle_status; writeiu_relationedges; refreshiu_tree_pathfor the affected subtree; emit IU events (STRUCTURE_OP_EVENTS). - verify — read-only: tree acyclic,
iu_tree_path==v_iu_treefor the subtree, one activecontainsparent per child,path_hashdistinct. - rollback / compensation —
enacted→rolled_back(retainsenacted_atper H4). Reverse the adjacency change; retireiu_relationedges viavalid_to+relation_status; restoreiu_tree_pathfromv_iu_tree.
dry-run / apply mode
plan leaves the op planned and writes nothing durable to the tree —
that is dry-run. apply is the gated, durable step. Both honour a master
gate; apply/rollback additionally require sovereign approval (mutating).
Tree maintenance
iu_tree_path is a cache of v_iu_tree. After any adjacency change, the
affected unit_id and its whole subtree must be re-derived from
v_iu_tree (depth, path_ids, path_addresses, path_hash). For the
current flat 158-IU tree (all depth 0) every op is a depth-0/1 change; a full
re-bootstrap (runtime/050 pattern) is also acceptable at this scale.
To build (next structure-ops macro)
- SQL:
fn_iu_structure_op_plan / _apply / _verify / _rollback(or acutter_agent/iu_core/structure_ops_workflow.pydriver over the existing helpers). - Reuse: birth gate for IU creation,
fn_iu_tree_assert_acyclicfor reparent,fn_iu_emit_eventforSTRUCTURE_OP_EVENTS— which the route worker built this macro will then consume. - Integration point with auto-cut: doc 07.