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