Tracker
Roadmap search
Versions, deliverables, workstreams, tasks, and pages
Program assembly - Design model
articleStandard
src/content/docs/platform-spec/compiler/build-pipeline/program-assembly/design-model.mdx
import SpecArticleChrome from '@beskid/beskid-ui/platform-spec/SpecArticleChrome.astro';
<SpecArticleChrome />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)
- 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
- 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
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
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
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
beskid_analysis::projects::assembly and beskid_analysis::services::front_end (see Implementation map).