pub struct Runtime {
pub schema_registry: Arc<TypeSchemaRegistry>,
/* private fields */
}Expand description
The main runtime engine for Shape
Fields§
§schema_registry: Arc<TypeSchemaRegistry>Per-runtime type schema registry.
Owns its own schema-ID counter + stdlib schemas; replaces the
process-global STDLIB_SCHEMA_REGISTRY + NEXT_SCHEMA_ID statics
that were retired in B1.7. Stored as Arc<_> so execution entry
points can cheaply install it as the task-local / thread-local
ambient registry (type_schema::current); mutations through
Runtime::schema_registry_mut use Arc::make_mut (copy-on-write
when the registry has already been scoped elsewhere).
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn extension_module_schemas(&self) -> &Arc<ExtensionModuleSchemaCache> ⓘ
pub fn extension_module_schemas(&self) -> &Arc<ExtensionModuleSchemaCache> ⓘ
Borrow this runtime’s extension module schema cache.
pub fn annotation_registry(&self) -> Arc<RwLock<AnnotationRegistry>> ⓘ
pub fn enable_persistent_context(&mut self, data: &DataFrame)
pub fn enable_persistent_context_without_data(&mut self)
pub fn set_persistent_context(&mut self, ctx: ExecutionContext)
pub fn persistent_context(&self) -> Option<&ExecutionContext>
pub fn persistent_context_mut(&mut self) -> Option<&mut ExecutionContext>
Sourcepub fn set_last_runtime_error(&mut self, payload: Option<WireValue>)
pub fn set_last_runtime_error(&mut self, payload: Option<WireValue>)
Store the last structured runtime error payload.
Sourcepub fn clear_last_runtime_error(&mut self)
pub fn clear_last_runtime_error(&mut self)
Clear any stored structured runtime error payload.
Sourcepub fn last_runtime_error(&self) -> Option<&WireValue>
pub fn last_runtime_error(&self) -> Option<&WireValue>
Borrow the last structured runtime error payload.
Sourcepub fn take_last_runtime_error(&mut self) -> Option<WireValue>
pub fn take_last_runtime_error(&mut self) -> Option<WireValue>
Take the last structured runtime error payload.
pub fn type_method_registry(&self) -> &Arc<TypeMethodRegistry> ⓘ
Sourcepub fn schema_registry(&self) -> &TypeSchemaRegistry
pub fn schema_registry(&self) -> &TypeSchemaRegistry
Borrow the per-runtime type schema registry.
During the B1 migration window this accessor is informational — most
decode / wire / printing / executor call sites still consult the
process-global statics. Track B1 threads &runtime.schema_registry
through those call sites and deletes the statics in B1.6.
Sourcepub fn schema_registry_mut(&mut self) -> &mut TypeSchemaRegistry
pub fn schema_registry_mut(&mut self) -> &mut TypeSchemaRegistry
Mutable access to the per-runtime type schema registry.
Uses Arc::make_mut — if the registry has been cloned elsewhere
(e.g. installed as the current async-scope ambient registry), this
performs a copy-on-write clone so the mutation is visible only on
this Runtime. Callers that want the mutation to be visible
through a live ambient handle must install the new Arc themselves.
Sourcepub fn schema_registry_arc(&self) -> Arc<TypeSchemaRegistry> ⓘ
pub fn schema_registry_arc(&self) -> Arc<TypeSchemaRegistry> ⓘ
Clone the Arc<TypeSchemaRegistry> for installation as the current
ambient registry (see type_schema::current).
Sourcepub fn enter_schema_scope(&self) -> SyncRegistryScope
pub fn enter_schema_scope(&self) -> SyncRegistryScope
Install this runtime’s schema registry as the current synchronous ambient registry for the returned guard’s lifetime.
Synchronous execution entry points (CLI scripts, tests, REPL
one-shots) should hold the guard for the duration of execution so
any code path that consults type_schema::current_registry
observes this runtime’s registry instead of reaching for the legacy
process-global statics.
Sourcepub fn module_binding_registry(&self) -> Arc<RwLock<ModuleBindingRegistry>> ⓘ
pub fn module_binding_registry(&self) -> Arc<RwLock<ModuleBindingRegistry>> ⓘ
Get the module-binding registry shared with VM/JIT execution.
Sourcepub fn get_or_init_core_stdlib_cache<T, F>(&self, init: F) -> Arc<T> ⓘ
pub fn get_or_init_core_stdlib_cache<T, F>(&self, init: F) -> Arc<T> ⓘ
Lazily initialize and return the core stdlib cache payload.
shape-runtime cannot name BytecodeProgram, so the payload is
stored type-erased. Callers in shape-vm pass a closure that
produces an Arc<T> (typically Arc<Result<BytecodeProgram>>);
on read the returned Arc<dyn Any> is downcast back to Arc<T>.
Panics if a subsequent call requests a different concrete T on
the same Runtime — the cache is single-typed per runtime.
Sourcepub fn add_module_path(&mut self, path: PathBuf)
pub fn add_module_path(&mut self, path: PathBuf)
Add a module search path for imports
This is useful when executing scripts - add the script’s directory to the module search paths for resolution.
Sourcepub fn set_keychain(&mut self, keychain: Keychain)
pub fn set_keychain(&mut self, keychain: Keychain)
Set the keychain for module signature verification.
Propagates to the module loader so it can verify module signatures at load time.
Sourcepub fn set_blob_store(&mut self, store: Arc<dyn BlobStore>)
pub fn set_blob_store(&mut self, store: Arc<dyn BlobStore>)
Set the blob store for content-addressed function blobs.
Propagates to the module loader so it can lazily fetch blobs not found in inline caches.
Sourcepub fn set_project_root(&mut self, root: &Path, extra_paths: &[PathBuf])
pub fn set_project_root(&mut self, root: &Path, extra_paths: &[PathBuf])
Set the project root and prepend its configured module paths
Sourcepub fn set_dependency_paths(&mut self, deps: HashMap<String, PathBuf>)
pub fn set_dependency_paths(&mut self, deps: HashMap<String, PathBuf>)
Set resolved dependency paths for the module loader
Sourcepub fn get_dependency_paths(&self) -> &HashMap<String, PathBuf>
pub fn get_dependency_paths(&self) -> &HashMap<String, PathBuf>
Get the resolved dependency paths from the module loader.
Sourcepub fn register_extension_module_artifacts(
&mut self,
modules: &[ParsedModuleSchema],
)
pub fn register_extension_module_artifacts( &mut self, modules: &[ParsedModuleSchema], )
Register extension-provided module artifacts into the unified module loader.
Sourcepub fn configured_module_loader(&self) -> ModuleLoader
pub fn configured_module_loader(&self) -> ModuleLoader
Build a fresh module loader with the same search/dependency settings.
This is used by external executors (VM/JIT) so import resolution stays aligned with runtime configuration.
Sourcepub fn load_core_stdlib_into_context(&mut self, data: &DataFrame) -> Result<()>
pub fn load_core_stdlib_into_context(&mut self, data: &DataFrame) -> Result<()>
Load std::core::* modules via the unified module loader and register them in runtime context.
This is the canonical stdlib bootstrap path used by the engine and CLI.
pub fn load_program( &mut self, program: &Program, data: &DataFrame, ) -> Result<()>
Sourcepub fn execute_query(
&mut self,
query: &Item,
data: &DataFrame,
) -> Result<QueryResult>
pub fn execute_query( &mut self, query: &Item, data: &DataFrame, ) -> Result<QueryResult>
Execute a query item against a data frame.
In the strict-typed runtime the AST-walking query evaluator has been
removed (see docs/defections.md 2026-05-06: AST-evaluation runtime
executors deletion). The replacement is “compile to bytecode, execute
in VM”, which is the responsibility of the rebuild workstream
ast-walking-interpreter-strict-rebuild. Until that lands this entry
point returns an empty QueryResult so existing callers keep linking.
Sourcepub fn format_value(
&mut self,
_value: WireValue,
type_name: &str,
format_name: Option<&str>,
_param_overrides: HashMap<String, WireValue>,
) -> Result<String>
pub fn format_value( &mut self, _value: WireValue, type_name: &str, format_name: Option<&str>, _param_overrides: HashMap<String, WireValue>, ) -> Result<String>
Format a value using Shape format definitions from stdlib
Currently a placeholder until VM-based format execution is implemented.
Sourcepub fn set_debug_mode(&mut self, enabled: bool)
pub fn set_debug_mode(&mut self, enabled: bool)
Enable or disable debug mode.
When enabled, the runtime produces verbose tracing output via tracing
and enables any debug-only code paths in the executor.
Sourcepub fn debug_mode(&self) -> bool
pub fn debug_mode(&self) -> bool
Query whether debug mode is active.
Sourcepub fn set_execution_timeout(&mut self, timeout: Duration)
pub fn set_execution_timeout(&mut self, timeout: Duration)
Set the maximum wall-clock duration for a single execution.
The executor can periodically check elapsed time against this limit and abort with a timeout error if exceeded.
Sourcepub fn execution_timeout(&self) -> Option<Duration>
pub fn execution_timeout(&self) -> Option<Duration>
Query the configured execution timeout, if any.
Sourcepub fn set_memory_limit(&mut self, limit: usize)
pub fn set_memory_limit(&mut self, limit: usize)
Set a memory limit (in bytes) for the runtime.
Allocation tracking can reference this value to decide when to refuse new allocations or trigger garbage collection.
Sourcepub fn memory_limit(&self) -> Option<usize>
pub fn memory_limit(&self) -> Option<usize>
Query the configured memory limit, if any.