1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
//! **Appendix B's two post-implementation validation obligations, run for
//! real — O53a (the ACK-loss-burst simulation) and O53b (the throughput
//! sanity check).**
//!
//! Both were written as *pre-ratification* gates: O53a says *"before
//! ratification hardens the fused choice"*, O53b *"before the §10.2
//! constants and `REASSEMBLY_CHUNKS_MAX` ratify"*. The wire ratified on
//! 2026/08/14 with neither run. **[Ruling 260]** re-scopes them from gates
//! on a decision already taken into **measured, pinned obligations**: the
//! numbers are taken here, recorded in the ruling, and left behind as
//! regression envelopes rather than as tight pins.
//!
//! # O53a — what is measured, and how
//!
//! The obligation: *"FlakyWire on the paused clock, sustained ACK-loss
//! bursts against the 2048-bit fused window under the every-2nd ACK
//! policy, quantifying spurious-retransmit and false-congestion-event
//! rates."*
//!
//! There is **no retransmit counter and no cwnd accessor** reachable from
//! an integration test — `congestion.rs`'s `cwnd`/`ssthresh` are
//! `pub(crate)` and `shell::Connection` exposes no stats verb — so both
//! rates are measured at the test level, from the fabric:
//!
//! * **Spurious-retransmit rate.** The transfer is one-way, A → B, and
//! **A's path never loses a datagram**. So B holds every byte that
//! leaves A the first time, and *every* forward datagram beyond the
//! loss-free minimum carries data the receiver already held. A baseline
//! run over an identical fabric with a loss-free return path supplies
//! that minimum empirically, which is tighter than deriving it from the
//! framing overhead. The rate is
//! `(fwd_burst − fwd_baseline) / fwd_burst`, in datagrams and in wire
//! bytes.
//!
//! * **False-congestion-event rate.** A cwnd collapse cannot be counted
//! without the accessor, so it is **inferred from virtual time**, and is
//! reported as an inference: the inflation
//! `elapsed_burst / elapsed_baseline`. Read it as an **upper bound** on
//! the false-congestion contribution, never as a count — the return path
//! of a one-way transfer carries ACKs *and* flow-control credit
//! (`MAX_DATA` / `MAX_STREAM_DATA`) in the same packets, so at a harsh
//! severity the sender is legitimately credit-starved as well as
//! feedback-starved, and a static 256 KiB window cannot open.
//!
//! The bursts are built with [`FlakyPolicy::drop_at`], which drops exactly
//! the named 0-based send indices with **no RNG involved**: [`BURSTS`]
//! consecutive return-path datagrams out of every [`PERIOD`], sustained
//! for the whole transfer. It is counter-proved — `FlakyWire::send_to`
//! writes the tap at step 4 and decides deliveries at step 5, so an index
//! the wire reached and the schedule names is an index that died. The
//! return path of a one-way transfer carries ACK-bearing packets (§12.4's
//! every-2nd ACK), so a burst on B's wire *is* an ACK-loss burst by
//! construction.
//!
//! ## What was measured, and what it says
//!
//! 2 MiB, 20 ms injected RTT, paused clock, seed `0x0053_A000`:
//!
//! | burst | ACK loss (counter-proved) | fwd datagrams | spurious (dgrams) | spurious (bytes) | virtual time | inflation |
//! |---|---|---|---|---|---|---|
//! | 0/8 (baseline) | 0.0 % (0 / 930) | 1838 | — | — | 310 ms | 1.000× |
//! | 2/8 | 25.1 % (234 / 933) | 1840 | 0.11 % | 0.04 % | 435 ms | 1.403× |
//! | 4/8 | 50.1 % (472 / 943) | 1846 | 0.43 % | 0.06 % | 924 ms | 2.981× |
//! | 6/8 | 75.1 % (750 / 999) | 1867 | **1.55 %** | 0.12 % | 10.386 s | 33.503× |
//!
//! **The numbers do not disappoint, and the mechanism is legible.** The
//! fused window is *cumulative*: `ack::derive` reads the replay window's
//! `ranges_desc()`, and on a lossless forward path that window is one
//! contiguous block, so `first_range = largest − start` covers every
//! counter ever received. Any **single** surviving ACK therefore carries
//! the receiver's complete state, and losing an ACK burst costs the sender
//! feedback *timing*, never feedback *information*. §19's range-tracker
//! ACK — the remedy the obligation held in reserve — is not needed.
//!
//! ## Working rule 9 — what the broken build scores
//!
//! *A bound is only a test if the degenerate case violates it.* The build
//! this obligation is really about is **a window that forgets ACKed
//! ranges**: an ACK that does not carry the cumulative range, so a packet
//! acknowledged only by a lost ACK is never acknowledged at all. One token
//! in `core::connection::ack::derive` produces it —
//! `first_range: largest - *first.start()` → `first_range: 0` — and it was
//! applied, measured, and reverted:
//!
//! | | fwd datagrams for 2 MiB | spurious vs the correct baseline | virtual time |
//! |---|---|---|---|
//! | correct build, **0 %** ACK loss | 1838 | — | 310 ms |
//! | forgetful ACK, **0 %** ACK loss | 3747 | **50.9 %** | 38.873 s (125×) |
//! | forgetful ACK, **25 %** ACK burst | — | — | **the connection dies**: `ConnectionLost(TimedOut)` |
//!
//! The broken build spends half its forward datagrams on data the receiver
//! already held *with no ACK loss at all*, and it cannot survive the
//! gentlest burst — §15's liveness timeout kills the connection before the
//! transfer finishes. [`SPURIOUS_CEILING`] sits two orders of magnitude
//! away from that.
//!
//! # O53b — what is pinned, and why it is machine-independent
//!
//! The obligation's original bar — *"within 20 % of quinn under its
//! shipped defaults"* — is not a bar a test can hold: it names a figure
//! from another crate on unstated hardware, and `benches/throughput.rs`
//! (ruling 247) is where slither's real throughput is measured. What can
//! be pinned, and is worth pinning, is the other half of the sentence:
//! **"with no stall"**.
//!
//! On tokio's paused clock virtual time advances *only* when the runtime
//! has nothing left to do but wait on a timer, so the same schedule
//! replays on every run and on every machine — the figure charges no
//! wall-clock work at all. Two bounds come out of that, and both are here:
//!
//! * **[`o53b_a_bulk_transfer_over_a_perfect_wire_never_waits_on_a_timer`]**
//! — over a zero-delay fabric the measured cost of 2 MiB is **0 ns of
//! virtual time**. Every microsecond on that clock would be a moment
//! some part of the stack sat on a deadline instead of making progress,
//! so the bound is *below the smallest timer in the stack*
//! (`K_GRANULARITY`, 1 ms): not one timer may fire. As a throughput
//! floor that is ≥ 2048 MiB/s of virtual-time throughput.
//! * **[`o53b_virtual_time_throughput_holds_its_floor`]** — over the
//! 20 ms-RTT fabric the transfer is window-limited and virtual time is
//! meaningful: 2 MiB in **310 ms**, i.e. **6.45 MiB/s**, against the
//! 12.5 MiB/s that `INITIAL_MAX_STREAM_DATA / RTT` predicts. The floor
//! is **half** the measured value.
//!
//! # Cost, and why O53a is a release-run test
//!
//! Measured on this commit, `--all-features`:
//!
//! | | debug | release |
//! |---|---|---|
//! | O53a (four 2 MiB transfers) | **9.1 s** | 0.3 s |
//! | both O53b tests | 0.8 s | < 0.1 s |
//!
//! The numbers are identical in both profiles — virtual time and datagram
//! counts do not depend on optimisation — so the debug run buys nothing
//! but 9.1 s on an ~18 s suite. Appendix B sanctions the alternative in as
//! many words: *"the production constant […] crossing once — **in the
//! release run if debug-slow**"* (ruling 251, the precedent
//! `tests/story_rekey.rs` set). O53a is therefore
//! `#[cfg_attr(debug_assertions, ignore)]` and runs under
//! `cargo test --release --all-features`, which every slice ends on. To
//! run it in debug anyway:
//!
//! ```text
//! cargo test --all-features --test spec_ack_burst -- --ignored
//! ```
//!
//! # Paused clock, never a sleep (§16.10)
//!
//! Every test here is `#[tokio::test(start_paused = true)]`. Virtual time
//! advances only where the fabric's injected delay and the protocol's own
//! timers ask it to.
//!
//! [`FlakyPolicy::drop_at`]: slither::testutil::FlakyPolicy::drop_at
use BTreeSet;
use SocketAddr;
use Duration;
use ;
use ;
use Instant;
// ══════════════════════════════════════════════════════════════════════
// SIZING
// ══════════════════════════════════════════════════════════════════════
/// Payload moved per run. Large enough that the 256 KiB stream window and
/// the 1 MiB connection window both cycle many times, so the measurement
/// is of the protocol in steady state rather than of the initial window.
const PAYLOAD: usize = 2 << 20;
/// One `write` call's size — well above the 1169-byte payload MTU, so the
/// send path does the framing rather than the test doing it by hand.
const CHUNK: usize = 64 << 10;
/// One-way fabric delay, i.e. a 20 ms RTT. Without an injected RTT the PTO
/// sits at its `K_GRANULARITY` floor and the congestion controller never
/// binds, so an ACK-loss experiment on a zero-delay fabric measures
/// nothing.
const ONE_WAY: Duration = from_millis;
/// Return-path datagrams per burst period.
const PERIOD: usize = 8;
/// The severities run, as consecutive drops out of every [`PERIOD`]:
/// 25 %, 50 % and 75 % ACK loss, in bursts rather than as a Bernoulli
/// sprinkle.
const BURSTS: = ;
/// **Ruling 260's envelope, and deliberately not a tight pin.**
///
/// The harshest burst (6/8, 75 % ACK loss) measured **1.55 %** of forward
/// datagrams spent on data the receiver already held. This is that figure
/// with the ×1.5 regression headroom the ruling specifies, rounded up:
/// 1.55 % × 1.5 = 2.33 %. It is a floor under a *regression*, not a claim
/// that 2.5 % is a meaningful boundary — see the module docs for what the
/// forgetful-ACK build scores (50.9 % at **zero** ACK loss, and death at
/// 25 %).
const SPURIOUS_CEILING: f64 = 0.025;
/// How far past the setup index the drop schedule is built. Comfortably
/// beyond the return-path send count of any run here (999 at the
/// harshest); a schedule that ran out mid-transfer would silently heal the
/// wire and understate every rate below.
const SCHEDULE: usize = 40_000;
// ══════════════════════════════════════════════════════════════════════
// THE HARNESS
// ══════════════════════════════════════════════════════════════════════
/// A payload whose bytes vary with offset, so nothing here can be
/// measuring a memset-friendly buffer, and so the reader can verify what
/// arrived against its absolute offset without holding the transfer in
/// memory.
/// `burst` consecutive drops at the head of every [`PERIOD`] sends,
/// starting at absolute send index `start`.
/// What one run of the transfer cost.
/// Move [`PAYLOAD`] bytes A → B over one uni stream, with `burst`
/// return-path datagrams dropped out of every [`PERIOD`] and `one_way` of
/// fabric delay in each direction.
///
/// `burst == 0` is the baseline: an identical fabric with a loss-free
/// return path, whose forward datagram count is the loss-free minimum
/// every other run is measured against.
async
// ══════════════════════════════════════════════════════════════════════
// O53a
// ══════════════════════════════════════════════════════════════════════
/// **Appendix B O53a, discharged.** Sustained ACK-loss bursts at 25 %,
/// 50 % and 75 % against the 2048-bit fused window under §12.4's every-2nd
/// ACK policy, on the paused clock, quantifying both rates the obligation
/// names.
///
/// The module docs carry the measured table and the broken build's score.
/// What is asserted here:
///
/// * **The bursts really bit.** Each severity's counter-proved ACK loss
/// must land within a point of nominal. Without this the spurious-rate
/// assertion below would pass for the wrong reason on a schedule that
/// ran out or a fixture that healed — working rule 9's degenerate case.
/// * **The envelope holds** at every severity: forward datagrams spent on
/// data the receiver already held stay under [`SPURIOUS_CEILING`].
/// * **The transfer completes and is byte-exact** at every severity — the
/// `transfer` harness asserts that per read. A build that stalls under
/// ACK loss fails on the 600 s virtual-time timeout rather than on a
/// rate.
async
// ══════════════════════════════════════════════════════════════════════
// O53b
// ══════════════════════════════════════════════════════════════════════
/// **Appendix B O53b's "with no stall", pinned.** 2 MiB over a perfect,
/// zero-delay `FlakyWire` costs **0 ns of virtual time**.
///
/// On the paused clock virtual time advances only when the runtime has
/// nothing left to do but wait on a timer, so this is not a speed
/// measurement — it is the statement that *no timer is on the critical
/// path of a bulk transfer*. The bound is set below `K_GRANULARITY`, the
/// smallest timer granularity in the stack (1 ms), so not one timer may
/// fire: a single delayed ACK would cost `MAX_ACK_DELAY` (25 ms) and a
/// single PTO more.
///
/// Deterministic and machine-independent because the paused clock replays
/// one schedule and charges no wall-clock work. Expressed as a throughput
/// floor it is ≥ 2 MiB / 1 ms = 2048 MiB/s of virtual-time throughput.
///
/// BROKEN BUILD: any regression that makes progress wait on a deadline —
/// a credit re-grant that arrives only on the ACK timer, a send path that
/// parks until the next PTO — spends virtual time here and fails, while
/// remaining invisible to every wall-clock benchmark on a fast machine.
async
/// **Appendix B O53b's throughput half, re-scoped.** The obligation's
/// original bar was *"within 20 % of quinn under its shipped defaults"* —
/// a figure from another crate on unstated hardware, which no test can
/// hold and which `benches/throughput.rs` (ruling 247) already answers
/// properly. What is pinned instead is **virtual-time throughput over a
/// 20 ms-RTT fabric**, where the transfer is window-limited and the clock
/// is deterministic.
///
/// Measured on ruling 260's commit: 2 MiB in **310 ms** of virtual time =
/// **6.45 MiB/s**, against the 12.5 MiB/s that
/// `INITIAL_MAX_STREAM_DATA / RTT` predicts for a static window. The floor
/// is **half** the measured value, per ruling 260.
///
/// BROKEN BUILD: one that halves the effective window, delays credit
/// re-grant by a round trip, or adds a round trip per window — each shows
/// up here as virtual time and nowhere else, because the wall clock on
/// this fabric is dominated by allocation in the fixture rather than by
/// the protocol's round trips.
async