From c0ce96ea67b0a55e59b17baebfab4577570e541b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 30 Oct 2026 01:25:40 -0700 Subject: [PATCH 1/6] chore(quest): claim quest/m2/miri-memory.md Quest-Claim: 5899c8af5f57410d From 4c88192bd0a326f95bb6595423a6101a32c40025 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 30 Oct 2026 02:58:28 -0700 Subject: [PATCH 2/6] test(rs): run kio and moq-net's in-memory unsafe under Miri nightly `just rs miri` runs kio's unit tests and moq-net's frame, group, and path tests under Miri through nextest, in two passes: Stacked Borrows with the leak check, and Tree Borrows without it for the tests that reach crossbeam-epoch's global collector. Nightly runs it as a Tests job. Co-Authored-By: Claude Opus 5.5 --- .config/nextest.toml | 9 +++++++ .github/workflows/nightly.yml | 5 ++++ quest/m2/README.md | 1 - quest/m2/miri-memory.md | 36 --------------------------- quest/m2/wire-fuzz-coverage.md | 2 +- rs/justfile | 8 ++++++ rs/kio/src/log.rs | 6 +++-- rs/kio/src/waiter.rs | 5 +++- rs/moq-net/AGENTS.md | 1 + rs/moq-net/src/model/frame.rs | 19 +++++++++++--- rs/moq-net/src/model/group.rs | 3 ++- rs/moq-net/src/path/mod.rs | 5 ++-- sh/rs/miri.sh | 45 ++++++++++++++++++++++++++++++++++ 13 files changed, 97 insertions(+), 48 deletions(-) delete mode 100644 quest/m2/miri-memory.md create mode 100755 sh/rs/miri.sh diff --git a/.config/nextest.toml b/.config/nextest.toml index eb336ae8e40..31ff300959d 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -53,3 +53,12 @@ slow-timeout = { period = "60s", terminate-after = 2 } retries = 0 # Repeat each failure at the end of the run, so it isn't buried in the log. failure-output = "immediate-final" + +# `just rs miri` interprets every instruction, orders of magnitude slower than +# native, so a test that takes a second here takes minutes there. The cap still +# turns a lost wakeup into a TIMEOUT; keep a test under it by shrinking its +# workload under `cfg(miri)`, as with the native ceiling above. +[profile.miri] +slow-timeout = { period = "300s", terminate-after = 3 } +retries = 0 +failure-output = "immediate-final" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 81c3d164218..a861c59952e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -368,6 +368,10 @@ jobs: include: - recipe: rs send-depth nightly: true + # Miri interprets kio's and moq-net's in-memory unsafe; too slow for the merge gate. + - recipe: rs miri + nightly: true + components: miri steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -384,6 +388,7 @@ jobs: uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable with: toolchain: nightly + components: ${{ matrix.components }} - name: Add a second IPv6 loopback address if: matrix.recipe == 'rs uring' # moq-uring's local address test reaches a wildcard socket on it. diff --git a/quest/m2/README.md b/quest/m2/README.md index f6d54a23242..01a54c9f93c 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -23,7 +23,6 @@ lite-07; bitrate enforcement is not part of this release. - [Release execution](/quest/m2/release/README.md) - publication, installed-artifact proof, cleanup, and downstream adoption after m1 - [Untrusted media parsers have fuzz targets](/quest/m2/media-fuzz.md) - fMP4, MKV, FLV, TS, Annex-B, catalog, and AMF0 parsing fuzzed with a bounded-work invariant - [Wire fuzz coverage](/quest/m2/wire-fuzz-coverage.md) - the audited moq-net decoders have targets that assert an invariant, and the unsafe peer input reaches runs under Miri -- [In-memory unsafe runs under Miri](/quest/m2/miri-memory.md) - kio's and moq-net's memory-only unsafe runs under a nightly Miri job - [VA-API renderer tests](/quest/m2/vaapi-render-tests.md) - the VA-API renderer, decode, and transcode tests run in `just rs gpu` on AMD and Intel and fail instead of skipping, and hosted CI reports them ignored - [Every opt-in test target has a CI caller](/quest/m2/test-inventory.md) - the merge gate flags ignored tests, fuzz and bench targets, recipes, and scripts no workflow runs - [Workflow and dependency security linting](/quest/m2/workflow-security.md) - zizmor gates workflow changes, and Nightly audits Go and Python dependencies diff --git a/quest/m2/miri-memory.md b/quest/m2/miri-memory.md deleted file mode 100644 index dff1868cc15..00000000000 --- a/quest/m2/miri-memory.md +++ /dev/null @@ -1,36 +0,0 @@ -# [M] In-memory unsafe runs under Miri - -## Goal - -The hand-written unsafe in `kio` and `moq-net` that touches only memory (no -sockets, GPU, or FFI) runs under Miri nightly, so a use-after-free, data race, -or aliasing violation fails a test instead of waiting for Loom or production. - -## Plan - -From the 2026-10-27 coverage audit. No Miri job exists anywhere in the repo. -[Wire fuzz coverage](/quest/m2/wire-fuzz-coverage.md) covers the -peer-reachable unsafe in `moq-c`, `moq-uring`, and `moq-sock`; this quest -covers the in-memory primitives it leaves out. `kio` has 33 `unsafe` sites -and `moq-net` 21 (2026-10-27), and Loom flagged concurrent `UnsafeCell` -access in kio's `a_log_reader_racing_eviction_never_touches_freed_memory` -that night, so start with kio's log and channels. - -Decided 2026-10-27 (maintainer): - -- Nightly only, never the merge gate: Miri is orders of magnitude slower than - native tests. -- Run kio's unit tests whole, and the `moq-net` tests that reach its unsafe, - selected by filter. Skip a test Miri cannot run (foreign calls, real - sockets, wall-clock time) with `#[cfg_attr(miri, ignore = "...")]` naming - why, not by narrowing the filter silently. -- Share one `just rs miri` recipe and nightly job with wire fuzz coverage: - whichever lands first creates it, the other adds crates. -- Fix what it finds at the cause. - -Public API: none. Wire: none. - -## Related - -- [Wire fuzz coverage](/quest/m2/wire-fuzz-coverage.md) - Miri for the peer-reachable unsafe -- [Nightly passes on main](/quest/m0/nightly/README.md) - the nightly this job joins diff --git a/quest/m2/wire-fuzz-coverage.md b/quest/m2/wire-fuzz-coverage.md index 2a3cf12d60c..9fb6878d2c5 100644 --- a/quest/m2/wire-fuzz-coverage.md +++ b/quest/m2/wire-fuzz-coverage.md @@ -18,7 +18,7 @@ Decided 2026-10-22 from the security audit, with the maintainer: - Add one target for a stream of frame headers, records, and payloads through the incremental ingest, asserting the declared sizes and the stream position stay consistent. - Add a target for request-stream framing. - Add seeds that approach a limit (`0xffff` and 64 MiB prefixes) so the rejection paths run. -- Add a Miri job for the crates whose unsafe is reachable from a peer, and a target for `moq-sock`'s cmsg walk and `moq-uring`'s `RecvMeta::parse`. Both walks must stop at a malformed length and keep what came before it. +- Add the crates whose unsafe is reachable from a peer to `just rs miri` (`sh/rs/miri.sh`), which Nightly already runs for `kio` and `moq-net`, and a target for `moq-sock`'s cmsg walk and `moq-uring`'s `RecvMeta::parse`. Both walks must stop at a malformed length and keep what came before it. - Wire every target and the Miri run into the nightly gate, and keep the merge-gate replay of committed regressions. The point is the invariant, not the coverage number: a target that only checks for a panic would miss the bugs this audit is about. diff --git a/rs/justfile b/rs/justfile index 6fe6122a0b9..8596eb9ae8b 100644 --- a/rs/justfile +++ b/rs/justfile @@ -337,6 +337,14 @@ loom *args: RUSTFLAGS="--cfg loom --cfg crossbeam_loom" cargo test --locked --release -p moq-net --test loom "$@" RUSTFLAGS="--cfg loom --cfg crossbeam_loom" cargo test --locked --release -p moq-net --test expiry-loom "$@" +# Needs nightly with the miri component; executes only in Nightly. See sh/rs/miri.sh +# for what runs and why it splits in two. + +# Run kio's and moq-net's hand-written in-memory unsafe under Miri. +[positional-arguments] +miri *args: + bash sh/rs/miri.sh "$@" + # Run the moq-quic simulation's random workloads from a fresh seed, printing the settings that replay it, then the bandwidth probe's acceptance suite. quic-sim: #!/usr/bin/env bash diff --git a/rs/kio/src/log.rs b/rs/kio/src/log.rs index 52443a1793d..3bf3988c245 100644 --- a/rs/kio/src/log.rs +++ b/rs/kio/src/log.rs @@ -851,6 +851,8 @@ mod test { /// it evicts behind them. #[test] fn concurrent_readers_see_every_entry() { + // Miri takes minutes over the full run; a tenth still evicts under the readers. + const ENTRIES: u64 = if cfg!(miri) { 1_000 } else { 10_000 }; let _collector = COLLECTOR.lock().unwrap(); let mut writer = Writer::new(0); let readers: Vec<_> = (0..4) @@ -859,7 +861,7 @@ mod test { std::thread::spawn(move || { let mut index = 0; let mut evicted = 0; - while index < 10_000 { + while index < ENTRIES { match reader.read().get(index) { Ok(Some(value)) => assert_eq!(*value, index), Ok(None) => { @@ -874,7 +876,7 @@ mod test { }) }) .collect(); - for i in 0..10_000u64 { + for i in 0..ENTRIES { writer.push(i); if i % 100 == 0 { writer.evict(i.saturating_sub(500)); diff --git a/rs/kio/src/waiter.rs b/rs/kio/src/waiter.rs index 1d26af18930..b3b90e004c8 100644 --- a/rs/kio/src/waiter.rs +++ b/rs/kio/src/waiter.rs @@ -575,8 +575,11 @@ mod tests { waiter.register(&mut list); } + // Miri takes over twenty minutes for the full run; a thousand rounds still far + // outnumber the bound. + let rounds = if cfg!(miri) { 1_000 } else { 100_000 }; let mut seed = 1u64; - for _ in 0..100_000 { + for _ in 0..rounds { seed = seed.wrapping_mul(6364136223846793005).wrapping_add(1442695040888963407); let i = (seed >> 33) as usize % LIVE; waiters[i] = Waiter::noop(); diff --git a/rs/moq-net/AGENTS.md b/rs/moq-net/AGENTS.md index 633d6ea0f17..a3edd14d233 100644 --- a/rs/moq-net/AGENTS.md +++ b/rs/moq-net/AGENTS.md @@ -18,3 +18,4 @@ The wire layer. Generic over the transport and media-agnostic: the relay never i - Tests never use tokio or the wall clock. Prefer a plain `#[test]` that polls with explicit instants; async bodies use `#[moq_clock::test]`, whose simulated time jumps only when every task is stalled. tokio is for the benches. - `just rs fuzz ` (one per file in `fuzz/fuzz_targets/`) needs nightly. The target bodies live in `src/fuzz.rs`; `fuzz/regressions//` replays under `just check`, so commit every crash input there. - `just rs loom` model-checks the concurrent handoffs. A hang is a lost wakeup, not a flake. +- `just rs miri` runs kio's and this crate's model tests under Miri, in Nightly (`sh/rs/miri.sh` lists them). A test Miri cannot run (foreign calls, sockets, the wall clock) carries `#[cfg_attr(miri, ignore = "...")]` naming why; a heavy workload shrinks under `cfg(miri)` instead. diff --git a/rs/moq-net/src/model/frame.rs b/rs/moq-net/src/model/frame.rs index 2b78458e3dd..497243e03e9 100644 --- a/rs/moq-net/src/model/frame.rs +++ b/rs/moq-net/src/model/frame.rs @@ -89,6 +89,17 @@ impl Frame { /// one, so a whole read of them never copies. pub(crate) const SEGMENT: usize = 1024 * 1024; +/// `len` test bytes counting up from `seed` modulo 251, a prime, so the pattern never +/// lines up with a [`SEGMENT`] and a segment out of place shows. Repeated rather than +/// generated byte by byte, which takes Miri minutes for a few segments. +#[cfg(test)] +pub(crate) fn pattern(seed: usize, len: usize) -> Vec { + let period: Vec = (0..251).map(|i| ((seed + i) % 251) as u8).collect(); + let mut bytes = period.repeat(len.div_ceil(period.len())); + bytes.truncate(len); + bytes +} + /// A completed frame's payload as its group stores it: one buffer, or the sealed /// segments of a frame larger than [`SEGMENT`] written in pieces. /// @@ -1680,7 +1691,7 @@ mod tests { #[test] fn a_conflicting_delivery_leaves_shared_content_and_progress_unchanged() { let size = SEGMENT + 8; - let payload: Vec<_> = (0..size).map(|i| (i % 251) as u8).collect(); + let payload = pattern(0, size); let a = FrameBuf::growing(size); a.append(&payload[..SEGMENT + 4]).unwrap(); let b = a.fork(); @@ -1725,7 +1736,7 @@ mod tests { fn simultaneous_deliveries_publish_one_segmented_payload() { const SIZE: usize = 2 * SEGMENT + 37; const ROUNDS: usize = 12; - let payload: Vec<_> = (0..SIZE).map(|i| (i % 251) as u8).collect(); + let payload = pattern(0, SIZE); for grow in [false, true] { let a = FrameBuf::with_growth(SIZE, grow); let b = a.fork(); @@ -1944,7 +1955,7 @@ mod tests { } }); - let payload: Vec = (0..SIZE).map(|i| (i % 251) as u8).collect(); + let payload = pattern(0, SIZE); for chunk in payload.chunks(1000) { buf.append(chunk).unwrap(); } @@ -1960,7 +1971,7 @@ mod tests { const SIZE: usize = 2 * SEGMENT + 100; // Straddles every segment boundary. const CHUNK: usize = 300_000; - let payload: Vec = (0..SIZE).map(|i| (i % 251) as u8).collect(); + let payload = pattern(0, SIZE); for grow in [false, true] { let buf = FrameBuf::with_growth(SIZE, grow); diff --git a/rs/moq-net/src/model/group.rs b/rs/moq-net/src/model/group.rs index 8acca9c11fc..978add1db8d 100644 --- a/rs/moq-net/src/model/group.rs +++ b/rs/moq-net/src/model/group.rs @@ -5114,6 +5114,7 @@ mod test { /// An explicit current timestamp is converted to the group's scale. #[test] + #[cfg_attr(miri, ignore = "reads the wall clock, which Miri's isolation refuses")] fn create_frame_converts_current_timestamp() { use crate::Timescale; @@ -5508,7 +5509,7 @@ mod test { let payloads: Vec = (0..Prefetch::CAP) .map(|i| match i % 2 { 0 => Bytes::from(vec![i as u8; 3]), - _ => Bytes::from((0..2 * frame::SEGMENT + 7).map(|b| (b + i) as u8).collect::>()), + _ => Bytes::from(frame::pattern(i, 2 * frame::SEGMENT + 7)), }) .collect(); for payload in &payloads { diff --git a/rs/moq-net/src/path/mod.rs b/rs/moq-net/src/path/mod.rs index 44d1050126e..2da24fa99d5 100644 --- a/rs/moq-net/src/path/mod.rs +++ b/rs/moq-net/src/path/mod.rs @@ -1065,8 +1065,9 @@ mod tests { #[test] #[should_panic(expected = "longer than")] fn test_from_static_too_long() { - let literal: &'static str = Box::leak("a".repeat(Path::MAX_BYTES + 1).into_boxed_str()); - Path::from_static(literal); + // A static rather than a leaked string, which Miri would report. + static LITERAL: [u8; Path::MAX_BYTES + 1] = [b'a'; Path::MAX_BYTES + 1]; + Path::from_static(std::str::from_utf8(&LITERAL).unwrap()); } #[test] diff --git a/sh/rs/miri.sh b/sh/rs/miri.sh new file mode 100755 index 00000000000..ab6611f5740 --- /dev/null +++ b/sh/rs/miri.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Run the hand-written in-memory unsafe under Miri: sh/rs/miri.sh [NEXTEST_ARGS...] +# +# Nightly only: Miri interprets every instruction, orders of magnitude slower than a +# native test, so the `miri` nextest profile gives each test longer. A test Miri cannot +# run (foreign calls, real sockets, the wall clock) carries +# `#[cfg_attr(miri, ignore = "...")]` rather than leaving a filter here. +# +# Two passes, by whether a test reaches crossbeam-epoch's global collector, which +# `kio::log` frees segments through: +# +# - strict: Stacked Borrows and the leak check. +# - epoch: Tree Borrows, because the collector's intrusive list breaks Stacked Borrows +# (https://github.com/crossbeam-rs/crossbeam/issues/545), and no leak check, because +# the global collector never runs at exit, so whatever it still holds then leaks. +set -euo pipefail + +cd "$(git rev-parse --show-toplevel)" + +if [[ "$(rustc --version)" == *-nightly* ]]; then + sysroot=$(rustc --print sysroot) +elif command -v rustup >/dev/null 2>&1; then + sysroot=$(rustup run nightly rustc --print sysroot) +else + echo "rs: nightly Rust is missing; select it or run rustup toolchain install nightly --component miri" >&2 + exit 1 +fi + +# Nix puts its pinned stable compiler first; cargo and rustc must both be nightly. +export PATH="$sysroot/bin:$PATH" +if ! cargo miri --version >/dev/null 2>&1; then + echo "rs: Miri is missing: rustup component add --toolchain nightly miri" >&2 + exit 1 +fi +rustc --version + +run() { + cargo miri nextest run --locked --profile miri --no-fail-fast "$@" +} + +run -p kio -p moq-net --lib \ + -E '(package(kio) & not test(/^log::/)) | (package(moq-net) & (test(/^model::frame::/) | test(/^path::/)))' "$@" + +MIRIFLAGS="${MIRIFLAGS:+$MIRIFLAGS }-Zmiri-tree-borrows -Zmiri-ignore-leaks" run -p kio -p moq-net --lib \ + -E '(package(kio) & test(/^log::/)) | (package(moq-net) & test(/^model::group::/))' "$@" From 4cf3c10ad48ebc8cef1a247c65348ea78f924b49 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 30 Oct 2026 23:14:33 -0700 Subject: [PATCH 3/6] fix(rs): intersect a caller's filterset with each Miri pass Nextest unions repeated `-E` filtersets, so `just rs miri -E ...` added tests to both passes instead of narrowing them, which could put crossbeam-epoch tests under the strict pass's Stacked Borrows. A narrowed run may also leave one pass empty, where nextest exits 4; allow that when the caller passed arguments, and fail only when neither pass ran a test. Co-Authored-By: Claude Opus 5.5 --- sh/rs/miri.sh | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/sh/rs/miri.sh b/sh/rs/miri.sh index ab6611f5740..d621bb5fff7 100755 --- a/sh/rs/miri.sh +++ b/sh/rs/miri.sh @@ -34,12 +34,45 @@ if ! cargo miri --version >/dev/null 2>&1; then fi rustc --version -run() { - cargo miri nextest run --locked --profile miri --no-fail-fast "$@" +# Nextest unions repeated filtersets, so a caller's `-E` would add tests to a pass +# rather than narrow it; intersect it with each pass's filter instead. +args=() +filters=() +while (($#)); do + case $1 in + --) args+=("$@"); break ;; + -E | --filterset) filters+=("${2:?$1 needs a filterset}"); shift 2 ;; + -E*) filters+=("${1#-E}"); shift ;; + --filterset=*) filters+=("${1#*=}"); shift ;; + *) args+=("$1"); shift ;; + esac +done +caller='all()' +if ((${#filters[@]})); then + caller=$(printf ' | (%s)' "${filters[@]}") + caller=${caller# | } +fi + +# Nextest exits 4 when a pass selects no tests. Without arguments that means a filter +# below went stale; with them, the caller may have narrowed the run to one pass. +ran=0 +pass() { + local status=0 + cargo miri nextest run --locked --profile miri --no-fail-fast -p kio -p moq-net --lib \ + -E "($1) & ($caller)" ${args[@]+"${args[@]}"} || status=$? + case $status in + 0) ran=1 ;; + 4) ((${#args[@]} + ${#filters[@]})) || exit 4 ;; + *) exit "$status" ;; + esac } -run -p kio -p moq-net --lib \ - -E '(package(kio) & not test(/^log::/)) | (package(moq-net) & (test(/^model::frame::/) | test(/^path::/)))' "$@" +pass '(package(kio) & not test(/^log::/)) | (package(moq-net) & (test(/^model::frame::/) | test(/^path::/)))' -MIRIFLAGS="${MIRIFLAGS:+$MIRIFLAGS }-Zmiri-tree-borrows -Zmiri-ignore-leaks" run -p kio -p moq-net --lib \ - -E '(package(kio) & test(/^log::/)) | (package(moq-net) & test(/^model::group::/))' "$@" +MIRIFLAGS="${MIRIFLAGS:+$MIRIFLAGS }-Zmiri-tree-borrows -Zmiri-ignore-leaks" \ + pass '(package(kio) & test(/^log::/)) | (package(moq-net) & test(/^model::group::/))' + +if ((!ran)); then + echo "rs: no test matched in either Miri pass" >&2 + exit 4 +fi From 7dd00539299c16773d68924f9177fe79d6f83b86 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 02:00:21 -0700 Subject: [PATCH 4/6] style(rs): format sh/rs/miri.sh with shfmt Co-Authored-By: Claude Opus 5.5 --- sh/rs/miri.sh | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/sh/rs/miri.sh b/sh/rs/miri.sh index d621bb5fff7..32cdbf903bb 100755 --- a/sh/rs/miri.sh +++ b/sh/rs/miri.sh @@ -40,11 +40,26 @@ args=() filters=() while (($#)); do case $1 in - --) args+=("$@"); break ;; - -E | --filterset) filters+=("${2:?$1 needs a filterset}"); shift 2 ;; - -E*) filters+=("${1#-E}"); shift ;; - --filterset=*) filters+=("${1#*=}"); shift ;; - *) args+=("$1"); shift ;; + --) + args+=("$@") + break + ;; + -E | --filterset) + filters+=("${2:?$1 needs a filterset}") + shift 2 + ;; + -E*) + filters+=("${1#-E}") + shift + ;; + --filterset=*) + filters+=("${1#*=}") + shift + ;; + *) + args+=("$1") + shift + ;; esac done caller='all()' @@ -61,9 +76,9 @@ pass() { cargo miri nextest run --locked --profile miri --no-fail-fast -p kio -p moq-net --lib \ -E "($1) & ($caller)" ${args[@]+"${args[@]}"} || status=$? case $status in - 0) ran=1 ;; - 4) ((${#args[@]} + ${#filters[@]})) || exit 4 ;; - *) exit "$status" ;; + 0) ran=1 ;; + 4) ((${#args[@]} + ${#filters[@]})) || exit 4 ;; + *) exit "$status" ;; esac } @@ -72,7 +87,7 @@ pass '(package(kio) & not test(/^log::/)) | (package(moq-net) & (test(/^model::f MIRIFLAGS="${MIRIFLAGS:+$MIRIFLAGS }-Zmiri-tree-borrows -Zmiri-ignore-leaks" \ pass '(package(kio) & test(/^log::/)) | (package(moq-net) & test(/^model::group::/))' -if ((!ran)); then +if ((! ran)); then echo "rs: no test matched in either Miri pass" >&2 exit 4 fi From ec518223d804fef034944c36e33b1391726501e0 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 02:41:42 -0700 Subject: [PATCH 5/6] test(moq-net): ignore the seven 32 MiB tail tests under Miri They fill MAX_CACHE_BYTES and hit the miri profile's 15-minute cap. AGENTS.md extends the convention: a full-size limit test that cannot finish under Miri is ignored with a reason. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/AGENTS.md | 2 +- rs/moq-net/src/model/group.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rs/moq-net/AGENTS.md b/rs/moq-net/AGENTS.md index 87f65052925..d874d72dab2 100644 --- a/rs/moq-net/AGENTS.md +++ b/rs/moq-net/AGENTS.md @@ -19,4 +19,4 @@ The wire layer. Generic over the transport and media-agnostic: the relay never i - Tests never use tokio or the wall clock. Prefer a plain `#[test]` that polls with explicit instants; async bodies use `#[moq_clock::test]`, whose simulated time jumps only when every task is stalled. tokio is for the benches. - `just rs fuzz ` (one per file in `fuzz/fuzz_targets/`) needs nightly. The target bodies live in `src/fuzz.rs`; `fuzz/regressions//` replays under `just check`, so commit every crash input there. - `just rs loom` model-checks the concurrent handoffs. A hang is a lost wakeup, not a flake. -- `just rs miri` runs kio's and this crate's model tests under Miri, in Nightly (`sh/rs/miri.sh` lists them). A test Miri cannot run (foreign calls, sockets, the wall clock) carries `#[cfg_attr(miri, ignore = "...")]` naming why; a heavy workload shrinks under `cfg(miri)` instead. +- `just rs miri` runs kio's and this crate's model tests under Miri, in Nightly (`sh/rs/miri.sh` lists them). A test Miri cannot run (foreign calls, sockets, the wall clock) carries `#[cfg_attr(miri, ignore = "...")]` naming why; a heavy workload shrinks under `cfg(miri)` instead. A test whose point is a full-size production limit (such as filling `MAX_CACHE_BYTES`) and which can't finish under the `miri` profile's 15-minute cap is ignored the same way, with the reason. diff --git a/rs/moq-net/src/model/group.rs b/rs/moq-net/src/model/group.rs index cb491e5f663..373517d90fe 100644 --- a/rs/moq-net/src/model/group.rs +++ b/rs/moq-net/src/model/group.rs @@ -4819,6 +4819,7 @@ mod test { /// A head's slots count against the live tail, so a head of empty frames that would /// take the group's slots past it is not adopted. #[test] + #[cfg_attr(miri, ignore = "fills the 32 MiB group tail, past Miri's 15-minute cap")] fn an_adopted_head_counts_its_slots() { let pool = cache::Pool::unbounded(); let cache = cache::Track::new(pool, Default::default(), kio::Weak::new()); @@ -5033,6 +5034,7 @@ mod test { /// A group grows past its live tail by shedding whole frames from its front: a reader /// that keeps up reads every frame, a late one gets `Evicted`, and nothing aborts. #[test] + #[cfg_attr(miri, ignore = "fills the 32 MiB group tail, past Miri's 15-minute cap")] #[cfg(feature = "async")] fn a_long_group_sheds_its_front() { let pool = cache::Pool::unbounded(); @@ -5068,6 +5070,7 @@ mod test { /// Empty frames still cost their slot, so a group of them sheds its front too. #[test] + #[cfg_attr(miri, ignore = "fills the 32 MiB group tail, past Miri's 15-minute cap")] fn empty_frames_shed_by_their_slots() { let mut producer = Info { sequence: 0 }.produce(); let slot = size_of::(); @@ -5084,6 +5087,7 @@ mod test { /// Batches of empty frames count their new slots too, so they shed the front as /// single writes do. #[test] + #[cfg_attr(miri, ignore = "fills the 32 MiB group tail, past Miri's 15-minute cap")] fn empty_frame_batches_shed_by_their_slots() { let mut producer = Info { sequence: 0 }.produce(); let count = 2 * MAX_CACHE_BYTES as usize / size_of::(); @@ -5325,6 +5329,7 @@ mod test { /// Frames a cursor already prefetched are its own, so shedding them from the group /// does not make `finished` report the cursor evicted. #[test] + #[cfg_attr(miri, ignore = "fills the 32 MiB group tail, past Miri's 15-minute cap")] #[cfg(feature = "async")] fn finished_counts_prefetched_frames_as_read() { let mut producer = Info { sequence: 0 }.produce(); @@ -6001,6 +6006,7 @@ mod test { /// front, and sheds its own front past the tail; a plain or raw reader that starts after /// frame 0 was shed gets `Evicted`. #[test] + #[cfg_attr(miri, ignore = "fills the 32 MiB group tail, past Miri's 15-minute cap")] #[cfg(feature = "async")] fn a_long_compressed_group_sheds_its_front() { let pool = cache::Pool::unbounded(); @@ -6047,6 +6053,7 @@ mod test { /// A batch of large frames that deflate to almost nothing stays within one tail of /// inflated bytes, and the copy sheds what the reader took past its tail. #[test] + #[cfg_attr(miri, ignore = "fills the 32 MiB group tail, past Miri's 15-minute cap")] #[cfg(feature = "async")] fn a_batch_of_large_compressible_frames_stays_in_the_tail() { let pool = cache::Pool::unbounded(); From e9945db493e7621a6348a986f241b933b322b445 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 1 Nov 2026 21:15:48 -0800 Subject: [PATCH 6/6] test(kio): fit main's new clock and channel tests under Miri Nightly 2026-10-22's Miri refuses two clock runtime tests under isolation: paused_runtimes_own_their_anchors re-runs itself in a fresh process (readlink of /proc/self/exe), and a_later_paused_runtime_does_not_skew_the_anchor reads the wall clock. Both are ignored under Miri with the reason. racing_publishes_and_closes_wake_every_waiter took 781 s under Miri, near the profile's 15-minute cap, so it shrinks to 1k steps there (34 s). Co-Authored-By: Claude Opus 5.5 --- rs/kio/src/channel.rs | 2 +- rs/kio/src/clock/runtime.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rs/kio/src/channel.rs b/rs/kio/src/channel.rs index ec9534c06db..ed2f57a0359 100644 --- a/rs/kio/src/channel.rs +++ b/rs/kio/src/channel.rs @@ -495,7 +495,7 @@ mod tests { #[test] fn racing_publishes_and_closes_wake_every_waiter() { const READERS: usize = 4; - const STEPS: u32 = 20_000; + const STEPS: u32 = if cfg!(miri) { 1_000 } else { 20_000 }; struct Unpark(std::thread::Thread); impl Wake for Unpark { diff --git a/rs/kio/src/clock/runtime.rs b/rs/kio/src/clock/runtime.rs index 0beec1e1403..37eb777174a 100644 --- a/rs/kio/src/clock/runtime.rs +++ b/rs/kio/src/clock/runtime.rs @@ -284,6 +284,7 @@ mod tests { /// A paused runtime counting from its own origin anchors on its own clock, not /// on one another runtime advanced. #[test] + #[cfg_attr(miri, ignore = "re-runs itself in a fresh process, which Miri cannot spawn")] fn paused_runtimes_own_their_anchors() { // A fresh process keeps other tests from taking the shared origin first. if !test_env::Env::default().set("MOQ_CLOCK_TEST_ORIGIN", "fresh").isolate() { @@ -316,6 +317,7 @@ mod tests { /// A paused runtime sharing the origin cannot skew the anchor of unpaused /// callers by advancing its clock before the anchor is first taken. #[test] + #[cfg_attr(miri, ignore = "reads the wall clock, which Miri's isolation refuses")] fn a_later_paused_runtime_does_not_skew_the_anchor() { let _ = crate::clock::now(); // Built after the origin, so it counts from the shared origin.