Skip to main content

shape_elide

Function shape_elide 

Source
pub(crate) fn shape_elide(unit: &Unit<'_>, report: &Reporter<'_>) -> bool
Expand description

Run the elide guards for a shaper’s tail-drop, and say whether the unit may be discarded.

Overflow::DropTail is sound precisely because it discards the arriving unit at admission time, where framer.note_elided is still legal — the framer’s positional cursor has not moved past the object, so the successor’s delta fix-up can still be armed. That is the same place Action::Drop(DropMode::Elide) is judged, so it is judged by the same code: this function asks crate::capability::classify exactly what prepare_content asks it, and the three elide guards — WouldRedefineSubgroupId, WouldDestroyStatusObject, ReservedHeaderMode — apply unchanged.

§What a refusal means, and why it is reported

false means an elide guard refused, and the caller must admit the unit anyway — the queue overshoots its depth by one. A shaper may not corrupt a stream to honour a depth limit: eliding an object the framer cannot renumber around does not lose one object, it makes every successor decode with a wrong absolute ID on drafts 14-19.

The refusal is reported as an ordinary ProxyEvent::ActionRefused and bumps Counters::actions_refused, through the same Reporter::refused every other refusal takes. That is why any test asserting an exact drop count must assert actions_refused == 0 in the same body: without it, the arrivals-minus-drops arithmetic is off by the number of refusals and “no guard fired” is hoped rather than checked.

§Why this is not execute(.., Action::Drop(DropMode::Elide), ..)

Because no hook returned one. Routing a configured drop through execute would emit ActionApplied { action: DropElide } per dropped unit — a per-object event claiming a hook decision that never happened, on a path whose reporting is capped at once per stream per outcome. What the shaper owes the observer is ProxyEvent::Shaped, which the caller emits; what it owes on a refusal is the refusal, which is here.