Tracker
Roadmap search
Versions, deliverables, workstreams, tasks, and pages
Stage ordering and lowering - Flow and algorithm
articleStandard
src/content/docs/platform-spec/compiler/build-pipeline/stage-ordering/flow-and-algorithm.mdx
import SpecArticleChrome from '@beskid/beskid-ui/platform-spec/SpecArticleChrome.astro';
<SpecArticleChrome />End-to-end lowering spine
flowchart TB
r[1 Resolve CompilePlan]
a[2 program.assemble]
p[3 Parse units]
m{Mods in graph?}
mh[4 Mod collect generate reparse]
s[5 Semantic rules]
e{Error diagnostics?}
stop[Abort]
h[7 HIR resolve type-check]
l[8 lower to CodegenArtifact]
r --> a --> p --> m
m -->|yes| mh --> s
m -->|no| s
s --> e
e -->|yes| stop
e -->|no| h --> l
Ordered steps
- Resolve source path/text through services (manifest, workspace graph,
CompilePlan, optional materialized workspace). - Assemble program — Build
ProgramAssemblyfrom effective roots (program.assemble); discover and parse compilation units per Program assembly. - Parse entry (and indexed units) and produce syntax diagnostics.
- Mod host (when transitive
Moddependencies exist) — Load AOT artifacts, discover contracts, run collect → generate → analyze → rewrite under Mod host bridge policy, merge typed AST contributions, and re-parse as required (bounded bymaxGeneratorRounds). Skip when no mod dependencies apply. - Run builtin staged semantic rules when diagnostics are enabled (same diagnostic channel as mod diagnostics).
- Abort on error diagnostics.
- Transform to HIR, resolve symbols against
ModuleIndex, and type-check the entry unit. - Lower typed program to backend artifact for JIT/AOT.
The canonical lowering entrypoint remains beskid_codegen::services::lower_source (and _with_pipeline); mod orchestration must live in beskid_analysis services (or a dedicated host module re-exported there) so CLI, LSP, and codegen share one scheduling spine.