KB-728B

IU Core Controlled Route — 07 Structure tree bootstrap (runtime 050)

3 min read Revision 1
dieu44iu-core-mvpcontrolled-routestructure-treeiu-tree-pathruntime-050v0.62026-05-21

IU Core Controlled Route — 07 Structure tree bootstrap

Live tree shape — completely flat

Survey of v_iu_tree (the recursive read-only projection of information_unit.parent_or_container_ref):

  • All 158 IUs are depth-0 rootsparent_or_container_ref IS NULL for all 158, 0 IUs carry a parent pointer.
  • 0 soft-deleted IUs, 0 orphans/unreachable.
  • iu_tree_path carried 0 rows; no triggers on it.

Migration runtime/050 — applied

050_structure_tree_bootstrap.sqlINSERT INTO iu_tree_path SELECT … FROM v_iu_tree ON CONFLICT (unit_id) DO NOTHING. path_hash = encode(sha256(<path_ids joined by '/'>), 'hex').

Result: 158 iu_tree_path rows inserted, all depth=0, matches_v_iu_tree=true. Invariants verified post-apply: array_length(path_ids)=depth+1 ✓, path_ids[1]=root_unit_id ✓, path_ids[last]=unit_id ✓, path_hash all distinct ✓.

Why this is safe (all 4 macro conditions met)

  • Additive / idempotentINSERT … ON CONFLICT (unit_id) DO NOTHING into a primary-keyed table that was empty; a re-run inserts nothing.
  • Source of truth = existing production IU state — derived from v_iu_tree, which reads information_unit.parent_or_container_ref. The bootstrap derives, never invents, the tree.
  • Rollback/cleanup clearruntime/rollback/050 clears iu_tree_path (restoring the pre-bootstrap empty state) and REFUSES if iu_structure_operation holds rows (structure-ops history present). iu_tree_path is a rebuildable cache of v_iu_tree.
  • No lifecycle status changediu_tree_path is a pure sidecar; no touch to information_unit / unit_version.

Lineage (iu_relation) — legitimately empty

iu_relation (typed lineage edges: contains, split_from, merged_from, supersedes) and iu_structure_operation both remain 0 rows. Lineage edges are produced by structure operations (add/split/merge/deprecate/reparent); no such operations have been recorded for the 158 IUs, and the flat tree has no contains parent→child edges. There is nothing to bootstrap into iu_relation — it correctly stays empty until structure operations run.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-controlled-route-mastergate-structure-observability-open-goal/07-structure-tree-bootstrap.md