From d6be52db2fb3b5e223742eeef6d306274ce5f3a0 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 21 Oct 2026 22:03:24 -0700 Subject: [PATCH 01/11] chore(quest): claim quest/m0/ci/local-gate.md Quest-Claim: 6de0347a3ba6e29d From ee0fe0898f3445d068c526675f0901b0d99d6746 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 21 Oct 2026 22:34:18 -0700 Subject: [PATCH 02/11] ci: share local check capacity across worktrees Co-Authored-By: GPT-6 --- .github/justfile | 3 +- README.md | 13 +++++ bench/README.md | 18 +++++++ bench/local.py | 82 ++++++++++++++++++++++++++++++ js/justfile | 2 +- justfile | 5 ++ py/justfile | 6 +-- quest/m0/ci/local-gate.md | 44 +++++++++------- rs/justfile | 70 +++++++++++++------------- sh/coverage.test.py | 4 +- sh/cpp/check.sh | 4 ++ sh/dart/check.sh | 4 ++ sh/dispatch-query.test.py | 4 +- sh/dispatch.sh | 8 +-- sh/go/check.sh | 4 ++ sh/js/workspace.py | 6 ++- sh/js/workspace.test.py | 4 +- sh/kt/check.sh | 4 ++ sh/local.sh | 19 +++++++ sh/local.test.py | 98 ++++++++++++++++++++++++++++++++++++ sh/local.ts | 18 +++++++ sh/obs/compile.sh | 4 ++ sh/obs/test.sh | 4 ++ sh/obs/unit.sh | 4 ++ sh/rs/c-tests.sh | 4 ++ sh/rs/gpu.sh | 4 ++ sh/rs/media-features.sh | 4 ++ sh/rs/net-features.sh | 4 ++ sh/rs/nextest.sh | 2 +- sh/rs/select.sh | 7 ++- sh/rs/select.test.py | 4 +- sh/rs/test-lints.test.py | 2 + sh/rs/tokio-features.sh | 4 ++ sh/swift/check.sh | 4 ++ sh/swift/simulator.sh | 4 ++ test/audio-quality/record.sh | 4 ++ test/audio-quality/run.sh | 4 ++ test/drain/run.sh | 4 ++ test/interop/compat.sh | 4 ++ test/interop/interop.sh | 4 ++ test/justfile | 10 ++-- test/native-play/run.sh | 4 ++ test/portrait/run.sh | 4 ++ test/ts/eit-roundtrip.sh | 4 ++ test/ts/run.sh | 4 ++ test/wasm/run.sh | 4 ++ 46 files changed, 447 insertions(+), 78 deletions(-) create mode 100644 bench/local.py create mode 100755 sh/local.sh create mode 100644 sh/local.test.py create mode 100644 sh/local.ts diff --git a/.github/justfile b/.github/justfile index b9fb18921b5..a73ec7efb32 100644 --- a/.github/justfile +++ b/.github/justfile @@ -2,7 +2,7 @@ set working-directory := '..' # Build and test the persistent NixOS runner VM on x86_64 Linux. runner-vm: - nix build --no-link .#checks.x86_64-linux.github-runner-vm .#checks.x86_64-linux.github-runner-vm-image .#checks.x86_64-linux.github-runner-vm-config --print-build-logs + bash sh/local.sh nix build --no-link .#checks.x86_64-linux.github-runner-vm .#checks.x86_64-linux.github-runner-vm-image .#checks.x86_64-linux.github-runner-vm-config --print-build-logs # Lint GitHub Actions workflows, their alert coverage, and that every step runs a recipe. check: @@ -14,6 +14,7 @@ check: # Tests of repository tooling; nightly, not on every pull request. test: + python3 sh/local.test.py python3 sh/coverage.test.py python3 sh/size/report.test.py python3 sh/size/release.test.py diff --git a/README.md b/README.md index 2465e66cb3c..5e7a78c7f2e 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,19 @@ just check --all just fix --all ``` +Expensive checks and test launchers automatically enter `quest gate` locally, +including direct language recipes and fixture scripts. Admission waits for host +CPU load and available memory before builds or test timeout clocks start; +nested checks reuse that admission. Hosted GitHub Actions keeps its runner +scheduling. Rust builds still use the dev shell's mbx Cargo shim. + +Local nextest runs default to at most four test workers; set +`NEXTEST_TEST_THREADS` to override it. Bun workspace scripts run sequentially +locally, preserving dependency order, while CI keeps its workspace parallelism. +Selection and an empty JS selection do not wait for admission. For a build +outside these entrypoints, use `quest gate COMMAND [ARGS...]`; gate thresholds +come from the host and have no configuration. + PRs into `main` get no cloud CI until the merge queue, so run `just ci` before pushing. It runs what the queue runs, the same ground as `just check`, plus two settings: `MOQ_STRICT=1`, which turns a missing tool into an error instead of a skipped check, and `NEXTEST_PROFILE=ci`, which allows a longer hang timeout. See the [development guide](https://doc.moq.dev/setup/dev) and the [justfile](justfile) for more. diff --git a/bench/README.md b/bench/README.md index dba26aa731b..c91e565776c 100644 --- a/bench/README.md +++ b/bench/README.md @@ -423,3 +423,21 @@ within a source; dimensions belong in the name. Supported units are `ns`, `us`, and context. Validate and split sources into cost and throughput histories with `just gh benchmark-report prepare INPUT_DIRECTORY OUTPUT_DIRECTORY`; extending the table requires no new renderer or data branch. + +## Local check capacity + +Prepare the same warm dependencies and artifacts in each isolated checkout, then +compare solo and concurrent suites with their actual worker counts: + +```bash +just bench-local --checkout "$PWD" --checkout /path/to/another/checkout \ + --workers 1 4 8 24 --samples 3 --cache warm -- \ + cargo nextest run --locked -p moq-net --lib +``` + +Each JSON record retains host load, configured workers, admission delay, work +wall time, total wall time, and child CPU time. Logs stay under each checkout's +`.scratch/local-bench/`. To compare Bun workspace fanout, repeat with the same +`bun run --filter=... test` command, then add `--sequential`. Admission remains +outside the suite's timeout clocks. Use separate checkouts to avoid measuring +Cargo's artifact lock instead of competing work. diff --git a/bench/local.py b/bench/local.py new file mode 100644 index 00000000000..21588b3655e --- /dev/null +++ b/bench/local.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 +"""Compare suite fanout across isolated checkouts, separating admission from work.""" + +import argparse +import json +import os +from pathlib import Path +import subprocess +import signal +import sys +import time +import uuid + + +ROOT = Path(__file__).resolve().parents[1] + + +def main(): + if sys.argv[1:2] == ["--started"]: + started = time.monotonic() + result = subprocess.run(sys.argv[3:]) + Path(sys.argv[2]).write_text(json.dumps({"start": started, "end": time.monotonic()})) + sys.exit(result.returncode) + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--checkout", action="append", type=Path, required=True) + parser.add_argument("--workers", nargs="+", type=int, required=True) + parser.add_argument("--samples", type=int, default=3) + parser.add_argument("--cache", required=True, help="Describe the prepared cache state") + parser.add_argument("command", nargs=argparse.REMAINDER) + args = parser.parse_args() + command = args.command[1:] if args.command[:1] == ["--"] else args.command + if not command or args.samples < 1 or any(n < 1 for n in args.workers): + parser.error("a command, positive samples and positive worker counts are required") + if os.name != "posix": + parser.error("CPU accounting requires a POSIX host") + def cancel(number, _frame): + raise SystemExit(128 + number) + for number in (signal.SIGTERM, signal.SIGHUP): + signal.signal(number, cancel) + for copies in sorted({1, len(args.checkout)}): + for workers in args.workers: + for sample in range(args.samples): + processes = [] + load = os.getloadavg() + try: + for checkout in args.checkout[:copies]: + directory = checkout / ".scratch/local-bench" + directory.mkdir(parents=True, exist_ok=True) + stem = directory / str(uuid.uuid4()) + stamp = stem.with_suffix(".started") + with stem.with_suffix(".log").open("w") as log: + env = dict(os.environ, NEXTEST_TEST_THREADS=str(workers)) + env.pop("QUEST_GATE_ADMITTED", None) + env.pop("MOQ_LOCAL_SUPERVISED", None) + env.pop("GITHUB_ACTIONS", None) + began = time.monotonic() + process = subprocess.Popen(["bash", str(ROOT / "sh/local.sh"), sys.executable, + str(Path(__file__).resolve()), "--started", str(stamp), + *command], cwd=checkout, env=env, stdout=log, stderr=log) + processes.append((process, began, stamp)) + results = [] + for process, began, stamp in processes: + _, status, usage = os.wait4(process.pid, 0) + process.returncode = os.waitstatus_to_exitcode(status) + if process.returncode: + raise RuntimeError(f"command failed ({process.returncode}); see {stamp.with_suffix('.log')}") + timing = json.loads(stamp.read_text()) + started, ended = timing["start"], timing["end"] + results.append({"admission_s": started - began, "work_s": ended - started, + "total_s": ended - began, "cpu_s": usage.ru_utime + usage.ru_stime}) + finally: + for process, _, _ in processes: + if process.returncode is None: + process.terminate() + process.wait() + print(json.dumps({"copies": copies, "nextest_workers": workers, "sample": sample, + "cache": args.cache, "host_load": load, "command": command, + "runs": results}), flush=True) + + +if __name__ == "__main__": + main() diff --git a/js/justfile b/js/justfile index 6cab4e0a74f..245ae20cba7 100644 --- a/js/justfile +++ b/js/justfile @@ -87,7 +87,7 @@ build: # Build browser/WASM bindings into @moq/wasm using the pinned wasm-bindgen toolchain. wasm PROFILE="wasm-release": - cargo build --locked -p moq-wasm --target wasm32-unknown-unknown --profile {{ PROFILE }} + bash ../sh/local.sh cargo build --locked -p moq-wasm --target wasm32-unknown-unknown --profile {{ PROFILE }} wasm-bindgen --target web --out-name moq --out-dir wasm/dist "${CARGO_TARGET_DIR:-../target}/wasm32-unknown-unknown/{{ if PROFILE == "dev" { "debug" } else { PROFILE } }}/moq_wasm.wasm" # Ensure the built public libraries can load without browser globals. diff --git a/justfile b/justfile index 6cd8b218f1e..e7c51037ea6 100644 --- a/justfile +++ b/justfile @@ -47,6 +47,11 @@ dev: bench $BASE="": bench/run.sh "$BASE" +# Compare admitted suites across checkouts and worker counts; see bench/README.md. +[positional-arguments] +bench-local *args: + python3 bench/local.py "$@" + # Benchmark selected wrappers against two Rust baselines on this machine. [positional-arguments] bench-ffi *runners: diff --git a/py/justfile b/py/justfile index 29cfab3ff74..60e37508134 100644 --- a/py/justfile +++ b/py/justfile @@ -22,7 +22,7 @@ default: # keeps uv from fetching moq-ffi off PyPI; maturin just installed it locally. _develop *args: - cd moq-ffi && uv run --no-sync maturin develop --locked --uv {{ args }} + cd moq-ffi && bash ../../sh/local.sh uv run --no-sync maturin develop --locked --uv {{ args }} uv pip install --no-deps -e moq-rs # Lint + format + editable build + pyright + doc samples + docs. `--no-install-workspace` @@ -60,7 +60,7 @@ fix: test: uv sync --locked --no-install-workspace just _develop {{ test_features }} - uv run --no-sync pytest moq-rs/tests/ moq-ffi/tests/ + bash ../sh/local.sh uv run --no-sync pytest moq-rs/tests/ moq-ffi/tests/ # Local dev build: editable install of moq-ffi (with the cdylib + uniffi @@ -72,7 +72,7 @@ build: # Run the binding benchmark's Python runner (see bench/README.md) on a release build. bench: uv sync --locked --no-install-workspace - cd moq-ffi && uv run --no-sync maturin develop --locked --uv --release + cd moq-ffi && bash ../../sh/local.sh uv run --no-sync maturin develop --locked --uv --release uv pip install --no-deps -e moq-rs uv run --no-sync python moq-rs/benches/ffi.py diff --git a/quest/m0/ci/local-gate.md b/quest/m0/ci/local-gate.md index e640c236061..d6162cf46ef 100644 --- a/quest/m0/ci/local-gate.md +++ b/quest/m0/ci/local-gate.md @@ -1,24 +1,32 @@ -# [M] Share local check capacity across worktrees +# [S] Verify shared local check admission ## Goal -Expensive local check and test phases enter `quest gate` automatically, sharing -one host/user budget with other worktrees and repositories. One admitted suite -also bounds its own worker fanout so it does not overwhelm the desktop. +Finish validating automatic host admission and bounded local worker fanout across +root, direct language, and fixture entrypoints, preserving selected tests, +failure status, and cancellation cleanup. ## Plan -- Decided 2026-10-15: gate expensive commands, not agent sessions. Put admission - before expensive builds and fixture launch, outside test timeout clocks. - Keep hosted CI's existing runner/merge-queue behavior. -- Audit root and direct language/test entrypoints together. Nested invocation - must not deadlock or bypass the cap. Cheap selection and docs-only checks - should remain cheap. Verify cancellation leaves no owned workload running. -- Reuse mbx for Rust compilation. Measure nextest thread/group limits and Bun - workspace fanout for local runs; do not blindly enable mbx test scheduling - where queued time would consume nextest's timeout budget. -- Benchmark representative solo and concurrent checkouts, recording wall time, - CPU time, worker counts, cache state, and other host load. Compare total work - separately from admission delay. Choose defaults from those measurements. -- Explain direct invocation and configuration in existing developer docs. - Preserve selected tests and their failure behavior. +- [Implementation PR](https://github.com/moq-dev/moq/pull/6256) adds shared + admission before expensive builds and fixture launch, outside test timeout + clocks. Nested work reuses admission and supervision; hosted CI keeps its + existing scheduling. Rust compilation still uses mbx. +- Measured warm solo and paired checkouts with admission delay separated from + work wall time and CPU time. Local nextest defaults to four workers, with + the existing io-uring group limit retained. Bun workspace scripts run + sequentially. The PR records the measurements and budget tradeoff. +- Launcher and dispatch tests verify hosted CI, nested and external admission, + failure status, worker overrides, and cancellation of descendants. They run + in the existing nightly tooling suite. +- Remaining: run the complete `just ci` gate on a host whose Nix runner-image + builder can create the required user namespace. The current builder fails + writing `/proc/self/uid_map` with `Operation not permitted`; other PRs report + the same restriction, including [the listener tests](https://github.com/moq-dev/moq/pull/6234). +- The direct Rust test phase also stops at + `stats::a_late_sink_reads_the_final_stats`, which fails with "the import + exited before its input ended". The CLI source is unchanged and + [the listener PR](https://github.com/moq-dev/moq/pull/6234) reproduces the + failure on the base. Resolve that independently before the full gate can pass. +- Two existing nightly fixture assertions are owned by + [the CI audit](https://github.com/moq-dev/moq/pull/6266). diff --git a/rs/justfile b/rs/justfile index 890c2934ceb..7979f6e16c6 100644 --- a/rs/justfile +++ b/rs/justfile @@ -29,7 +29,7 @@ default: # Compile, lint, format-check, doc-check, and verify dependency hygiene. [positional-arguments] check *args: - cargo clippy --locked --all-targets "$@" -- -D warnings + bash sh/local.sh cargo clippy --locked --all-targets "$@" -- -D warnings just rs lint "$@" # `check` with clippy enforced by the `test` build. A selection can hold @@ -49,14 +49,14 @@ lint *args: cargo fmt --all --check # quinn-udp and quinn keep quinn's formatting; cargo fmt skips them (see moq-sock's lib.rs, moq-tokio's quic.rs). rustfmt --edition 2024 --check rs/moq-sock/src/udp/mod.rs rs/moq-tokio/src/quic/driver/mod.rs - RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps "$@" + RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked --no-deps "$@" cargo shear cargo sort --workspace --check --no-format # Auto-fix clippy/format/shear/sort. [positional-arguments] fix *args: - cargo clippy --locked --fix --allow-staged --allow-dirty --all-targets "$@" + bash sh/local.sh cargo clippy --locked --fix --allow-staged --allow-dirty --all-targets "$@" cargo fmt --all rustfmt --edition 2024 rs/moq-sock/src/udp/mod.rs rs/moq-tokio/src/quic/driver/mod.rs cargo shear --fix @@ -117,13 +117,13 @@ uring-changed base="": uring *args: just rs uring-check "$@" bash sh/rs/nextest.sh cargo nextest run --locked -p moq-uring -p moq-relay --features moq-relay/io-uring --tests "$@" - cargo clippy --locked -p moq-uring -p moq-relay --features moq-relay/io-uring,moq-relay/qlog --all-targets "$@" -- -D warnings + bash sh/local.sh cargo clippy --locked -p moq-uring -p moq-relay --features moq-relay/io-uring,moq-relay/qlog --all-targets "$@" -- -D warnings bash sh/rs/nextest.sh cargo nextest run --locked -p moq-uring --features qlog --tests "$@" # Compile the io_uring relay path, off the default feature set. [positional-arguments] uring-check *args: - cargo clippy --locked -p moq-uring -p moq-relay --features moq-relay/io-uring --all-targets "$@" -- -D warnings + bash sh/local.sh cargo clippy --locked -p moq-uring -p moq-relay --features moq-relay/io-uring --all-targets "$@" -- -D warnings # The Apple-gated code in moq-video, moq-audio, and moq-sock, which # platform.yml compiles on a Mac runner alongside `windows`. @@ -142,7 +142,7 @@ macos-test: # Compile and lint the capture and playback features, which the default check skips. [positional-arguments] capture *args: - cargo clippy --locked -p moq-video -p moq-audio --all-targets --features moq-video/capture,moq-audio/capture,moq-audio/playback "$@" -- -D warnings + bash sh/local.sh cargo clippy --locked -p moq-video -p moq-audio --all-targets --features moq-video/capture,moq-audio/capture,moq-audio/playback "$@" -- -D warnings # The capture and playback tests drive synthetic devices, so they need no hardware. @@ -181,8 +181,8 @@ x11-bench-ci: # moq-ffi library links logcat: `Log::init` is silent on Android without it. [positional-arguments] android *args: - cargo ndk -t arm64-v8a --platform 26 check --locked -p moq-video --all-targets "$@" - cargo ndk -t arm64-v8a --platform 26 -o target/android-jni build --locked -p moq-ffi --features openh264 "$@" + bash sh/local.sh cargo ndk -t arm64-v8a --platform 26 check --locked -p moq-video --all-targets "$@" + bash sh/local.sh cargo ndk -t arm64-v8a --platform 26 -o target/android-jni build --locked -p moq-ffi --features openh264 "$@" nm -D --undefined-only target/android-jni/arm64-v8a/libmoq_ffi.so | grep -q __android_log_ # moq-wasm's crate root is `#![cfg(target_arch = "wasm32")]`, so only a wasm32 @@ -195,23 +195,23 @@ android *args: # Compile and lint the browser/WASM bindings, which the host-target check skips. [positional-arguments] wasm *args: - cargo clippy --locked -p moq-wasm -p moq-mux -p moq-ffi -p moq-clock --target wasm32-unknown-unknown --lib "$@" -- -D warnings + bash sh/local.sh cargo clippy --locked -p moq-wasm -p moq-mux -p moq-ffi -p moq-clock --target wasm32-unknown-unknown --lib "$@" -- -D warnings # Run the browser clock backend on the Playwright Chromium installed by wasm.yml, # with the runtime and with reads alone. wasm-test: - CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="bun {{ justfile_directory() }}/test/wasm/rust.ts" cargo test --locked -p moq-clock --lib --target wasm32-unknown-unknown - CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="bun {{ justfile_directory() }}/test/wasm/rust.ts" cargo test --locked -p moq-clock --lib --target wasm32-unknown-unknown --no-default-features + CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="bun {{ justfile_directory() }}/test/wasm/rust.ts" bash sh/local.sh cargo test --locked -p moq-clock --lib --target wasm32-unknown-unknown + CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="bun {{ justfile_directory() }}/test/wasm/rust.ts" bash sh/local.sh cargo test --locked -p moq-clock --lib --target wasm32-unknown-unknown --no-default-features # Auto-fix the browser/WASM bindings. [positional-arguments] wasm-fix *args: - cargo clippy --locked --fix --allow-staged --allow-dirty -p moq-wasm -p moq-mux -p moq-ffi -p moq-clock --target wasm32-unknown-unknown --lib "$@" + bash sh/local.sh cargo clippy --locked --fix --allow-staged --allow-dirty -p moq-wasm -p moq-mux -p moq-ffi -p moq-clock --target wasm32-unknown-unknown --lib "$@" cargo fmt -p moq-wasm -p moq-mux -p moq-ffi -p moq-clock # Audit dependencies against deny.toml. Nightly: advisories land without a diff. audit: - cargo deny check --show-stats + bash sh/local.sh cargo deny check --show-stats # Verify relay startup validation without a QUIC backend. relay-minimal: @@ -234,18 +234,18 @@ features: just rs quic-features just rs tokio-features --all just rs media-features --all - cargo check --locked --workspace {{ no_fuzz }} --all-targets --no-default-features - cargo hack check --locked -p moq-tokio --each-feature --exclude-features _transport --features aws-lc-rs - cargo check --locked -p moq-relay --no-default-features + bash sh/local.sh cargo check --locked --workspace {{ no_fuzz }} --all-targets --no-default-features + bash sh/local.sh cargo hack check --locked -p moq-tokio --each-feature --exclude-features _transport --features aws-lc-rs + bash sh/local.sh cargo check --locked -p moq-relay --no-default-features just rs relay-minimal - cargo check --locked -p moq-cli --no-default-features + bash sh/local.sh cargo check --locked -p moq-cli --no-default-features just rs test -p moq-cli --no-default-features --features capture,websocket -E 'test(capture_window)' just rs test -p moq-cli --no-default-features --features capture,pipewire,websocket -E 'test(capture_window)' - cargo check --locked -p moq-bench --no-default-features - cargo check --locked -p moq-boy --no-default-features - cargo check --locked -p moq-hls -p moq-rtmp -p moq-rtc --no-default-features --all-targets - cargo clippy --locked --workspace {{ no_fuzz }} --all-targets --all-features -- -D warnings - RUSTDOCFLAGS="-D warnings" cargo doc --locked --workspace {{ no_fuzz }} --all-features --no-deps + bash sh/local.sh cargo check --locked -p moq-bench --no-default-features + bash sh/local.sh cargo check --locked -p moq-boy --no-default-features + bash sh/local.sh cargo check --locked -p moq-hls -p moq-rtmp -p moq-rtc --no-default-features --all-targets + bash sh/local.sh cargo clippy --locked --workspace {{ no_fuzz }} --all-targets --all-features -- -D warnings + RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked --workspace {{ no_fuzz }} --all-features --no-deps bash sh/rs/nextest.sh cargo nextest run --locked --workspace {{ no_fuzz }} --all-targets --all-features # Compile and test the explicit-time model without async helpers or sessions. @@ -261,7 +261,7 @@ quic-features: echo "moq-quic must not depend on a native runtime" >&2 exit 1 fi - cargo clippy --locked -p moq-quic --all-targets --no-default-features -- -D warnings + bash sh/local.sh cargo clippy --locked -p moq-quic --all-targets --no-default-features -- -D warnings # Compile media boundaries (--all isolates every mode) and prove expensive # native/render dependencies are absent when their features are excluded. @@ -298,7 +298,7 @@ play *args: # Compile and run the `/// ```` examples, which nextest skips. [positional-arguments] doctest *args: - cargo test --locked --doc "$@" + bash sh/local.sh cargo test --locked --doc "$@" # `--cfg loom` swaps kio's primitives for loom's, so it rebuilds the world and # stays out of `check`. `--release` because a model check runs the body once @@ -383,26 +383,26 @@ coverage crate="workspace": # Build the default workspace members. build: - cargo build --locked + bash sh/local.sh cargo build --locked # Run the comparable epoll and io_uring UDP matrices. [positional-arguments] bench-udp *args: - cargo bench -p moq-uring --bench udp_tokio -- "$@" - cargo bench -p moq-uring --bench udp_uring -- "$@" + bash sh/local.sh cargo bench -p moq-uring --bench udp_tokio -- "$@" + bash sh/local.sh cargo bench -p moq-uring --bench udp_uring -- "$@" # Measure a QUIC echo through the io_uring worker, ablating receive # batching, GRO, and GSO one at a time. Linux 6.12+ (skips loudly otherwise). [positional-arguments] bench-echo *args: - cargo bench -p moq-uring --bench echo_quic -- "$@" + bash sh/local.sh cargo bench -p moq-uring --bench echo_quic -- "$@" # Measure a full moq-lite session (publisher to subscriber) through the # io_uring worker, same ablations and per-iteration unit as bench-echo. # Linux 6.12+ (skips loudly otherwise). [positional-arguments] bench-session *args: - cargo bench -p moq-uring --bench session_lite -- "$@" + bash sh/local.sh cargo bench -p moq-uring --bench session_lite -- "$@" # Create release PRs and publish crates via release-plz. release: @@ -460,17 +460,17 @@ bench-playback: # Sweep retained RTMP chunk-stream IDs independently of message and chunk sizes. [positional-arguments] bench-rtmp *args: - cargo bench --locked -p moq-rtmp --bench chunk_interleaving -- "$@" + bash sh/local.sh cargo bench --locked -p moq-rtmp --bench chunk_interleaving -- "$@" # Refresh one credential across unrelated sessions and held token counts. [positional-arguments] bench-relay-auth *args: - cargo bench --locked -p moq-relay --bench auth -- "$@" + bash sh/local.sh cargo bench --locked -p moq-relay --bench auth -- "$@" # One relay's stats tick, plus the decode and aggregate tables. `--test` runs each tick once; the tables ignore it and print every configuration. [positional-arguments] bench-stats *args: - cargo bench --locked -p moq-stats --features bench --bench producer_tick --bench decode --bench aggregate -- "$@" + bash sh/local.sh cargo bench --locked -p moq-stats --features bench --bench producer_tick --bench decode --bench aggregate -- "$@" # Sweep latency observations against writer count and report density. bench-latency: @@ -479,14 +479,14 @@ bench-latency: # Exact TS receiver scheduling across PID and queued-unit fanout. [positional-arguments] bench-ts-schedule *args: - cargo bench --locked -p moq-mux --bench ts_schedule -- "$@" + bash sh/local.sh cargo bench --locked -p moq-mux --bench ts_schedule -- "$@" # Sweep container export tracks and queued frames independently. [positional-arguments] bench-export *args: - cargo bench --locked -p moq-mux --bench export -- "$@" + bash sh/local.sh cargo bench --locked -p moq-mux --bench export -- "$@" # Requested-pad catalog gating and resolved EOS lookup across renditions x touched pads. [positional-arguments] bench-gst-catalog *args: - cargo bench -p moq-gst --bench catalog "$@" + bash sh/local.sh cargo bench -p moq-gst --bench catalog "$@" diff --git a/sh/coverage.test.py b/sh/coverage.test.py index 8ff5e20b0f8..8be259b43d0 100644 --- a/sh/coverage.test.py +++ b/sh/coverage.test.py @@ -18,7 +18,7 @@ def setUp(self): self.directory = tempfile.TemporaryDirectory() self.addCleanup(self.directory.cleanup) self.root = Path(self.directory.name) - for script in ("sh/js/coverage.py", "sh/rs/coverage.sh", "sh/rs/nextest.sh"): + for script in ("sh/js/coverage.py", "sh/rs/coverage.sh", "sh/rs/nextest.sh", "sh/local.sh"): target = self.root / script target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(ROOT / script, target) @@ -44,7 +44,7 @@ def setUp(self): target.chmod(0o755) self.calls = self.root / "calls" self.env = dict(os.environ, PATH=f"{self.bin}:{os.environ['PATH']}", - COVERAGE_CALLS=str(self.calls), BASH_ENV="/dev/null", GITHUB_ACTIONS="") + COVERAGE_CALLS=str(self.calls), BASH_ENV="/dev/null", GITHUB_ACTIONS="", MOQ_LOCAL_SUPERVISED="1") def javascript(self, name="", fail=False): directories = ["js/first", "js/second", "js/empty"] diff --git a/sh/cpp/check.sh b/sh/cpp/check.sh index 7a133c6423b..5b7bdabb388 100755 --- a/sh/cpp/check.sh +++ b/sh/cpp/check.sh @@ -6,6 +6,10 @@ # Unix; Windows uses MSVC. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + ffi_dir="" archive="" if [[ $# -gt 0 ]]; then diff --git a/sh/dart/check.sh b/sh/dart/check.sh index 46c85add991..1d047d4ef18 100755 --- a/sh/dart/check.sh +++ b/sh/dart/check.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + DART_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../../dart" && pwd) ACTION=check diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index f59b19d54dc..a490df0967c 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -22,13 +22,13 @@ def setUp(self): self.root = Path(self.temp.name) self.repo = self.root / "repo" (self.repo / "sh").mkdir(parents=True) - for script in ("dispatch.sh", "changed.sh"): + for script in ("dispatch.sh", "changed.sh", "local.sh"): shutil.copy(ROOT / "sh" / script, self.repo / "sh" / script) self.bin = self.root / "bin" self.bin.mkdir() for command in ("bash", "git", "sort", "mktemp", "rm", "grep"): (self.bin / command).symlink_to(shutil.which(command)) - self.env = dict(os.environ, PATH=str(self.bin), GIT_CONFIG_NOSYSTEM="1", + self.env = dict(os.environ, MOQ_LOCAL_SUPERVISED="1", PATH=str(self.bin), GIT_CONFIG_NOSYSTEM="1", GIT_CONFIG_GLOBAL=os.devnull, MOQ_STRICT="1") for key in ("MOQ_DEV_SHELL", "MOQ_ALLOW_HOST", "GITHUB_BASE_REF"): self.env.pop(key, None) diff --git a/sh/dispatch.sh b/sh/dispatch.sh index 9174ee0ce5d..e87f10efce3 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -44,7 +44,7 @@ else # These files hold the map and the recipes that call it, and match no # module, so a change to them would otherwise validate none of it. - if grep -qE '^(justfile|sh/(dispatch|changed)\.sh)$' "$changed"; then + if grep -qE '^(justfile|sh/(dispatch|changed)\.sh|sh/local\.(sh|ts))$' "$changed"; then echo "$action: root orchestration changed; running everything." >&2 all=1 fi @@ -61,7 +61,7 @@ declare -A scope=( [workers]='^(infra/apt/|infra/rpm/|infra/moq-sh/|demo/pub/|sh/js/workers\.sh$)' [moq_sh]='^infra/moq-sh/' # sh/rs/select.sh widens to the whole workspace for inputs every crate shares. - [rs]='^(rs/|demo/carla/bridge/|sh/rs/|Cargo\.(toml|lock)$|rust-toolchain\.toml$|\.config/nextest\.toml$)' + [rs]='^(sh/local\.(sh|ts)$|rs/|demo/carla/bridge/|sh/rs/|Cargo\.(toml|lock)$|rust-toolchain\.toml$|\.config/nextest\.toml$)' [bench]='^bench/' # The CARLA demo's simulator worker and launchers. Its player is a JS # package and its GPU bridge a Rust crate, so those modules cover them. @@ -280,11 +280,11 @@ for module in "${selected[@]}"; do # The preamble keeps docs and target-specific lints; the test build # below enforces default-feature clippy without a second compile. check:rs) just rs lint-changed "$rs_list" ;; - check:bench) cargo check --locked --package moq-relay --package moq-bench --features moq-relay/io-uring ;; + check:bench) bash sh/local.sh cargo check --locked --package moq-relay --package moq-bench --features moq-relay/io-uring ;; check:quest) quest check ;; check:drill) just test drill-sensitivity --apply-only ;; check:obs_compile) just obs compile ;; - check:flake) nix flake check ;; + check:flake) bash sh/local.sh nix flake check ;; check:ts_paths) python3 sh/gh/ts-paths.py ;; check:markdown) bun install --frozen-lockfile diff --git a/sh/go/check.sh b/sh/go/check.sh index a96a6e82def..5989be580aa 100755 --- a/sh/go/check.sh +++ b/sh/go/check.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + # Local smoke check for the Go module. # # Stages the ffi + wrapper modules from this checkout (sh/go/stage.sh) and diff --git a/sh/js/workspace.py b/sh/js/workspace.py index 19cf4f73f18..275a7c41e80 100644 --- a/sh/js/workspace.py +++ b/sh/js/workspace.py @@ -138,7 +138,8 @@ def scripts(verb): filters = [f"--filter={name}" for name, package in packages.items() if verb in package["manifest"].get("scripts", {})] if filters: - command("bun", "run", *filters, "--elide-lines=0", verb) + concurrency = [] if os.environ.get("GITHUB_ACTIONS") == "true" else ["--sequential"] + command("bun", "run", *concurrency, *filters, "--elide-lines=0", verb) command("bun", "install", "--frozen-lockfile") if action == "test": @@ -204,6 +205,9 @@ def main(): if action == "plan": print(json.dumps(plan, default=sorted)) else: + if plan["packages"] and os.environ.get("GITHUB_ACTIONS") != "true" and os.environ.get("MOQ_LOCAL_SUPERVISED") != "1": + os.execvp("bash", ["bash", str(ROOT / "sh/local.sh"), + sys.executable, str(Path(__file__).resolve()), *sys.argv[1:]]) started = time.monotonic() run(action, plan) print(f"js: {action} finished in {time.monotonic() - started:.2f}s", flush=True) diff --git a/sh/js/workspace.test.py b/sh/js/workspace.test.py index d90ede5bff5..3263b2ed4fd 100644 --- a/sh/js/workspace.test.py +++ b/sh/js/workspace.test.py @@ -191,7 +191,7 @@ def invoke(args, **kwargs): def test_executor_runs_only_selected_package_scripts_without_wasm(self): calls = self.calls(["doc/index.md"]) scripts = [c for c in calls if c[:2] == ["bun", "run"]] - self.assertEqual(scripts, [["bun", "run", "--filter=docs", "--elide-lines=0", action] + self.assertEqual(scripts, [["bun", "run", "--sequential", "--filter=docs", "--elide-lines=0", action] for action in ("check", "build")]) self.assertNotIn(["just", "js", "wasm", "dev"], calls) self.assertTrue(any(c[:2] == ["bunx", "tsc"] for c in calls)) @@ -225,7 +225,7 @@ def test_executor_builds_wasm_before_consumer_check(self): def test_tests_do_not_build_wasm_or_unselected_packages(self): calls = self.calls(["doc/index.md"], "test") - self.assertIn(["bun", "run", "--filter=docs", "--elide-lines=0", "test"], calls) + self.assertIn(["bun", "run", "--sequential", "--filter=docs", "--elide-lines=0", "test"], calls) self.assertFalse(any(c[0] == "just" for c in calls)) def test_owned_package_without_scripts_keeps_harness_check(self): diff --git a/sh/kt/check.sh b/sh/kt/check.sh index 04ffb59fc8c..ecd789971cc 100644 --- a/sh/kt/check.sh +++ b/sh/kt/check.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + # Full check for the Kotlin packages: regenerate the bindings + native lib # (sh/kt/generate.sh), then run the raw-bindings and wrapper JVM tests. # diff --git a/sh/local.sh b/sh/local.sh new file mode 100755 index 00000000000..1e29e3d3e94 --- /dev/null +++ b/sh/local.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Admit a local suite once; cheap selection runs before calling this launcher. +set -euo pipefail + +if [[ $# == 0 ]]; then + echo 'usage: sh/local.sh COMMAND [ARGS...]' >&2 + exit 2 +fi +if [[ "${GITHUB_ACTIONS:-}" == true ]]; then + exec "$@" +fi +export NEXTEST_TEST_THREADS="${NEXTEST_TEST_THREADS-4}" +if [[ "${MOQ_LOCAL_SUPERVISED:-}" == 1 ]]; then + exec "$@" +fi +if [[ "${QUEST_GATE_ADMITTED:-}" == 1 ]]; then + exec bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" +fi +exec quest gate bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" diff --git a/sh/local.test.py b/sh/local.test.py new file mode 100644 index 00000000000..ff52f6f594e --- /dev/null +++ b/sh/local.test.py @@ -0,0 +1,98 @@ +"""Admission must preserve failures and own the entire admitted command tree.""" + +import os +from pathlib import Path +import signal +import shutil +import subprocess +import sys +import tempfile +import unittest + + +ROOT = Path(__file__).resolve().parents[1] +LAUNCHER = ROOT / "sh/local.sh" +SUPERVISOR = ROOT / "sh/local.ts" +BUN = shutil.which("bun") +BASH = shutil.which("bash") + + +class LocalGate(unittest.TestCase): + def env(self, **changes): + env = dict(os.environ) + for key in ("QUEST_GATE_ADMITTED", "MOQ_LOCAL_SUPERVISED", "GITHUB_ACTIONS", "NEXTEST_TEST_THREADS"): + env.pop(key, None) + env.update(changes) + return env + + def run_command(self, script, **changes): + return subprocess.run([BASH, str(LAUNCHER), sys.executable, "-c", script], + env=self.env(**changes), text=True, capture_output=True) + + def test_hosted_ci_bypasses_admission_and_worker_defaults(self): + result = self.run_command('import os; print(os.getenv("NEXTEST_TEST_THREADS")); exit(7)', + GITHUB_ACTIONS="true", PATH="") + self.assertEqual(result.returncode, 7, result.stderr) + self.assertEqual(result.stdout.strip(), "None") + + def test_nested_admission_preserves_failures_and_worker_override(self): + result = self.run_command('import os; print(os.environ["NEXTEST_TEST_THREADS"]); exit(9)', + MOQ_LOCAL_SUPERVISED="1", NEXTEST_TEST_THREADS="2", PATH="") + self.assertEqual(result.returncode, 9, result.stderr) + self.assertEqual(result.stdout.strip(), "2") + result = self.run_command('import os; print(os.environ["NEXTEST_TEST_THREADS"])', + MOQ_LOCAL_SUPERVISED="1", PATH="") + self.assertEqual(result.returncode, 0, result.stderr) + self.assertLessEqual(int(result.stdout), 4) + self.assertGreater(int(result.stdout), 0) + + def test_admission_precedes_launch_and_nested_calls_skip_it(self): + with tempfile.TemporaryDirectory() as directory: + (Path(directory) / "bun").symlink_to(BUN) + quest = Path(directory) / "quest" + quest.write_text(f'#!{sys.executable}\n' + 'import os, sys\n' + 'assert sys.argv[1] == "gate"\n' + 'print("admitted", flush=True)\n' + 'os.environ["QUEST_GATE_ADMITTED"] = "1"\n' + 'os.execvp(sys.argv[2], sys.argv[2:])\n') + quest.chmod(0o755) + script = ('import subprocess, sys; print("outer", flush=True); ' + f'sys.exit(subprocess.call([{BASH!r}, {str(LAUNCHER)!r}, ' + 'sys.executable, "-c", "print(\'inner\'); exit(11)"]))') + result = self.run_command(script, PATH=directory) + self.assertEqual(result.returncode, 11, result.stderr) + self.assertEqual(result.stdout.splitlines(), ["admitted", "outer", "inner"]) + + def test_external_admission_keeps_descendant_supervision(self): + with tempfile.TemporaryDirectory() as directory: + (Path(directory) / "bun").symlink_to(BUN) + result = self.run_command('import os; print(os.environ["MOQ_LOCAL_SUPERVISED"])', + QUEST_GATE_ADMITTED="1", PATH=directory) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual(result.stdout.strip(), "1") + + @unittest.skipUnless(os.name == "posix", "process groups require POSIX") + def test_cancellation_reaches_descendants_and_waits_for_cleanup(self): + # The grandchild inherits stdout; EOF proves no descendant holds it open. + script = """import signal, subprocess, sys +child = subprocess.Popen([sys.executable, "-c", "import signal; print('ready', flush=True); signal.pause()"]) +signal.pause() +""" + process = subprocess.Popen([BUN, "--no-orphans", str(SUPERVISOR), sys.executable, "-c", script], + env=self.env(QUEST_GATE_ADMITTED="1"), + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + try: + self.assertEqual(process.stdout.readline().strip(), "ready") + process.send_signal(signal.SIGTERM) + output, error = process.communicate() + self.assertEqual(process.returncode, 128 + signal.SIGTERM, error) + self.assertEqual(output.strip(), "") + finally: + if process.poll() is None: + process.kill() + process.wait() + + +if __name__ == "__main__": + unittest.main() diff --git a/sh/local.ts b/sh/local.ts new file mode 100644 index 00000000000..688cbcbae52 --- /dev/null +++ b/sh/local.ts @@ -0,0 +1,18 @@ +// Bun's --no-orphans owns every descendant, including detached fixture groups. +import { constants } from "node:os"; + +const command = Bun.argv.slice(2); +if (!command.length) throw new Error("usage: sh/local.ts COMMAND [ARGS...]"); +const child = Bun.spawn(command, { + stdin: "inherit", + stdout: "inherit", + stderr: "inherit", + env: { ...process.env, MOQ_LOCAL_SUPERVISED: "1" }, +}); +for (const name of ["SIGINT", "SIGTERM", "SIGHUP"] as const) { + process.on(name, () => { + child.kill(name); + process.exit(128 + constants.signals[name]); + }); +} +process.exit(await child.exited); diff --git a/sh/obs/compile.sh b/sh/obs/compile.sh index 09aeaf5595e..3c6a2535d0f 100755 --- a/sh/obs/compile.sh +++ b/sh/obs/compile.sh @@ -18,6 +18,10 @@ # only where obs.yml's path filter reaches; `just obs test` is manual. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) cd "$here/../../cpp/obs" diff --git a/sh/obs/test.sh b/sh/obs/test.sh index 90460c66bf5..179d8db4bbc 100755 --- a/sh/obs/test.sh +++ b/sh/obs/test.sh @@ -9,6 +9,10 @@ # can't check. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) cd "$here/../../cpp/obs" diff --git a/sh/obs/unit.sh b/sh/obs/unit.sh index 50c4b0a215e..62704c05dee 100755 --- a/sh/obs/unit.sh +++ b/sh/obs/unit.sh @@ -5,6 +5,10 @@ # both run the same assertions. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) cd "$here/../../cpp/obs" mode=${1:-plain} diff --git a/sh/rs/c-tests.sh b/sh/rs/c-tests.sh index e0f4c01c4d4..873e69b93cb 100755 --- a/sh/rs/c-tests.sh +++ b/sh/rs/c-tests.sh @@ -6,6 +6,10 @@ # Unix only. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + cd "$(git rev-parse --show-toplevel)" cc="${CC:-cc}" diff --git a/sh/rs/gpu.sh b/sh/rs/gpu.sh index cf7899e1c4e..4ac870e4f41 100755 --- a/sh/rs/gpu.sh +++ b/sh/rs/gpu.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash # Hardware tests are opt-in; a detected GPU must have its driver and pass its tests. set -euo pipefail + +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi cd "$(git rev-parse --show-toplevel)" declare -A vendors=() diff --git a/sh/rs/media-features.sh b/sh/rs/media-features.sh index a2148513c26..70a73a7e20e 100755 --- a/sh/rs/media-features.sh +++ b/sh/rs/media-features.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + all=0 if [[ $# == 1 && $1 == --all ]]; then all=1 diff --git a/sh/rs/net-features.sh b/sh/rs/net-features.sh index f2be50fcf7c..605ac62c13a 100644 --- a/sh/rs/net-features.sh +++ b/sh/rs/net-features.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + # Build moq-net alone: a workspace build unifies its default features back in. # Normal dependencies exclude the simulation executor and bench-only Tokio. minimal=$(cargo tree --locked -p moq-net --no-default-features -e normal --prefix none) diff --git a/sh/rs/nextest.sh b/sh/rs/nextest.sh index b03650e7f12..79218b80726 100644 --- a/sh/rs/nextest.sh +++ b/sh/rs/nextest.sh @@ -10,4 +10,4 @@ if [[ "$(uname -s)" == Linux ]]; then ulimit -Sl "$(ulimit -Hl)" fi fi -exec "$@" +exec bash "$(dirname "$0")/../local.sh" "$@" diff --git a/sh/rs/select.sh b/sh/rs/select.sh index c84ae0b11fa..c36d8ac21ae 100755 --- a/sh/rs/select.sh +++ b/sh/rs/select.sh @@ -20,7 +20,7 @@ select_packages() { echo ALL return fi - if [[ "$list" == --all ]] || grep -qE '^(Cargo\.(toml|lock)|rust-toolchain\.toml|rs/justfile|sh/rs/(select|platform|nextest)\.sh|\.config/nextest\.toml)$' "$list"; then + if [[ "$list" == --all ]] || grep -qE '^(sh/local\.(sh|ts)|Cargo\.(toml|lock)|rust-toolchain\.toml|rs/justfile|sh/rs/(select|platform|nextest)\.sh|\.config/nextest\.toml)$' "$list"; then echo ALL return fi @@ -113,6 +113,11 @@ case "$packages" in *) echo "rs: selecting $names" ;; esac +# Selection and empty crate sets stay outside admission. +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + # The `*-fuzz` crates need a nightly toolchain; only `just rs fuzz` compiles them. if [[ "$packages" == ALL ]]; then flags=(--workspace --exclude moq-net-fuzz --exclude moq-quic-fuzz) diff --git a/sh/rs/select.test.py b/sh/rs/select.test.py index 7d7f9bee0cf..8093fc087d6 100644 --- a/sh/rs/select.test.py +++ b/sh/rs/select.test.py @@ -21,7 +21,7 @@ def selected(self, *paths, action="lint"): just.chmod(0o755) changed = scratch / "changed" changed.write_text("\n".join(paths) + "\n") - env = dict(os.environ, PATH=f"{scratch}:{os.environ['PATH']}", + env = dict(os.environ, MOQ_LOCAL_SUPERVISED="1", PATH=f"{scratch}:{os.environ['PATH']}", SELECT_CALLS=str(calls), BASH_ENV=os.devnull) subprocess.run(["bash", "sh/rs/select.sh", action, str(changed)], cwd=ROOT, env=env, check=True, capture_output=True, text=True) @@ -104,7 +104,7 @@ def trace(self, owner, *args): cargo = scratch / "cargo" cargo.write_text(CARGO_STUB) cargo.chmod(0o755) - env = dict(os.environ, PATH=f"{scratch}:{os.environ['PATH']}", + env = dict(os.environ, MOQ_LOCAL_SUPERVISED="1", PATH=f"{scratch}:{os.environ['PATH']}", FEATURE_CALLS=str(calls), BASH_ENV=os.devnull) result = subprocess.run(["bash", f"sh/rs/{owner}-features.sh", *args], cwd=ROOT, env=env, capture_output=True, text=True) diff --git a/sh/rs/test-lints.test.py b/sh/rs/test-lints.test.py index e9c16c0802b..2f80fecf8de 100644 --- a/sh/rs/test-lints.test.py +++ b/sh/rs/test-lints.test.py @@ -18,6 +18,8 @@ def test_clippy_warning_fails_test_build(self): (root / "rs").mkdir() (root / "sh" / "rs").mkdir(parents=True) (root / "src").mkdir() + for script in ("local.sh", "local.ts"): + shutil.copy(ROOT / "sh" / script, root / "sh" / script) (root / "justfile").write_text("mod rs\n") shutil.copy(ROOT / "rs" / "justfile", root / "rs" / "justfile") shutil.copy(ROOT / "sh" / "rs" / "nextest.sh", root / "sh" / "rs" / "nextest.sh") diff --git a/sh/rs/tokio-features.sh b/sh/rs/tokio-features.sh index 44c60af47c7..18f09c24ed2 100755 --- a/sh/rs/tokio-features.sh +++ b/sh/rs/tokio-features.sh @@ -5,6 +5,10 @@ # through unification. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + all=0 if [[ $# == 1 && $1 == --all ]]; then all=1 diff --git a/sh/swift/check.sh b/sh/swift/check.sh index a6032d13859..3dec50d406b 100755 --- a/sh/swift/check.sh +++ b/sh/swift/check.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + # Local smoke check for the Swift wrapper. Builds moq-ffi for the host # macOS target, lays out a local XCFramework, and runs `swift test`. # diff --git a/sh/swift/simulator.sh b/sh/swift/simulator.sh index 9b1621b8c2d..2244d2bbc3a 100755 --- a/sh/swift/simulator.sh +++ b/sh/swift/simulator.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" +fi + # The simulators have no hardware encoder, so the release build (rs/moq-ffi/build.sh) # turns on `openh264`; check the same feature set it ships. for target in aarch64-apple-ios-sim x86_64-apple-ios; do diff --git a/test/audio-quality/record.sh b/test/audio-quality/record.sh index 22114369693..395e9c42855 100755 --- a/test/audio-quality/record.sh +++ b/test/audio-quality/record.sh @@ -10,6 +10,10 @@ # replay budgets after. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../../sh/local.sh" bash "$0" "$@" +fi + AQ_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) WORKSPACE=$(cd "$AQ_DIR/../.." && pwd) CLIENT="$AQ_DIR/clients/js" diff --git a/test/audio-quality/run.sh b/test/audio-quality/run.sh index e72442f5f45..9531c7de5d1 100755 --- a/test/audio-quality/run.sh +++ b/test/audio-quality/run.sh @@ -7,6 +7,10 @@ # the browser's. See README.md for the profiles, the metric contract, and the void rules. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../../sh/local.sh" bash "$0" "$@" +fi + AQ_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) WORKSPACE=$(cd "$AQ_DIR/../.." && pwd) CLIENT="$AQ_DIR/clients/js" diff --git a/test/drain/run.sh b/test/drain/run.sh index e15615f1c6c..957e14669df 100755 --- a/test/drain/run.sh +++ b/test/drain/run.sh @@ -3,6 +3,10 @@ # migrates to relay B when A drains, without a dropped group. See README.md. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../../sh/local.sh" bash "$0" "$@" +fi + DRAIN_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) WORKSPACE=$(cd "$DRAIN_DIR/../.." && pwd) diff --git a/test/interop/compat.sh b/test/interop/compat.sh index 0ddef6d3350..17c12f84185 100755 --- a/test/interop/compat.sh +++ b/test/interop/compat.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash # Compare this checkout with registry releases using the existing interop drivers. set -euo pipefail + +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../../sh/local.sh" bash "$0" "$@" +fi DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) WORKSPACE=$(cd "$DIR/../.." && pwd) # shellcheck source-path=SCRIPTDIR source=../lib/harness.sh diff --git a/test/interop/interop.sh b/test/interop/interop.sh index 99d3ece29ef..9b177a3e698 100755 --- a/test/interop/interop.sh +++ b/test/interop/interop.sh @@ -24,6 +24,10 @@ # their defaults, and the matrix also crosses versions through the relay. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../../sh/local.sh" bash "$0" "$@" +fi + INTEROP_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) WORKSPACE=$(cd "$INTEROP_DIR/../.." && pwd) CLIENTS="$INTEROP_DIR/clients" diff --git a/test/justfile b/test/justfile index 4c3cec9d6e9..a32330346fb 100644 --- a/test/justfile +++ b/test/justfile @@ -30,7 +30,7 @@ harness: cd .. && bun test test/interop/compat/resolve.test.ts test/interop/compat/claims.test.ts cd .. && bun install --frozen-lockfile cd interop/clients/js && bunx playwright install chromium - cd interop/clients/js && bun test ./harness.browser.ts ./signals-dom.browser.ts ./publish-ui.browser.ts ./capture-channel-count.browser.ts ./open-gop.browser.ts ./src/contract.test.ts ./src/resume.test.ts + cd interop/clients/js && bash ../../../../sh/local.sh bun test ./harness.browser.ts ./signals-dom.browser.ts ./publish-ui.browser.ts ./capture-channel-count.browser.ts ./open-gop.browser.ts ./src/contract.test.ts ./src/resume.test.ts # Cross-language media interop test, built from this checkout. Stands up a # relay and runs the publisher x subscriber matrix. Default: rust only (fast @@ -214,11 +214,11 @@ wasm *args: video: cd .. && bun install --frozen-lockfile cd video && bunx playwright install chromium - cd video && bun test ./renderer.browser.ts + cd video && bash ../../sh/local.sh bun test ./renderer.browser.ts # Optional publisher retention across Rust/JS sessions through a Rust relay. max-age: - cargo nextest run --locked -p moq-tokio --test integration -E 'test(/^max_age::/)' --run-ignored all + bash ../sh/local.sh cargo nextest run --locked -p moq-tokio --test integration -E 'test(/^max_age::/)' --run-ignored all # Cross-language subscription termination over in-memory transports. bare-fin: @@ -226,7 +226,7 @@ bare-fin: # Explore JSON snapshot codec sequences with a fresh replayable seed. json-properties: - bash json-properties.sh + bash ../sh/local.sh bash json-properties.sh # The TypeScript qmux peer as client and server against qmux 0.6.3's Rust # interop examples, per draft. `cargo install` keeps that release out of the @@ -242,7 +242,7 @@ qmux: p2p: cd .. && bun install --frozen-lockfile cd p2p && bunx playwright install chromium - cd p2p && bun test ./transport.browser.ts + cd p2p && bash ../../sh/local.sh bun test ./transport.browser.ts # Retain complete backend assets, parity, and raw alternating browser samples. [positional-arguments] diff --git a/test/native-play/run.sh b/test/native-play/run.sh index ab5f28f1c17..565bd0b2b73 100755 --- a/test/native-play/run.sh +++ b/test/native-play/run.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash # Hear the shipped headless player through a private, clocked null audio device. set -euo pipefail + +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../../sh/local.sh" bash "$0" "$@" +fi if [[ $(uname -s) != Linux ]]; then echo "native-play requires Linux ALSA/cpal and PulseAudio" >&2 exit 2 diff --git a/test/portrait/run.sh b/test/portrait/run.sh index 46751493771..d88d3b22b8e 100755 --- a/test/portrait/run.sh +++ b/test/portrait/run.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash # Publish a coded portrait, transcode a short-side rung, and paint it in Chromium. set -euo pipefail + +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../../sh/local.sh" bash "$0" "$@" +fi DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) WORKSPACE=$(cd "$DIR/../.." && pwd) # shellcheck source-path=SCRIPTDIR source=../lib/harness.sh diff --git a/test/ts/eit-roundtrip.sh b/test/ts/eit-roundtrip.sh index 35f4da7e903..959efab0962 100755 --- a/test/ts/eit-roundtrip.sh +++ b/test/ts/eit-roundtrip.sh @@ -16,6 +16,10 @@ set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../../sh/local.sh" bash "$0" "$@" +fi + DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # shellcheck source-path=SCRIPTDIR source=../lib/harness.sh source "$DIR/../lib/harness.sh" diff --git a/test/ts/run.sh b/test/ts/run.sh index cbca53d1473..87eba95c6e3 100755 --- a/test/ts/run.sh +++ b/test/ts/run.sh @@ -49,6 +49,10 @@ # see a cadence regression at all. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../../sh/local.sh" bash "$0" "$@" +fi + DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) WORKSPACE=$(cd "$DIR/../.." && pwd) diff --git a/test/wasm/run.sh b/test/wasm/run.sh index 4d2037392a5..657425aea83 100755 --- a/test/wasm/run.sh +++ b/test/wasm/run.sh @@ -17,6 +17,10 @@ # so each case is also an interop check. See README.md. set -euo pipefail +if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then + exec bash "$(dirname "$0")/../../sh/local.sh" bash "$0" "$@" +fi + WASM_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) WORKSPACE=$(cd "$WASM_DIR/../.." && pwd) From 765230e930172af3b80e898a155f88e7b65c2d3c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 15:38:14 -0700 Subject: [PATCH 03/11] quest: retire local check admission Co-Authored-By: Claude Opus 5.5 --- quest/m0/ci/README.md | 1 - quest/m0/ci/local-gate.md | 32 -------------------------------- 2 files changed, 33 deletions(-) delete mode 100644 quest/m0/ci/local-gate.md diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index 3fee91ca6af..e1f609c4324 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -81,7 +81,6 @@ The historical samples locate candidates; they are not controlled benchmarks. ## Required - [Require the release gate](/quest/m0/ci/release-gates.md) - condition: the next cut carries `release-gate.yml`; then release PRs require it -- [Share local check capacity](/quest/m0/ci/local-gate.md) - gate expensive phases and bound internal fanout - [Verify the R2 Rust cache](/quest/m0/ci/mbx-r2-verify.md) - condition: the maintainer bootstrap; then measure the hosted Nightly jobs' hits, restore time, and expiry - [Verify the Nix cache](/quest/m0/ci/nix-cache-verify.md) - confirm CI and releases use `nix.moq.dev` and retire Cachix - [First shared FFI release](/quest/m0/ci/nightly-ffi-reuse.md) - condition: the first `moq-ffi-v*` tag that runs `Release FFI`, and a `Shipping sizes` run; verify the wrappers and size keys diff --git a/quest/m0/ci/local-gate.md b/quest/m0/ci/local-gate.md deleted file mode 100644 index d6162cf46ef..00000000000 --- a/quest/m0/ci/local-gate.md +++ /dev/null @@ -1,32 +0,0 @@ -# [S] Verify shared local check admission - -## Goal - -Finish validating automatic host admission and bounded local worker fanout across -root, direct language, and fixture entrypoints, preserving selected tests, -failure status, and cancellation cleanup. - -## Plan - -- [Implementation PR](https://github.com/moq-dev/moq/pull/6256) adds shared - admission before expensive builds and fixture launch, outside test timeout - clocks. Nested work reuses admission and supervision; hosted CI keeps its - existing scheduling. Rust compilation still uses mbx. -- Measured warm solo and paired checkouts with admission delay separated from - work wall time and CPU time. Local nextest defaults to four workers, with - the existing io-uring group limit retained. Bun workspace scripts run - sequentially. The PR records the measurements and budget tradeoff. -- Launcher and dispatch tests verify hosted CI, nested and external admission, - failure status, worker overrides, and cancellation of descendants. They run - in the existing nightly tooling suite. -- Remaining: run the complete `just ci` gate on a host whose Nix runner-image - builder can create the required user namespace. The current builder fails - writing `/proc/self/uid_map` with `Operation not permitted`; other PRs report - the same restriction, including [the listener tests](https://github.com/moq-dev/moq/pull/6234). -- The direct Rust test phase also stops at - `stats::a_late_sink_reads_the_final_stats`, which fails with "the import - exited before its input ended". The CLI source is unchanged and - [the listener PR](https://github.com/moq-dev/moq/pull/6234) reproduces the - failure on the base. Resolve that independently before the full gate can pass. -- Two existing nightly fixture assertions are owned by - [the CI audit](https://github.com/moq-dev/moq/pull/6266). From c51900da27f8bce45500d8174e501daf8cb20dcf Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 16:18:44 -0700 Subject: [PATCH 04/11] fix(sh): adopt orphans so cancellation reaches the whole tree Bun's --no-orphans only kills descendants still under the supervisor, and a grandchild whose parent exits first reparented out of reach. The supervisor now becomes a child subreaper on Linux and waits for its child after forwarding a signal, so every survivor is its own child when it exits. Co-Authored-By: Claude Opus 5.5 --- sh/local.test.py | 20 ++++++++++++++++++++ sh/local.ts | 17 +++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/sh/local.test.py b/sh/local.test.py index ff52f6f594e..de4b03fdbfd 100644 --- a/sh/local.test.py +++ b/sh/local.test.py @@ -93,6 +93,26 @@ def test_cancellation_reaches_descendants_and_waits_for_cleanup(self): process.kill() process.wait() + @unittest.skipUnless(sys.platform == "linux", "adopting orphans requires Linux") + def test_exit_reaches_descendants_orphaned_by_their_parent(self): + # The child exits first, so its grandchild reparents before the supervisor exits. + script = """import subprocess, sys +subprocess.Popen([sys.executable, "-c", "import signal; signal.pause()"]) +print("ready", flush=True) +sys.exit(5) +""" + process = subprocess.Popen([BUN, "--no-orphans", str(SUPERVISOR), sys.executable, "-c", script], + env=self.env(QUEST_GATE_ADMITTED="1"), + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + try: + output, error = process.communicate(timeout=30) + self.assertEqual(process.returncode, 5, error) + self.assertEqual(output.strip(), "ready") + finally: + if process.poll() is None: + process.kill() + process.wait() + if __name__ == "__main__": unittest.main() diff --git a/sh/local.ts b/sh/local.ts index 688cbcbae52..fdfc908ad37 100644 --- a/sh/local.ts +++ b/sh/local.ts @@ -1,18 +1,31 @@ // Bun's --no-orphans owns every descendant, including detached fixture groups. +import { dlopen, FFIType } from "bun:ffi"; import { constants } from "node:os"; const command = Bun.argv.slice(2); if (!command.length) throw new Error("usage: sh/local.ts COMMAND [ARGS...]"); + +// --no-orphans only reaches descendants still in this tree, and a grandchild whose parent +// exits first reparents out of it. Adopting orphans keeps them reachable on Linux. +if (process.platform === "linux") { + const PR_SET_CHILD_SUBREAPER = 36; + const libc = dlopen("libc.so.6", { prctl: { args: [FFIType.i32, FFIType.u64], returns: FFIType.i32 } }); + if (libc.symbols.prctl(PR_SET_CHILD_SUBREAPER, 1) !== 0) throw new Error("prctl(PR_SET_CHILD_SUBREAPER) failed"); +} + const child = Bun.spawn(command, { stdin: "inherit", stdout: "inherit", stderr: "inherit", env: { ...process.env, MOQ_LOCAL_SUPERVISED: "1" }, }); +// Forward cancellation and let the child clean up; once it exits, every survivor is ours. +let signaled: number | undefined; for (const name of ["SIGINT", "SIGTERM", "SIGHUP"] as const) { process.on(name, () => { + signaled ??= 128 + constants.signals[name]; child.kill(name); - process.exit(128 + constants.signals[name]); }); } -process.exit(await child.exited); +const code = await child.exited; +process.exit(signaled ?? code); From f6930b7b74a25baee0937d971c36365ac05c0137 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 23 Oct 2026 16:53:23 -0700 Subject: [PATCH 05/11] fix(bench): run every checkout solo and alternate run order bench/local.py measured only the first checkout solo, ran every solo sample before any concurrent one, and accepted missing or duplicate checkouts. The JS workspace executor tests now pin GITHUB_ACTIONS, which `just gh test` runs under hosted CI on every check, and cover the hosted command without `--sequential`. Co-Authored-By: Claude Opus 5.5 --- bench/local.py | 17 ++++++++++++----- sh/js/workspace.test.py | 7 +++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/bench/local.py b/bench/local.py index 21588b3655e..921d260096b 100644 --- a/bench/local.py +++ b/bench/local.py @@ -33,17 +33,23 @@ def main(): parser.error("a command, positive samples and positive worker counts are required") if os.name != "posix": parser.error("CPU accounting requires a POSIX host") + checkouts = [checkout.resolve() for checkout in args.checkout] + if not all(checkout.is_dir() for checkout in checkouts) or len(set(checkouts)) != len(checkouts): + parser.error("each checkout must be a distinct existing directory") + # Every checkout runs solo, so a concurrent run is compared against its own baseline. + groups = [[checkout] for checkout in checkouts] + ([checkouts] if len(checkouts) > 1 else []) def cancel(number, _frame): raise SystemExit(128 + number) for number in (signal.SIGTERM, signal.SIGHUP): signal.signal(number, cancel) - for copies in sorted({1, len(args.checkout)}): - for workers in args.workers: - for sample in range(args.samples): + # Alternating the order spreads drift in host load or thermals over solo and concurrent runs. + for sample in range(args.samples): + for group in groups if sample % 2 == 0 else reversed(groups): + for workers in args.workers: processes = [] load = os.getloadavg() try: - for checkout in args.checkout[:copies]: + for checkout in group: directory = checkout / ".scratch/local-bench" directory.mkdir(parents=True, exist_ok=True) stem = directory / str(uuid.uuid4()) @@ -73,7 +79,8 @@ def cancel(number, _frame): if process.returncode is None: process.terminate() process.wait() - print(json.dumps({"copies": copies, "nextest_workers": workers, "sample": sample, + print(json.dumps({"copies": len(group), "checkouts": [str(checkout) for checkout in group], + "nextest_workers": workers, "sample": sample, "cache": args.cache, "host_load": load, "command": command, "runs": results}), flush=True) diff --git a/sh/js/workspace.test.py b/sh/js/workspace.test.py index 3263b2ed4fd..7cb6b7e939a 100644 --- a/sh/js/workspace.test.py +++ b/sh/js/workspace.test.py @@ -174,7 +174,7 @@ def test_cycles_terminate(self): self.assertEqual(set(self.plan(["js/view/src/index.ts"])["packages"]), {"@example/core", "@example/view", "docs"}) - def calls(self, paths, action="check"): + def calls(self, paths, action="check", github_actions=False): calls = [] self.configurations = [] def invoke(args, **kwargs): @@ -182,7 +182,8 @@ def invoke(args, **kwargs): if args[:2] == ("bunx", "tsc") and args[-1] != "test/tsconfig.json": self.configurations.append(json.loads(Path(args[-1]).read_text())) return type("Result", (), {"returncode": 1 if args[0] == "grep" else 0})() - with patch.object(selector, "ROOT", self.root), patch.object(selector.os, "chdir"), \ + with patch.dict(selector.os.environ, GITHUB_ACTIONS=str(github_actions).lower()), \ + patch.object(selector, "ROOT", self.root), patch.object(selector.os, "chdir"), \ patch.object(selector.subprocess, "run", side_effect=invoke), \ patch.object(selector.shutil, "which", return_value="tool"): selector.run(action, self.plan(paths)) @@ -226,6 +227,8 @@ def test_executor_builds_wasm_before_consumer_check(self): def test_tests_do_not_build_wasm_or_unselected_packages(self): calls = self.calls(["doc/index.md"], "test") self.assertIn(["bun", "run", "--sequential", "--filter=docs", "--elide-lines=0", "test"], calls) + hosted = self.calls(["doc/index.md"], "test", github_actions=True) + self.assertIn(["bun", "run", "--filter=docs", "--elide-lines=0", "test"], hosted) self.assertFalse(any(c[0] == "just" for c in calls)) def test_owned_package_without_scripts_keeps_harness_check(self): From 4cb4700777b2f64d9aa9768085f3926cb44c6105 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 23 Oct 2026 22:33:41 -0700 Subject: [PATCH 06/11] docs(bench): drop a doubled blank line left by the main merge Co-Authored-By: Claude Opus 5.5 --- bench/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/bench/README.md b/bench/README.md index 7107b62ca66..9fac1c40947 100644 --- a/bench/README.md +++ b/bench/README.md @@ -492,7 +492,6 @@ Each run's evidence directory keeps both builds' estimates (`criterion` and `criterion-base`), the confirmation rounds under `confirm/`, and the run's `paired.json`. - ## Local check capacity Prepare the same warm dependencies and artifacts in each isolated checkout, then From 53cb206cef669fb2a4bd5f872f7ef3446ffd6592 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 12:01:16 -0700 Subject: [PATCH 07/11] bench: sweep check lanes in bench-local Co-Authored-By: Claude Opus 5.5 --- bench/README.md | 14 ++++++++------ bench/local.py | 11 +++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/bench/README.md b/bench/README.md index 9fac1c40947..61a13828c53 100644 --- a/bench/README.md +++ b/bench/README.md @@ -503,9 +503,11 @@ just bench-local --checkout "$PWD" --checkout /path/to/another/checkout \ cargo nextest run --locked -p moq-net --lib ``` -Each JSON record retains host load, configured workers, admission delay, work -wall time, total wall time, and child CPU time. Logs stay under each checkout's -`.scratch/local-bench/`. To compare Bun workspace fanout, repeat with the same -`bun run --filter=... test` command, then add `--sequential`. Admission remains -outside the suite's timeout clocks. Use separate checkouts to avoid measuring -Cargo's artifact lock instead of competing work. +Each JSON record retains host load, configured workers and lanes, admission +delay, work wall time, total wall time, and child CPU time. Logs stay under each +checkout's `.scratch/local-bench/`. To compare Bun workspace fanout, repeat with +the same `bun run --filter=... test` command, then add `--sequential`. To compare +the module lanes `just check` runs at once, sweep `--jobs 1 3` over +`bash sh/dispatch.sh check BASE`, which is then admitted once as a whole. +Admission remains outside the suite's timeout clocks. Use separate checkouts to +avoid measuring Cargo's artifact lock instead of competing work. diff --git a/bench/local.py b/bench/local.py index 921d260096b..1ac9effdeb5 100644 --- a/bench/local.py +++ b/bench/local.py @@ -24,13 +24,14 @@ def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--checkout", action="append", type=Path, required=True) parser.add_argument("--workers", nargs="+", type=int, required=True) + parser.add_argument("--jobs", nargs="+", type=int, help="MOQ_CHECK_JOBS lane counts to sweep") parser.add_argument("--samples", type=int, default=3) parser.add_argument("--cache", required=True, help="Describe the prepared cache state") parser.add_argument("command", nargs=argparse.REMAINDER) args = parser.parse_args() command = args.command[1:] if args.command[:1] == ["--"] else args.command - if not command or args.samples < 1 or any(n < 1 for n in args.workers): - parser.error("a command, positive samples and positive worker counts are required") + if not command or args.samples < 1 or any(n < 1 for n in args.workers + (args.jobs or [])): + parser.error("a command, positive samples and positive worker and job counts are required") if os.name != "posix": parser.error("CPU accounting requires a POSIX host") checkouts = [checkout.resolve() for checkout in args.checkout] @@ -45,7 +46,7 @@ def cancel(number, _frame): # Alternating the order spreads drift in host load or thermals over solo and concurrent runs. for sample in range(args.samples): for group in groups if sample % 2 == 0 else reversed(groups): - for workers in args.workers: + for workers, jobs in ((w, j) for w in args.workers for j in args.jobs or [None]): processes = [] load = os.getloadavg() try: @@ -56,6 +57,8 @@ def cancel(number, _frame): stamp = stem.with_suffix(".started") with stem.with_suffix(".log").open("w") as log: env = dict(os.environ, NEXTEST_TEST_THREADS=str(workers)) + if jobs: + env["MOQ_CHECK_JOBS"] = str(jobs) env.pop("QUEST_GATE_ADMITTED", None) env.pop("MOQ_LOCAL_SUPERVISED", None) env.pop("GITHUB_ACTIONS", None) @@ -80,7 +83,7 @@ def cancel(number, _frame): process.terminate() process.wait() print(json.dumps({"copies": len(group), "checkouts": [str(checkout) for checkout in group], - "nextest_workers": workers, "sample": sample, + "nextest_workers": workers, "check_jobs": jobs, "sample": sample, "cache": args.cache, "host_load": load, "command": command, "runs": results}), flush=True) From fca1ec190f22bd681a0c52044ee736e9adc49598 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 12:42:41 -0700 Subject: [PATCH 08/11] test: keep tooling tests out of the host gate The selection and lint tests ran sh/local.sh unsupervised, so each case took a real quest gate admission: about 20 per just check, spaced 5 seconds apart once they filled the host's headroom, which made the gh tests the slowest lane and slowed other worktrees' admissions for a minute. Co-Authored-By: Claude Opus 5.5 --- sh/rs/select.test.py | 2 +- sh/rs/test-lints.test.py | 5 ++--- sh/rs/uring.test.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sh/rs/select.test.py b/sh/rs/select.test.py index eb62496ae5d..f3d5fb4afca 100644 --- a/sh/rs/select.test.py +++ b/sh/rs/select.test.py @@ -104,7 +104,7 @@ def test_unexecuted_bench_is_not_compiled(self): (scratch / "benches/unexecuted.rs").write_text( 'compile_error!("nextest must not compile a benchmark it never runs");\nfn main() {}\n' ) - env = dict(os.environ, BASH_ENV=os.devnull, TMPDIR="/tmp", + env = dict(os.environ, MOQ_LOCAL_SUPERVISED="1", BASH_ENV=os.devnull, TMPDIR="/tmp", NEXTEST_PROFILE="default") result = subprocess.run( ["just", "rs", "test", "--manifest-path", str(scratch / "Cargo.toml")], diff --git a/sh/rs/test-lints.test.py b/sh/rs/test-lints.test.py index 2f80fecf8de..005dd6eff01 100644 --- a/sh/rs/test-lints.test.py +++ b/sh/rs/test-lints.test.py @@ -18,8 +18,7 @@ def test_clippy_warning_fails_test_build(self): (root / "rs").mkdir() (root / "sh" / "rs").mkdir(parents=True) (root / "src").mkdir() - for script in ("local.sh", "local.ts"): - shutil.copy(ROOT / "sh" / script, root / "sh" / script) + shutil.copy(ROOT / "sh" / "local.sh", root / "sh" / "local.sh") (root / "justfile").write_text("mod rs\n") shutil.copy(ROOT / "rs" / "justfile", root / "rs" / "justfile") shutil.copy(ROOT / "sh" / "rs" / "nextest.sh", root / "sh" / "rs" / "nextest.sh") @@ -31,7 +30,7 @@ def test_clippy_warning_fails_test_build(self): '#[test]\nfn runs() { assert!(empty(&[])); }\n' ) toolchain = Path(shutil.which("clippy-driver")).parent - env = dict(os.environ, CARGO_TARGET_DIR=str(root / "target"), + env = dict(os.environ, MOQ_LOCAL_SUPERVISED="1", CARGO_TARGET_DIR=str(root / "target"), PATH=f"{toolchain}:{os.environ['PATH']}", NEXTEST_PROFILE="default") subprocess.run(["cargo", "generate-lockfile", "--offline"], cwd=root, diff --git a/sh/rs/uring.test.py b/sh/rs/uring.test.py index 207969b9b59..0646adfac3c 100644 --- a/sh/rs/uring.test.py +++ b/sh/rs/uring.test.py @@ -31,7 +31,7 @@ def test_selection_follows_shared_dependencies(self): cargo.write_text('#!/bin/sh\ncat "$TEST_METADATA"\n') cargo.chmod(0o755) changed = scratch / "changed" - env = dict(os.environ, PATH=f"{scratch}:{os.environ['PATH']}", + env = dict(os.environ, MOQ_LOCAL_SUPERVISED="1", PATH=f"{scratch}:{os.environ['PATH']}", SELECT_CALLS=str(calls), TEST_METADATA=str(fixture)) for path, passes in ( ("rs/moq-uring/src/worker.rs", True), ("rs/moq-relay/src/uring.rs", True), From 53fef2c04cedd6a5fe877f094840dcdc79c11ff8 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 12:42:56 -0700 Subject: [PATCH 09/11] docs: name the check lanes beside admission Co-Authored-By: Claude Opus 5.5 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b60f0bf3670..d8f13dad37f 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,8 @@ CPU load and available memory before builds or test timeout clocks start; nested checks reuse that admission. Hosted GitHub Actions keeps its runner scheduling. Rust builds still use the dev shell's mbx Cargo shim. +`just check` and `just ci` run three module lanes at once, each admitted per +command; set `MOQ_CHECK_JOBS` to change that, or to 1 to run them in order. Local nextest runs default to at most four test workers; set `NEXTEST_TEST_THREADS` to override it. Bun workspace scripts run sequentially locally, preserving dependency order, while CI keeps its workspace parallelism. From 217d8d76d0fd0ef50b3d9e24bda44d6c9de2f17f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 13:16:41 -0700 Subject: [PATCH 10/11] bench: record the lane count bench-local actually ran Co-Authored-By: Claude Opus 5.5 --- bench/local.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bench/local.py b/bench/local.py index 1ac9effdeb5..2ad7f59dfce 100644 --- a/bench/local.py +++ b/bench/local.py @@ -57,6 +57,8 @@ def cancel(number, _frame): stamp = stem.with_suffix(".started") with stem.with_suffix(".log").open("w") as log: env = dict(os.environ, NEXTEST_TEST_THREADS=str(workers)) + # Without --jobs, the record's null means sh/dispatch.sh's default. + env.pop("MOQ_CHECK_JOBS", None) if jobs: env["MOQ_CHECK_JOBS"] = str(jobs) env.pop("QUEST_GATE_ADMITTED", None) From 66dd38dc9e9fce1acbc016a6218d9f9d7de2a7f7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 21:19:23 -0700 Subject: [PATCH 11/11] ci: re-exec select.sh by root-relative paths The cd to the repository root invalidated a relative $0, so running select.sh from a subdirectory failed to find sh/local.sh. Co-Authored-By: Claude Opus 5.5 --- sh/rs/select.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sh/rs/select.sh b/sh/rs/select.sh index 69842faca99..01153beddde 100755 --- a/sh/rs/select.sh +++ b/sh/rs/select.sh @@ -113,9 +113,10 @@ case "$packages" in *) echo "rs: selecting $names" ;; esac -# Selection and empty crate sets stay outside admission. +# Selection and empty crate sets stay outside admission. The paths are +# root-relative because the `cd` above invalidates a relative `$0`. if [[ "${GITHUB_ACTIONS:-}" != true && "${MOQ_LOCAL_SUPERVISED:-}" != 1 ]]; then - exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" + exec bash sh/local.sh bash sh/rs/select.sh "$@" fi # The `*-fuzz` crates need a nightly toolchain; only `just rs fuzz` compiles them.