pub struct Vm {
pub state: ShellState,
pub steps: u64,
pub limits: ExecutionLimits,
pub output_bytes: u64,
pub budget: BudgetTracker,
pub diagnostics: Vec<DiagnosticEvent>,
pub stdout: Vec<u8>,
pub stderr: Vec<u8>,
/* private fields */
}Expand description
The shell virtual machine.
Fields§
§state: ShellStateShell state (variables, params, cwd, etc.).
steps: u64Number of steps executed so far.
limits: ExecutionLimitsExecution limits.
output_bytes: u64Bytes of output produced so far.
budget: BudgetTrackerShared budget accounting and stable stop reasons.
diagnostics: Vec<DiagnosticEvent>Collected diagnostic events.
stdout: Vec<u8>Collected stdout output from command execution.
stderr: Vec<u8>Collected stderr output from command execution.
Implementations§
Source§impl Vm
impl Vm
Sourcepub fn new(state: ShellState, step_budget: u64) -> Self
pub fn new(state: ShellState, step_budget: u64) -> Self
Create a new VM with the given state and limits.
Sourcepub fn with_limits(state: ShellState, limits: ExecutionLimits) -> Self
pub fn with_limits(state: ShellState, limits: ExecutionLimits) -> Self
Create a VM with full execution limits.
Sourcepub fn emit_diagnostic(
&mut self,
level: DiagLevel,
category: DiagCategory,
message: String,
)
pub fn emit_diagnostic( &mut self, level: DiagLevel, category: DiagCategory, message: String, )
Emit a diagnostic event.
pub fn stop_reason(&self) -> Option<&StopReason>
Sourcepub fn track_output(&mut self, bytes: u64) -> bool
pub fn track_output(&mut self, bytes: u64) -> bool
Track output bytes and check the limit. Returns true if within limits.
Sourcepub fn write_stdout(&mut self, data: &[u8])
pub fn write_stdout(&mut self, data: &[u8])
Append stdout bytes and update output accounting.
Sourcepub fn write_stderr(&mut self, data: &[u8])
pub fn write_stderr(&mut self, data: &[u8])
Append stderr bytes and update output accounting.
Sourcepub fn write_streams(&mut self, stdout: &[u8], stderr: &[u8])
pub fn write_streams(&mut self, stdout: &[u8], stderr: &[u8])
Append both stdout and stderr bytes and update output accounting once.
Sourcepub fn check_output_limit(&mut self) -> Result<(), StepResult>
pub fn check_output_limit(&mut self) -> Result<(), StepResult>
Check whether the accumulated output has exceeded the configured limit.
Sourcepub fn begin_step(&mut self) -> Result<(), StepResult>
pub fn begin_step(&mut self) -> Result<(), StepResult>
Consume one execution step using the VM’s shared budget/cancel semantics.
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
Get the cancellation token (can be cloned and shared).
Sourcepub fn run(&mut self, program: &IrProgram) -> StepResult
pub fn run(&mut self, program: &IrProgram) -> StepResult
Execute an IR program to completion (or until yield/cancel).