pub enum TurnEvent {
FunctionCall {
function_name: String,
args: CallArgs,
call_id: u32,
object_id: Option<MontyUuid>,
allow_eager_await: bool,
position: SourceRange,
},
OsCall {
function_name: String,
args: CallArgs,
call_id: u32,
allow_eager_await: bool,
system_sleep: Option<Duration>,
position: SourceRange,
},
NameLookup {
name: String,
object_id: Option<MontyUuid>,
position: SourceRange,
},
ResolveFutures {
pending_call_ids: Vec<u32>,
position: SourceRange,
},
Complete(MontyObject),
}Expand description
How a protocol turn ended: a suspension that needs an answer from the caller, or completion of the fed snippet.
Variants§
FunctionCall
The sandbox called an external function — answer with
Checkout::resume. When object_id is set this is a method call on
a host-backed object, routed by uuid — a class instance, or a class
type (a classmethod call, or construction of a host class, which is
spelled __call__); the receiver is NOT included in args.
Fields
allow_eager_await: boolCoroutine results may be awaited and returned via Checkout::resume_futures.
position: SourceRangeWhere the call expression is in the source.
OsCall
The sandbox performed an OS operation (e.g. "Path.read_text").
Answer it from this feed’s mounts with
Checkout::resume_from_mounts, or directly with
Checkout::resume. A caller with no handler should resume with
ResumeValue::NotHandled; the sandbox then raises the call’s own
no-handler default.
Answer host imports from the caller’s modules before other handlers.
OsFunctionCall::Import takes a module value; NotFound / NotHandled raise
ModuleNotFoundError. OsFunctionCall::ImportStubs takes a dict of dotted
module paths to .pyi source or None, or NotHandled for no stubs.
Fields
allow_eager_await: boolAs on FunctionCall: the caller may await
the wait and answer with Checkout::resume_futures. Only set on
a call OsFunctionCall::accepts_future allows a future for.
system_sleep: Option<Duration>Wait this duration, then return MontyObject::none() (as a future for asyncio.sleep).
The parent caps the untrusted worker’s delay and charges max_total_sleep before returning it.
None delegates to the caller’s OS handler.
position: SourceRangeWhere the call expression is in the source.
NameLookup
The sandbox read an undefined name, or — when object_id is set — a
lazy attribute on the host-backed object with that uuid (a class
instance, or a class type) — answer with
Checkout::resume_name_lookup. An Undefined (or None) answer
raises NameError for plain lookups, AttributeError for attribute
lookups; an Error answer raises the host’s exception in the sandbox.
Fields
position: SourceRangeWhere the name (or attribute access) is in the source.
ResolveFutures
Every sandbox task is blocked on external futures — answer with
Checkout::resume_futures.
Fields
position: SourceRangeWhere the main task’s blocked await is in the source.
Complete(MontyObject)
The fed snippet completed with this value; the session is ready for
the next Checkout::feed.