Skip to content

ci: Rust tests run when a file they read outside rs changes - #9271

Merged
kixelated merged 3 commits into
mainfrom
quest/m0/ci/rust-test-reads
Nov 21, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m0/ci/rust-test-reads

Conversation

@kixelated

@kixelated kixelated commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/ci/rust-test-reads.md.

Problem

When a PR changed a file that a Rust test reads from outside rs/, the gate skipped that test. moq-dev/moq#8459 added a test/**.toml that broke moq-relay's repository_configs_load, and the gate had scoped Rust out. The rs scope in sh/dispatch.sh listed only the NixOS module, and sh/rs/select.sh mapped that one path to moq-relay by hand. Grepping found more reads the scope misses than the quest listed: moq-net's Bun scripts (test/interop/*.ts), moq-e2ee's vectors (drafts/moq-e2ee-01-wip.json), moq-mux's clock corpus, and the relay's packaged systemd unit.

Approach

  • New sh/rs/reads.sh lists every path a Rust source under rs/ reads outside its crate, as <crate dir> <glob> <file>:<line>, the last naming the literal behind the read. It counts three kinds of literal: an include_*! or #[path] literal (resolved from its file), and a literal that climbs out with ../ in a file that uses CARGO_MANIFEST_DIR (resolved from the crate). A format interpolation such as {name} counts as one path segment. A #[path] to a mod.rs covers its whole directory. It takes about 0.3 s, using only grep and jq.
  • sh/rs/select.sh seeds the reading crate whenever a changed path matches one of its reads, then walks to dependents as before. This replaces the hand-written NixOS seed and needs no list of reads to maintain. It also fixes an existing gap inside rs/: a change to rs/moq-net/benches/session/ used to select moq-net alone, although moq-relay's bench includes that module.
  • The rs scope in sh/dispatch.sh grows narrow patterns for the reads outside rs/: (demo/relay|packaging|test)/**.toml, the relay's unit, test/interop/*.ts, the five test/*/…ts scripts moq-tokio and moq-uring run, doc/concept/audio-jitter/**.json, and the e2ee vectors.
  • The check: SelectTest.test_dispatch_scope_covers_rust_reads in sh/rs/select.test.py probes each read outside rs/ against the scope. A plain read probes its file. A directory read probes a new file inside it. A glob probes a new file wherever a wildcard leaves room, such as test/added.toml and test/added/added.toml. On failure it names the crate and the path. just gh check, which gates every diff, runs it, so a new read fails in the PR that adds it. A read of the whole repository fails too.
  • Three reads were rewritten so the lister sees exactly what they read:
    • moq-relay's repository_configs_load lists :(glob)../../{demo/relay,packaging,test}/**/*.toml from its crate, where it used to list everything from the repo root.
    • moq-net's bun() takes a script stem and appends .ts.
    • moq-audio's corpus case() joins one {name}.json path.
  • No file moved into a crate. Every read lives where it does for another reason: the TS scripts are Bun programs that the JS side checks, the audio corpora are the docs' reference vectors, the e2ee vectors come from the draft and are shared with js/e2ee, and the configs and unit ship in packages.

Impact

No public API or wire change. CI only: the gate now runs Rust for changes to the paths above. Across main's last 1000 first-parent commits (2026-11-07 to 2026-11-20), 39 touched a widened path. 12 of those (1.2%) did not already select Rust, and #8459 is one of the 12. Those 12 run only the reading crate and its dependents, not the whole workspace. A change to test/interop/*.ts reaches moq-net and so selects almost all of it.

Alternatives

  • Sending every widened path to the whole workspace, as the quest's Plan expected. Seeding the crate that reads the path costs less and comes from the same list the check uses.
  • Deriving the dispatch scope from reads.sh at query time instead of checking a literal pattern. Rejected: the pattern can stay narrower than a read, for example .toml only under test/, and the maintainer's decision was to widen the scope and check it.
  • Skipped: reads that a TS script makes in turn, such as test/interop/*.ts importing js/net. The JS lane tests those packages.
  • Skipped: the Rust interop clients under test/interop/clients/rust/. They are moq-cli examples that only the interop harness runs.

Decisions

Made without asking, for review:

  • The reading crate plus its dependents is selected, not the whole workspace.
  • The nix-module seed now comes from reads.sh (the quest's recommendation).
  • The check runs in just gh check on every diff, which adds about 1 s.
  • A ../ literal in a file that mentions CARGO_MANIFEST_DIR still counts as a read file-wide, and reads.sh now prints each read's file:line, which the scope check's failure names, with a hint to keep a non-path literal out of such files. ✅ attribute file-wide reads (rejected: count only literals in the statement that mentions CARGO_MANIFEST_DIR, which would silently miss a read built across statements, as moq-relay's config test does today; rejected: drop reads that match no tracked file, which still keeps "../../.." and misses a glob that matches nothing yet). Answers Pullfrog's finding.

Caused by

  • No single PR. The rs scope never covered reads outside rs/ other than the NixOS module. The gap surfaced in moq-dev/moq#8459, and moq-dev/moq#8486 moved the fixture without fixing the scope.

Validation

  • test(audio-quality): grade steady-state lag, the player's own trims, and recovery from congestion #8459's shape, end to end. With an untracked test/added/relay.toml and nothing else changed, the old sh/dispatch.sh check HEAD --query printed rust=false and the new one prints rust=true. select.sh selects moq-relay (plus moq-cli). With a bogus key in that file, repository_configs_load fails.
  • The check fails before the fix. With test/ dropped from the new TOML pattern, it fails with rs/moq-relay reads test/**/*.toml, which sh/dispatch.sh's rs scope misses. With main's relay test restored, it fails with rs/moq-relay reads the whole repository. It passes on the branch.
  • select.sh on single paths: doc/concept/audio-jitter/outage.json selects moq-audio, test/interop/varint.ts selects moq-net, test/max-age/client.ts selects moq-tokio, and rs/moq-net/benches/session/added.rs selects moq-relay. test/interop/clients/js/added.ts, a doc reference.ts, and README.md select nothing. The new test_a_read_selects_its_reader covers the same cases.
  • python3 sh/rs/select.test.py (27 tests), python3 sh/dispatch-query.test.py (42), and sh/gh/test-inventory.py pass. cargo nextest run -p moq-net -p moq-relay --lib passes 3810 tests. The moq-audio jitter corpus tests and moq-net's Bun interop tests pass. shfmt, shellcheck, ruff, cargo fmt, and quest check are clean.
  • Not run: the full just ci. Changing sh/dispatch.sh turns it into the whole repository's suite, which the merge queue runs anyway.

