Expand description
Core domain model for beams and Beamfiles.
alba-core takes the AST alba-syntax produces and evaluates it into
the typed Project model the execution engine schedules: resolving
let bindings and {expr} interpolation, checking the small type
system (strings and booleans), and running the built-in env()/glob()
functions. See render_template and eval_expr for the
load-time-vs-schedule-time rendering split between a beam’s fields.
Multi-file loading (import "path" as alias, namespaced beam ids) is
load_project’s job, which also validates the resulting dependency
graph (unknown needs targets, needs-cycles) via validate_graph
before returning it. execution_subgraph extracts the transitive
closure of a target beam, for whichever engine schedules and runs it.
git wraps the git CLI, the only place in the workspace that spawns it.
Modules§
- git
- The one place Alba talks to git: a thin wrapper over the
gitCLI.
Structs§
- Beam
- A single beam: the unit of work produced by evaluating a
beam { ... }declaration. - BeamId
- A fully namespaced beam identifier, e.g.
"api:build"for a beam imported under the aliasapi,"api:db:migrate"for one imported transitively through a chain of aliases, or"build"for a local one. - Core
Error - An error produced while evaluating a Beamfile: an unknown variable, a
type mismatch, an unresolvable built-in call, and so on. Carries the
span of the offending source text (and, when a nearby valid name
exists, help text) so it can be rendered the same way
alba_syntax::Diagnosticrenders parse errors. - Hook
- A git hook bound to a beam:
hook pre-commit { beam check }. Only the root Beamfile’s hooks make it here; an import’s are ignored, as itsdefaultis. - Load
Error - A
load_projectfailure, paired with every source file successfully read before it happened.sourceslets a caller rendererror(viaSourceMap::getandalba_syntax::render_diagnostic) even though loading never finished —error.source_idis always resolvable through it, since a file is registered insourcesbefore it’s parsed or evaluated. - Project
- A fully evaluated Beamfile (single-file loading only; see the module doc comment): every beam it declares, and which one runs by default.
- Scope
- Name bindings available while evaluating expressions: a file’s
evaluated
lets, later composed with a beam’s own parameter values. - Source
Id - Identifies which source file a
Beamorcrate::CoreErrorcame from, for pointing diagnostics at the right source text. Assigned bycrate::loader::load_project(the root file is alwaysSourceId(0), each import gets the next one in load order) and resolvable back to a path and source text viacrate::loader::SourceMap::get.load_str’s single-file loading always producesSourceId(0). - Source
Map - The path and source text of every file
load_projectread, indexed bySourceId, so aCoreError’ssource_idcan be turned back into something renderable: look up(path, source)here and hand both toalba_syntax::render_diagnostic(source, &path.display().to_string(), &diagnostic).
Enums§
- Executor
Kind - How a beam’s commands run.
- Option
Value - The value half of an executor option, once rendered (its
{expr}interpolation resolved, for theStr/Listcases) at load time. Mirrorsalba_syntax::ExecutorOptionValue, minus the interpolation itself. - Value
- A value produced by evaluating an
alba_syntax::Expr: either of the DSL’s two runtime types.
Functions§
- anchor_
pattern - Where
pattern’s matches live:basewith the pattern’s leading.and..components applied, and the rest of the pattern, relative to that directory.../../Dockerfiledeclared in/repo/contexts/sharedanchors at/repoasDockerfile. - eval_
expr - Evaluates
expragainstscope. The public entry point; internally delegates to a private helper that threads a span to fall back on for spanless expression kinds (Bool,Binary,If) down through recursive calls. Called directly (rather than throughrender_templateor the deferred-template checker below, both of which have richer context to use as that fallback), the best available fallback isexpr’s own span if it has one, or a zero-width span at the start of the source as a last resort. - execution_
subgraph - The transitive closure of
target(itself included), unordered: scheduling order is the engine’s job, not this crate’s. Aneedsentry repeated within one beam (needs [a, a]) contributesato the closure once, not twice. - expand_
globs - The files matching any of
patterns, resolved frombase, as(relative path with '/' separators, absolute path)pairs sorted by relative path — sorted so a fingerprint built from the list is deterministic across platforms and directory iteration orders. - load_
project - Loads
rootand every Beamfile it (transitively)imports into oneProject, namespacing imported beams by the alias they were imported under. See the module doc comment for the resolution rules. - outputs_
satisfied - Whether every
outputspattern is satisfied on disk: a literal path must exist, a glob pattern must match at least one entry. Raw disk, no.gitignorefiltering — see the module doc comment. - pattern_
dir - The deepest directory every match of
pattern, resolved frombase, lies under: itsanchor_patternjoined with the pattern’s leading literal directories. Watching it recursively sees every file the pattern can ever match. - render_
template - Renders
templateagainstscope: literal parts pass through unchanged,{expr}parts are evaluated and interpolated (strings verbatim, booleans astrue/false). - suggest
- The closest name in
candidatestoname, if within Levenshtein distance 2, matchingalba_syntax’s unknown-field suggestion threshold. Ties are broken alphabetically, not by iteration order:candidatesis typically aHashMap’s keys (viaScope::names), whose iteration order is randomized per process, so without an explicit tie-break the suggestion offered for the same typo could change from run to run. - validate_
graph - Checks that every
needsentry inprojectnames a beam that actually exists, thatproject’sdefault(if it declares one) does too, and that no beam (transitively) needs itself.