Skip to main content

DecisionRecorder

Trait DecisionRecorder 

Source
pub trait DecisionRecorder: Send + Sync {
    // Required methods
    fn begin_call(
        &self,
        caller: &str,
        capability: &str,
        line: Option<SourceLine>,
    ) -> CallTicket;
    fn mark_last_filtered(&self);
    fn wants_line(&self) -> bool;
    fn note_line_capture(&self, frames: usize);
    fn enter_host_call(&self) -> u64;
    fn exit_host_call(&self, marker: u64, returned: bool);
    fn call_payload(&self, call_index: u64, side: Side, payload: Payload<'_>);
    fn call_usage(&self, call_index: u64, usage: ModelUsage);

    // Provided method
    fn wants_payload(&self, _call_index: u64) -> bool { ... }
}
Expand description

The runtime’s side of a recorder: identity for each call. Record contents arrive through SecurityCheck::audit.

Required Methods§

Source

fn begin_call( &self, caller: &str, capability: &str, line: Option<SourceLine>, ) -> CallTicket

A new host call. line is the program line that led to it, when known.

Source

fn mark_last_filtered(&self)

Marks the latest call’s record as a denial the host function treated as a filter.

Source

fn wants_line(&self) -> bool

Whether the next call’s source line would be kept. Callers check it before paying for a backtrace; it is false once the decision cap is reached, the byte budget cannot fit even a bare record, a record has been dropped whole for want of bytes, or the frame budget is exceeded. Other truncation (a payload drop, the pair cap) does not turn it off.

Source

fn note_line_capture(&self, frames: usize)

Counts the frames of a backtrace captured for a line. Past the recorder’s frame budget it marks the run truncated and stops further captures.

Source

fn enter_host_call(&self) -> u64

A host function that can begin calls was entered. Returns the marker its exit_host_call passes back.

Source

fn exit_host_call(&self, marker: u64, returned: bool)

That host function returned (returned) or failed. Ends every call begun since marker that is still open; a nested host function has ended its own already.

Source

fn call_payload(&self, call_index: u64, side: Side, payload: Payload<'_>)

One side of a call that reached outside the program.

Source

fn call_usage(&self, call_index: u64, usage: ModelUsage)

Token counts a model provider reported for a call.

Provided Methods§

Source

fn wants_payload(&self, _call_index: u64) -> bool

Whether a payload for the call call_index would be kept: the call is open and the payload budget is not spent. Callers check it before building a payload. The default asks for every payload.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§