Prepared shells, bound dependencies and local declaration order give each module its top-level silhouette before bodies type-check.
Bodies can wait. Before the compiler checks whether greet(visitor) type-checks, it needs the module's top-level shape: which declarations exist, which dependencies wait on providers and which local names depend on which other local names.
Header work finds that shape once. Later stages bind and consume retained syntax. They do not reparse the file from characters whenever a provider finishes.
From located tokens, syntax preparation extracts shells:
$config input contracts, per-item $export visibility and $doc/$todo operand rangesFor the greeting source, shells include something like "constant greeting_prefix" and "function greet with these parameter and return type shells." For the page, preparation keeps the @greeting dependency selection shell, the entry-body token stream that contains visitor and the fragment-placement metadata around the HTML template.
Note what has not happened yet. greet is not bound to anything, and visitor is not a declaration the header stage understands. Binding resolves the first later, and AST parses the second out of the entry body.
Preparation does not type-check executable bodies. It does not open source provider interfaces. It records what source syntax already makes knowable without them.
Header processing keeps four edge families distinct. Mixing them is a reliable way to build a confusing compiler. Each authored path row has exactly one role.
Structural provider references belong to Stage 0 graph construction. They answer "which module or package must exist before this consumer can bind?"
Structural file references also belong to Stage 0, plus physical-input resolution. They answer "which file on disk does this path point at?"
Dependency-bound symbol bindings belong to visibility and AST. They answer "which public names from a provider become usable here, under which local spellings?"
Local declaration-ordering edges belong to Stage 3 inside one module. They answer "which top-level declarations must be processed before which others in this module?"
A dependency-bound declaration is never a node in the consumer's local declaration graph. Copying provider declarations into each consumer would destroy identity and explode work.
PreparedHeaderSyntax exists before providers compile. Dependency shells wait with their source locations intact.
In the walkthrough both files live in one directory-scoped module, so greeting.moth is owned source rather than a separate provider. The module compiles once and the retained @greeting clause binds inside it. Provider-first scheduling is for the other case, where a dependency resolves to a different module or package.
Dependency binding resolves each retained clause against its permitted source: same-module helper declarations or an external provider's finished public interface.
Binding does not retokenize. It does not reparse declaration syntax. It fills in what only a finished provider can supply.
A qualified expression such as @settings site_name uses the same provider path and visibility rules, but it is not a dependency clause. It creates no bound local spelling. Binding resolves the single selected declaration for that authored occurrence and never installs an import, alias or namespace. At top level, an unassigned @module symbol, other remains an ordinary dependency clause. The qualified expression form applies in value positions, including template heads.
Before binding, greet is a name in a dependency shell. After binding, it is a stable origin identity with known type facts the AST can trust.
Inside one module, Stage 3 builds a declaration dependency DAG from retained local edges and sorts it.
Edges include facts AST needs before linear consumption:
Function-body references do not create ordering edges. Bodies may call functions declared later in the file. Only the top-level shape needs a stable process order.
A qualified reference inside a constant initializer or a .mtf template head contributes the selected same-module declaration to that containing declaration's existing local edge. A cross-module selection uses the provider edge Stage 0 already established. The occurrence itself never becomes a declaration-graph node.
Sorting uses stable tie-breaking so independent declarations keep their source order. Same-file constants keep source-order semantics. Same-file forward references among constants are rejected. Cross-module constants arrive already folded in provider interfaces.
The dormant entry root appends after declarations. It never participates as a dependency node that other declarations wait on.
If two local declarations require each other in a way the edge set captures, the sort stops and a cycle diagnostic fires.
Visibility rules stay strict. User-visible names do not silently shadow one another across same-file declarations, dependencies, aliases, prelude symbols and builtins. One collision policy covers the surface.
Dependency-bound declarations influence visibility after binding. They still do not become local graph nodes for Stage 3.
@mod or @package roots that illegally carry entry runtime activityFinal prose and rendering of diagnostics wait for the diagnostics article. Here the failures are structural.
Alternative: reparse source after providers compile, or copy declarations into each consumer.
Choice: parse and retain syntax once, then bind immutable provider interfaces.
Benefit: source locations, identities and graph scheduling stay aligned. Parallel workers can prepare shells early and bind later.
Cost: prepared syntax carries more metadata across the build boundary.
PreparedHeaderSyntax, BoundModuleHeaders and distinct relationship classes.$config, $export, $doc and $todo source modifiers attach through one contiguous directive run to their eligible targets, with retained input, visibility and declaration documentation facts. Bare direct entry templates are const-required and explicit ~ templates are runtime fragments. Use the progress matrix for current support.You leave with bound visibility, stable dependency facts and ordered declarations. Next: how syntax acquires checked semantic meaning in the AST.