pub struct Delivery { /* private fields */ }Expand description
One event and, at a strong decision point, its exactly-once decision guard.
Most deliveries are ordinary transport: read the event
and move on. Three decision points are rendezvous the Run is blocked on, and
it does not proceed until this delivery is accepted or
rejected. Dropping one undecided rejects it.
Do not infer this from Event::kind.
AfterToolCommit can accompany either an
Audit or Error event, and either kind can
also be an ordinary delivery. Always call
decision_point for each delivery; that makes the
whole acceptance protocol one line:
if delivery.decision_point().is_some() {
delivery.accept()?;
}A consumer that means to refuse further work — a policy that says no, a host
shutting down — calls reject instead. At
ToolCall, rejection prevents tool-hook and executor
processing. At ToolResult or
AfterToolCommit, execution and commit have
already happened; rejection does not undo those facts and only prevents later
work.
Implementations§
Source§impl Delivery
impl Delivery
Sourcepub const fn decision_point(&self) -> Option<DecisionPoint>
pub const fn decision_point(&self) -> Option<DecisionPoint>
Returns the strong decision point, or None for ordinary transport delivery.
Sourcepub fn accept(&self) -> Result<(), DecisionError>
pub fn accept(&self) -> Result<(), DecisionError>
Accepts this strong boundary exactly once.
§Errors
DecisionError::NotRequiredif this is ordinary transport delivery rather than one of the three strong seams. Checkdecision_pointto tell them apart; nothing is owed for an ordinary delivery and nothing happens if it is dropped undecided.DecisionError::AlreadyDecidedif this delivery has already been decided, or if cancellation resolved it first. A cancelled Run’s deliveries report this even on a first call, because acceptance would authorize work the Run is already unwinding out of — so a consumer cannot treat this variant as “somebody else said yes”.
Either way the governed work does not proceed on this call’s authority, and the decision that did win is not displaced.
Sourcepub fn reject(&self) -> Result<(), DecisionError>
pub fn reject(&self) -> Result<(), DecisionError>
Rejects this strong boundary exactly once.
At DecisionPoint::ToolCall, rejection prevents subsequent tool-hook and
executor processing. At DecisionPoint::ToolResult or
DecisionPoint::AfterToolCommit, the tool has already executed and its
result has already been committed. Rejection does not undo those facts; it
only prevents later work.
§Errors
DecisionError::NotRequired if this is ordinary transport delivery, or
DecisionError::AlreadyDecided if a decision or a cancellation already
won — the same two conditions accept reports, for the
same reasons.
Neither is a reason to retry. NotRequired means no decision was owed;
AlreadyDecided means the winning decision remains in force, and this
error does not reveal whether it accepted, rejected, or cancelled the
boundary.
Trait Implementations§
Source§impl Debug for Delivery
impl Debug for Delivery
Source§fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
Shows the event, the decision point, and whether a decision is owed.
The decision guard is reported by presence rather than by state: reading its state would mean loading the very atomic whose exactly-once transition the guard exists to serialise, and a formatter has no business participating in that handshake.