Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Program assembly - Design model

Platform spec article

Program assembly - Design model

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki
ObjectRole
EffectiveCompilationRootsHost + dependency source roots; materialized paths from PreparedProjectWorkspace or Project.lock take precedence over plan source_root paths
SourceUnitOne parsed .bd file: logical name, path, text, Spanned<Program>
ModuleIndexCross-unit module graph and item table used to prefetch resolution for the entry unit
ProgramAssemblyRoots, units, entry index, discovery mode, and ModuleIndex
AssemblyOptionsdiscovery (ImportClosure vs WorkspaceScan), include_std_prelude, max_units
  • Build / run / lower / testImportClosure: entry file, transitive use edges, and implicit std/prelude when CompilePlan.has_std_dependency is true.
  • LSP workspace file indexWorkspaceScan: all *.bd files under each effective root for closed-buffer diagnostics indexing, capped by max_units (deterministic sort order).
  • LSP / IDE document snapshotsImportClosure via CompilationContext::assembly_for_entry so IntelliSense resolution matches compile/lower (ModuleIndex::resolve_entry_hir on the entry buffer).
  • A use declaration registers an import alias (explicit as name or default tail of the path, e.g. use Std.System.IO → alias IO) mapped to the full logical module path in the merged ModuleGraph from ModuleIndex.
  • Value and type paths such as IO.PrintLine or String.IsEmpty must resolve through alias expansion to Std::System::IO::PrintLine (etc.) during the resolver pass, producing ordinary Item bindings—not ItemKind::Use placeholders.
  • Staged semantic E1105 (unknown import path) must consult assembly-known module paths when ProgramAssembly is available, not file-local root heuristics alone.
  • beskid_analysis::services::build_document_analysis_with_context lowers and normalizes the entry program, then calls assembly.module_index.resolve_entry_hir when assembly is available.
  • Resolved items from dependency units carry ItemInfo.source_path so LSP go-to-definition, find references, and hover map to the declaring .bd file URI.
  • Workspace find references on non-entry units use ModuleIndex::resolve_unit_hir per dependency unit when merging matches into references_at_offset_workspace.
  • Import aliases collected in the entry unit are exposed on Resolution.module_imports for member completion (IO.Std::System::IO scope).

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.

beskid_analysis::projects::assembly and beskid_analysis::services::front_end (see Implementation map).