IU Core 30x Structure/Autocut — 02 All-documents tree build (runtime/180)
02 — All-documents Tree Build (runtime/180)
Candidate selection — live discovery, no hardcoded id
runtime/180 generalises runtime/170: where 170 selected the single richest
document, 180 discovers every buildable flat draft IU across every
document by live query and builds them all in one atomic transaction. A child
is buildable iff it is flat (parent_or_container_ref IS NULL), draft, and a
sibling exists at the canonical_address-derived parent
(regexp_replace(addr,'-[^-]+$','')) in the same document.
B0 cross-document survey:
| doc_code | buildable | flat_total |
|---|---|---|
| DIEU-28 | 14 | 27 |
| DIEU-32 | 12 | 23 |
| DIEU-35 | 0 | 17 (already built by runtime/170) |
No document code and no IU id is baked into runtime/180; the test
test_180_has_no_hardcoded_doc_or_id enforces this.
Batch execution
One atomic BEGIN … COMMIT. The structure-op gate is opened and closed inside
the same transaction. Pairs ordered (doc_code, canonical_address) so a parent
piece is nested before its sub-piece. For every buildable reparent:
fn_iu_structure_op_plan → _apply → _verify. Any non-ok RAISEs and rolls back.
runtime/180: docs=2 applied=26 already_enacted=0 iu_event_outbox 18->44
Post-batch verification (B1–B7, in-transaction)
| Check | Result |
|---|---|
| B1 ops | reparent_piece / enacted = 45 (1×140 + 18×170 + 26×180) |
| B2 depth | depth 0 = 113, depth 1 = 42, depth 2 = 3 (Σ = 158) |
| B3 consistency | iu_tree_path 158 = v_iu_tree 158 = live IU 158 |
| B4 relation | active contains = 45, nested IU = 45 |
| B5 events | event_outbox structure_op_applied = 44 |
| B6 per-doc | DIEU-28 14 nested/13 flat; DIEU-32 12/11; DIEU-35 19/17 |
| B7 gate | iu_core.structure_ops_enabled = false (layer inert) |
Independent verification — runtime/130 (read-only)
S5 iu_structure_operation=45 iu_relation=45 iu_tree_path=158, S6 tree
consistency 158=158=158 counts_agree=t, S8 stranded_midflight=0 enacted_terminal=45 rolled_back_terminal=0.
Rollback / compensation readiness
runtime/rollback/180 reverses the whole batch by actor iu_core_runtime_180
(reverse canonical order) behind the gate. Per-op fn_iu_structure_op_rollback
is compensation-snapshot-driven. Each op individually reversible.