pub struct ExecutionContext {
pub bindings: HashMap<String, RuntimeValue>,
pub has_errors: bool,
pub compute_steps: usize,
pub max_compute_steps: usize,
pub compute_quota_grant: u64,
pub supervisor_admission: Option<SystemSupervisorAdmission>,
/* private fields */
}Expand description
Execution context for document evaluation and capability permission gating.
Capability authorization lives strictly in the host (ExecutionContext). Historical
System-block graph pinning (Dc 641 "Global graph system block most recent node ID at time of document creation")
applies only to language and document semantics and never grants, restores, or modifies
host security permissions or capability policies.
Fields§
§bindings: HashMap<String, RuntimeValue>Active variable bindings.
has_errors: boolWhether the parsed document contains syntax or framing errors.
compute_steps: usizeCount of compute steps consumed.
max_compute_steps: usizeMaximum allowed compute steps before raising a budget interruption.
compute_quota_grant: u64Portable compute quota units granted each time Privilege::ExcessiveCompute
is approved with PermissionDecision::Allow.
supervisor_admission: Option<SystemSupervisorAdmission>Optional authenticated System supervisor admission metadata recorded in execution traces.
Implementations§
Source§impl ExecutionContext
impl ExecutionContext
Sourcepub fn new_execution_kernel(has_errors: bool) -> Result<Self>
pub fn new_execution_kernel(has_errors: bool) -> Result<Self>
Creates a new execution context authenticated against the bundled standalone execution
kernel (Dc 1936 "Dc document execution kernel").
§Errors
Returns an error if loading or authenticating the bundled System execution kernel fails.
Sourcepub fn new_workspace_supervisor(has_errors: bool) -> Result<Self>
pub fn new_workspace_supervisor(has_errors: bool) -> Result<Self>
Creates a new execution context authenticated against the bundled workspace supervisor
(Dc 1937 "Collective Toolbox Workspace").
§Errors
Returns an error if loading or authenticating the bundled workspace supervisor fails.
Sourcepub fn with_system_supervisor_admission(
self,
admission: SystemSupervisorAdmission,
) -> Self
pub fn with_system_supervisor_admission( self, admission: SystemSupervisorAdmission, ) -> Self
Builder-style method attaching an authenticated SystemSupervisorAdmission to this
execution context so all execution traces record the supervisor revision, dependency
snapshot, accounting version, and canonical configuration snapshot.
Sourcepub fn admit_system_supervisor(
&mut self,
seed_graph: &SeedGraphIndex,
bootstrap_tokens: &[DcShorthand],
user_limits: DcWasmResourceLimits,
watchdog: DcWasmWatchdogLimits,
) -> Result<&SystemSupervisorAdmission>
pub fn admit_system_supervisor( &mut self, seed_graph: &SeedGraphIndex, bootstrap_tokens: &[DcShorthand], user_limits: DcWasmResourceLimits, watchdog: DcWasmWatchdogLimits, ) -> Result<&SystemSupervisorAdmission>
Authenticates and admits the unpinned 1-Short-Dc System supervisor bootstrap document
from seed_graph and attaches it to this execution context.
§Errors
Returns an error if bootstrap_tokens is pinned, multi-token, non-Short-Dc, lacks
authenticated bundled System provenance, or specifies invalid resource limits.
Sourcepub const fn with_compute_quota_grant(self, grant: u64) -> Self
pub const fn with_compute_quota_grant(self, grant: u64) -> Self
Builder-style method configuring the portable compute quota grant added when
Privilege::ExcessiveCompute is approved with PermissionDecision::Allow.
Sourcepub fn set_privilege_decision(
&mut self,
privilege: Privilege,
decision: PermissionDecision,
)
pub fn set_privilege_decision( &mut self, privilege: Privilege, decision: PermissionDecision, )
Configures a host capability policy override for privilege.
Sourcepub fn with_privilege_decision(
self,
privilege: Privilege,
decision: PermissionDecision,
) -> Self
pub fn with_privilege_decision( self, privilege: Privilege, decision: PermissionDecision, ) -> Self
Builder-style method configuring a host capability policy override for privilege.
Sourcepub fn request_permission(&self, privilege: &Privilege) -> PermissionDecision
pub fn request_permission(&self, privilege: &Privilege) -> PermissionDecision
Evaluates a permission request against the current host policy, strongly steering
toward mocking or denying if has_errors is true.
Historical Dc 641 graph pins on documents or WASM sessions are intentionally
excluded from capability evaluation so historical pinning can never grant or restore
obsolete security permissions.
Sourcepub fn step(&mut self) -> Result<PermissionDecision, Error>
pub fn step(&mut self) -> Result<PermissionDecision, Error>
Increments compute step count, checking if the compute budget is
exhausted. If exhausted, raises a permission request for
Privilege::ExcessiveCompute.
Sourcepub fn execute_wasm_session_with_trace<F>(
&mut self,
session: &mut DcWasmSession,
input: &DcMstr,
capability_handler: F,
) -> Result<WasmExecutionTrace>
pub fn execute_wasm_session_with_trace<F>( &mut self, session: &mut DcWasmSession, input: &DcMstr, capability_handler: F, ) -> Result<WasmExecutionTrace>
Drives a [DcWasmSession] over input and records the full WasmExecutionTrace
(distinguishing logical document progress from physical VM resource interruptions and
non-resource guest traps).
Both physical VM resource interruptions and non-resource guest traps preserve all
accumulated frames and events in the returned WasmExecutionTrace so the finite
prefix can be inspected and deterministically replayed. Call
WasmExecutionTrace::ensure_not_denied to convert denied resource interruptions or
non-resource traps into Err.
§Errors
Returns an error if capability_handler fails.
Sourcepub fn execute_wasm_session_default_with_resolver_and_trace(
&mut self,
session: &mut DcWasmSession,
input: &DcMstr,
resolver: &dyn SyntaxRuleResolver,
) -> Result<WasmExecutionTrace>
pub fn execute_wasm_session_default_with_resolver_and_trace( &mut self, session: &mut DcWasmSession, input: &DcMstr, resolver: &dyn SyntaxRuleResolver, ) -> Result<WasmExecutionTrace>
Drives a [DcWasmSession] with the default capability response encoder
and pure Dc 1939/Dc 1940 capability dispatch against resolver.
§Errors
Returns an error if a non-resource capability handler fails.
Sourcepub fn execute_wasm_session_default_with_trace(
&mut self,
session: &mut DcWasmSession,
input: &DcMstr,
) -> Result<WasmExecutionTrace>
pub fn execute_wasm_session_default_with_trace( &mut self, session: &mut DcWasmSession, input: &DcMstr, ) -> Result<WasmExecutionTrace>
Drives a [DcWasmSession] with the default capability response encoder and returns
the full WasmExecutionTrace.
§Errors
Returns an error if the capability handler fails.
Sourcepub fn execute_dc_document_default_with_trace(
&mut self,
ordinary_doc: &DcMstr,
input: &DcMstr,
resolver: &dyn SyntaxRuleResolver,
) -> Result<WasmExecutionTrace>
pub fn execute_dc_document_default_with_trace( &mut self, ordinary_doc: &DcMstr, input: &DcMstr, resolver: &dyn SyntaxRuleResolver, ) -> Result<WasmExecutionTrace>
Compiles and executes an arbitrary ordinary Dc document ordinary_doc through the
Dc 1936 execution kernel pipeline ([Dc 1938 <pin> [Dc 2608 <quoted_doc>]]), sharing
one [ctb_formats_dcstring::converters::wasm::SharedWasmTaskQuota] across both
compilation (Dc 2608 + any graph converter routine) and target .WASM execution.
§Errors
Returns an error if ordinary_doc attempts privilege elevation, fails compilation/assembly,
or fails capability handling.
Sourcepub fn execute_ordinary_dc_wasm_default_with_trace(
&mut self,
ordinary_doc: &DcMstr,
input: &DcMstr,
most_recent_node_id: Option<u128>,
supervisor_entry_dc: DcChar,
) -> Result<WasmExecutionTrace>
pub fn execute_ordinary_dc_wasm_default_with_trace( &mut self, ordinary_doc: &DcMstr, input: &DcMstr, most_recent_node_id: Option<u128>, supervisor_entry_dc: DcChar, ) -> Result<WasmExecutionTrace>
Verifies that an ordinary Dc-WASM document does not attempt to elevate to System
supervisor privilege, then instantiates and executes it without granting supervisor
authority (even if the document carries a leading Dc 641 pin or references
supervisor_entry_dc).
§Errors
Returns an error if ordinary_doc attempts to claim supervisor privilege or fails
to assemble/instantiate.
Sourcepub fn replay_wasm_session_trace(
&mut self,
session: &mut DcWasmSession,
input: &DcMstr,
recorded_trace: &WasmExecutionTrace,
) -> Result<WasmExecutionTrace>
pub fn replay_wasm_session_trace( &mut self, session: &mut DcWasmSession, input: &DcMstr, recorded_trace: &WasmExecutionTrace, ) -> Result<WasmExecutionTrace>
Replays a [DcWasmSession] against a previously recorded WasmExecutionTrace:
- Verifies that the active accounting version and canonical resource configuration match.
- Compares every capability request (
PrivilegeandDcMstringrequest payload) emitted by the document at each logical step, then supplies the recorded allow/deny/mock response. - Actually executes
session.step()at every recorded resource interruption boundary and verifies that the module triggers the recordedWasmResourceInterruptionat the exact recordedlast_interrupted_op_ordinalandlast_interrupted_op_required_cost.
§Errors
Returns an error if the document’s capability requests, yielded frames, completion
output, or trap/interruption behavior diverge from recorded_trace.
Sourcepub fn execute_wasm_session<F>(
&mut self,
session: &mut DcWasmSession,
input: &DcMstr,
capability_handler: F,
) -> Result<WasmExecutionResult>
pub fn execute_wasm_session<F>( &mut self, session: &mut DcWasmSession, input: &DcMstr, capability_handler: F, ) -> Result<WasmExecutionResult>
Drives a [DcWasmSession] over input using the standard 32-byte linear-memory
mailbox ABI and step() -> StatusCode protocol:
0 = Complete: returnsWasmExecutionResultwith the finalDcMstringoutput.1 = YieldFrame: appends the yieldedDcMstringframe toframesand resumes.2 = RequestCapability: classifies the requestedPrivilege, evaluatesself.request_permission, invokescapability_handlerto produce the responseDcMstring, writes that response into the session’s input mailbox, and resumes.- If
self.step()orself.request_permissionreturnsPermissionDecision::BreakOutResumeNext, stops immediately withbroke_out_early: true.
Sourcepub fn execute_wasm_session_default(
&mut self,
session: &mut DcWasmSession,
input: &DcMstr,
) -> Result<WasmExecutionResult>
pub fn execute_wasm_session_default( &mut self, session: &mut DcWasmSession, input: &DcMstr, ) -> Result<WasmExecutionResult>
Drives a [DcWasmSession] with a default capability response encoder:
PermissionDecision::Allow->Dc 517 "Boolean true"PermissionDecision::AutoMock/PermissionDecision::ManualMock->Dc 316 "Optional value absent"PermissionDecision::Deny->Dc 518 "Boolean false"
Sourcepub fn execute_wasm_bytes_with_trace<F>(
&mut self,
wasm_bytes: &[u8],
input: &DcMstr,
most_recent_node_id: Option<u128>,
resource_limits: DcWasmResourceLimits,
capability_handler: F,
) -> Result<WasmExecutionTrace>
pub fn execute_wasm_bytes_with_trace<F>( &mut self, wasm_bytes: &[u8], input: &DcMstr, most_recent_node_id: Option<u128>, resource_limits: DcWasmResourceLimits, capability_handler: F, ) -> Result<WasmExecutionTrace>
Instantiates and executes compiled .wasm module bytes over input with explicit
[ctb_formats_dcstring::DcWasmResourceLimits], capturing construction-time resource
interruptions (initial memory/table limits or start compute_quota exhaustion) and
start-section non-resource traps in the returned WasmExecutionTrace.
§Errors
Returns an error if the module fails to parse or if capability_handler fails.
Sourcepub fn replay_wasm_bytes_trace(
&mut self,
wasm_bytes: &[u8],
input: &DcMstr,
most_recent_node_id: Option<u128>,
resource_limits: DcWasmResourceLimits,
recorded_trace: &WasmExecutionTrace,
) -> Result<WasmExecutionTrace>
pub fn replay_wasm_bytes_trace( &mut self, wasm_bytes: &[u8], input: &DcMstr, most_recent_node_id: Option<u128>, resource_limits: DcWasmResourceLimits, recorded_trace: &WasmExecutionTrace, ) -> Result<WasmExecutionTrace>
Replays compiled .wasm module bytes against a recorded WasmExecutionTrace,
actually instantiating and running the module to verify construction-time resource
interruptions, start-section non-resource traps, and provide_input / step events.
§Errors
Returns an error if replay diverges from recorded_trace.
Trait Implementations§
Source§impl Clone for ExecutionContext
impl Clone for ExecutionContext
Source§fn clone(&self) -> ExecutionContext
fn clone(&self) -> ExecutionContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExecutionContext
impl Debug for ExecutionContext
Source§impl Default for ExecutionContext
impl Default for ExecutionContext
Source§fn default() -> ExecutionContext
fn default() -> ExecutionContext
Auto Trait Implementations§
impl Freeze for ExecutionContext
impl RefUnwindSafe for ExecutionContext
impl Send for ExecutionContext
impl Sync for ExecutionContext
impl Unpin for ExecutionContext
impl UnwindSafe for ExecutionContext
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
fn exact_from(value: T) -> U
§impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
fn exact_into(self) -> U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);