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
impl DeliveryState
pub fn prune(&mut self, now: i64)
pub fn fallback_claimed(&self, block_id: &str, reason: Reason) -> bool
Sourcepub fn claim_fallback(
&mut self,
block_id: &str,
reason: Reason,
now: i64,
since: i64,
) -> FallbackClaim
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.
pub fn record_boundary(&mut self, uuid: &str, block_id: &str, now: i64)
Sourcepub fn claim_boundary(
&mut self,
block_id: &str,
reason: Reason,
boundary_uuid: Option<&str>,
now: i64,
) -> FallbackClaim
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.
Sourcepub fn claim_event(
&mut self,
block_id: &str,
reason: Reason,
event_at: i64,
now: i64,
) -> FallbackClaim
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.
Sourcepub fn park_compaction_notice(
&mut self,
block_id: &str,
created_ms: i64,
line: String,
) -> Option<String>
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.
Sourcepub fn take_parked(
&mut self,
block_id: &str,
created_ms: Option<i64>,
) -> Vec<String>
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).
Sourcepub fn note_completed(&mut self, key: &DeliveryKey, created_ms: i64)
pub fn note_completed(&mut self, key: &DeliveryKey, created_ms: i64)
The hook finished a delivery: its notice went out.
Sourcepub fn take_over_from_hook(&mut self, block_id: &str, reason: Reason, now: i64)
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
impl Default for DeliveryState
Source§fn default() -> DeliveryState
fn default() -> DeliveryState
Auto Trait Implementations§
impl !RefUnwindSafe for DeliveryState
impl !UnwindSafe for DeliveryState
impl Freeze for DeliveryState
impl Send for DeliveryState
impl Sync for DeliveryState
impl Unpin for DeliveryState
impl UnsafeUnpin for DeliveryState
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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> ⓘ
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