Expand description
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.
§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.
Re-exports§
pub use error::SandboxError;pub use files::FileAccess;pub use files::ReadError;pub use host::EmittedFact;pub use host::HOST_API_VERSION;pub use host::HostContext;pub use host::ReduceContext;pub use host::ReduceFact;pub use host::ReduceReport;pub use host::Report;pub use host::merge_file;pub use limits::DEFAULT_GLOBAL_TIMEOUT;pub use limits::DEFAULT_MEMORY_BYTES;pub use limits::DEFAULT_RULE_TIMEOUT;pub use limits::Limits;pub use limits::RunClock;pub use loader::BuiltinSource;pub use loader::HOST_MODULE;pub use loader::ResolveError;pub use loader::RuleLoader;pub use loader::RuleResolver;pub use loader::RuleRoot;pub use nodes::Handle;pub use nodes::NodeArena;pub use sandbox::Sandbox;pub use typescript::StripError;pub use typescript::Unsupported;pub use typescript::strip_types;
Modules§
- error
- Why sandboxed execution failed.
- files
- Tracked, confined filesystem reads.
- host
- The
ctxobject rule code receives. - limits
- Execution budgets.
- loader
- Module resolution and loading for rule files.
- nodes
- Node handles: how AST nodes cross into the sandbox.
- sandbox
- The sandbox: a JavaScript runtime with no ambient authority and enforced budgets.
- typescript
- Turning TypeScript rule modules into JavaScript the engine can run.
Traits§
- Language
- Re-exported so consumers can supply languages without depending on
lanekeep-langdirectly. A language lanekeep can parse.