Skip to main content

Module read

Module read 

Source
Expand description

Reading a document tree: a map of logical paths to text becomes the distribution the equivalent single document would have produced.

Mirrors IR/src/layout/read-tree.ts in ecosystem/morphir-typescript; see .dev/docs/superpowers/maps/2026-09-17-reference-tree-layout-map.md section 4. A tree is a distribution taken apart, so reading one is putting it back together: the root manifest says which kind it is and which packages live under deps/, each …/module file says what its directory holds, and each node file is one type or one value. Nothing here parses anything itself — the caller’s parser turns text into the payload its profile produces, and the tree’s TreeModel decodes that and assembles the pieces. What this module adds is what a single document does not have: which file a name is in, which package a directory belongs to, and the rule that every file under pkg/ and deps/ is claimed by exactly one module.

A directory carries no order, so modules are assembled in logical-path order: a distribution whose modules were written in some other order comes back sorted. That is the one thing a tree does not preserve, and it is why a round trip is stable even though the writer never sorts.

Two cursor conventions meet here. A file that is not there at all is reported at its bare logical path; everything else is <logical path>#<json pointer>, whether the diagnostic is about the shape of the tree or is a file reader’s own, re-cursored onto the file it came from.

Functions§

read_tree
Reads a document tree into the IRFile the equivalent single document would have produced, with the warnings its files produced.