Expose loop transfers through versioned public observations
This commit is contained in:
1 parent
69c5dc8d20
commit
71d29261a8
21 files changed
+486
-35
No files matched your search
@@ -1047,6 +1047,25 @@ impl Host for StdHost {
|
||||
false,
|
||||
)
|
||||
}
|
||||
RuntimeObservation::LoopTransfer {
|
||||
frame_id,
|
||||
transfer,
|
||||
module_id,
|
||||
span,
|
||||
} => {
|
||||
let Some(frame_id) = frame_id else {
|
||||
return Ok(());
|
||||
};
|
||||
self.emit_observation(
|
||||
ObservationEvent::LoopTransfer {
|
||||
frame_id,
|
||||
transfer,
|
||||
module_id,
|
||||
span,
|
||||
},
|
||||
false,
|
||||
)
|
||||
}
|
||||
RuntimeObservation::VariableAssigned {
|
||||
frame_id,
|
||||
name,
|
||||
|
||||
@@ -30,7 +30,7 @@ pub use handles::{contains_plugin_handle, PluginHandleTable};
|
||||
pub use host::{arity, expect_text, Host, HostOp, StdHost};
|
||||
pub use marqdo_sandbox::{PlatformCapabilities, SandboxMode, StrictIsolation};
|
||||
pub use observe::{
|
||||
encode_value, estimate_event_bytes, FrameId, ObservationConfig, ObservationError,
|
||||
encode_value, estimate_event_bytes, FrameId, LoopTransfer, ObservationConfig, ObservationError,
|
||||
ObservationEvent, ObservationSink, ObservedValue, ParameterSource, RuntimeObservation,
|
||||
ValueState, DEFAULT_MAX_OBSERVATION_BYTES, DEFAULT_MAX_OBSERVATION_EVENTS,
|
||||
DEFAULT_MAX_VALUE_BYTES, MAX_STREAM_CHUNK_BYTES,
|
||||
|
||||
@@ -193,6 +193,13 @@ pub enum ObservationEvent<'a> {
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// An explicit loop control statement executed.
|
||||
LoopTransfer {
|
||||
frame_id: FrameId,
|
||||
transfer: LoopTransfer,
|
||||
module_id: &'a str,
|
||||
span: Span,
|
||||
},
|
||||
/// The host completed a controlled effect attempt.
|
||||
Effect {
|
||||
operation: &'a str,
|
||||
@@ -230,6 +237,25 @@ pub enum ObservationEvent<'a> {
|
||||
},
|
||||
}
|
||||
|
||||
/// The action carried by a structured loop transfer observation.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum LoopTransfer {
|
||||
/// Exit the enclosing loop.
|
||||
Break,
|
||||
/// Proceed to the enclosing loop's next condition check.
|
||||
Continue,
|
||||
}
|
||||
|
||||
impl LoopTransfer {
|
||||
/// The event kind in Trace and Execution Events.
|
||||
pub fn event_kind(self) -> &'static str {
|
||||
match self {
|
||||
Self::Break => "control.break",
|
||||
Self::Continue => "control.continue",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Borrowed runtime notification accepted by [`crate::Host::observe_runtime`].
|
||||
///
|
||||
/// Every variant carries an `Option<FrameId>`; observation of values and
|
||||
@@ -257,6 +283,13 @@ pub enum RuntimeObservation<'a> {
|
||||
module_id: &'a str,
|
||||
span: Option<Span>,
|
||||
},
|
||||
/// An explicit loop control statement executed.
|
||||
LoopTransfer {
|
||||
frame_id: Option<FrameId>,
|
||||
transfer: LoopTransfer,
|
||||
module_id: &'a str,
|
||||
span: Span,
|
||||
},
|
||||
/// A local variable assignment committed.
|
||||
VariableAssigned {
|
||||
frame_id: Option<FrameId>,
|
||||
@@ -498,6 +531,7 @@ pub fn estimate_event_bytes(event: &ObservationEvent<'_>) -> u64 {
|
||||
}
|
||||
ObservationEvent::BranchEval { module_id, .. }
|
||||
| ObservationEvent::LoopIteration { module_id, .. }
|
||||
| ObservationEvent::LoopTransfer { module_id, .. }
|
||||
| ObservationEvent::Effect { module_id, .. } => {
|
||||
add_text(module_id);
|
||||
if let ObservationEvent::LoopIteration { decision, .. } = event {
|
||||
|
||||
Reference in new issue
Block a user