Skip to main content

execute

Function execute 

Source
pub(crate) fn execute(
    unit: &Unit<'_>,
    action: Action,
    engine: &mut Engine<'_>,
    report: &Reporter<'_>,
) -> Outcome
Expand description

Execute one Action at one site.

Emits exactly one ProxyEvent::ActionApplied or exactly one ProxyEvent::ActionRefused, plus any impairment the decision produced, and returns the wire operation the caller must perform.

A refused unit is forwarded unchanged, through the same queue-or-write-now fork an admitted Pass takes — a refusal must not let a unit overtake one already waiting.

§Order of checks

  1. crate::capability::classify on the (site, kind) pair. The site’s own verdict comes first because it is the one the published table makes, and the table must win: Delay { then: ResetStream } at the datagram site is the datagram column’s WrongSite, not a composition complaint.
  2. Composition, for Action::Delay / Action::Hold, which is validated before the unit is queued so a bad composition never reaches the deque and never bumps egress_items_queued.
  3. The inner action, classified in its own right — Delay { then: ReplacePayload(b) } with the wrong length is Refusal::LengthChanged, reported against the inner kind, which is the informative one.
  4. The numeric code range, then the session-closing latch.

§A close is reported before it takes effect

Action::CloseSession is recorded in plan_action, but the session is cancelled only here, after its ActionApplied — or its SessionAlreadyClosing refusal — has gone out. Cancelling wakes the session’s other tasks on other worker threads, and they report the teardown they perform: a Site::StreamEnd decision on every stream the close cuts. Cancelled first, those reports could reach the observer before the close that caused them, and an observer reading in order would see a stream end for no reason and only then the close.