Skip to main content

buildl_lua/
lib.rs

1//! Lua build-file evaluation for buildl, on the airsl embedded runtime.
2//!
3//! This crate is the only part of buildl that depends on a Lua runtime, so the effect of an
4//! airsl upgrade stays within one crate. It implements `buildl-core`'s [`DeclarationSource`]
5//! port as [`LuaSource`].
6//!
7//! [`DeclarationSource`]: buildl_core::DeclarationSource
8//!
9//! # Responsibilities
10//!
11//! - Evaluating one build file per call on a fresh airsl engine, and returning what it staged
12//!   exactly as written, or the one failure that stopped it.
13//! - Installing the `buildl` module table, reachable from Lua both as `airsstack.buildl` and as
14//!   the global `buildl`: `target`, `test`, `discover`, `rule`, `alias`, `option`, `subdir`,
15//!   `sources`, `discovered`, which returns the result a discovery target last produced,
16//!   `decode_all`, which returns the JSON values of a stream as a list, and `use`, which loads a
17//!   plugin under an environment of its own.
18//! - Keeping the declaration phase sandboxed: airsl's minimal language surface, no grant of any
19//!   kind, only the `json`, `path`, `regex`, `hash` and `glob` modules, and no `math.random`,
20//!   `math.randomseed`, `print` or `airsstack.path.absolute`, and with `tostring` and
21//!   `string.format` refusing address-derived text (a table, function, thread or userdata without `__tostring`,
22//!   and `%p`). `buildl.sources` is the only filesystem read, and it walks only the declaring
23//!   directory, never entering a directory [`LuaSource::new`] was told to skip, such as the
24//!   workspace's output and state directories, and never listing a path the
25//!   [`IgnoreRules`](buildl_core::IgnoreRules) it was given report ignored.
26//! - Bounding a build file's memory, instructions and source walk: the ceilings of
27//!   [`DeclarationLimits`], and a byte budget, equal to the memory ceiling, on what one file may
28//!   stage. The `buildl.sources` walk is capped at `walk_entries` directory entries per build
29//!   file, counted across all its calls. Wall time is outside every ceiling.
30//!
31//! # Non-responsibilities
32//!
33//! - Deciding which build files to evaluate, validating names, resolving labels or joining
34//!   paths. The caller does all of that with what a file staged.
35//! - Resolving, planning, scheduling, caching, or executing anything a build file declares.
36//!
37//! # Where things live
38//!
39//! | Module | Holds |
40//! |---|---|
41//! | `source` | [`LuaSource`]: read, evaluate, report |
42//! | `limits` | [`DeclarationLimits`] |
43//! | `engine` | the airsl engine configuration |
44//! | `curated` | airsl's `path` module without `absolute` |
45//! | `snapshot` | one-level copies of the library and module tables a plugin must not share |
46//! | `module` | the `buildl` host module, which raises refusals |
47//! | `plugin` | `buildl.use`: a plugin's manifest, environment, `require` and instances |
48//! | `decode_all` | `buildl.decode_all`: a stream of JSON values as a list |
49//! | `primitives` | each primitive's argument shape |
50//! | `env_marks` | a target's `env` table: each name beside its written mark |
51//! | `values` | the Lua value readers every primitive shares |
52//! | `refusal` | why a primitive call was refused |
53//! | `results` | the discovery results `buildl.discovered` reads |
54//! | `sources` | the host-side walk behind `buildl.sources` |
55//! | `stable_text` | `tostring` and `string.format` without address-derived text |
56//! | `staging` | the staging buffer: order, byte budget, first refusal |
57//! | `classify` | airsl failures named as `EvaluationFailure` kinds |
58//!
59//! This file holds only module declarations and re-exports, so it carries no logic to
60//! unit-test.
61
62mod classify;
63mod curated;
64mod decode_all;
65mod engine;
66mod env_marks;
67mod limits;
68mod module;
69mod plugin;
70mod primitives;
71mod refusal;
72mod results;
73mod snapshot;
74mod source;
75mod sources;
76mod stable_text;
77mod staging;
78mod values;
79
80pub use limits::DeclarationLimits;
81pub use source::LuaSource;