KB-5170

IU Core Structure-Event/Tree Scale — 03 Batch tree build result (runtime/170)

3 min read Revision 1
dieu44iu-core-mvpstructure-eventtree-buildruntime-170batchv0.62026-05-22

03 — Batch Structure-op Tree Build (runtime/170)

Candidate selection — live discovery, no hardcoded id

runtime/170 discovers the target document by query: the document with the most flat draft IUs whose canonical_address-derived parent (regexp_replace(addr,'-[^-]+$','')) already exists in the same document.

Cross-document buildability survey (B0, printed by runtime/170):

doc_code buildable flat_total
DIEU-35 18 35
DIEU-28 14 27
DIEU-32 12 23
(null) 0 72 (60 non-draft — no encoded hierarchy)

DIEU-35 selected — highest buildable count, all candidates draft (zero non-draft flat IUs), and the first durable reparent was already proven there. No document code and no IU id is baked into runtime/170; the test test_170_has_no_hardcoded_doc_or_id enforces this.

Batch execution

One atomic BEGIN ... COMMIT. Gate opened and closed inside the same transaction. For every buildable reparent: fn_iu_structure_op_plan -> fn_iu_structure_op_apply -> fn_iu_structure_op_verify. Any non-ok apply/verify RAISEs and rolls the whole transaction back.

runtime/170: doc=DIEU-35 applied=18 already_enacted=0 iu_event_outbox 0->18

Post-batch verification (B1-B6, in-transaction)

Check Result
B1 ops reparent_piece / enacted = 19 (1 from runtime/140 + 18)
B2 depth depth 0 = 139, depth 1 = 16, depth 2 = 3 (sum = 158)
B3 consistency iu_tree_path 158 = v_iu_tree 158 = live IU 158
B4 relation active contains = 19, nested IU = 19
B5 events event_outbox structure_op_applied = 18
B6 gate iu_core.structure_ops_enabled = false (layer inert)

The built tree (DIEU-35): each S{n} section stays a root (its derived parent D38-DIEU35 does not exist — correct, sections are top-level); the P pieces nest under their S section (depth 1); the P-N sub-pieces nest under their P (depth 2). depth-1 = 16 (S4x4 + S6x7 + S8x5); depth-2 = 3 (S4-P1-1/2/3).

Independent read-back (post-commit, separate query)

nested=19, ops_enacted=19, active_contains=19, struct_events=18, dry_run_attempts=18, dlq_open=0, structure_gate=false, tree_path=158, recursive_view=158. All consistent.

Verification — runtime/130 (read-only)

S1 6/6 functions, S2 view present, S3 gate false / fn_reports_enabled=f, S4 fail-closed true, S5 iu_structure_operation=19 iu_relation=19 iu_tree_path=158, S6 tree consistency 158=158=158 counts_agree=t, S7 acyclic guard present, S8 stranded_midflight=0 enacted_terminal=19 rolled_back_terminal=0 (see finding H5, doc 05), S9 rollback file pathed.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-structure-event-tree-autocut-worker-scale-open-goal/03-batch-tree-build-result.md