Implements the single side-effect boundary from blueprint sections 7.3 and 9: - Capabilities: console/math, project-relative fs globs, net hosts, process, foreign, plugins; pure/project defaults deny external I/O and grants are explicit, checked at execution time (never at parse time). - Budget: evaluation fuel, call-stack depth, program output bytes and a wall-clock deadline, all reported as resource.exhausted. - EffectTrace: op/module/span/duration/result entries with no secret data. - StdHost: canonical Host implementation dispatching print, fs read/write and the math/foreign kernels; all errors are structured RuntimeErrors, including a permission.denied path with a grant hint. - ProjectFs: project-rooted, rejects absolute paths, `..` traversal and symlink escapes outside the root; bounded UTF-8 reads and safe writes. - Math adapter: parse/eval/substitute through marqdo-math with exact rational binding conversion and explicit unsupported-operation errors. - Foreign adapter: capability-gated one-shot run/call through marqdo-foreign, typed wire input, structured result map, timeout/output limits mapped to budget errors.
32 lines
824 B
Rust
32 lines
824 B
Rust
//! Per-call execution context passed to the host boundary.
|
|
|
|
use marqdo_span::Span;
|
|
|
|
/// Context attached to every host invocation.
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct ExecutionContext {
|
|
/// Canonical module that initiated the operation.
|
|
pub module_id: String,
|
|
/// Source span of the call site, when known.
|
|
pub span: Option<Span>,
|
|
/// Correlates trace entries belonging to one run.
|
|
pub trace_id: u64,
|
|
}
|
|
|
|
impl ExecutionContext {
|
|
/// Create a context.
|
|
pub fn new(module_id: impl Into<String>, span: Option<Span>) -> Self {
|
|
Self {
|
|
module_id: module_id.into(),
|
|
span,
|
|
trace_id: 0,
|
|
}
|
|
}
|
|
|
|
/// Set the trace id.
|
|
pub fn with_trace_id(mut self, trace_id: u64) -> Self {
|
|
self.trace_id = trace_id;
|
|
self
|
|
}
|
|
}
|