Skip to main content

TurnActivityTracker

Struct TurnActivityTracker 

Source
pub struct TurnActivityTracker { /* private fields */ }
Expand description

Per-block turn-activity tracker.

Implementations§

Source§

impl TurnActivityTracker

Source

pub fn new(block_id: String) -> Self

Source

pub fn for_block(block_id: String, broker: Option<&Arc<Broker>>) -> Self

A tracker that publishes its turn ledger on broker, when there is one.

Source

pub fn set_ledger_publisher(&self, publisher: TurnLedgerPublisher)

Where ledger changes go (the agentturn event). Set once by the controller that owns this tracker, when it has a broker.

Source

pub fn set_active_turn(&self, active: bool)

Called when a new turn starts (subprocess spawned).

Source

pub fn mark_turn_active_returning_was_active(&self) -> bool

Atomically marks a turn active and reports whether one was already in flight (the pre-call value) — a single lock acquisition, unlike calling is_active_turn() then set_active_turn(true) separately. That two-step form is a check-then-act race: send_message (user input) and send_user_message (muxbus delivery) can run concurrently on the same block, and both reading false before either writes true lets both decide to spawn a watchdog — the exact duplicate the “only re-arm when resuming from idle” logic exists to prevent.

Source

pub fn mark_turn_active_from(&self, input: Option<TurnInput>) -> bool

Self::mark_turn_active_returning_was_active, saying who delivered the input (turn provenance, SPEC_AGENT_SELF_QUIT §6.3):

  • starting a turn records input as what started it — or, unlabelled, whatever was queued for it (else unknown);
  • into a running turn, non-user input — or unlabelled input, which can’t be proven to be the user — taints it.
Source

pub fn note_cli_task_notification(&self, summary: Option<&str>)

The CLI reported a finished background task (system/task_notification). It tells the model in a pass it starts itself: at once if it is idle, straight after the running pass otherwise.

Source

pub fn mark_turn_active_from_cli(&self) -> bool

The CLI began a pass with no input from srv (system/init while idle). Marked active only when something explains it (a task notification, or input that reached it during the last pass), so a stray line can never leave the agent reported busy with nothing to end it. Returns whether the pass was marked (the caller then publishes status and re-arms the heartbeat).

Source

pub fn end_pass(&self, stats: Option<PassStats>)

The CLI’s result: the running pass is over. Its figures (when the frame carries them) go to the turn it belonged to in the same step as the idle flip, so input that arrives right after can’t take them.

Source

pub fn hint_join(&self, turn_id: u64)

A message the pane held while turn turn_id ran is about to be sent through a controller whose pass start carries no input (ACP, App Server, one-shot subprocess): the pass it starts joins that turn, as TurnInput::joins_turn does for the persistent controller (§4.3, J3).

Source

pub fn clear_join_hint(&self)

Drop a join hint whose dispatch failed: no pass will consume it, and a later message must not.

Source

pub fn set_exited(&self, exit_code: i32)

Called when the subprocess exits.

Source

pub fn set_turn_exited(&self, exit_code: i32, completed: bool)

The process of a one-shot turn (a container exec, a per-turn subprocess) exited, which is how every one of its turns ends. With completed (a clean exit and no failure) the turn is recorded as completed, not as a process that exited under it: the leader of a worker is told “stopped: its process exited” for the second, and a job follows it as interrupted.

Source

pub fn is_active_turn(&self) -> bool

Whether there’s an active turn in progress.

Source

pub fn hint_next_turn(&self, input: TurnInput)

A message queued now will start a later turn (it waits for the process to spawn). Two queued before that turn starts: the second, if not the user’s, taints it.

Source

pub fn hint_next_turn_unlabelled(&self)

An unlabelled message queued for the next turn: it can’t be proven to be the user, so a turn already labelled by an earlier queued message is tainted. (Queued first, it leaves the turn unknown anyway.)

Source

pub fn mark_turn_active_for_queued(&self) -> bool

The turn is active because messages already accounted for are being delivered — the queue drained after a spawn, a retry flush. Not new input: an idle tracker starts the turn with whatever was queued for it, and a running turn is left as it is (ReAgent P1 on #3789 — the plain unlabelled mark tainted every freshly spawned user turn).

Source

pub fn note_spawned(&self)

The agent’s process was spawned just now.

Source

pub fn note_output(&self)

The agent wrote output just now: a stdout line or a protocol frame.

Source

pub fn note_user_reply(&self)

The user’s answer to a parked question or permission request was delivered to the agent just now.

Source

pub fn last_user_reply_ms(&self) -> Option<i64>

When the user’s last answer to a parked request was delivered (unix ms).

Source

pub fn spawned_at_ms(&self) -> Option<i64>

When the agent’s process was last spawned (unix ms), if it has been.

Source

pub fn last_output_ms(&self) -> Option<i64>

When the agent last wrote output (unix ms), if it has.

Source

pub fn pass_started_ms(&self) -> Option<i64>

When the pass in flight started (unix ms); None between passes.

Source

pub fn provenance(&self) -> Option<TurnProvenance>

What started the turn in flight, if one is and it was reported.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more