Tracker
Roadmap search
Versions, deliverables, workstreams, tasks, and pages
mod host bridge - Flow and algorithm
articleStandard
src/content/docs/platform-spec/compiler/compiler-mods/mod-host-bridge/flow-and-algorithm.mdx
import SpecArticleChrome from '@beskid/beskid-ui/platform-spec/SpecArticleChrome.astro';
<SpecArticleChrome />Mod host orchestration
flowchart TB
load[Load Mod AOT artifacts]
collect[mod.collect target sets]
gen[mod.generate typed AST]
merge[Merge contributions]
reparse{Syntax changed?}
sem[semantic.snapshot]
analyze[mod.analyze diagnostics]
rewrite[mod.rewrite optional]
load --> collect --> gen --> merge --> reparse
reparse -->|yes bounded rounds| collect
reparse -->|no| sem --> analyze --> rewrite
Primary flow
- After
parse(andmacro.expand),mod.loadregisters contracts from resolvedModprojects in the dependency graph. mod.collectrecords generator/analyzer/rewriter target sets per mod.mod.generateemits typed AST contributions; the host merges and re-parses affected units when syntax changed (bounded bymaxGeneratorRounds).- Builtin semantic rules run on the merged program; emit
semantic.snapshotbefore analyzers read frozen state. mod.analyzepublishes diagnostics;mod.rewriteapplies typed replacements when enabled.- Emit
lower.readyonly when the merged tree is consistent for HIR lowering.
Ordering constraints
- No mod body runs before a parseable
Programsnapshot exists for its compilation unit. - Analyzers must not mutate syntax after
semantic.snapshot; rewrites go throughmod.rewriteonly. - Capability checks and step budgets are enforced in the Rust host before Beskid mod entrypoints run (see Incremental scheduling and determinism).