Follow-ups

None.

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, low effort (iterate, M, arm B)

🤖 Generated with Claude Code

(Written by Claude Opus 5.5 with high effort)

Review

Rewritten by quest review after each round.

  • Head: 33c1158

  • Base: origin/main at 36a5c1a

  • Risk: medium, The Rust merge-gate selection changes could skip required checks or select unnecessary work for contributors building on main; the changes preserve published APIs and wire formats and are fully undone by a revert.

  • Classified: medium by Codex, gpt-6.1-sol, low effort, session 01a1fc7e-5263-7a63-8edf-7e96f67a9b11

  • Reviewer: Codex, gpt-6.1-sol, high effort

  • Session: 01a1fbb8-68c6-79d1-9a2d-0b0dd17f67f4, round 2

  • Score: 10/10, The incremental change adds source locations and updates both consumers consistently, with no actionable defects found by code inspection; builds and tests were not run as instructed.

  • Rounds: 2; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 2 commits November 20, 2026 17:13
sh/rs/reads.sh lists every path a Rust source reads outside its crate. select.sh
seeds the reading crate from it, replacing the hand-kept NixOS module seed, and
select.test.py holds dispatch's rs scope to cover every read outside rs/, run by
`just gh check` on every diff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Rust tests run when a file they read outside rs changes ci: Rust tests run when a file they read outside rs changes Nov 21, 2026
@kixelated
kixelated marked this pull request as ready for review November 21, 2026 01:31
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2576d574-80dc-4a7b-8dfd-b4e24c8f18cb
Commits

Reviewing files that changed from the base of the PR and between f839672 and 33c1158.

Files selected for processing: 10

  • .github/justfile
  • quest/m0/ci/rust-test-reads.md
  • rs/moq-audio/src/jitter.rs
  • rs/moq-net/src/ietf/publisher.rs
  • rs/moq-net/src/test_interop.rs
  • rs/moq-relay/src/config.rs
  • sh/dispatch.sh
  • sh/rs/reads.sh
  • sh/rs/select.sh
  • sh/rs/select.test.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one rough edge in the read lister's heuristic.

Approach: sound. It derives the crate-to-read mapping from the sources and uses it for both seeding and the scope check, so the hand-kept nix seed goes away and a new outside read fails just gh check in the PR that adds it.

Reviewed changes

I reviewed the full diff, ran sh/rs/reads.sh against the branch, checked the relay's new :(glob) listing, and ran sh/rs/select.test.py. The new tests pass. The three failures are from the sandbox: just is missing and clippy can't run.

  • sh/rs/reads.sh: lists outside-crate reads from include_*!, #[path], and ../ literals in files that mention CARGO_MANIFEST_DIR. Its output covers every read the PR description names.
  • sh/rs/select.sh: turns each read glob into a regex and seeds the reading crate when a changed path matches. This replaces the hard-coded nix/modules/moq-relay.nix seed and fixes the benches/session gap.
  • sh/dispatch.sh: the rs scope gains narrow patterns for the TOML configs, the relay unit, the Bun scripts, the jitter corpora, and the e2ee vectors.
  • sh/rs/select.test.py: test_dispatch_scope_covers_rust_reads probes each read outside rs/ against the scope, and test_a_read_selects_its_reader covers the seeds.
  • Rust literal rewrites: run from rs/moq-relay, git ls-files ':(glob)../../{demo/relay,packaging,test}/**/*.toml' returns the same 26 files the old root listing plus extension filter did. The bun() and case() rewrites don't change behavior.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread sh/rs/reads.sh Resolved
reads.sh prints each read's source file and line, so a `../` string that
is no path, in a file that mentions CARGO_MANIFEST_DIR, fails the scope
check with a message pointing at that literal. The file-wide rule stays:
narrowing it to one statement would miss a read built across statements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Since the last review, the read lister now records where each read comes from. I ran sh/rs/reads.sh on the branch, and every line ends in a plausible file:line, such as rs/moq-relay/src/config.rs:1115 for test/**/*.toml.

  • sh/rs/reads.sh names each read's source: it prints <crate dir> <glob> <file>:<line>, and a header comment explains why the CARGO_MANIFEST_DIR rule covers the whole file.
  • sh/rs/select.sh takes the glob as the second field: it parses the new three-field format and still keys only on crate and glob.
  • test_dispatch_scope_covers_rust_reads cites the source: both failure messages name the source line and say to keep a non-path ../ literal out of such files. This answers the earlier finding about false reads, and that thread is resolved.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 4874e86 Nov 21, 2026
5 checks passed
@kixelated
kixelated deleted the quest/m0/ci/rust-test-reads branch November 21, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant