pub async fn nothing_waiting_means_the_next_pull_is_empty<F: SyncFixture>(
open: impl AsyncFn() -> F,
) -> Result<RuleOutcome, Violation>Expand description
SY-37: a peer that answers a pull with [Waiting::Nothing] hands back
an empty batch on the next pull from the token that answer carried.
The rule writes two logs, each to a fresh peer from open:
- Cut by count: 257 single-event groups of a few bytes, pushed at
most [
PeerLimits::max_batch_events] to a push, so a peer that pages at any event count up to 256 shows a page boundary. - Cut by bytes: single-event groups whose payloads are sized from
the declared limits so [
PeerLimits::max_batch_bytes] ends a page before the event count does, one group past that page, pushed one event to a push so the pull alone draws the boundary. Written only where the bytes do cut first, and the log fits in 257 groups and 64 MiB.
On each it follows the peer’s tokens from the start, and on the first
Nothing pulls once more from that token. That pull must be empty. A
peer that never says Nothing passes: it costs its runner the empty
pull, and never a missed event.
A log the peer refuses to take is not built, and shows no page. Whose
failure the refusal is depends on the log. The byte-cut log goes one
event to a push, each sized from [PeerLimits::max_event_bytes] and no
larger than SY-18’s boundary event, so refusing it is SY-18’s subject,
and peer_declares_its_own_limits judges it; a peer that overstates
only max_batch_bytes takes it. The count-cut log is tiny events, at
most max_batch_events to a push, so refusing it is a lie about the
batch limits, which that rule says it does not judge and
peer_takes_a_batch_at_its_declared_limits judges.
If neither log showed a second non-empty page, the rule could not have
failed the peer, and it reports a skip rather than a pass: naming
LOG_REFUSED if the peer refused a log, with
COUNT_LOG_REFUSED_REASON or BYTE_LOG_REFUSED_REASON saying which
(the count-cut one if both), and NO_SECOND_PAGE if it took every log
the rule wrote and one pull carried each. The two need opposite fixes: a
push that honours the declared limits, and narrower limits. One log that
paged is enough for the rule to have run, so a refusal of the other is
not reported over it.
The bound on pulls — one more than the log has groups — is the suite’s liveness guard, not SY-37’s claim: a peer that ignores its token and keeps handing back groups is reported here, and fails SY-1’s and SY-2’s rules too.
§Rejects
A peer that says Nothing because its page ran out rather than its log
— the natural slip for an adapter that reports “this page is the last
one I fetched” — so a runner that believes it stops short and the rest
of the log waits for the next wake. tests/wrong_peers.rs carries two:
a peer that says Nothing on every pull, which the count-cut log
catches, and one that says it whenever a page carried fewer events than
max_batch_events, which only the byte-cut log can catch.
§Does not reject
A wrong [Waiting::Events] count: it is advisory, and checking it would
need a snapshot of the far side the port does not offer. Nor a peer
that says Nothing while stalled behind a group too large for any pull:
SY-37 forbids it, but a conformant push cannot put such a group on the
far side, so the rule cannot build the case. Nor a peer whose single
pull carries all of both logs, which it reports as a skip; the caps
bound the work against a peer that declares huge limits (H-13), at that
price.
§Errors
A Violation of SY-37 if the peer refuses a pull, keeps handing back
groups past the log the rule wrote, or hands back events on the pull
after it said nothing was waiting.