Sibling articles under this feature previously restated requirements in inconsistent forms.
Program assembly - Design model
Platform spec article
Program assembly - Design model
Spec standingStandard
-
This feature hub owns normative MUST/SHOULD contract text for Program assembly.
Context
Decision
This feature hub owns normative MUST/SHOULD contract text. Sibling articles must not redefine hub requirements and should link here for authority.
Consequences
Contract changes start on the hub or in linked ADRs, then propagate to articles and implementation anchors.
Verification anchors
site/website/src/content/docs/platform-spec/compiler/build-pipeline/program-assembly/index.mdxarticle bundle under the same feature directory.
-
Platform-spec text supersedes informal crate comments for Program assembly.
Context
Implementation crates accumulated informal notes that diverged from published contracts.
Decision
Normative platform-spec prose and ADRs under this feature supersede informal comments in implementation crates until explicitly migrated into spec text.
Consequences
Engineers file spec/ADR updates when behavior changes; crate comments are non-authoritative for conformance arguments.
Verification anchors
compiler/crates/beskid_analysis/
-
This feature hub defines how the reference compiler turns a resolved **`CompilePlan`** plus **effective (materialized-fi
Context
This feature hub defines how the reference compiler turns a resolved
CompilePlanplus effective (materialized-first) source roots into aProgramAssembly: discovered.bdunits, a sharedModuleIndexfor cross-module resolution, and a single front-end spine consumed by CLI, LSP, analyze, and codegen. JIT and AOT backends consumeCodegenArtifactonly and do not re-run assembly.Decision
The reference compiler must implement Program assembly as documented in this feature hub and its article bundle.
Consequences
Changes require hub/ADR updates and verification anchor extensions.
Verification anchors
compiler/crates/beskid_analysis/
- Program assembly - Contracts and edge cases Materialized-first roots, discovery caps, and parity across CLI and LSP.
- Program assembly - Design model EffectiveCompilationRoots, ProgramAssembly, ModuleIndex, and hybrid discovery modes.
- Program assembly - Flow and algorithm Ordered assembly after workspace materialize and before multi-unit parse and HIR resolution.
- Program assembly - Verification and traceability Test and source anchors for ProgramAssembly and effective roots.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Core objects
Section titled “Core objects”| Object | Role |
|---|---|
EffectiveCompilationRoots | Host + dependency source roots; materialized paths from PreparedProjectWorkspace or Project.lock take precedence over plan source_root paths |
SourceUnit | One parsed .bd file: logical name, path, text, Spanned<Program> |
ModuleIndex | Cross-unit module graph and item table used to prefetch resolution for the entry unit |
ProgramAssembly | Roots, units, entry index, discovery mode, and ModuleIndex |
AssemblyOptions | discovery (ImportClosure vs WorkspaceScan), include_std_prelude, max_units |
Hybrid discovery (normative)
Section titled “Hybrid discovery (normative)”- Build / run / lower / test —
ImportClosure: entry file, transitiveuseedges, and implicit std/prelude whenCompilePlan.has_std_dependencyis true. - LSP workspace file index —
WorkspaceScan: all*.bdfiles under each effective root for closed-buffer diagnostics indexing, capped bymax_units(deterministic sort order). - LSP / IDE document snapshots —
ImportClosureviaCompilationContext::assembly_for_entryso IntelliSense resolution matches compile/lower (ModuleIndex::resolve_entry_hiron the entry buffer).
use aliases and step-6 resolution
Section titled “use aliases and step-6 resolution”- A
usedeclaration registers an import alias (explicitasname or default tail of the path, e.g.use Std.System.IO→ aliasIO) mapped to the full logical module path in the mergedModuleGraphfromModuleIndex. - Value and type paths such as
IO.PrintLineorString.IsEmptymust resolve through alias expansion toStd::System::IO::PrintLine(etc.) during the resolver pass, producing ordinaryItembindings—notItemKind::Useplaceholders. - Staged semantic E1105 (
unknown import path) must consult assembly-known module paths whenProgramAssemblyis available, not file-local root heuristics alone.
IDE consumption
Section titled “IDE consumption”beskid_analysis::services::build_document_analysis_with_contextlowers and normalizes the entry program, then callsassembly.module_index.resolve_entry_hirwhen assembly is available.- Resolved items from dependency units carry
ItemInfo.source_pathso LSP go-to-definition, find references, and hover map to the declaring.bdfile URI. - Workspace find references on non-entry units use
ModuleIndex::resolve_unit_hirper dependency unit when merging matches intoreferences_at_offset_workspace. - Import aliases collected in the entry unit are exposed on
Resolution.module_importsfor member completion (IO.→Std::System::IOscope).
CLI and JIT/AOT parity
Section titled “CLI and JIT/AOT parity”beskid buildandbeskid runmust use the samePreparedProjectWorkspacematerialized roots andModuleIndex::resolve_entry_hiron the entry unit before codegen.beskid runmust callcompile_front_end_from_resolved_input(or equivalent) withprepared_workspacefrom project resolve — not a second assemble path withprepared_workspace: None.
Backend boundary
Section titled “Backend boundary”Assembly and the shared front-end spine end at typed HIR and CodegenArtifact. beskid_engine (JIT) and beskid_aot (link) must not rebuild CompilePlan or rediscover modules.
Implementation owner
Section titled “Implementation owner”beskid_analysis::projects::assembly and beskid_analysis::services::front_end (see Implementation map).