Skip to main content

Module engine

Module engine 

Source
Expand description

Per-plugin rhai::Engine factory.

Builds a Rhai engine configured for the framework’s sandbox model:

  • Eval disabled at the symbol level so scripts cannot smuggle in dynamic code generation.
  • Module resolver replaced with a deny-all stub so import always fails. Modules can only be made available through host-registered Rhai packages (none are exposed in v1).
  • Resource limits wired from the effective CapabilitySet: Capability::FuelPerCall(N)Engine::set_max_operations(N); Capability::MemoryBytes(N) → conservative caps on string / array / map sizes (full memory accounting is M10’s broader work).
  • Capability-gated host fns registered conditionally — fns whose required_capability is not in the effective set are simply not registered, and the script fails at parse-resolution with ErrorFunctionNotFound. This is the in-host analogue of CM’s linker-absence guarantee (proposal §10.2).

Constants§

DEFAULT_MAX_CALL_LEVELS
Default maximum recursion depth for Rhai scripts. Overridable by scripts via the loader’s per-plugin engine configuration; future: expose a Capability::MaxCallLevels(N) so plugins can request more.
DEFAULT_MAX_OPERATIONS
Default Rhai operation-limit floor applied to every engine.

Functions§

build_engine
Build a Rhai engine pre-configured for a single plugin’s effective capability set.