Skip to main content

DeliveryState

Struct DeliveryState 

Source
pub struct DeliveryState {
    pub deliveries: HashMap<DeliveryKey, Delivery>,
    pub fallback_claims: HashMap<(String, Reason), i64>,
    pub fallbacks: HashMap<String, FallbackDelivery>,
    pub boundary_origins: VecDeque<(String, String, i64)>,
    pub completed: HashMap<(String, Reason), i64>,
    pub compose_gates: HashMap<DeliveryKey, Arc<Mutex<()>>>,
    pub composed_nothing: HashMap<DeliveryKey, i64>,
    pub parked: HashMap<String, Vec<(i64, String)>>,
}
Expand description

Deliveries and fallback claims, behind one lock so “who claimed this event first” is decided atomically.

Fields§

§deliveries: HashMap<DeliveryKey, Delivery>§fallback_claims: HashMap<(String, Reason), i64>

Events the frontend’s hidden-reinjection fallback claimed: (block, reason) → when.

§fallbacks: HashMap<String, FallbackDelivery>

Re-deliveries srv composed for the frontend’s fallback, by delivery_id, until the hidden message that sends one arrives.

§boundary_origins: VecDeque<(String, String, i64)>

Which block’s CLI wrote each compaction boundary, and when: (uuid, block, ms), oldest first.

§completed: HashMap<(String, Reason), i64>

The newest hook delivery each (block, reason) finished: when it was composed. Unlike deliveries it isn’t pruned, so a fallback deferred behind a long turn still finds it. One entry per block and reason.

§compose_gates: HashMap<DeliveryKey, Arc<Mutex<()>>>

One gate per delivery being composed. The 8 parts of a session start ask at once; the first composes while the rest wait here and then read its result, instead of each reading the memory and composing it again.

§composed_nothing: HashMap<DeliveryKey, i64>

Session starts that composed to nothing (no memory to deliver), by the time they did: the parts that ask after the first answer from here, instead of each reading the memory again to find it still empty.

§parked: HashMap<String, Vec<(i64, String)>>

A compaction’s notice that finished before this block’s stdout showed the boundary (the CLI runs its SessionStart hooks first): block → (delivery composed at, notice line). The stdout reader writes them after the boundary and its summary ([take_parked_notices]); a timer writes any left after PARKED_NOTICE_WAIT (SPEC_CONTEXT_DELIVERY_2026_09_30.md §9 C2).

Implementations§

Source§

impl DeliveryState

Source

pub fn prune(&mut self, now: i64)

Source

pub fn fallback_claimed(&self, block_id: &str, reason: Reason) -> bool

Source

pub fn claim_fallback( &mut self, block_id: &str, reason: Reason, now: i64, since: i64, ) -> FallbackClaim

The fallback’s atomic claim on an event. A Deliver for an unclaimed event records the claim, so the hook’s parts for it come back empty. Hook deliveries created at or before since belong to an earlier event.

Source

pub fn record_boundary(&mut self, uuid: &str, block_id: &str, now: i64)

Source

pub fn claim_boundary( &mut self, block_id: &str, reason: Reason, boundary_uuid: Option<&str>, now: i64, ) -> FallbackClaim

A claim naming its compaction boundary. Only the block whose own CLI wrote the boundary may deliver: another block of the agent reads it from the shared transcript zone, and its CLI did not compact. A boundary no stdout here wrote (another srv instance’s) is not this block’s either. A hook delivery from before the block’s previous boundary was that compaction’s, not this one’s.

Dated by when this srv read the boundary, like Self::claim_event: a hook delivery finished after it is this compaction’s however late the claim comes, so a pane that reads the boundary minutes later (a reconnect, a remount reading the gap) doesn’t deliver the memory twice (SPEC_CONTEXT_DELIVERY_2026_09_30.md §9 B2). The hook’s first part can reach srv before the stdout reader sees the boundary, hence the slack.

Source

pub fn claim_event( &mut self, block_id: &str, reason: Reason, event_at: i64, now: i64, ) -> FallbackClaim

A claim dated by its event: a fresh session, at its agentmux_session_outcome frame’s timestamp (srv’s own clock). A hook delivery composed after the event and finished is that event’s however long ago, so a fallback deferred behind the session’s first turn stands down even past CLAIM_WINDOW_MS. One from before it was an earlier session’s and doesn’t count.

Source

pub fn park_compaction_notice( &mut self, block_id: &str, created_ms: i64, line: String, ) -> Option<String>

Holds a compaction’s notice until this block’s stdout shows the boundary, so the card lands under “Context compacted”, not above it. Some(line) when the boundary was already written: write it now. A boundary from up to EVENT_SLACK_MS before the delivery was composed counts, as the hook can be asked just before the reader sees the line.

Source

pub fn take_parked( &mut self, block_id: &str, created_ms: Option<i64>, ) -> Vec<String>

The notices parked for block_id, oldest first, taken once. With created_ms, only that delivery’s (the timer’s own).

Source

pub fn note_completed(&mut self, key: &DeliveryKey, created_ms: i64)

The hook finished a delivery: its notice went out.

Source

pub fn take_over_from_hook(&mut self, block_id: &str, reason: Reason, now: i64)

The fallback gave up waiting for the hook: it delivers, and the hook’s unfinished delivery is closed so a late acknowledgement adds no second notice.

Trait Implementations§

Source§

impl Default for DeliveryState

Source§

fn default() -> DeliveryState

Returns the “default value” for a type. Read more

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> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

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