pub struct AgentEvent {
pub run_id: i64,
pub step: u32,
pub kind: String,
pub child_run_id: Option<i64>,
pub detail: Option<String>,
pub tokens: Option<u64>,
pub remaining: Option<u64>,
}Expand description
One event in a tree of agents: a parent spawning a child, a spawn refused by the containment boundary, or a draw against the tree’s shared spend ceiling.
Together with each run’s parent_run_id these make the tree a reconstructable
graph — who spawned whom, what was refused, and what the tree spent — long
after the process that ran it has exited.
use io_harness::{AgentEvent, Store};
// The only audit of what each step drew against the tree's *shared* ceiling.
// A run's own token total does not show this: the ceiling is tree-wide, so
// what matters is how fast `remaining` is falling for everyone.
let events = store.agent_events(run_id)?;
let drawn: u64 = events.iter().filter_map(|e| e.tokens).sum();
let left = events.iter().filter_map(|e| e.remaining).last();
assert_eq!(drawn, 9_280);
// 720 left after three steps that averaged over 3,000: this tree ends in
// `BudgetCeilingReached` next step, and the row says so before it happens.
assert_eq!(left, Some(720));
// The same table carries the shape of the tree and what it was denied.
let children: Vec<i64> = events.iter().filter_map(|e| e.child_run_id).collect();
let refusals: Vec<&str> = events
.iter()
.filter(|e| e.kind == "spawn_refused")
.filter_map(|e| e.detail.as_deref())
.collect();
assert_eq!(children, [2]);
// A parent that wanted a second child and hit the agent cap — a run doing
// less work than it planned to, which is invisible in its outcome.
assert_eq!(refusals, ["agents"]);Fields§
§run_id: i64The agent this event belongs to (the parent, for a spawn; the drawing agent, for a budget draw).
step: u32The step it occurred on.
kind: String"spawn", "spawn_refused", or "budget_draw".
child_run_id: Option<i64>The spawned child’s run id, for a "spawn".
detail: Option<String>Free-form detail: the child’s goal for a spawn, the breached cap for a refusal.
tokens: Option<u64>Tokens drawn, for a "budget_draw".
remaining: Option<u64>The tree’s remaining tokens after the draw.
Implementations§
Trait Implementations§
Source§impl Clone for AgentEvent
impl Clone for AgentEvent
Source§fn clone(&self) -> AgentEvent
fn clone(&self) -> AgentEvent
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AgentEvent
impl Debug for AgentEvent
impl Eq for AgentEvent
Source§impl PartialEq for AgentEvent
impl PartialEq for AgentEvent
impl StructuralPartialEq for AgentEvent
Auto Trait Implementations§
impl Freeze for AgentEvent
impl RefUnwindSafe for AgentEvent
impl Send for AgentEvent
impl Sync for AgentEvent
impl Unpin for AgentEvent
impl UnsafeUnpin for AgentEvent
impl UnwindSafe for AgentEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.