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.
25//! - Bounding a build file's memory, instructions and source walk: the ceilings of
26//!   [`DeclarationLimits`], and a byte budget, equal to the memory ceiling, on what one file may
27//!   stage. The `buildl.sources` walk is capped at `walk_entries` directory entries per build
28//!   file, counted across all its calls. Wall time is outside every ceiling.
29//!
30//! # Non-responsibilities
31//!
32//! - Deciding which build files to evaluate, validating names, resolving labels or joining
33//!   paths. The caller does all of that with what a file staged.
34//! - Resolving, planning, scheduling, caching, or executing anything a build file declares.
35//!
36//! # Where things live
37//!
38//! | Module | Holds |
39//! |---|---|
40//! | `source` | [`LuaSource`]: read, evaluate, report |
41//! | `limits` | [`DeclarationLimits`] |
42//! | `engine` | the airsl engine configuration |
43//! | `curated` | airsl's `path` module without `absolute` |
44//! | `snapshot` | one-level copies of the library and module tables a plugin must not share |
45//! | `module` | the `buildl` host module, which raises refusals |
46//! | `plugin` | `buildl.use`: a plugin's manifest, environment, `require` and instances |
47//! | `decode_all` | `buildl.decode_all`: a stream of JSON values as a list |
48//! | `primitives` | each primitive's argument shape |
49//! | `env_marks` | a target's `env` table: each name beside its written mark |
50//! | `values` | the Lua value readers every primitive shares |
51//! | `refusal` | why a primitive call was refused |
52//! | `results` | the discovery results `buildl.discovered` reads |
53//! | `sources` | the host-side walk behind `buildl.sources` |
54//! | `stable_text` | `tostring` and `string.format` without address-derived text |
55//! | `staging` | the staging buffer: order, byte budget, first refusal |
56//! | `classify` | airsl failures named as `EvaluationFailure` kinds |
57//!
58//! This file holds only module declarations and re-exports, so it carries no logic to
59//! unit-test.
60
61mod classify;
62mod curated;
63mod decode_all;
64mod engine;
65mod env_marks;
66mod limits;
67mod module;
68mod plugin;
69mod primitives;
70mod refusal;
71mod results;
72mod snapshot;
73mod source;
74mod sources;
75mod stable_text;
76mod staging;
77mod values;
78
79pub use limits::DeclarationLimits;
80pub use source::LuaSource;