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
//! Embedded JavaScript sandbox and host API for lanekeep rules.
//!
//! The embedded QuickJS runtime, the capability-restricted host API, the TypeScript
//! stripping step, and the module loader.
//!
//! The sandbox boundary lives here. Rule code reaches exactly the functions this crate
//! exposes and nothing else: no ambient filesystem, no process, no network, no clock, no
//! randomness. Those globals are not restricted, they are absent.
//!
//! Every addition to the host API widens the trust boundary and bumps the API version that
//! feeds the cache key.
//!
//! `FileAccess`/`ReadError` and `NodeArena`/`Handle` are re-exported rather than owned here:
//! the first lives in `lanekeep-core`, the second in `lanekeep-nodes`. Both moved out once a
//! second engine (`lanekeep-wasm`) needed the identical definitions — a copy per engine
//! would let one run enforce two different notions of "the same file" or "the same node",
//! each correct alone and disagreeing with the other.
//!
//! `Limits`/`RunClock` (and the `Budget`/`Trip` this sandbox arms and reads) moved to
//! `lanekeep-core` for a sharper version of the same reason: a run has exactly one global
//! budget, not one per engine, so two `RunClock`s would each be a correct clock in isolation
//! while the run as a whole overran both. This sandbox still does the arming, disarming and
//! interrupt wiring — only the type that makes "one clock" possible moved out.
//!
//! # How absence is achieved
//!
//! Two mechanisms, and the first is much stronger than the second.
//!
//! **Not installed.** The engine's optional intrinsics are opted into rather than opted out
//! of, so `Date`, `Performance` and `WeakRef` are never created. There is no original for a
//! rule to reach: nothing to patch, nothing to restore, no prototype chain leading back.
//!
//! **Deleted at startup.** `Math.random` lives among the non-optional base objects, so it
//! has to go afterwards. This is weaker in principle — deletion can be undone if a
//! reference escapes — but a rule that defines its own `Math.random` has written
//! deterministic code, which is all this needs to guarantee.
//!
//! Anything a host function does not offer, a rule cannot do. `fs`, `process`, `fetch`,
//! `setTimeout` and friends were never part of this engine to begin with, which is asserted
//! rather than assumed.
//!
//! # What is here so far
//!
//! The sandbox and its budgets. The host API, TypeScript stripping and the module loader
//! arrive in later milestones.
pub use SandboxError;
pub use ;
pub use ;
pub use ;
/// Re-exported so consumers can supply languages without depending on `lanekeep-lang` directly.
pub use Language;
pub use ;
pub use ;
pub use Sandbox;
pub use ;