From 412a6cd4d6e04b916cf3ac7c9e95929a6dc214ce Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 07:39:19 -0700 Subject: [PATCH 1/4] chore(quest): claim quest/m1/env-unknown.md Quest-Claim: 40a7c5404978fab5 From e5a3115fa8caa9ba6f840f900bdf52ff0f682a26 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 08:06:20 -0700 Subject: [PATCH 2/4] feat(cli)!: refuse MOQ_* environment variables a binary does not read moq-relay, moq, moq-bench, and moq-boy now exit at startup naming any MOQ_* variable that neither their usage spec declares nor they read directly, so a stale or misspelled deployment name fails loudly instead of running on defaults. The check lives in moq_tokio::cli::check_env and scans vars_os, since vars panics on any non-UTF-8 entry. MOQ_* now belongs to the binaries, so the harness, dev-shell, and CI variables that reach a binary's environment move out of it: MOQ_STRICT -> CI_STRICT, MOQ_DEV_SHELL -> IN_MOQ_DEV_SHELL, MOQ_ALLOW_HOST -> ALLOW_HOST_TOOLCHAIN, MOQ_TEST_* -> HARNESS_*, MOQ_BIN -> CLI_BIN, the smoke docker knobs -> SMOKE_*, the bench harness knobs -> BENCH_*, and a few more. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/audio-quality.yml | 2 +- .github/workflows/features.yml | 2 +- .github/workflows/ietf-conformance.yml | 4 +- .github/workflows/interop.yml | 30 +-- .github/workflows/nightly.yml | 18 +- .github/workflows/smoke.yml | 10 +- .github/workflows/ts.yml | 50 ++--- .github/workflows/uring.yml | 4 +- .github/workflows/wasm.yml | 2 +- README.md | 2 +- bench/README.md | 8 +- bench/browser/run.sh | 4 +- bench/run.sh | 32 ++-- demo/web/justfile | 2 +- demo/web/open-tabs.ts | 4 +- doc/bin/cli.md | 4 +- doc/bin/relay/index.md | 6 +- doc/setup/dev.md | 2 +- doc/setup/upgrade.md | 5 +- flake.nix | 6 +- justfile | 10 +- quest/m1/README.md | 1 - quest/m1/bench-ci.md | 2 +- quest/m1/env-unknown.md | 31 ---- quest/m1/ietf-lazy-discovery.md | 2 +- quest/m1/release-perf/README.md | 2 +- quest/m2/audit-interop.md | 2 +- quest/m2/bench-base-paired.md | 2 +- quest/m2/usage-unknown-env.md | 8 +- quest/m2/v4l2-virtual-camera.md | 2 +- rs/justfile | 4 +- rs/moq-bench/src/config.rs | 4 +- rs/moq-boy/MIGRATE.md | 5 + rs/moq-boy/src/main.rs | 1 + rs/moq-cli/MIGRATE.md | 5 + rs/moq-cli/src/args.rs | 14 +- rs/moq-mux/src/container/ts/recovery_test.rs | 8 +- rs/moq-relay/MIGRATE.md | 5 + rs/moq-relay/src/config.rs | 9 +- rs/moq-relay/src/uring.rs | 6 +- rs/moq-relay/tests/integration/embed.rs | 4 +- rs/moq-relay/tests/integration/lan_mesh.rs | 4 +- rs/moq-relay/tests/integration/peer_limits.rs | 2 +- .../tests/integration/runtime_uring.rs | 4 +- rs/moq-relay/tests/integration/wire_stats.rs | 2 +- rs/moq-tokio/src/cli.rs | 5 +- rs/moq-tokio/src/cli/env.rs | 171 ++++++++++++++++++ rs/moq-tokio/src/mdns.rs | 4 +- rs/moq-uring/README.md | 2 +- rs/moq-uring/src/udp.rs | 6 +- rs/moq-uring/src/worker.rs | 2 +- rs/moq-uring/tests/allocations.rs | 4 +- rs/moq-uring/tests/integration/credit.rs | 4 +- rs/moq-uring/tests/integration/echo.rs | 2 +- rs/moq-uring/tests/integration/ecn.rs | 4 +- rs/moq-uring/tests/integration/endpoint.rs | 4 +- rs/moq-uring/tests/integration/identity.rs | 4 +- rs/moq-uring/tests/integration/local_addr.rs | 4 +- rs/moq-uring/tests/integration/mtu.rs | 4 +- rs/moq-uring/tests/integration/qlog.rs | 4 +- .../tests/integration/receive_credit.rs | 4 +- rs/moq-uring/tests/integration/session.rs | 2 +- rs/moq-uring/tests/integration/teardown.rs | 4 +- rs/moq-uring/tests/integration/web.rs | 4 +- rs/moq-uring/tests/integration/workers.rs | 4 +- rs/moq-video/src/lib.rs | 10 + sh/dispatch-query.test.py | 6 +- sh/dispatch.sh | 14 +- sh/gh/bench-report.py | 4 +- sh/gh/bench-report.test.py | 4 +- sh/gh/nightly.sh | 26 +-- sh/gh/nightly.test.py | 14 +- sh/js/workspace.test.py | 2 +- sh/obs/check.sh | 6 +- test/README.md | 18 +- test/ietf-conformance/README.md | 2 +- test/ietf-conformance/run.sh | 2 +- test/interop/README.md | 6 +- test/interop/clients/js/harness.ts | 8 +- test/interop/compat.sh | 10 +- test/interop/interop.sh | 12 +- test/interop/report.py | 2 +- test/interop/report.test.py | 6 +- test/justfile | 6 +- test/lib/harness.sh | 30 +-- test/lib/harness.test.sh | 12 +- test/native-play/play.py | 2 +- test/smoke/AGENTS.md | 2 +- test/smoke/README.md | 4 +- test/smoke/clients/docker/moq | 4 +- test/smoke/clients/docker/moq-relay | 6 +- test/smoke/cloudflare.sh | 2 +- test/smoke/justfile | 12 +- test/smoke/moxygen.sh | 2 +- test/smoke/smoke.sh | 18 +- test/smoke/token.sh | 4 +- test/ts/README.md | 6 +- test/wasm/baseline/driver.ts | 6 +- test/wasm/driver.ts | 2 +- test/wasm/run.sh | 4 +- test/wasm/uniffi/driver.ts | 4 +- 101 files changed, 520 insertions(+), 336 deletions(-) delete mode 100644 quest/m1/env-unknown.md create mode 100644 rs/moq-tokio/src/cli/env.rs diff --git a/.github/workflows/audio-quality.yml b/.github/workflows/audio-quality.yml index ac771295727..3221cb41749 100644 --- a/.github/workflows/audio-quality.yml +++ b/.github/workflows/audio-quality.yml @@ -34,7 +34,7 @@ jobs: shell: bash -leo pipefail {0} env: # Somewhere upload-artifact can reach; the harness default is under $TMPDIR. - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs # The harness keeps a failing run's directory: every row's samples and summary. - name: Keep the failing run diff --git a/.github/workflows/features.yml b/.github/workflows/features.yml index 29f459d7130..703b038a50e 100644 --- a/.github/workflows/features.yml +++ b/.github/workflows/features.yml @@ -36,4 +36,4 @@ jobs: run: nix develop --command just ${{ matrix.recipe }} env: NEXTEST_PROFILE: ci - MOQ_STRICT: 1 + CI_STRICT: 1 diff --git a/.github/workflows/ietf-conformance.yml b/.github/workflows/ietf-conformance.yml index afe1f63e61b..e82a60cac7e 100644 --- a/.github/workflows/ietf-conformance.yml +++ b/.github/workflows/ietf-conformance.yml @@ -23,8 +23,8 @@ jobs: - name: Pinned Moxygen through the relay under the conformance profile run: nix develop --command just test ietf-conformance env: - MOQ_TEST_RUNS: ${{ runner.temp }}/ietf-conformance - MOQ_TEST_KEEP: 1 + HARNESS_RUNS: ${{ runner.temp }}/ietf-conformance + HARNESS_KEEP: 1 - name: Keep conformance reports and endpoint logs if: ${{ !cancelled() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 diff --git a/.github/workflows/interop.yml b/.github/workflows/interop.yml index a036636c49b..ce55160b206 100644 --- a/.github/workflows/interop.yml +++ b/.github/workflows/interop.yml @@ -72,7 +72,7 @@ jobs: shell: bash -leo pipefail {0} env: # Fail rather than skip the io_uring arm if the runner's kernel lacks it. - MOQ_STRICT: 1 + CI_STRICT: 1 - name: Harness regressions id: harness @@ -101,8 +101,8 @@ jobs: # The run writes its directory here, so a failed one is uploaded below # and a passing one is deleted as usual. Each case's record lands beside # it, for the report below. - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs - MOQ_TEST_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl # The same matrix with every client pinned to one moq-transport draft per pass. A release # PR runs the oldest and newest even draft between Rust and native JS; nightly and manual @@ -116,8 +116,8 @@ jobs: shell: bash -leo pipefail {0} env: INTEROP_ARGS: ${{ github.event_name == 'pull_request' && '--publishers rust --subscribers rust,js-native-node,js-native-bun --versions moq-transport-14,moq-transport-22' || '--all --versions ietf' }} - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs - MOQ_TEST_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl # Registry installs and the release matrix run only on main, nightly or # on demand: a break only needs catching before the next release. @@ -128,8 +128,8 @@ jobs: shell: bash -leo pipefail {0} env: GH_TOKEN: ${{ github.token }} - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs - MOQ_TEST_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl - name: Portrait transcode id: portrait @@ -137,8 +137,8 @@ jobs: run: nix develop --command just test portrait shell: bash -leo pipefail {0} env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs - MOQ_TEST_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl - name: Interop negative control id: negative @@ -146,8 +146,8 @@ jobs: run: nix develop --command just test interop-negative shell: bash -leo pipefail {0} env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs - MOQ_TEST_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl # Browser-to-browser media QA: presented frame progress, audible tone, audio/video skew, and # the publication lifecycle, plus the negative controls that prove each assertion can fail. @@ -157,8 +157,8 @@ jobs: run: nix develop --command just test media shell: bash -leo pipefail {0} env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs - MOQ_TEST_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl # Run independently so an unrelated cold-start failure cannot hide the # codec replacement and same-track coded-size growth measurements. @@ -168,8 +168,8 @@ jobs: run: nix develop --command just test media --media-cases rename shell: bash -leo pipefail {0} env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs - MOQ_TEST_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RESULTS: ${{ runner.temp }}/moq-test-runs/results.jsonl # A failing harness run keeps its directory, holding the process logs, the # relay config, and a Playwright trace of the failing page. Upload it for a diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7cfc10e5d2a..5ee34d09615 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -235,7 +235,7 @@ jobs: run: nix develop ${{ matrix.shell }} --command just ${{ matrix.recipe }} env: NEXTEST_PROFILE: default - MOQ_BENCH_BASE: ${{ matrix.paired && (inputs.bench-base || 'previous-nightly') || '' }} + BENCH_BASE: ${{ matrix.paired && (inputs.bench-base || 'previous-nightly') || '' }} GH_TOKEN: ${{ matrix.paired && github.token || '' }} - name: Record benchmark outcome @@ -351,7 +351,7 @@ jobs: fail-fast: false matrix: # `rs uring` is a separate feature compile (off the default set), and - # MOQ_STRICT fails it below the 6.12 kernel floor. The embedding tests for + # CI_STRICT fails it below the 6.12 kernel floor. The embedding tests for # io_uring live there; uring.yml also runs it on affected release PRs. # `test drain` stands up two relays and drains one under a live JS # viewer: diff-independent, since a break can arrive through the relay, @@ -393,7 +393,7 @@ jobs: run: nix develop --command just ${{ matrix.recipe }} env: NEXTEST_PROFILE: ci - MOQ_STRICT: 1 + CI_STRICT: 1 # Media QA with a Firefox player against a Chromium fixture. The Chromium # player already runs in interop.yml, nightly and on release PRs. WebKit has @@ -423,7 +423,7 @@ jobs: - name: Media and negative controls run: nix develop --command env PLAYWRIGHT_BROWSERS_PATH="${{ runner.temp }}/playwright" just test media --media-engines firefox env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs # Playwright checks a browser's libraries with the `ldd` on PATH, which in the # dev shell is Nix glibc's and can't see the ones `--with-deps` installed, so # it refuses a Firefox that launches fine. @@ -478,16 +478,16 @@ jobs: run: nix develop --command just test native-play shell: bash -leo pipefail {0} env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs - name: Audio quality if: ${{ !cancelled() }} run: nix develop --command just test audio-quality --runtimes chromium --enforce --capture shell: bash -leo pipefail {0} env: # Somewhere upload-artifact can reach; the harness default is under $TMPDIR. - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs # A passing run is kept too: budgets.json is measured from these nights. - MOQ_TEST_KEEP: 1 + HARNESS_KEEP: 1 # The native player's rows, graded but not enforced: an intermittent device # stall voids about one AAC row in seven, which would fail most nights until # it is fixed. Kept beside the browser run so its ceilings can be re-measured. @@ -496,8 +496,8 @@ jobs: run: nix develop --command just test audio-quality --runtimes native shell: bash -leo pipefail {0} env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs - MOQ_TEST_KEEP: 1 + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_KEEP: 1 # The run directory is the diagnosis: each process's log, the shaper's # counters, the raw samples, and every row's summary. - name: Keep the run diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index df4d98ec673..50148eeb6a4 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -209,7 +209,7 @@ jobs: cli=$(nix build --refresh --no-link --print-out-paths 'github:moq-dev/moq#moq') { echo "RELAY_BIN=$relay/bin/moq-relay" - echo "MOQ_BIN=$cli/bin/moq" + echo "CLI_BIN=$cli/bin/moq" } >> "$GITHUB_ENV" # cachix.yml only pushes release tags, so each new HEAD @@ -228,19 +228,19 @@ jobs: echo "no CACHIX_AUTH_TOKEN secret; not pushing" exit 0 fi - nix run nixpkgs#cachix -- push kixelated "${RELAY_BIN%/bin/*}" "${MOQ_BIN%/bin/*}" + nix run nixpkgs#cachix -- push kixelated "${RELAY_BIN%/bin/*}" "${CLI_BIN%/bin/*}" - name: Pull moqdev images (docker channel) if: matrix.channel == 'docker' # Pull :latest fresh, then point smoke.sh at the wrapper scripts (which - # `docker run --network host` the images) via RELAY_BIN/MOQ_BIN. Docker is + # `docker run --network host` the images) via RELAY_BIN/CLI_BIN. Docker is # preinstalled on the Linux runners. run: | docker pull moqdev/moq-relay docker pull moqdev/moq { echo "RELAY_BIN=$PWD/clients/docker/moq-relay" - echo "MOQ_BIN=$PWD/clients/docker/moq" + echo "CLI_BIN=$PWD/clients/docker/moq" } >> "$GITHUB_ENV" # ── browser deps (Chromium runtime libs on Linux) ────────────────── @@ -290,7 +290,7 @@ jobs: # ── token interop ────────────────────────────────────────────────── # Independent of the media matrix: prove the published token tooling # cross-verifies. `moq auth` rides the same channel as moq-relay/moq - # (cargo/apt/brew/nix, on PATH or MOQ_BIN); @moq/auth comes from npm and + # (cargo/apt/brew/nix, on PATH or CLI_BIN); @moq/auth comes from npm and # runs under both node and bun; rust-docker runs `auth` in the # moqdev/moq image. The negative pass inside token.sh confirms each verifier rejects # tampered tokens and the wrong key. diff --git a/.github/workflows/ts.yml b/.github/workflows/ts.yml index 5eeb015d1ce..03e93c9a7f9 100644 --- a/.github/workflows/ts.yml +++ b/.github/workflows/ts.yml @@ -41,7 +41,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts-controls env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs - name: TS pair controls if: ${{ !cancelled() }} @@ -53,14 +53,14 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} - name: TS fragmented PES headers if: ${{ !cancelled() }} run: nix develop --command just test ts --fragment-pes env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # KLV and DVB AC-3 the importer carries as whole PES: each PES comes back byte-equal @@ -69,7 +69,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts --klv --strict env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # A KLV stream joins the program mid-stream and leaves it: the export announces each @@ -78,28 +78,28 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts --revision --strict env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} - name: TS audio-only SCTE-35 if: ${{ !cancelled() }} run: nix develop --command just test ts --clockless audio-scte35 env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} - name: TS sections-only clock if: ${{ !cancelled() }} run: nix develop --command just test ts --clockless sections env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} - name: TS whole-PES-only clock if: ${{ !cancelled() }} run: nix develop --command just test ts --clockless pes env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # `import/export ts --passthrough`: from its first packet the capture is the source's @@ -109,7 +109,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts --passthrough env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # The same over a hardware encoder's capture the T-STD model passes, with a dirty start @@ -118,7 +118,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts-passthrough-capture env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # The same over a whole MPTS: two programs on their own PCR PIDs, whose recovery points @@ -127,7 +127,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts --passthrough --mpts env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # The same round-trip at 2 Mb/s, where every keyframe outgrows a 25 ms PCR slot, @@ -137,7 +137,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts --bitrate 2000000 env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # 1080p video filling a broadcast-sized 9 Mbit CPB, at the default delay: the @@ -147,7 +147,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts --hrd env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # 1080p video with no HRD at its level's 24 Mb/s leak, so the export has to admit @@ -156,7 +156,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts --leak env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # The same video beside two audio PIDs in a multiplex the source fills with no nulls, @@ -166,7 +166,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts --full env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # The same video beside four audio PIDs in a multiplex faster than its Rx: each slot @@ -175,7 +175,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts --headroom env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # The same round-trip over an open-GOP clip: recovery-group orphans are trimmed, @@ -184,7 +184,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts --open-gop --strict env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # Builds the sparse-EPG and pending-version fixtures and round-trips @@ -193,7 +193,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts-eit env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # The T-STD model must pass a broadcast capture and fail the same capture @@ -202,7 +202,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just test ts-tstd env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs shell: bash -leo pipefail {0} # The pair needs enough overlap to grade the slower table cadences. @@ -210,14 +210,14 @@ jobs: if: ${{ !cancelled() && github.event_name != 'pull_request' }} run: nix develop --command just test ts --pair env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs # Live timing needs the real-time window to distinguish drift from startup. - name: TS live release timing if: ${{ !cancelled() && github.event_name != 'pull_request' }} run: nix develop --command just test ts --live --duration 120 env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs # The subscriber's leg congested the way real paths are, through moq-shaper: 7 Mb/s under # the 9 Mb/s video and four audio PIDs, behind a 2 s queue, 25 ms each way. The export must @@ -226,7 +226,7 @@ jobs: if: ${{ !cancelled() && github.event_name != 'pull_request' }} run: nix develop --command just test ts --headroom --rate 7000000 --duration 120 env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs # The same path behind a 250 ms queue, with the relay's loss-based CUBIC: BBRv3 never fills a # queue this deep, CUBIC overflows it every sawtooth. QUIC must recover what the queue drops @@ -235,7 +235,7 @@ jobs: if: ${{ !cancelled() && github.event_name != 'pull_request' }} run: nix develop --command just test ts --headroom --rate 7000000 --queue 250ms --duration 120 env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs MOQ_QUIC_CONGESTION_CONTROL: loss # Passthrough over the overflowing path, under its 10 Mb/s multiplex: what arrives must be @@ -244,7 +244,7 @@ jobs: if: ${{ !cancelled() && github.event_name != 'pull_request' }} run: nix develop --command just test ts --passthrough --rate 7000000 --queue 250ms --duration 120 env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs MOQ_QUIC_CONGESTION_CONTROL: loss # Two minutes of MoQ content faults and a congested bottleneck, on a paused clock: each @@ -253,7 +253,7 @@ jobs: if: ${{ !cancelled() && github.event_name != 'pull_request' }} run: nix develop --command just rs ts-recovery env: - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs - name: Upload failure artifacts if: ${{ failure() }} diff --git a/.github/workflows/uring.yml b/.github/workflows/uring.yml index efc133a0a12..fdd353f8d87 100644 --- a/.github/workflows/uring.yml +++ b/.github/workflows/uring.yml @@ -15,11 +15,11 @@ concurrency: jobs: uring: name: io_uring - # This image provides a 6.12+ kernel; MOQ_STRICT fails the tests if that changes. + # This image provides a 6.12+ kernel; CI_STRICT fails the tests if that changes. runs-on: ubuntu-24.04-arm timeout-minutes: 60 env: - MOQ_STRICT: 1 + CI_STRICT: 1 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 9e868cdb720..a2d96cbf5c5 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -74,7 +74,7 @@ jobs: env: # The run writes its directory here, so a failed one is uploaded below # and a passing one is deleted as usual. - MOQ_TEST_RUNS: ${{ runner.temp }}/moq-test-runs + HARNESS_RUNS: ${{ runner.temp }}/moq-test-runs # A failing harness run keeps its directory, holding the relay logs, their # configs, and a Playwright trace of the failing page. Upload it for a diff --git a/README.md b/README.md index fcd5dad5d92..c99c3988ed3 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ just check --all just fix --all ``` -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. +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: `CI_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 57b07ac885c..0887bf6d2ca 100644 --- a/bench/README.md +++ b/bench/README.md @@ -207,9 +207,9 @@ to the performance cores wherever the kernel lists them already allowed, so an outer `taskset` or cpuset still narrows it. The run prints the pinned cores beside its result and records them as `affinity` in the metadata. A CPU with one core type runs unpinned. -BASE comparisons run paired rounds (default three, `MOQ_BENCH_RUNTIME_ROUNDS`), +BASE comparisons run paired rounds (default three, `BENCH_RUNTIME_ROUNDS`), alternating base/current order. Startup remains outside the final five-second -throughput window. `MOQ_BENCH_ARTIFACTS` chooses the evidence parent (default +throughput window. `BENCH_ARTIFACTS` chooses the evidence parent (default the current worktree's `.scratch/bench`), which must be outside the repository, or git-ignored and outside `bench/`; each invocation retains a new run directory even on failure. It contains raw load/host JSONL, process diagnostics, Criterion statistics, @@ -443,7 +443,7 @@ The latter two write `target/bench/nightly/{rust-bench,js}/report.json`. For a f measured Rust run using the same evidence lifecycle: ```bash -nix develop --command env MOQ_BENCH_LABEL=pattern MOQ_BENCH_RUNS=/tmp/criterion-runs.txt just gh criterion -p moq-pattern --bench matching +nix develop --command env BENCH_LABEL=pattern BENCH_RUNS=/tmp/criterion-runs.txt just gh criterion -p moq-pattern --bench matching nix develop --command just gh benchmark-report rust /tmp /tmp/rust-report.json ``` @@ -484,7 +484,7 @@ Reproduce a paired group locally against any revision; `previous-nightly` resolves the last scheduled Nightly's commit through `gh`: ```bash -nix develop --command env MOQ_BENCH_BASE=previous-nightly just gh nightly rust-bench +nix develop --command env BENCH_BASE=previous-nightly just gh nightly rust-bench nix develop --command just gh benchmark-report gate target/bench/nightly/rust-bench ``` diff --git a/bench/browser/run.sh b/bench/browser/run.sh index 4276908e1f7..6d4239c613e 100755 --- a/bench/browser/run.sh +++ b/bench/browser/run.sh @@ -53,8 +53,8 @@ while [[ $# -gt 0 ]]; do done # Evidence outlives the run, under the benchmark artifact root rather than $TMPDIR. -export MOQ_TEST_RUNS="${MOQ_TEST_RUNS:-$WORKSPACE/target/bench/browser}" -export MOQ_TEST_KEEP=1 +export HARNESS_RUNS="${HARNESS_RUNS:-$WORKSPACE/target/bench/browser}" +export HARNESS_KEEP=1 PROFILE="${BENCH_PROFILE:-release}" RELAY="${RELAY_BIN:-}" diff --git a/bench/run.sh b/bench/run.sh index 89aedccb864..55032de6530 100755 --- a/bench/run.sh +++ b/bench/run.sh @@ -12,9 +12,9 @@ set -euo pipefail # `--shard` sweeps the QUIC shard count against the connection count. MODE=${1:-} -ROUNDS=${MOQ_BENCH_RUNTIME_ROUNDS:-3} +ROUNDS=${BENCH_RUNTIME_ROUNDS:-3} if [[ ! $ROUNDS =~ ^[0-9]+$ ]] || ((10#$ROUNDS < 1)); then - printf 'MOQ_BENCH_RUNTIME_ROUNDS must be a positive integer, got %q\n' "$ROUNDS" >&2 + printf 'BENCH_RUNTIME_ROUNDS must be a positive integer, got %q\n' "$ROUNDS" >&2 exit 1 fi ROUNDS=$((10#$ROUNDS)) @@ -48,10 +48,10 @@ usable_cpus() { } case $MODE in --criterion) - # MOQ_BENCH_BASE pairs each selected target with the same target built at that revision. + # BENCH_BASE pairs each selected target with the same target built at that revision. BASE= - if [[ -n ${MOQ_BENCH_BASE:-} ]]; then - BASE=$(git rev-parse --verify "$MOQ_BENCH_BASE^{commit}") + if [[ -n ${BENCH_BASE:-} ]]; then + BASE=$(git rev-parse --verify "$BENCH_BASE^{commit}") fi CRITERION_CARGO_ARGS=() CRITERION_FILTER_ARGS=() @@ -71,11 +71,11 @@ case $MODE in ;; --profile) BASE= - PROFILE_MODES=${MOQ_BENCH_PROFILE:-} - PROFILE_WORKLOAD=${MOQ_BENCH_PROFILE_WORKLOAD:-fanout} - PROFILE_WORKERS=${MOQ_BENCH_PROFILE_WORKERS:-1 4 16} + PROFILE_MODES=${BENCH_PROFILE_MODES:-} + PROFILE_WORKLOAD=${BENCH_PROFILE_WORKLOAD:-fanout} + PROFILE_WORKERS=${BENCH_PROFILE_WORKERS:-1 4 16} if [[ -z $PROFILE_MODES ]]; then - printf 'MOQ_BENCH_PROFILE must name one or more of: lock cpu heap\n' >&2 + printf 'BENCH_PROFILE_MODES must name one or more of: lock cpu heap\n' >&2 exit 1 fi for value in $PROFILE_MODES; do @@ -90,8 +90,8 @@ case $MODE in ;; --shard) BASE= - SHARD_COUNTS=${MOQ_BENCH_SHARD_COUNTS:-0 1 4 16} - SHARD_CONNECTIONS=${MOQ_BENCH_SHARD_CONNECTIONS:-16 64 256} + SHARD_COUNTS=${BENCH_SHARD_COUNTS:-0 1 4 16} + SHARD_CONNECTIONS=${BENCH_SHARD_CONNECTIONS:-16 64 256} for value in $SHARD_COUNTS $SHARD_CONNECTIONS; do if [[ ! $value =~ ^[0-9]+$ ]]; then printf 'shard benchmark counts must be integers, got %q\n' "$value" >&2 @@ -101,7 +101,7 @@ case $MODE in ;; --runtime) BASE= - RUNTIME_WORKERS=${MOQ_BENCH_RUNTIME_WORKERS:-} + RUNTIME_WORKERS=${BENCH_RUNTIME_WORKERS:-} if [[ -z $RUNTIME_WORKERS ]]; then RUNTIME_WORKERS=$(usable_cpus) if ((RUNTIME_WORKERS > 256)); then @@ -126,13 +126,13 @@ fi BASE_TARGET=$TARGET/base CURRENT_TARGET=$TARGET/current -ARTIFACTS=${MOQ_BENCH_ARTIFACTS:-$ROOT/.scratch/bench} +ARTIFACTS=${BENCH_ARTIFACTS:-$ROOT/.scratch/bench} mkdir -p "$ARTIFACTS" ARTIFACTS=$(cd "$ARTIFACTS" && pwd -P) # Each run copies bench/ and untracked sources, so it must land in neither. if [[ $ARTIFACTS/ == "$ROOT"/bench/* ]] || { [[ $ARTIFACTS/ == "$ROOT"/* ]] && ! git -C "$ROOT" check-ignore -q "$ARTIFACTS"; }; then - printf 'MOQ_BENCH_ARTIFACTS must be outside the repository, or git-ignored and outside bench/: %s\n' \ + printf 'BENCH_ARTIFACTS must be outside the repository, or git-ignored and outside bench/: %s\n' \ "$ARTIFACTS" >&2 exit 1 fi @@ -887,8 +887,8 @@ if [[ $MODE == --criterion ]]; then # Each invocation owns fresh results; previous runs cannot become new points. python3 -c 'import json,sys; from pathlib import Path; Path(sys.argv[1]).write_text(json.dumps(sys.argv[2:]))' \ "$RUN/criterion-command.json" "${@:2}" - if [[ -n ${MOQ_BENCH_RUNS:-} ]]; then - printf '%s\n' "$RUN" >>"$MOQ_BENCH_RUNS" + if [[ -n ${BENCH_RUNS:-} ]]; then + printf '%s\n' "$RUN" >>"$BENCH_RUNS" fi measure_criterion exit diff --git a/demo/web/justfile b/demo/web/justfile index 7eac80ea2ac..29d6637263c 100644 --- a/demo/web/justfile +++ b/demo/web/justfile @@ -7,7 +7,7 @@ default: # Run the web server targeting the specified relay. # The vite config opens the watch, publish, and stats demos in separate tabs; -# set MOQ_NO_OPEN=1 to skip opening a browser. +# set DEMO_NO_OPEN=1 to skip opening a browser. serve url='http://localhost:4443': install VITE_RELAY_URL="{{ url }}" bun --bun vite diff --git a/demo/web/open-tabs.ts b/demo/web/open-tabs.ts index 49639112be6..7f275a046bd 100644 --- a/demo/web/open-tabs.ts +++ b/demo/web/open-tabs.ts @@ -7,14 +7,14 @@ import type { Plugin } from "vite"; * `just web` brings up the watch, publish, and stats demos side by side. * * Pass `--open` to vite to also let it open the default page (don't; this - * replaces it). Set MOQ_NO_OPEN=1 to skip opening entirely. + * replaces it). Set DEMO_NO_OPEN=1 to skip opening entirely. */ export function openTabs(paths: string[]): Plugin { return { name: "moq-open-tabs", apply: "serve", configureServer(server) { - if (process.env.MOQ_NO_OPEN) return; + if (process.env.DEMO_NO_OPEN) return; server.httpServer?.once("listening", () => { const address = server.httpServer?.address(); diff --git a/doc/bin/cli.md b/doc/bin/cli.md index bbb84ae55fd..bb40282e8d7 100644 --- a/doc/bin/cli.md +++ b/doc/bin/cli.md @@ -60,7 +60,9 @@ the handshake, so `--listen-timeout` bounds it too; `0s` leaves admission withou a deadline. `moq import --help` lists the sources and `moq import rtmp --help` a specific -one; every flag is documented there. Flags renamed between releases are listed in +one; every flag is documented there. A `MOQ_*` environment variable `moq` does +not read, such as a misspelling or one meant for `moq-relay`, stops it at startup +with the variable named. Flags renamed between releases are listed in [MIGRATE.md](https://github.com/moq-dev/moq/blob/main/rs/moq-cli/MIGRATE.md). ```bash diff --git a/doc/bin/relay/index.md b/doc/bin/relay/index.md index 4fd631190fe..79af9ecd559 100644 --- a/doc/bin/relay/index.md +++ b/doc/bin/relay/index.md @@ -45,7 +45,8 @@ public = "**" # anonymous access to everything; development only ``` Every option is also a `--flag` or `MOQ_*` environment variable, and -`RUST_LOG` controls logging. The +`RUST_LOG` controls logging. A `MOQ_*` variable the relay does not read, such as +a misspelling, stops it at startup with the variable named. The [configuration reference](/bin/relay/config) covers every section, and [`demo/relay/`](https://github.com/moq-dev/moq/tree/main/demo/relay) has working configs for development, production, and a cluster. Options renamed @@ -60,7 +61,8 @@ what you need, and call `run`, which keeps the listeners, QUIC workers, and shutdown inside the relay. An embedded CLI calls `config.relay.merge(&cli_layer)?` after its own `parse_from_with_settings` to load the relay file and environment, retain provenance, and refuse obsolete -spellings. CLI-only fields on the embedding root stay intact. +spellings, then `moq_tokio::cli::check_env` with its own spec to refuse `MOQ_*` +variables it does not read. CLI-only fields on the embedding root stay intact. ```rust use axum::routing::get; diff --git a/doc/setup/dev.md b/doc/setup/dev.md index 9d5bbd3157b..7767ff79884 100644 --- a/doc/setup/dev.md +++ b/doc/setup/dev.md @@ -8,7 +8,7 @@ description: Build, test, and debug the MoQ repository The repository uses [Just](https://github.com/casey/just) as its command runner. Run commands inside the Nix dev shell (`nix develop`) so your tools match CI. `just check` and `just fix` refuse to run outside it; set -`MOQ_ALLOW_HOST=1` to use the host toolchain anyway. +`ALLOW_HOST_TOOLCHAIN=1` to use the host toolchain anyway. | Command | Purpose | | --- | --- | diff --git a/doc/setup/upgrade.md b/doc/setup/upgrade.md index 86ad4cce3d1..f04d064eb2d 100644 --- a/doc/setup/upgrade.md +++ b/doc/setup/upgrade.md @@ -19,8 +19,9 @@ wire changes that decide the order to upgrade a deployment. A released flag, environment variable, or config key that was renamed is refused at startup with its replacement named, rather than ignored. Fix what the -error lists and rerun. The one exception is moq-cli's removed `MOQ_HOP`, which is -ignored; its guide says what replaces it. +error lists and rerun. Any other `MOQ_*` variable a binary does not read, such as +moq-cli's removed `MOQ_HOP`, is refused at startup too; its guide says what +replaces it. ## Migration guides diff --git a/flake.nix b/flake.nix index 0c254a48be7..f5b825986bc 100644 --- a/flake.nix +++ b/flake.nix @@ -285,7 +285,7 @@ ]; # Linters / formatters used by `just check` and `just fix`, which - # skip a module whose tools aren't on $PATH. CI sets MOQ_STRICT=1, + # skip a module whose tools aren't on $PATH. CI sets CI_STRICT=1, # which turns that skip into an error (see the tools map in # sh/dispatch.sh), so this list and that one have to stay in step. lintDeps = with pkgs; [ @@ -390,7 +390,7 @@ # uniffi-bindgen-cpp renders rs/moq-ffi for cpp/moq's CMake build. Not in # nixpkgs, so build it from source; without it `just check` skips the - # cpp module, which MOQ_STRICT turns into a failure in CI. + # cpp module, which CI_STRICT turns into a failure in CI. # # Like uniffi-bindgen-go, the tag pairs the generator's version with the # uniffi release it reads, so it moves with the `uniffi` dependency in @@ -643,7 +643,7 @@ env = { # What sh/dispatch.sh checks before a scoped `just check` or `just # fix`. IN_NIX_SHELL would also pass inside another project's shell. - MOQ_DEV_SHELL = "1"; + IN_MOQ_DEV_SHELL = "1"; PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}"; PLAYWRIGHT_VERSION = pkgs.playwright-driver.version; diff --git a/justfile b/justfile index 6cd8b218f1e..96f16ce4248 100644 --- a/justfile +++ b/justfile @@ -64,17 +64,17 @@ bench-audio: # io_uring workers; WORKERS defaults to every logical CPU. # Example: `just bench-runtime 5 16`. bench-runtime $ROUNDS="3" $WORKERS="": - MOQ_BENCH_RUNTIME_ROUNDS="$ROUNDS" MOQ_BENCH_RUNTIME_WORKERS="$WORKERS" bench/run.sh --runtime + BENCH_RUNTIME_ROUNDS="$ROUNDS" BENCH_RUNTIME_WORKERS="$WORKERS" bench/run.sh --runtime # Sweep the relay's QUIC shard count against room and fanout connection counts; # 0 shards is the shared runtime. Example: `just bench-shard "0 1 8" "64 512"`. bench-shard $SHARDS="0 1 4 16" $CONNECTIONS="16 64 256": - MOQ_BENCH_SHARD_COUNTS="$SHARDS" MOQ_BENCH_SHARD_CONNECTIONS="$CONNECTIONS" bench/run.sh --shard + BENCH_SHARD_COUNTS="$SHARDS" BENCH_SHARD_CONNECTIONS="$CONNECTIONS" bench/run.sh --shard # Profile the relay at each worker count: std mutex waits by stack (lock), CPU # stacks (cpu), or jemalloc heap and churn (heap). Example: `just bench-profile "cpu heap" fanout-heavy 4`. bench-profile $MODES $WORKLOAD="fanout" $WORKERS="1 4 16": - MOQ_BENCH_PROFILE="$MODES" MOQ_BENCH_PROFILE_WORKLOAD="$WORKLOAD" MOQ_BENCH_PROFILE_WORKERS="$WORKERS" bench/run.sh --profile + BENCH_PROFILE_MODES="$MODES" BENCH_PROFILE_WORKLOAD="$WORKLOAD" BENCH_PROFILE_WORKERS="$WORKERS" bench/run.sh --profile # Real-browser transport, CMAF, and publish/watch costs, optionally against a base: # `just bench-browser origin/main`. `--smoke` is the bounded correctness lane. @@ -99,11 +99,11 @@ check $BASE="": # The merge queue runs this gate in one job. The test build also enforces # default-feature clippy; distinct feature permutations and optimized binding -# builds run nightly and on release PRs. Missing tools fail under MOQ_STRICT. +# builds run nightly and on release PRs. Missing tools fail under CI_STRICT. # Run the merge queue's Linux gate over the branch diff against BASE. ci $BASE="": - MOQ_STRICT=1 NEXTEST_PROFILE=ci sh/dispatch.sh ci "$BASE" + CI_STRICT=1 NEXTEST_PROFILE=ci sh/dispatch.sh ci "$BASE" # Run the queue's Linux gate over every package. gate: diff --git a/quest/m1/README.md b/quest/m1/README.md index 293cb64ec03..45c62156bec 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -158,7 +158,6 @@ audit's receive-memory, priority, and lease bugs rank ahead of that reshape. - [Peers advertise their implementation and version](/quest/m1/peer-version.md) - moq-net and `@moq/net` send a `name/version` SETUP parameter both ways, and the auth request and session span carry the client's - [Binding peer version](/quest/m1/binding-peer-version.md) - every binding names itself ahead of the Rust core in that parameter - [Calibrate the paired nightly benchmarks](/quest/m1/bench-ci.md) - A/A and deliberately slowed Nightly runs set the paired comparison's threshold, so its regression alerts can be trusted -- [Refuse unknown MOQ_* environment variables](/quest/m1/env-unknown.md) - every binary exits at startup naming a `MOQ_*` variable it does not read - [HLS recorder in the CLI](/quest/m1/hls-record-cli.md) - `export hls --output ` records playlists and segments to a directory - [Group storage benchmark](/quest/m1/group-storage-bench.md) - numbers pick the append-only log, a ring buffer, or sorted runs for `GroupState` before either lands - [Unbounded groups](/quest/m1/unbounded-groups/README.md) - groups and frames lose their size caps; the cache sheds parts of a group under pressure and refills the holes in place diff --git a/quest/m1/bench-ci.md b/quest/m1/bench-ci.md index c40eaa0d119..bd76c349318 100644 --- a/quest/m1/bench-ci.md +++ b/quest/m1/bench-ci.md @@ -21,7 +21,7 @@ lands; agents never dispatch Nightly. one cheap bench (so tonight's `main` reads as slower), and check the job fails with that case alone. - Tune `THRESHOLD_PCT`, `CONFIRMATIONS` (`bench/compare.py`) and the round count - (`MOQ_BENCH_RUNTIME_ROUNDS`, default three) from what the runs show, and + (`BENCH_RUNTIME_ROUNDS`, default three) from what the runs show, and update the README's numbers. Bimodal series (about 50% up and back across nights) are the expected false positives; three alternating rounds pass one only when all three land on the slow mode. diff --git a/quest/m1/env-unknown.md b/quest/m1/env-unknown.md deleted file mode 100644 index a414cee666e..00000000000 --- a/quest/m1/env-unknown.md +++ /dev/null @@ -1,31 +0,0 @@ -# [S] Refuse unknown MOQ_* environment variables - -## Goal - -Every binary that reads `MOQ_*` variables (`moq-relay`, `moq`, `moq-bench`, -`moq-boy`) exits at startup, naming the variable, when the environment holds -a `MOQ_*` variable the binary does not read. A deployment (Docker, systemd, -NixOS) that sets a stale or misspelled name fails loudly instead of silently -running on defaults. - -## Plan - -Decided 2026-10-23 (maintainer interview): - -- Every binary, as an error. A shell holding one tool's `MOQ_*` variables - while running another trips it; that is accepted. -- One helper in `moq_tokio::cli` compares the environment's `MOQ_*` names - with those the binary's usage spec declares, plus any it reads directly, - and each binary calls it after parsing. It scans `std::env::vars_os()`, - since `vars()` panics on any non-UTF-8 entry, even an unrelated one. - usage-rs has no unknown-env check yet; - [the upstream option](/quest/m2/usage-unknown-env.md) replaces this helper - once released. -- Turns the nix module's unit-test guard from - [moq-dev/moq#6474](https://github.com/moq-dev/moq/pull/6474) into a check - every deployment hits. Note the new startup error in `doc/bin/relay/` and - `doc/bin/cli.md`. - -## Related - -- [Upstream unknown-env option](/quest/m2/usage-unknown-env.md) - replaces the helper diff --git a/quest/m1/ietf-lazy-discovery.md b/quest/m1/ietf-lazy-discovery.md index aa9f21c0653..09a8472a221 100644 --- a/quest/m1/ietf-lazy-discovery.md +++ b/quest/m1/ietf-lazy-discovery.md @@ -20,7 +20,7 @@ CLI does no scoping of its own: the subtree scope tried for this in [moq-dev/moq#6255](https://github.com/moq-dev/moq/pull/6255) lost the sibling broadcasts a catalog references, such as a transcode's `.` source. Asking for the watched prefixes fixes the cell without that loss; verify -it with `MOQ_BIN=target/debug/moq just relays --only moxygen` from +it with `CLI_BIN=target/debug/moq just relays --only moxygen` from `test/smoke`. - First step: Rust sends UNSUBSCRIBE_NAMESPACE on d14/15. It never does diff --git a/quest/m1/release-perf/README.md b/quest/m1/release-perf/README.md index b473e0e9b4d..2b8192ed5a8 100644 --- a/quest/m1/release-perf/README.md +++ b/quest/m1/release-perf/README.md @@ -159,7 +159,7 @@ A/A of 3 to 8% on the same host. Decided 2026-10-23 (maintainer): browser parity accepted on this evidence; the final re-run above checks it again. The raw report lived in a scratch directory that has since been removed. -`just bench ` now pairs full Criterion IDs; point `MOQ_BENCH_ARTIFACTS` +`just bench ` now pairs full Criterion IDs; point `BENCH_ARTIFACTS` outside the worktree to keep the next one. ## Required diff --git a/quest/m2/audit-interop.md b/quest/m2/audit-interop.md index 8b5594f7a1a..c0ce7ff9f38 100644 --- a/quest/m2/audit-interop.md +++ b/quest/m2/audit-interop.md @@ -42,7 +42,7 @@ Decided with the maintainer on 2026-10-21: Both reports run published packages, so a fix turns green only after it ships. Verify from `main` instead. For our clients through a third-party -relay, `MOQ_BIN=target/debug/moq just relays --only --publishers rust +relay, `CLI_BIN=target/debug/moq just relays --only --publishers rust --subscribers rust` from `test/smoke`. For a third-party client through our relay, run its published runner image (`RELAY_URL`, `TLS_DISABLE_VERIFY=1`, `TESTCASE`) on the host network against a `moq-relay` built from `main`. diff --git a/quest/m2/bench-base-paired.md b/quest/m2/bench-base-paired.md index eeb36707b3f..d918a773a6e 100644 --- a/quest/m2/bench-base-paired.md +++ b/quest/m2/bench-base-paired.md @@ -8,7 +8,7 @@ the nightly uses, and the old per-case comparison is deleted. ## Plan [moq-dev/moq#6511](https://github.com/moq-dev/moq/pull/6511) added the paired -path (`--criterion` with `MOQ_BENCH_BASE`, writing `paired.json`). The BASE +path (`--criterion` with `BENCH_BASE`, writing `paired.json`). The BASE mode in `bench/run.sh` still goes through `compare_criterion`. Route it through the paired path, and delete `criterion_cases`, `compare_criterion`, `report_set_changes`, and `--criterion-baseline`. That also deletes the diff --git a/quest/m2/usage-unknown-env.md b/quest/m2/usage-unknown-env.md index c716a0142fc..79d73af0648 100644 --- a/quest/m2/usage-unknown-env.md +++ b/quest/m2/usage-unknown-env.md @@ -5,8 +5,8 @@ usage-rs ([jdx/usage](https://github.com/jdx/usage)) can refuse unknown environment variables under a prefix, the way `unknown_flags = "error"` refuses unknown flags. Once a release ships it, bump usage-rs and replace -the `moq_tokio::cli` helper from [the env check](/quest/m1/env-unknown.md) -with the option. +`moq_tokio::cli::check_env` with the option. The option needs a way to +accept names read outside the spec, such as `moq_video::ENV`. ## Plan @@ -14,7 +14,3 @@ Decided 2026-10-23 (maintainer interview): the maintainer approved posting an issue or PR on jdx/usage for this. Waiting on jdx/usage is the condition: check the upstream issue or PR and its releases; delete this quest if upstream declines, keeping the helper. - -## Required - -- [Refuse unknown MOQ_* environment variables](/quest/m1/env-unknown.md) - ships the helper this replaces diff --git a/quest/m2/v4l2-virtual-camera.md b/quest/m2/v4l2-virtual-camera.md index efc2fa90244..8050438d3b3 100644 --- a/quest/m2/v4l2-virtual-camera.md +++ b/quest/m2/v4l2-virtual-camera.md @@ -21,7 +21,7 @@ developer's camera. name rather than a fixed `/dev/videoN`: enumerate formats and frame sizes, stream a few frames in a raw format and in MJPEG, assert their size and count, then close and reopen. Select them with a `just rs v4l2` recipe. -- A missing device fails under `MOQ_STRICT`, the convention the io_uring and +- A missing device fails under `CI_STRICT`, the convention the io_uring and mDNS tests use, and skips otherwise. - Nightly only: loading a kernel module is a runner mutation no pull request job should make. diff --git a/rs/justfile b/rs/justfile index df314f95b21..5a242b950dd 100644 --- a/rs/justfile +++ b/rs/justfile @@ -114,7 +114,7 @@ uring-changed base="": bash sh/rs/select.sh uring "$changed" # Compile and test the io_uring relay path, which is off the default feature set. -# Linux-only; MOQ_STRICT requires a supported kernel instead of skipping tests. +# Linux-only; CI_STRICT requires a supported kernel instead of skipping tests. [positional-arguments] uring *args: just rs uring-check "$@" @@ -359,7 +359,7 @@ multicast: just rs test -p moq-tokio --features mdns --lib --run-ignored only -E 'test(=mdns::tests::apps_partition_discovery) | test(/^mdns::tests::daemon_/)' just rs test -p moq-relay --features cluster-lan --run-ignored only -E 'test(/^lan_mesh::/)' -# Run the long TS recovery arms; a failing arm keeps its export and ledgers under $MOQ_TEST_RUNS. +# Run the long TS recovery arms; a failing arm keeps its export and ledgers under $HARNESS_RUNS. ts-recovery: just rs test -p moq-mux --lib --run-ignored only -E 'test(/^container::ts::recovery_test::long_/)' diff --git a/rs/moq-bench/src/config.rs b/rs/moq-bench/src/config.rs index c4f3ecc75fd..8558c2a890f 100644 --- a/rs/moq-bench/src/config.rs +++ b/rs/moq-bench/src/config.rs @@ -137,7 +137,8 @@ impl Default for Config { } impl Config { - /// Parse from CLI args, optionally merging a TOML file, then init the logger. + /// Parse from CLI args, optionally merging a TOML file, refuse any `MOQ_*` + /// variable moq-bench does not read, then init the logger. pub fn load() -> anyhow::Result { let args: Vec = std::env::args_os().collect(); // `#[usage(completion)]` installs the `__complete_word__` interception in the @@ -149,6 +150,7 @@ impl Config { std::process::exit(0); } let config = Self::parse_and_merge(args)?; + moq_tokio::cli::check_env(&[Self::spec()], &[])?; config.log.init()?; tracing::trace!(?config, "final config"); Ok(config) diff --git a/rs/moq-boy/MIGRATE.md b/rs/moq-boy/MIGRATE.md index b2f353dab50..4767d3c405c 100644 --- a/rs/moq-boy/MIGRATE.md +++ b/rs/moq-boy/MIGRATE.md @@ -4,6 +4,11 @@ How to update your invocation and config for each breaking change, newest first. ## Unreleased +### Unknown `MOQ_*` environment variables stop startup ([#6633](https://github.com/moq-dev/moq/pull/6633)) + +A `MOQ_*` variable moq-boy does not read, such as a misspelling, a removed name, or one meant for another binary, now stops startup with the variable named instead of being ignored. +Remove or rename what the error lists. + ### Key logging is opt-in (#5907) `SSLKEYLOGFILE` alone no longer writes TLS session secrets. diff --git a/rs/moq-boy/src/main.rs b/rs/moq-boy/src/main.rs index 83b2bea4d99..599184ccde7 100644 --- a/rs/moq-boy/src/main.rs +++ b/rs/moq-boy/src/main.rs @@ -482,6 +482,7 @@ async fn main() -> Result<()> { let config = Config::parse(); config.log.init()?; config.check_deprecated()?; + moq_tokio::cli::check_env(&[Config::spec()], &[])?; // A 160x144 frame is below every hardware encoder's minimum, so OpenH264 is the only one. if !cfg!(feature = "openh264") { anyhow::bail!("built without the `openh264` feature: cargo install moq-boy --features openh264"); diff --git a/rs/moq-cli/MIGRATE.md b/rs/moq-cli/MIGRATE.md index f015f1cb53b..db2d68ee07d 100644 --- a/rs/moq-cli/MIGRATE.md +++ b/rs/moq-cli/MIGRATE.md @@ -4,6 +4,11 @@ How to update your invocation and config for each breaking change, newest first. ## Unreleased +### Unknown `MOQ_*` environment variables stop startup ([#6633](https://github.com/moq-dev/moq/pull/6633)) + +A `MOQ_*` variable `moq` does not read, such as a misspelling, a removed name, or one meant for another binary, now stops startup with the variable named instead of being ignored. +Remove or rename what the error lists. + ### The `nvenc` and `nvdec` Cargo features are removed ([#6483](https://github.com/moq-dev/moq/pull/6483)) Enable `nvidia` instead; the old names were aliases for it. diff --git a/rs/moq-cli/src/args.rs b/rs/moq-cli/src/args.rs index 5cbc04a7324..cfc3f5182d1 100644 --- a/rs/moq-cli/src/args.rs +++ b/rs/moq-cli/src/args.rs @@ -154,6 +154,12 @@ impl std::fmt::Display for ParseError { impl std::error::Error for ParseError {} +/// The `MOQ_*` variables read outside the command-line spec. +#[cfg(any(feature = "capture", feature = "transcode", feature = "play"))] +const DIRECT_ENV: &[&str] = moq_video::ENV; +#[cfg(not(any(feature = "capture", feature = "transcode", feature = "play")))] +const DIRECT_ENV: &[&str] = &[]; + /// Whether `flag` is one of the flags `T` declares. fn owns(flag: &usage_rs::Flag<'_>) -> bool { T::COMMAND.flags.iter().any(|own| own.key == flag.key) @@ -174,7 +180,13 @@ impl Invocation { print!("{reply}"); std::process::exit(0); } - match Self::try_parse_from(args) { + match Self::try_parse_from(args).and_then(|parsed| { + // Here rather than in `try_parse_from`, which tests drive under whatever + // environment the test runner has. + moq_tokio::cli::check_env(&[Cli::spec(), Stage::spec()], DIRECT_ENV) + .map_err(|err| ParseError::new(ParseErrorKind::ValueValidation, format!("error: {err}\n")))?; + Ok(parsed) + }) { Ok(parsed) => parsed, Err(err) => err.exit(), } diff --git a/rs/moq-mux/src/container/ts/recovery_test.rs b/rs/moq-mux/src/container/ts/recovery_test.rs index 063f1903fe7..92caaa72911 100644 --- a/rs/moq-mux/src/container/ts/recovery_test.rs +++ b/rs/moq-mux/src/container/ts/recovery_test.rs @@ -1250,13 +1250,13 @@ fn segments<'a>(ts: &[u8], video: &'a Ledger, pids: (u16, u16)) -> Result); impl Evidence { fn save(run: &Run) -> Self { - let Some(root) = std::env::var_os("MOQ_TEST_RUNS") else { + let Some(root) = std::env::var_os("HARNESS_RUNS") else { return Self(None); }; // libtest names each test's thread after it; a test run on the main thread has its process. @@ -1277,7 +1277,7 @@ impl Drop for Evidence { fn drop(&mut self) { if let Some(dir) = &self.0 && !std::thread::panicking() - && std::env::var_os("MOQ_TEST_KEEP").is_none() + && std::env::var_os("HARNESS_KEEP").is_none() { let _ = std::fs::remove_dir_all(dir); } diff --git a/rs/moq-relay/MIGRATE.md b/rs/moq-relay/MIGRATE.md index be2064a16ea..813c42619ec 100644 --- a/rs/moq-relay/MIGRATE.md +++ b/rs/moq-relay/MIGRATE.md @@ -5,6 +5,11 @@ Rolling a cluster across a release also follows the [upgrade guide](https://moq. ## Unreleased +### Unknown `MOQ_*` environment variables stop startup ([#6633](https://github.com/moq-dev/moq/pull/6633)) + +A `MOQ_*` variable moq-relay does not read, such as a misspelling, a removed name, or one meant for another binary, now stops startup with the variable named instead of being ignored. +Remove or rename what the error lists. + ### Auth `server_name` is the SNI only (#6509) The auth request's `server_name` no longer falls back to the HTTP `Host` header, `:authority`, or the WebTransport CONNECT host: it is absent over plain `http://` and `ws://` and for an IP-literal dial, while HTTPS and `wss://` report the SNI. diff --git a/rs/moq-relay/src/config.rs b/rs/moq-relay/src/config.rs index c49f4c68584..6681bdd2310 100644 --- a/rs/moq-relay/src/config.rs +++ b/rs/moq-relay/src/config.rs @@ -218,8 +218,8 @@ impl Config { } /// Parses configuration from CLI arguments, optionally merging with a - /// TOML file specified via the positional `file` argument. Also initializes - /// the logger. + /// TOML file specified via the positional `file` argument, and refuses any + /// `MOQ_*` variable the relay does not read. Also initializes the logger. pub fn load() -> anyhow::Result { let args: Vec = std::env::args_os().collect(); // `#[usage(completion)]` installs the `__complete_word__` interception in the @@ -231,6 +231,7 @@ impl Config { std::process::exit(0); } let config = Self::parse_and_merge(args)?; + moq_tokio::cli::check_env(&[Cli::spec()], &[])?; config.log.init()?; tracing::trace!(?config, "final config"); Ok(config) @@ -1133,8 +1134,8 @@ ws = false assert!(drift.is_empty(), "{drift:#?}"); } - /// The relay ignores a `MOQ_*` variable it doesn't know, so a stale name in the - /// NixOS module would silently drop that setting. + /// The relay refuses to start on a `MOQ_*` variable it doesn't read, so a stale + /// name in the NixOS module would stop every NixOS relay; catch it here first. #[test] fn the_nixos_module_sets_only_known_variables() { let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../../nix/modules/moq-relay.nix"); diff --git a/rs/moq-relay/src/uring.rs b/rs/moq-relay/src/uring.rs index 436c5146e2b..b90431d8536 100644 --- a/rs/moq-relay/src/uring.rs +++ b/rs/moq-relay/src/uring.rs @@ -1011,7 +1011,7 @@ mod tests { async fn a_group_stopped_before_serving_joins() { let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); if let Err(moq_uring::Error::Unsupported(reason)) = moq_uring::Worker::new(Default::default()) - && std::env::var_os("MOQ_STRICT").is_none() + && std::env::var_os("CI_STRICT").is_none() { eprintln!("skipping io_uring relay test: {reason}"); return; @@ -1038,7 +1038,7 @@ mod tests { async fn pending_admission_is_abandoned_at_the_deadline() { let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); if let Err(moq_uring::Error::Unsupported(reason)) = moq_uring::Worker::new(Default::default()) - && std::env::var_os("MOQ_STRICT").is_none() + && std::env::var_os("CI_STRICT").is_none() { eprintln!("skipping io_uring relay test: {reason}"); return; @@ -1095,7 +1095,7 @@ mod tests { async fn pending_admission_is_abandoned_at_the_handshake_deadline() { let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); if let Err(moq_uring::Error::Unsupported(reason)) = moq_uring::Worker::new(Default::default()) - && std::env::var_os("MOQ_STRICT").is_none() + && std::env::var_os("CI_STRICT").is_none() { eprintln!("skipping io_uring relay test: {reason}"); return; diff --git a/rs/moq-relay/tests/integration/embed.rs b/rs/moq-relay/tests/integration/embed.rs index a34400c6682..d68b3978ca3 100644 --- a/rs/moq-relay/tests/integration/embed.rs +++ b/rs/moq-relay/tests/integration/embed.rs @@ -400,13 +400,13 @@ async fn worker_tokio_custom_route_and_quic() { } /// io_uring workers. Off the default feature set; `just rs uring` and nightly -/// `--all-features` compile it. Skips below the 6.12 floor unless MOQ_STRICT. +/// `--all-features` compile it. Skips below the 6.12 floor unless CI_STRICT. #[cfg(all(target_os = "linux", feature = "_uring"))] #[tokio::test] async fn uring_custom_route_and_quic() { match moq_uring::Worker::new(Default::default()) { Ok(_) => {} - Err(moq_uring::Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(moq_uring::Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring embed test: {reason}"); return; } diff --git a/rs/moq-relay/tests/integration/lan_mesh.rs b/rs/moq-relay/tests/integration/lan_mesh.rs index 245eb8d7f5c..65aedb41bae 100644 --- a/rs/moq-relay/tests/integration/lan_mesh.rs +++ b/rs/moq-relay/tests/integration/lan_mesh.rs @@ -22,7 +22,7 @@ use moq_relay::cluster; /// Two clusters that can advertise (fingerprint + node) start without a secret. /// Binding mDNS is the recipe's gate; skip when the host cannot announce, -/// unless MOQ_STRICT makes that a failure. +/// unless CI_STRICT makes that a failure. #[tokio::test] #[ignore = "needs multicast on the host network; run by just rs multicast"] async fn moq_import_cluster_lan_beside_a_relay() { @@ -57,7 +57,7 @@ async fn moq_import_cluster_lan_beside_a_relay() { match tokio::time::timeout(Duration::from_secs(10), cluster.start()).await { Ok(Ok(_)) => {} Ok(Err(err)) - if format!("{err:#}").contains("no network interface") && std::env::var_os("MOQ_STRICT").is_none() => + if format!("{err:#}").contains("no network interface") && std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping: {err:#}"); } diff --git a/rs/moq-relay/tests/integration/peer_limits.rs b/rs/moq-relay/tests/integration/peer_limits.rs index b77ff9ab159..6c20afb2f3d 100644 --- a/rs/moq-relay/tests/integration/peer_limits.rs +++ b/rs/moq-relay/tests/integration/peer_limits.rs @@ -335,7 +335,7 @@ async fn uring_peer_session_widens_quic_limits() { let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); match moq_uring::Worker::new(Default::default()) { Ok(_) => {} - Err(moq_uring::Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(moq_uring::Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring relay test: {reason}"); return; } diff --git a/rs/moq-relay/tests/integration/runtime_uring.rs b/rs/moq-relay/tests/integration/runtime_uring.rs index 4c7f74f6b76..e1131d3d611 100644 --- a/rs/moq-relay/tests/integration/runtime_uring.rs +++ b/rs/moq-relay/tests/integration/runtime_uring.rs @@ -4,7 +4,7 @@ //! runtime and the frame crossing worker threads through the shared origin. //! //! Linux-only like the mode itself. Unsupported local kernels skip loudly; -//! MOQ_STRICT makes CI refuse them. +//! CI_STRICT makes CI refuse them. #![cfg(all(target_os = "linux", feature = "_uring"))] use std::net::SocketAddr; @@ -27,7 +27,7 @@ fn timed() -> moq_net::track::Info { fn supported() -> bool { match moq_uring::Worker::new(Default::default()) { Ok(_) => true, - Err(moq_uring::Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(moq_uring::Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring relay test: {reason}"); false } diff --git a/rs/moq-relay/tests/integration/wire_stats.rs b/rs/moq-relay/tests/integration/wire_stats.rs index 0c71c4ca0f5..bcf13ade57d 100644 --- a/rs/moq-relay/tests/integration/wire_stats.rs +++ b/rs/moq-relay/tests/integration/wire_stats.rs @@ -134,7 +134,7 @@ async fn native_sessions_supply_direct_wire_counters() { async fn uring_sessions_supply_direct_wire_counters() { match moq_uring::Worker::new(Default::default()) { Ok(_) => (), - Err(moq_uring::Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(moq_uring::Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring wire stats test: {reason}"); return; } diff --git a/rs/moq-tokio/src/cli.rs b/rs/moq-tokio/src/cli.rs index fc65af205e9..a99a2d0bb23 100644 --- a/rs/moq-tokio/src/cli.rs +++ b/rs/moq-tokio/src/cli.rs @@ -6,11 +6,13 @@ //! never reaches that code, so it has to answer them itself. Both shapes exist here: //! a TOML merge that layers CLI, env, and file with recorded provenance, and //! moq-cli's repeated `--` stage grammar. [`Duration`] parses the human-readable -//! values used by those flags and TOML keys. +//! values used by those flags and TOML keys, and [`check_env`] refuses `MOQ_*` +//! variables a binary does not read. #[path = "deprecated.rs"] mod deprecated; pub(crate) mod duration; +mod env; use std::collections::HashSet; use std::ffi::OsStr; @@ -25,6 +27,7 @@ use usage_rs::config::{ pub use deprecated::Deprecated; pub use duration::Duration; +pub use env::{UnknownEnv, check_env}; /// Re-exported because [`Merge`] and [`answer`] use Usage types in their APIs. pub use usage_rs; diff --git a/rs/moq-tokio/src/cli/env.rs b/rs/moq-tokio/src/cli/env.rs new file mode 100644 index 00000000000..8b77d634d95 --- /dev/null +++ b/rs/moq-tokio/src/cli/env.rs @@ -0,0 +1,171 @@ +//! Refusing `MOQ_*` environment variables a binary does not read. + +use std::collections::HashSet; +use std::ffi::OsString; + +use usage_rs::argv::spec::{ArgMeta, CommandMeta, FlagMeta, Spec}; + +/// The prefix every MoQ binary's environment variables share. +const PREFIX: &str = "MOQ_"; + +/// `MOQ_*` environment variables that nothing in the binary reads. +/// +/// Returned by [`check_env`]. The [`std::fmt::Display`] names each one. +#[derive(Clone, Debug)] +pub struct UnknownEnv(Vec); + +impl std::fmt::Display for UnknownEnv { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "unknown environment variables, which this binary does not read; remove or rename them: {}", + self.0.join(", ") + ) + } +} + +impl std::error::Error for UnknownEnv {} + +/// Refuse every `MOQ_*` variable in the process environment that none of `specs` +/// declares and `direct` does not name. +/// +/// `specs` are the command-line specs the binary parses with, and `direct` the +/// variables it reads outside them. Without this, a deployment that sets a stale or +/// misspelled name runs on defaults without a word. +pub fn check_env<'a>(specs: &[&'a Spec<'a>], direct: &[&'a str]) -> Result<(), UnknownEnv> { + let mut known = HashSet::new(); + for spec in specs { + declared(spec.root, &mut known); + } + known.extend(direct.iter().copied()); + + // `vars_os`, because `vars` panics on any entry that is not UTF-8, even an unrelated one. + let unknown = unknown(std::env::vars_os().map(|(name, _)| name), &known); + if unknown.is_empty() { + Ok(()) + } else { + Err(UnknownEnv(unknown)) + } +} + +/// Every environment variable `meta` and its subcommands declare, including deprecated ones. +fn declared<'a>(meta: &'a CommandMeta<'a>, known: &mut HashSet<&'a str>) { + let flag = |flag: &FlagMeta<'a>| { + flag.env() + .into_iter() + .chain(flag.env_fallback().iter().copied()) + .chain(flag.deprecated_env().iter().copied()) + }; + let arg = |arg: &ArgMeta<'a>| { + arg.env() + .into_iter() + .chain(arg.env_fallback().iter().copied()) + .chain(arg.deprecated_env().iter().copied()) + }; + + known.extend(meta.flags().iter().flat_map(flag)); + known.extend(meta.args().iter().flat_map(arg)); + if let Some(clause) = meta.clause() { + known.extend(clause.flags.iter().flat_map(flag)); + known.extend(clause.args.iter().flat_map(arg)); + } + for sub in meta.subcommands() { + declared(sub, known); + } +} + +/// The `MOQ_*` names in `names` that `known` lacks, sorted and deduplicated. +fn unknown(names: impl IntoIterator, known: &HashSet<&str>) -> Vec { + let mut unknown: Vec = names + .into_iter() + .map(|name| { + let name = name.to_string_lossy().into_owned(); + // Windows matches variable names case-insensitively, so `moq_connect` + // sets `MOQ_CONNECT` there. + if cfg!(windows) { name.to_ascii_uppercase() } else { name } + }) + .filter(|name| name.starts_with(PREFIX) && !known.contains(name.as_str())) + .collect(); + unknown.sort(); + unknown.dedup(); + unknown +} + +#[cfg(test)] +mod tests { + use super::*; + + // Only the derived spec is read, never the parsed fields. + #[allow(dead_code)] + #[derive(usage_rs::Args)] + struct Shared { + /// Declared by a flattened section. + #[usage(long, env = "MOQ_SHARED")] + shared: Option, + + /// A released spelling, still declared so it can be reported. + #[usage(long, env = "MOQ_RELEASED", hide)] + released: Option, + } + + #[allow(dead_code)] + #[derive(usage_rs::Cli)] + #[usage(unknown_flags = "error")] + struct Cli { + #[usage(flatten)] + shared: Shared, + + #[usage(subcommand)] + command: Command, + } + + #[allow(dead_code)] + #[derive(usage_rs::Subcommands)] + enum Command { + /// Declares a variable only under a subcommand. + Run { + #[usage(long, env = "MOQ_RUN")] + run: Option, + }, + } + + fn known() -> HashSet<&'static str> { + let mut known = HashSet::new(); + declared(Cli::spec().root, &mut known); + known + } + + fn names(names: &[&str]) -> Vec { + names.iter().map(OsString::from).collect() + } + + /// Flattened, hidden, and subcommand variables all count as read. + #[test] + fn declared_reaches_every_section() { + let known = known(); + for name in ["MOQ_SHARED", "MOQ_RELEASED", "MOQ_RUN"] { + assert!(known.contains(name), "{name} is declared"); + } + } + + /// Only `MOQ_*` names are checked, and each is reported once, sorted. + #[test] + fn unknown_names_only_moq() { + let found = unknown( + names(&["MOQ_SHARED", "PATH", "MOQ_TYPO", "MOQ", "MOQ_RUN", "MOQ_A", "MOQ_TYPO"]), + &known(), + ); + assert_eq!(found, ["MOQ_A", "MOQ_TYPO"]); + } + + /// A name that is not UTF-8 is still refused, rather than panicking or slipping past. + #[cfg(unix)] + #[test] + fn unknown_non_utf8() { + use std::os::unix::ffi::OsStringExt; + + let found = unknown([OsString::from_vec(b"MOQ_\xff".to_vec())], &known()); + assert_eq!(found, ["MOQ_\u{fffd}"]); + assert!(unknown([OsString::from_vec(b"OTHER_\xff".to_vec())], &known()).is_empty()); + } +} diff --git a/rs/moq-tokio/src/mdns.rs b/rs/moq-tokio/src/mdns.rs index 4abb47b7c36..947fe09694c 100644 --- a/rs/moq-tokio/src/mdns.rs +++ b/rs/moq-tokio/src/mdns.rs @@ -1344,14 +1344,14 @@ mod tests { /// /// Ignored because it multicasts on the host network; nightly runs it with /// `just rs multicast`. A host where no interface can announce skips, unless - /// MOQ_STRICT makes that a failure. + /// CI_STRICT makes that a failure. #[tokio::test] #[ignore = "needs multicast on the host network; run by just rs multicast"] async fn apps_partition_discovery() { let shared = unique_app(); let mut same_a = match discovery(shared.clone(), Some(KEY_A), "same-a").await { Ok(discovery) => discovery, - Err(err) if no_multicast(&err) && std::env::var_os("MOQ_STRICT").is_none() => { + Err(err) if no_multicast(&err) && std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping: {err}"); return; } diff --git a/rs/moq-uring/README.md b/rs/moq-uring/README.md index 0c4337111e3..3d63c91aa1b 100644 --- a/rs/moq-uring/README.md +++ b/rs/moq-uring/README.md @@ -106,7 +106,7 @@ steered two-worker reuseport group serving one port across threads, and datagram echo through the H3 framing, close codes through the capsule, and a full moq-lite session over WebTransport. All of them skip (loudly) below the kernel floor. CI runs them -on `ubuntu-24.04-arm`, whose kernel clears it, with `MOQ_STRICT=1` refusing a +on `ubuntu-24.04-arm`, whose kernel clears it, with `CI_STRICT=1` refusing a skip: in the `uring.yml` release gate and the nightly `rs uring` job. ## Benchmarks diff --git a/rs/moq-uring/src/udp.rs b/rs/moq-uring/src/udp.rs index 206030dc08b..48e0cf54988 100644 --- a/rs/moq-uring/src/udp.rs +++ b/rs/moq-uring/src/udp.rs @@ -2031,7 +2031,7 @@ mod tests { fn a_failed_send_costs_only_its_packet() { let mut worker = match crate::Worker::new(crate::Config::default()) { Ok(worker) => worker, - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring socket test: {reason}"); return; } @@ -2119,7 +2119,7 @@ mod tests { fn a_stale_source_keeps_segmentation() { let mut worker = match crate::Worker::new(crate::Config::default()) { Ok(worker) => worker, - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring socket test: {reason}"); return; } @@ -2182,7 +2182,7 @@ mod tests { let mut worker = match crate::Worker::new(crate::Config::default()) { Ok(worker) => worker, - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring socket test: {reason}"); return; } diff --git a/rs/moq-uring/src/worker.rs b/rs/moq-uring/src/worker.rs index 124bfa51124..61b0202d0f4 100644 --- a/rs/moq-uring/src/worker.rs +++ b/rs/moq-uring/src/worker.rs @@ -779,7 +779,7 @@ mod tests { } fn worker_with(config: Config) -> Option { - worker_result(Worker::new(config), std::env::var_os("MOQ_STRICT").is_some()) + worker_result(Worker::new(config), std::env::var_os("CI_STRICT").is_some()) } /// A worker on a manual clock, which only `advance` moves. diff --git a/rs/moq-uring/tests/allocations.rs b/rs/moq-uring/tests/allocations.rs index 4c99709e719..3a8b1077044 100644 --- a/rs/moq-uring/tests/allocations.rs +++ b/rs/moq-uring/tests/allocations.rs @@ -1,6 +1,6 @@ //! The worker's UDP send and pump path must not allocate in steady state. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(target_os = "linux")] @@ -57,7 +57,7 @@ const SENDS: usize = 1_000; fn steady_state_sends_do_not_allocate() { let mut worker = match Worker::new(Config::default()) { Ok(worker) => worker, - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring allocation test: {reason}"); return; } diff --git a/rs/moq-uring/tests/integration/credit.rs b/rs/moq-uring/tests/integration/credit.rs index 2036c7832dd..d3c62c6b3e5 100644 --- a/rs/moq-uring/tests/integration/credit.rs +++ b/rs/moq-uring/tests/integration/credit.rs @@ -2,7 +2,7 @@ //! until consumed, a stuck window evicts the lowest-priority stream, and a //! chunked write takes no more from its buffer than the peer's window admits. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(all(target_os = "linux", feature = "quic"))] @@ -24,7 +24,7 @@ const WINDOW: usize = 32 * 1024; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring credit test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/echo.rs b/rs/moq-uring/tests/integration/echo.rs index 10a99e3464f..86ff04c4673 100644 --- a/rs/moq-uring/tests/integration/echo.rs +++ b/rs/moq-uring/tests/integration/echo.rs @@ -14,7 +14,7 @@ const PAYLOAD: usize = 512 * 1024; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring echo test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/ecn.rs b/rs/moq-uring/tests/integration/ecn.rs index 97a8728bcb0..76ec02d252c 100644 --- a/rs/moq-uring/tests/integration/ecn.rs +++ b/rs/moq-uring/tests/integration/ecn.rs @@ -4,7 +4,7 @@ //! traffic-class control messages the peer sees no mark, its ACKs carry no //! ECN counts, and moq-quic disables ECN on the first one. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(target_os = "linux")] @@ -15,7 +15,7 @@ use moq_uring::{Config, Error, Worker, udp}; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring ecn test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/endpoint.rs b/rs/moq-uring/tests/integration/endpoint.rs index 110c76c3d00..3d8ac6d6261 100644 --- a/rs/moq-uring/tests/integration/endpoint.rs +++ b/rs/moq-uring/tests/integration/endpoint.rs @@ -2,7 +2,7 @@ //! accepting at once, version negotiation, the dial-only refusal, and how a //! close is reported. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(all(target_os = "linux", feature = "quic"))] @@ -19,7 +19,7 @@ use web_transport_trait::poll::{RecvStream as _, SendStream as _, Session as _}; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring endpoint test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/identity.rs b/rs/moq-uring/tests/integration/identity.rs index 309ad0ddd16..4e206ddb9aa 100644 --- a/rs/moq-uring/tests/integration/identity.rs +++ b/rs/moq-uring/tests/integration/identity.rs @@ -2,7 +2,7 @@ //! endpoint runs where its socket was adopted, whichever handle is in scope, //! and a socket whose worker is gone refuses to start anything. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(all(target_os = "linux", feature = "quic"))] @@ -17,7 +17,7 @@ use moq_uring::{Config, Error, Worker, quic, udp}; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring identity test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/local_addr.rs b/rs/moq-uring/tests/integration/local_addr.rs index def8f0af8d7..a6f5434a363 100644 --- a/rs/moq-uring/tests/integration/local_addr.rs +++ b/rs/moq-uring/tests/integration/local_addr.rs @@ -6,7 +6,7 @@ //! All of 127/8 is local, so IPv4 reaches `127.0.0.2`. IPv6 has only `::1`, so //! the IPv6 case is ignored by default and `just rs uring` runs it after its CI //! lanes add [`SECOND_V6`] to `lo`; without it the case skips loudly, and -//! MOQ_STRICT makes CI refuse it. +//! CI_STRICT makes CI refuse it. #![cfg(target_os = "linux")] @@ -23,7 +23,7 @@ const SECOND_V6: Ipv6Addr = Ipv6Addr::new(0xfd6d, 0x6f71, 0, 0, 0, 0, 0, 2); const TIMEOUT: Duration = Duration::from_secs(5); fn strict() -> bool { - std::env::var_os("MOQ_STRICT").is_some() + std::env::var_os("CI_STRICT").is_some() } fn worker() -> Option { diff --git a/rs/moq-uring/tests/integration/mtu.rs b/rs/moq-uring/tests/integration/mtu.rs index b03de41da57..2948ef3e190 100644 --- a/rs/moq-uring/tests/integration/mtu.rs +++ b/rs/moq-uring/tests/integration/mtu.rs @@ -7,7 +7,7 @@ //! word, the way a tunnel behind a firewall that eats ICMP does. It crosses //! real sockets, so these run on the wall clock. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(all(target_os = "linux", feature = "quic"))] @@ -36,7 +36,7 @@ const PAYLOAD: usize = 1 << 20; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring MTU test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/qlog.rs b/rs/moq-uring/tests/integration/qlog.rs index e6f5003a1ab..e8fb3ca898b 100644 --- a/rs/moq-uring/tests/integration/qlog.rs +++ b/rs/moq-uring/tests/integration/qlog.rs @@ -5,7 +5,7 @@ //! actually produces a file for each end of the connection, and every record in it is JSON, so a reader is not handed a truncated or //! interleaved trace. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(all(target_os = "linux", feature = "qlog", feature = "quic"))] @@ -18,7 +18,7 @@ use moq_uring::{Config, Error, Worker, quic, udp}; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring qlog test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/receive_credit.rs b/rs/moq-uring/tests/integration/receive_credit.rs index 08a3d44272d..adf57a8bd4a 100644 --- a/rs/moq-uring/tests/integration/receive_credit.rs +++ b/rs/moq-uring/tests/integration/receive_credit.rs @@ -8,7 +8,7 @@ //! JavaScript arm serves WebTransport to a Bun publisher; it needs Bun and runs in the //! interop workflow. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(all(target_os = "linux", feature = "quic"))] @@ -29,7 +29,7 @@ const WINDOW: usize = 256 * 1024; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring receive credit test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/session.rs b/rs/moq-uring/tests/integration/session.rs index 33f060b6ea0..66ae281723b 100644 --- a/rs/moq-uring/tests/integration/session.rs +++ b/rs/moq-uring/tests/integration/session.rs @@ -20,7 +20,7 @@ use moq_uring::{Config, Error, Worker, quic, udp}; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring session test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/teardown.rs b/rs/moq-uring/tests/integration/teardown.rs index ccb1b5d7da4..6dbf1bb8117 100644 --- a/rs/moq-uring/tests/integration/teardown.rs +++ b/rs/moq-uring/tests/integration/teardown.rs @@ -8,7 +8,7 @@ //! datagram, and a QUIC close whose CONNECTION_CLOSE is the last thing a //! one-shot client ever sends. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(all(target_os = "linux", feature = "quic"))] @@ -27,7 +27,7 @@ const CLOSE_REASON: &str = "done"; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring teardown test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/web.rs b/rs/moq-uring/tests/integration/web.rs index 443991e144d..df295569264 100644 --- a/rs/moq-uring/tests/integration/web.rs +++ b/rs/moq-uring/tests/integration/web.rs @@ -3,7 +3,7 @@ //! streams and datagrams through the H3 framing; the other runs a whole //! moq-lite session over it, which is exactly the browser-to-relay path. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(all(target_os = "linux", feature = "quic"))] @@ -19,7 +19,7 @@ use web_transport_trait::poll::{RecvStream as _, SendStream as _, Session as _}; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring web test: {reason}"); None } diff --git a/rs/moq-uring/tests/integration/workers.rs b/rs/moq-uring/tests/integration/workers.rs index 965da153ef4..9f744873d2c 100644 --- a/rs/moq-uring/tests/integration/workers.rs +++ b/rs/moq-uring/tests/integration/workers.rs @@ -7,7 +7,7 @@ //! continuation included) on that worker; a wrong prefix stalls the //! handshake, so every dial being accepted is what proves the steering. //! -//! Unsupported local kernels skip loudly; MOQ_STRICT makes CI refuse them. +//! Unsupported local kernels skip loudly; CI_STRICT makes CI refuse them. #![cfg(all(target_os = "linux", feature = "quic"))] @@ -23,7 +23,7 @@ use moq_uring::{Config, Error, Worker, quic, udp}; fn worker() -> Option { match Worker::new(Config::default()) { Ok(worker) => Some(worker), - Err(Error::Unsupported(reason)) if std::env::var_os("MOQ_STRICT").is_none() => { + Err(Error::Unsupported(reason)) if std::env::var_os("CI_STRICT").is_none() => { eprintln!("skipping io_uring workers test: {reason}"); None } diff --git a/rs/moq-video/src/lib.rs b/rs/moq-video/src/lib.rs index a784605df25..718815e2241 100644 --- a/rs/moq-video/src/lib.rs +++ b/rs/moq-video/src/lib.rs @@ -100,6 +100,16 @@ mod mf; #[cfg(all(target_os = "linux", feature = "v4l2"))] mod v4l2; +/// The environment variables this build reads, for a binary that refuses `MOQ_*` names nothing reads. +pub const ENV: &[&str] = &[ + #[cfg(all(target_os = "linux", feature = "vaapi"))] + "MOQ_VAAPI_DEVICE", + #[cfg(all(target_os = "linux", feature = "v4l2"))] + "MOQ_V4L2_ENCODER", + #[cfg(all(target_os = "linux", feature = "v4l2"))] + "MOQ_V4L2_DECODER", +]; + pub use color::Color; pub use error::Error; #[cfg(all(target_os = "linux", feature = "dmabuf"))] diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index 1bd05ddaaf7..492b198592b 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -29,8 +29,8 @@ def setUp(self): 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", - GIT_CONFIG_GLOBAL=os.devnull, MOQ_STRICT="1") - for key in ("MOQ_DEV_SHELL", "MOQ_ALLOW_HOST", "GITHUB_BASE_REF"): + GIT_CONFIG_GLOBAL=os.devnull, CI_STRICT="1") + for key in ("IN_MOQ_DEV_SHELL", "ALLOW_HOST_TOOLCHAIN", "GITHUB_BASE_REF"): self.env.pop(key, None) self.git("init", "-q", "-b", "main") self.git("config", "user.name", "test") @@ -188,7 +188,7 @@ def run_ci(self, base="origin/main"): nix = self.bin / "nix" nix.write_text('#!/usr/bin/env bash\nprintf "nix %s\\n" "$*" >>"$CALLS"\n') nix.chmod(0o755) - self.env.update(MOQ_DEV_SHELL="1", CALLS=str(self.root / "calls")) + self.env.update(IN_MOQ_DEV_SHELL="1", CALLS=str(self.root / "calls")) (self.root / "calls").unlink(missing_ok=True) self.env["PATH"] = f"{self.bin}:{os.environ['PATH']}" for script in ("markdown.sh", "shell.sh", "large-files.sh"): diff --git a/sh/dispatch.sh b/sh/dispatch.sh index ee43d44bd4b..ae73c73fe5e 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -22,11 +22,11 @@ esac # A host toolchain fails deep in a build instead: its gcc keeps the # _FORTIFY_SOURCE the dev shell disables, which breaks jemalloc's -Werror -# configure probes. This flake's dev shell sets MOQ_DEV_SHELL. Windows has no +# configure probes. This flake's dev shell sets IN_MOQ_DEV_SHELL. Windows has no # Nix, so it always runs on the host. -if [[ -z "$query" && -z "${MOQ_DEV_SHELL:-}" && -z "${MOQ_ALLOW_HOST:-}" && "$OSTYPE" != msys && "$OSTYPE" != cygwin ]]; then +if [[ -z "$query" && -z "${IN_MOQ_DEV_SHELL:-}" && -z "${ALLOW_HOST_TOOLCHAIN:-}" && "$OSTYPE" != msys && "$OSTYPE" != cygwin ]]; then echo "error: run inside the Nix dev shell ('nix develop' or direnv) so tools match CI" >&2 - echo " or set MOQ_ALLOW_HOST=1 to use the host toolchain anyway" >&2 + echo " or set ALLOW_HOST_TOOLCHAIN=1 to use the host toolchain anyway" >&2 exit 1 fi @@ -131,7 +131,7 @@ if [[ "$action" == ci-platform ]]; then fi # The tools each module needs. A module missing one is skipped locally, so an -# incomplete toolchain checks less; under MOQ_STRICT (CI) it is an error, up +# incomplete toolchain checks less; under CI_STRICT (CI) it is an error, up # front, because there a skip is indistinguishable from a pass. swift needs # none: it skips off macOS by design, and platform.yml is its real gate. declare -A tools=( @@ -198,7 +198,7 @@ for module in "${modules[@]}"; do done if ((${#absent[@]} == 0)); then selected+=("$module") - elif [[ -n "${MOQ_STRICT:-}" ]]; then + elif [[ -n "${CI_STRICT:-}" ]]; then missing+=("${absent[@]}") else echo "$action: skipping $module; missing ${absent[*]}" >&2 @@ -220,8 +220,8 @@ if [[ -n "$query" ]]; then fi if ((${#missing[@]})); then - echo "error: MOQ_STRICT is set but these tools are missing: $(printf '%s\n' "${missing[@]}" | sort -u | tr '\n' ' ')" >&2 - echo " run inside 'nix develop', or unset MOQ_STRICT to skip what isn't installed" >&2 + echo "error: CI_STRICT is set but these tools are missing: $(printf '%s\n' "${missing[@]}" | sort -u | tr '\n' ' ')" >&2 + echo " run inside 'nix develop', or unset CI_STRICT to skip what isn't installed" >&2 exit 1 fi diff --git a/sh/gh/bench-report.py b/sh/gh/bench-report.py index 88319665f75..b771fc91710 100644 --- a/sh/gh/bench-report.py +++ b/sh/gh/bench-report.py @@ -57,7 +57,7 @@ def rust(directory): metadata = json.loads((run / 'metadata.json').read_text()) if metadata['mode'] != '--criterion': raise ValueError(f'not a measured Criterion run: {run}') - label = metadata['environment'].get('MOQ_BENCH_LABEL') + label = metadata['environment'].get('BENCH_LABEL') if not isinstance(label, str) or not label: raise ValueError(f'missing Criterion source label: {run}') estimates = sorted((run / 'criterion').glob('**/new/estimates.json')) @@ -92,7 +92,7 @@ def paired(directory): for key in ('commit', 'base', 'threshold_pct', 'rounds'): if combined.setdefault(key, comparison[key]) != comparison[key]: raise ValueError(f'paired run disagrees on {key}: {run}') - label = data['environment']['MOQ_BENCH_LABEL'] + label = data['environment']['BENCH_LABEL'] combined['unavailable'] += [{'name': f'rust/{label}/{entry["target"]}', 'reason': entry['reason']} for entry in comparison['unavailable']] for case in comparison['cases']: diff --git a/sh/gh/bench-report.test.py b/sh/gh/bench-report.test.py index 5027052dd4f..4a7a61be5dc 100644 --- a/sh/gh/bench-report.test.py +++ b/sh/gh/bench-report.test.py @@ -66,7 +66,7 @@ def test_criterion_requires_fresh_measured_estimates(self): run.mkdir(parents=True) (self.root / 'criterion-runs.txt').write_text(f'{run}\n') (run / 'metadata.json').write_text(json.dumps({'mode': '--criterion', 'revision': 'abc', - 'environment': {'MOQ_BENCH_LABEL': 'net-cpu', 'SESSION_CPU': '1'}})) + 'environment': {'BENCH_LABEL': 'net-cpu', 'SESSION_CPU': '1'}})) with self.assertRaises(ValueError): report.rust(self.root) case = run / 'criterion' / 'delivery' / 'new' @@ -86,7 +86,7 @@ def paired_runs(self, comparisons): run = self.root / 'runs' / label run.mkdir(parents=True) (run / 'metadata.json').write_text(json.dumps({'mode': '--criterion', 'revision': 'c2', 'base': base, - 'environment': {'MOQ_BENCH_LABEL': label}})) + 'environment': {'BENCH_LABEL': label}})) if comparison is not None: (run / 'paired.json').write_text(json.dumps(comparison)) runs.append(str(run)) diff --git a/sh/gh/nightly.sh b/sh/gh/nightly.sh index b86d907d26b..2da42f7be9d 100755 --- a/sh/gh/nightly.sh +++ b/sh/gh/nightly.sh @@ -18,36 +18,36 @@ case "$1" in ;; esac -# MOQ_BENCH_BASE pairs every Rust bench target with its build at that revision, run on the +# BENCH_BASE pairs every Rust bench target with its build at that revision, run on the # same machine; `previous-nightly` is the commit of the latest other scheduled Nightly on main. -if [[ -n ${MOQ_BENCH_BASE:-} ]]; then +if [[ -n ${BENCH_BASE:-} ]]; then if [[ $report != rust ]]; then - echo "nightly: MOQ_BENCH_BASE applies only to the Rust bench groups" >&2 + echo "nightly: BENCH_BASE applies only to the Rust bench groups" >&2 exit 2 fi - if [[ $MOQ_BENCH_BASE == previous-nightly ]]; then - MOQ_BENCH_BASE=$(gh run list --workflow nightly.yml --branch main --event schedule --limit 2 \ + if [[ $BENCH_BASE == previous-nightly ]]; then + BENCH_BASE=$(gh run list --workflow nightly.yml --branch main --event schedule --limit 2 \ --json databaseId,headSha --jq "map(select(.databaseId != ${GITHUB_RUN_ID:-0}))[0].headSha // empty") - if [[ -z $MOQ_BENCH_BASE ]]; then + if [[ -z $BENCH_BASE ]]; then echo "nightly: no previous scheduled Nightly on main" >&2 exit 1 fi fi # A shallow CI checkout has only its own commit. Fetching a branch name only updates # FETCH_HEAD, so the base is exported as the commit it resolved to. - if ! base=$(git rev-parse --verify --quiet "$MOQ_BENCH_BASE^{commit}"); then - git fetch --no-tags --depth=1 origin "$MOQ_BENCH_BASE" + if ! base=$(git rev-parse --verify --quiet "$BENCH_BASE^{commit}"); then + git fetch --no-tags --depth=1 origin "$BENCH_BASE" base=$(git rev-parse --verify 'FETCH_HEAD^{commit}') fi - export MOQ_BENCH_BASE=$base + export BENCH_BASE=$base fi if [[ -n $report ]]; then root=$(git rev-parse --show-toplevel) - out=${MOQ_BENCH_RESULTS:-$root/target/bench/nightly/$1} + out=${BENCH_RESULTS:-$root/target/bench/nightly/$1} mkdir -p "$out" - export MOQ_BENCH_RUNS="$out/criterion-runs.txt" - : >"$MOQ_BENCH_RUNS" + export BENCH_RUNS="$out/criterion-runs.txt" + : >"$BENCH_RUNS" rm -f "$out/report.json" "$out/paired.json" fi @@ -60,7 +60,7 @@ run() { criterion() { local label=$1 shift - run env MOQ_BENCH_LABEL="$label" MOQ_BENCH_ARTIFACTS="$out/runs" just gh criterion "$@" + run env BENCH_LABEL="$label" BENCH_ARTIFACTS="$out/runs" just gh criterion "$@" } javascript() { diff --git a/sh/gh/nightly.test.py b/sh/gh/nightly.test.py index 1bd0f4286bb..d13c445b1e7 100644 --- a/sh/gh/nightly.test.py +++ b/sh/gh/nightly.test.py @@ -24,7 +24,7 @@ def run_group(self, group, fail="", **environment): stub.write_text( '#!/usr/bin/env bash\n' 'printf "%s %s\n" "${0##*/}" "$*" >> "$NIGHTLY_CALLS"\n' - 'printf "%s\n" "${MOQ_BENCH_BASE:-}" >> "$NIGHTLY_CALLS.base"\n' + 'printf "%s\n" "${BENCH_BASE:-}" >> "$NIGHTLY_CALLS.base"\n' '[[ "$*" != "$NIGHTLY_FAIL" ]]\n' ) stub.chmod(0o755) @@ -34,8 +34,8 @@ def run_group(self, group, fail="", **environment): 'printf "%s" "$NIGHTLY_RUNS" | jq -r "$2"\n') gh.chmod(0o755) env = dict(os.environ, PATH=f"{scratch}:{os.environ['PATH']}", - MOQ_BENCH_RESULTS=str(scratch / "results"), NIGHTLY_CALLS=str(calls), NIGHTLY_FAIL=fail, BASH_ENV="/dev/null") - env.pop("MOQ_BENCH_BASE", None) + BENCH_RESULTS=str(scratch / "results"), NIGHTLY_CALLS=str(calls), NIGHTLY_FAIL=fail, BASH_ENV="/dev/null") + env.pop("BENCH_BASE", None) env.update(environment) result = subprocess.run(["bash", "sh/gh/nightly.sh", group], cwd=ROOT, env=env, capture_output=True, text=True) @@ -47,14 +47,14 @@ def test_paired_base_is_the_previous_scheduled_nightly(self): check=True).stdout.strip() for revision in ("HEAD", "HEAD~1")) # This run is the newest scheduled one; the previous run's commit is the base. runs = json.dumps([{"databaseId": 2, "headSha": parent}, {"databaseId": 1, "headSha": head}]) - result, _ = self.run_group("rust-uring", MOQ_BENCH_BASE="previous-nightly", GITHUB_RUN_ID="2", NIGHTLY_RUNS=runs) + result, _ = self.run_group("rust-uring", BENCH_BASE="previous-nightly", GITHUB_RUN_ID="2", NIGHTLY_RUNS=runs) self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(self.bases, {head}) # A named revision reaches the runner as its commit. - result, _ = self.run_group("rust-uring", MOQ_BENCH_BASE="HEAD~1") + result, _ = self.run_group("rust-uring", BENCH_BASE="HEAD~1") self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(self.bases, {parent}) - result, calls = self.run_group("rust-uring", MOQ_BENCH_BASE="previous-nightly", GITHUB_RUN_ID="1", + result, calls = self.run_group("rust-uring", BENCH_BASE="previous-nightly", GITHUB_RUN_ID="1", NIGHTLY_RUNS=json.dumps([{"databaseId": 1, "headSha": head}])) self.assertEqual(result.returncode, 1) self.assertIn("no previous scheduled Nightly", result.stderr) @@ -62,7 +62,7 @@ def test_paired_base_is_the_previous_scheduled_nightly(self): def test_paired_base_applies_only_to_rust_bench_groups(self): for group in ("js", "rust-test"): - result, calls = self.run_group(group, MOQ_BENCH_BASE="HEAD") + result, calls = self.run_group(group, BENCH_BASE="HEAD") self.assertEqual(result.returncode, 2, group) self.assertEqual(calls, []) diff --git a/sh/js/workspace.test.py b/sh/js/workspace.test.py index ccfba76fb3c..f1030fb7625 100644 --- a/sh/js/workspace.test.py +++ b/sh/js/workspace.test.py @@ -62,7 +62,7 @@ def test_dispatcher_passes_only_js_impact_paths(self): just = tools / "just" subprocess.run(["git", "init", "--quiet", str(self.root)], check=True) calls = self.root / "calls" - env = dict(os.environ, PATH=f"{tools}:{os.environ['PATH']}", MOQ_ALLOW_HOST="1", + env = dict(os.environ, PATH=f"{tools}:{os.environ['PATH']}", ALLOW_HOST_TOOLCHAIN="1", SELECT_CALLS=str(calls)) for script in ("markdown.sh", "shell.sh", "large-files.sh"): path = sh / script diff --git a/sh/obs/check.sh b/sh/obs/check.sh index 5588f74d90f..802840905c3 100755 --- a/sh/obs/check.sh +++ b/sh/obs/check.sh @@ -32,11 +32,11 @@ fi # the change that opens the gap and so the one that should fail. # OBS_LINKED_VERSION comes from the dev shell (see flake.nix), so this leg # is skipped outside it, where there is no nixpkgs obs-studio to compare. -# MOQ_STRICT turns that skip into an error for the same reason it turns a +# CI_STRICT turns that skip into an error for the same reason it turns a # missing tool into one: in CI a leg that checks nothing still reports green. if [ -z "${OBS_LINKED_VERSION:-}" ]; then - if [ -n "${MOQ_STRICT:-}" ]; then - echo "MOQ_STRICT is set but OBS_LINKED_VERSION is unset; run inside 'nix develop', which exports it" >&2 + if [ -n "${CI_STRICT:-}" ]; then + echo "CI_STRICT is set but OBS_LINKED_VERSION is unset; run inside 'nix develop', which exports it" >&2 exit 1 fi else diff --git a/test/README.md b/test/README.md index 43a9cb67058..9121c84ea71 100644 --- a/test/README.md +++ b/test/README.md @@ -32,15 +32,15 @@ when run concurrently or from different worktrees. The shared Every run owns three things and touches nothing else. **A private run directory.** `mktemp -d` under `$TMPDIR/moq-test-`, mode 700, -holding every log, generated config, and capture. `MOQ_TEST_RUNS` moves the root. +holding every log, generated config, and capture. `HARNESS_RUNS` moves the root. Client builds go here too (the Python venv, the staged Go modules, the browser page), so two runs from one checkout never rebuild a client the other is running. **Reserved ports.** A port is claimed by creating a directory under -`/tmp/moq-test-ports-` (`MOQ_TEST_PORTS`), held for the whole run, and +`/tmp/moq-test-ports-` (`HARNESS_PORT_ROOT`), held for the whole run, and released on the way out. That reservation is the point: probing for a free port and then releasing it is a race, and two runs that probe at the same moment pick the same -number. The walk starts at `MOQ_TEST_PORT_BASE` (4500). A reservation whose owner +number. The walk starts at `HARNESS_PORT_BASE` (4500). A reservation whose owner process is gone is reclaimed, atomically, so two reclaimers cannot both win. Replacement is serialized by `flock` on Linux or `lockf` on macOS, and the reservation records the owner's process start so a reused PID is not mistaken @@ -48,7 +48,7 @@ for the original run. The reservation root ignores `TMPDIR`: Nix shells have private temporary directories but share the host's ports. The user id avoids ownership conflicts in -world-writable `/tmp`. An override via `MOQ_TEST_PORTS` must be the same for every +world-writable `/tmp`. An override via `HARNESS_PORT_ROOT` must be the same for every run sharing the network. The root must belong to the current user and cannot be a symlink; new roots are private. Runs by different users still need disjoint ports. @@ -58,7 +58,7 @@ machine, so each harness still refuses a port something unrelated is already serving on. Pinning a port (`INTEROP_PORT`, `WASM_PORT`, `TSC_PORT`, `--port`) takes that exact one or fails. -Every port, pinned or walked to from `MOQ_TEST_PORT_BASE`, has to be 1024..65535 +Every port, pinned or walked to from `HARNESS_PORT_BASE`, has to be 1024..65535 before a reservation is created. A reservation is a directory named after the port, so the check keeps a malformed value from naming somewhere else on the filesystem, and it refuses an unbindable number up front instead of after the @@ -92,17 +92,17 @@ any Playwright trace survive with the command that reproduces it. A passing run deletes its own. ```bash -MOQ_TEST_KEEP=1 just test interop +HARNESS_KEEP=1 just test interop ``` -`MOQ_TEST_KEEP=1` keeps a passing run's directory too, for when the problem is in +`HARNESS_KEEP=1` keeps a passing run's directory too, for when the problem is in what the test did not assert. Either way the children are still reaped and the ports still released: what is kept is evidence, not a live session. Remove it with the `rm -rf` the run prints; nothing expires it for you. -In CI the harness writes under `MOQ_TEST_RUNS`, and `interop.yml` and `wasm.yml` +In CI the harness writes under `HARNESS_RUNS`, and `interop.yml` and `wasm.yml` upload that directory as a short-lived artifact when the job fails. -`MOQ_TEST_RESULTS` names a JSON Lines file a harness appends one record per case to, +`HARNESS_RESULTS` names a JSON Lines file a harness appends one record per case to, through `harness_result`; `interop.yml` builds its report from it. See [interop/README.md](interop/README.md#ci). diff --git a/test/ietf-conformance/README.md b/test/ietf-conformance/README.md index a252809a15d..b089af5a52d 100644 --- a/test/ietf-conformance/README.md +++ b/test/ietf-conformance/README.md @@ -25,7 +25,7 @@ relay before starting cases and rejects upstream publisher reconnects, so a recovered session cannot hide a failure. -The nightly workflow runs this recipe. `MOQ_TEST_KEEP=1` retains the upstream +The nightly workflow runs this recipe. `HARNESS_KEEP=1` retains the upstream reports, client and server logs, relay logs, configs, and endpoints. All children and port reservations belong to the shared harness and are reaped on exit. The pinned C++ build is opt-in under `legacyPackages..moxygen`; ordinary diff --git a/test/ietf-conformance/run.sh b/test/ietf-conformance/run.sh index 517fae082a5..6913c9da4fa 100755 --- a/test/ietf-conformance/run.sh +++ b/test/ietf-conformance/run.sh @@ -15,7 +15,7 @@ relay="$WORKSPACE/${CARGO_TARGET_DIR:-target}/debug/moq-relay" # Cargo accepts an absolute target directory too. [[ "${CARGO_TARGET_DIR:-}" != /* ]] || relay="$CARGO_TARGET_DIR/debug/moq-relay" -harness_begin ietf-conformance "$(harness_env MOQ_TEST_RESULTS)just test ietf-conformance" +harness_begin ietf-conformance "$(harness_env HARNESS_RESULTS)just test ietf-conformance" python3 "$CONFORMANCE_DIR/prepare.py" "$package/share/moxygen/conformance_test.sh" "$HARNESS_RUN/conformance.sh" # LibreSSL in the dev shell has no system-wide openssl.cnf. cat >"$HARNESS_RUN/openssl.cnf" <<'EOF' diff --git a/test/interop/README.md b/test/interop/README.md index 74dbb10a68d..438ecbae5fa 100644 --- a/test/interop/README.md +++ b/test/interop/README.md @@ -481,7 +481,7 @@ and any claim about physical playback. The relay's port is reserved for the run rather than fixed, so two checkouts can run the interop test at once; `INTEROP_PORT` pins one instead. A failing run keeps its directory, including a Playwright trace of the failing page, and CI uploads it; -`MOQ_TEST_KEEP=1` keeps a passing run's too. See [the harness +`HARNESS_KEEP=1` keeps a passing run's too. See [the harness contract](../README.md). ## Layout @@ -527,7 +527,7 @@ table of publisher by subscriber for each suite, case, transport, and version, p workflow step's outcome. A red cell links to its run and to the failure artifact, and its tooltip names the log inside that artifact. -The report reads records, never logs. With `MOQ_TEST_RESULTS` set, `interop.sh` and +The report reads records, never logs. With `HARNESS_RESULTS` set, `interop.sh` and `compat.sh` append one JSON line per case through `harness_result` (`test/lib/harness.sh`): suite, case, publisher, subscriber, transport, version, outcome, seconds, detail, and log. A run first records every case it will reach as `not run`, before building @@ -536,7 +536,7 @@ rather than missing ones. Transport and version are `auto` where each client neg its own; a pinned pass, the drop lanes, and wire-compat record their version. `report.py` renders the page: ```bash -MOQ_TEST_RESULTS=/tmp/results.jsonl just test interop +HARNESS_RESULTS=/tmp/results.jsonl just test interop just test interop-report /tmp/results.jsonl /tmp/interop-report ``` diff --git a/test/interop/clients/js/harness.ts b/test/interop/clients/js/harness.ts index f37f49a725a..dbfc11f693d 100644 --- a/test/interop/clients/js/harness.ts +++ b/test/interop/clients/js/harness.ts @@ -82,7 +82,7 @@ export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve * it mid-load; outside a harness run, it is vite's default `dist/`. */ export function serve(): { origin: string; stop: () => void } { - const run = process.env.MOQ_TEST_RUN; + const run = process.env.HARNESS_RUN_DIR; const root = run ? join(run, "js-dist") : join(new URL(".", import.meta.url).pathname, "dist"); const server = Bun.serve({ port: 0, @@ -141,18 +141,18 @@ const traces: Array<{ context: BrowserContext; name: string }> = []; /** * Start a Playwright trace on the page's context, before it navigates. * - * A no-op outside a harness run: without `MOQ_TEST_RUN` there is no directory to write to, and a + * A no-op outside a harness run: without `HARNESS_RUN_DIR` there is no directory to write to, and a * trace only survives a failure anyway. See {@link finishTraces}. */ export async function startTrace(page: Page, name: string): Promise { - if (!process.env.MOQ_TEST_RUN) return; + if (!process.env.HARNESS_RUN_DIR) return; await page.context().tracing.start({ screenshots: true, snapshots: true }); traces.push({ context: page.context(), name: `${name}-${randomUUID()}` }); } /** Save a trace per started context into the run directory when `failed`, and discard it otherwise. */ export async function finishTraces(failed: boolean): Promise { - const run = process.env.MOQ_TEST_RUN; + const run = process.env.HARNESS_RUN_DIR; for (const { context, name } of traces) { try { // `path` is what writes the trace; without it, stop only frees the buffers. diff --git a/test/interop/compat.sh b/test/interop/compat.sh index 0ddef6d3350..1366ec43c41 100755 --- a/test/interop/compat.sh +++ b/test/interop/compat.sh @@ -168,7 +168,7 @@ cell() { ran=$((ran + 1)) echo "=== $name${planned:+ (planned break $planned)} ===" # The nested interop.sh runs are this cell, not cases of their own. - if (unset MOQ_TEST_RESULTS && "$@"); then + if (unset HARNESS_RESULTS && "$@"); then echo "PASS $name" result=pass else @@ -184,7 +184,7 @@ cell() { fetch() { local relay="$1" pub="$2" sub="$3" js="$4" version="$5" - RELAY_BIN="$relay" MOQ_BIN="$pub" INTEROP_SUB_MOQ="$sub" INTEROP_VERSION="$version" \ + RELAY_BIN="$relay" CLI_BIN="$pub" INTEROP_SUB_MOQ="$sub" INTEROP_VERSION="$version" \ INTEROP_COMPAT_CLIENT="$js" INTEROP_FETCH_TRACK=1 \ bash "$DIR/interop.sh" --publishers rust --subscribers rust } @@ -201,7 +201,7 @@ while read -r source version <&3; do exit 1 ;; esac - cell media-control "$version" "$source" "$source" env RELAY_BIN="$relay" MOQ_BIN="$pub" INTEROP_SUB_MOQ="$pub" INTEROP_VERSION="$version" \ + cell media-control "$version" "$source" "$source" env RELAY_BIN="$relay" CLI_BIN="$pub" INTEROP_SUB_MOQ="$pub" INTEROP_VERSION="$version" \ INTEROP_COMPAT_CLIENT="$js" INTEROP_DECODE=1 bash "$DIR/interop.sh" --subscribers rust,js-native-node done 3<"$HARNESS_RUN/controls" @@ -240,14 +240,14 @@ while read -r version <&3; do fi # One cell per reader, so a planned break in one reader's release keeps the other running. for reader in rust js-native-node; do - cell "media-$reader" "$version" "$relay_source" "$source" env RELAY_BIN="$relay" MOQ_BIN="$pub" INTEROP_SUB_MOQ="$sub" INTEROP_VERSION="$version" \ + cell "media-$reader" "$version" "$relay_source" "$source" env RELAY_BIN="$relay" CLI_BIN="$pub" INTEROP_SUB_MOQ="$sub" INTEROP_VERSION="$version" \ INTEROP_COMPAT_CLIENT="$other_js" INTEROP_DECODE=1 bash "$DIR/interop.sh" --subscribers "$reader" done [[ "$released_fetch" == true && "$current_fetch" == true ]] || continue # Drive JS publication from actual subscriber demand: the publisher's own JS # subscribes and observes the group, which the opposite Rust CLI then # FETCHes by ID. Reading the newest group races its live delivery. - cell js-publish "$version" "$relay_source" "$source" env RELAY_BIN="$relay" MOQ_BIN="$pub" INTEROP_SUB_MOQ="$sub" INTEROP_VERSION="$version" \ + cell js-publish "$version" "$relay_source" "$source" env RELAY_BIN="$relay" CLI_BIN="$pub" INTEROP_SUB_MOQ="$sub" INTEROP_VERSION="$version" \ INTEROP_COMPAT_CLIENT="$own_js" INTEROP_FETCH_DATA=1 bash "$DIR/interop.sh" --publishers js-native --subscribers rust # Both Rust sources fetch the same group and compare exact payloads. The # publisher's own JS finds the group, so a catalog break fails only the diff --git a/test/interop/interop.sh b/test/interop/interop.sh index 2eecb6bd1cb..0ef153eadcb 100755 --- a/test/interop/interop.sh +++ b/test/interop/interop.sh @@ -46,7 +46,7 @@ source "$INTEROP_DIR/../lib/harness.sh" # Captured before the parse below consumes it, so the rerun command carries every # flag and every environment override this run was actually given. -RERUN="$(harness_env INTEROP_TIMEOUT INTEROP_FPS INTEROP_SIZE INTEROP_PORT INTEROP_PROFILE RELAY_BIN MOQ_BIN INTEROP_SUB_MOQ INTEROP_VERSION INTEROP_COMPAT_CLIENT INTEROP_DECODE INTEROP_FETCH_DATA INTEROP_FETCH_TRACK)just test interop$(harness_argv "$@")" +RERUN="$(harness_env INTEROP_TIMEOUT INTEROP_FPS INTEROP_SIZE INTEROP_PORT INTEROP_PROFILE RELAY_BIN CLI_BIN INTEROP_SUB_MOQ INTEROP_VERSION INTEROP_COMPAT_CLIENT INTEROP_DECODE INTEROP_FETCH_DATA INTEROP_FETCH_TRACK)just test interop$(harness_argv "$@")" PUBLISHERS="rust" SUBSCRIBERS="rust" @@ -55,7 +55,7 @@ SUBSCRIBERS="rust" # can't be held to them: a released client may not close cleanly, a released relay names no # connection when one closes, and the tail clients are built from this checkout only. IN_TREE=1 -if [[ -n "${RELAY_BIN:-}${MOQ_BIN:-}${INTEROP_SUB_MOQ:-}${INTEROP_COMPAT_CLIENT:-}" ]]; then +if [[ -n "${RELAY_BIN:-}${CLI_BIN:-}${INTEROP_SUB_MOQ:-}${INTEROP_COMPAT_CLIENT:-}" ]]; then IN_TREE=0 fi TIMEOUT="${INTEROP_TIMEOUT:-20}" @@ -82,9 +82,9 @@ IETF_VERSIONS="moq-transport-14,moq-transport-16,moq-transport-18,moq-transport- PROFILE="${INTEROP_PROFILE:-debug}" # Binaries under test. Built from source below unless overridden to point at a -# prebuilt (mirrors test/smoke's RELAY_BIN/MOQ_BIN escape hatch). +# prebuilt (mirrors test/smoke's RELAY_BIN/CLI_BIN escape hatch). RELAY="${RELAY_BIN:-}" -MOQ="${MOQ_BIN:-}" +MOQ="${CLI_BIN:-}" require_value() { # require_value "$@": the flag plus the rest of the argv. Ensures a @@ -327,7 +327,7 @@ COMPRESS_VERSIONS=(moq-lite-07-wip moq-lite-06) # checks audio only in its decoding media lanes, and the bindings' clients, which always check it, # refuse to run in the rest. AUDIO=1 -[[ -z "${MOQ_BIN:-}${INTEROP_SUB_MOQ:-}${INTEROP_COMPAT_CLIENT:-}" || "${INTEROP_DECODE:-0}" == 1 ]] || AUDIO=0 +[[ -z "${CLI_BIN:-}${INTEROP_SUB_MOQ:-}${INTEROP_COMPAT_CLIENT:-}" || "${INTEROP_DECODE:-0}" == 1 ]] || AUDIO=0 if [[ "$AUDIO" -eq 0 ]]; then for sub in "${SUB_LIST[@]}"; do case "$sub" in @@ -336,7 +336,7 @@ if [[ "$AUDIO" -eq 0 ]]; then *) sub_needs_audio="$sub" ;; esac if [[ -n "${sub_needs_audio:-}" ]]; then - echo "error: the $sub subscriber always checks audio, which a run with MOQ_BIN, INTEROP_SUB_MOQ, or INTEROP_COMPAT_CLIENT turns off without INTEROP_DECODE" >&2 + echo "error: the $sub subscriber always checks audio, which a run with CLI_BIN, INTEROP_SUB_MOQ, or INTEROP_COMPAT_CLIENT turns off without INTEROP_DECODE" >&2 exit 2 fi done diff --git a/test/interop/report.py b/test/interop/report.py index 94d0e6241b0..d4b1093c684 100644 --- a/test/interop/report.py +++ b/test/interop/report.py @@ -65,7 +65,7 @@ def steps(text): def passed(records, suites): """Cases were recorded, nothing failed or went unreached, and something passed. - A run that recorded no case (a lost MOQ_TEST_RESULTS) or skipped every step is not green. + A run that recorded no case (a lost HARNESS_RESULTS) or skipped every step is not green. """ outcomes = [record['outcome'] for record in records] + list(suites.values()) return bool(records) and 'pass' in outcomes and all(outcome in ('pass', 'skip') for outcome in outcomes) diff --git a/test/interop/report.test.py b/test/interop/report.test.py index 0e03ed1ac07..3a7cf25255f 100644 --- a/test/interop/report.test.py +++ b/test/interop/report.test.py @@ -27,7 +27,7 @@ def setUp(self): def harness(self, *args): """Record through the real harness_result, as interop.sh does.""" script = f'source {HERE.parent / "lib" / "harness.sh"}; HARNESS_RUN={self.run}; harness_result "$@"' - env = dict(os.environ, MOQ_TEST_RESULTS=str(self.results)) + env = dict(os.environ, HARNESS_RESULTS=str(self.results)) return subprocess.run(['bash', '-euo', 'pipefail', '-c', script, 'harness', *args], env=env, capture_output=True, text=True) @@ -97,9 +97,9 @@ def test_the_harness_refuses_malformed_records(self): ('pass', 'suite=s', 'case=c', 'outcome=fail'), ('pass', 'suite=s', 'case=c', 'seconds=soon')): self.assertNotEqual(self.harness(*args).returncode, 0, args) self.assertFalse(self.results.exists()) - # Without MOQ_TEST_RESULTS the harness records nothing, for any input. + # Without HARNESS_RESULTS the harness records nothing, for any input. script = f'source {HERE.parent / "lib" / "harness.sh"}; harness_result bogus' - env = {k: v for k, v in os.environ.items() if k != 'MOQ_TEST_RESULTS'} + env = {k: v for k, v in os.environ.items() if k != 'HARNESS_RESULTS'} subprocess.run(['bash', '-euo', 'pipefail', '-c', script], env=env, check=True) def test_the_report_refuses_malformed_records_and_steps(self): diff --git a/test/justfile b/test/justfile index 5134a3ac50c..3694d7e22e1 100644 --- a/test/justfile +++ b/test/justfile @@ -70,7 +70,7 @@ interop *args: --run-ignored all ./interop/interop.sh "$@" -# The harnesses append one record per case to MOQ_TEST_RESULTS; flags link the page to its +# The harnesses append one record per case to HARNESS_RESULTS; flags link the page to its # workflow run. See interop/report.py. # Render interop case records as a static HTML report. @@ -277,5 +277,5 @@ p2p: # Retain complete backend assets, parity, and raw alternating browser samples. [positional-arguments] wasm-baseline *args: - MOQ_TEST_RUNS="${MOQ_TEST_RUNS:-../target/test/wasm-backend}" ./wasm/run.sh "$@" - MOQ_TEST_RUNS="${MOQ_TEST_RUNS:-../target/test/wasm-backend}" ./wasm/run.sh --baseline "$@" + HARNESS_RUNS="${HARNESS_RUNS:-../target/test/wasm-backend}" ./wasm/run.sh "$@" + HARNESS_RUNS="${HARNESS_RUNS:-../target/test/wasm-backend}" ./wasm/run.sh --baseline "$@" diff --git a/test/lib/harness.sh b/test/lib/harness.sh index 196ccaa98c7..bc8e04497d6 100644 --- a/test/lib/harness.sh +++ b/test/lib/harness.sh @@ -65,7 +65,7 @@ harness_argv() { # is exactly what a collision or a filesystem failure depends on. harness_env() { local name value - for name in MOQ_TEST_RUNS MOQ_TEST_PORTS MOQ_TEST_PORT_BASE MOQ_TEST_KEEP "$@"; do + for name in HARNESS_RUNS HARNESS_PORT_ROOT HARNESS_PORT_BASE HARNESS_KEEP "$@"; do value="${!name-}" [[ -n "$value" ]] || continue printf '%s=%q ' "$name" "$value" @@ -77,9 +77,9 @@ harness_env() { harness_begin() { local name="$1" rerun="${2:-}" - local root="${MOQ_TEST_RUNS:-${TMPDIR:-/tmp}}" + local root="${HARNESS_RUNS:-${TMPDIR:-/tmp}}" root="${root%/}" - [[ -n "${MOQ_TEST_RUNS:-}" ]] || root="$root/moq-test-$(id -u)" + [[ -n "${HARNESS_RUNS:-}" ]] || root="$root/moq-test-$(id -u)" mkdir -p "$root" # Harnesses change directory after this, so a relative root would move under them. root=$(CDPATH='' cd -- "$root" && pwd) @@ -90,7 +90,7 @@ harness_begin() { HARNESS_RERUN="$rerun" # The browser drivers cannot see a shell variable, and a Playwright trace has # to land beside the logs it explains, so the path rides the environment. - export MOQ_TEST_RUN="$HARNESS_RUN" + export HARNESS_RUN_DIR="$HARNESS_RUN" # Cancellation needs its own traps: children run in their own process groups # (see `harness_spawn`), so a ^C aimed at this shell's group never reaches @@ -111,9 +111,9 @@ harness_begin() { # host network. Keep claims in /tmp regardless of each shell's scratch root. # The user id avoids ownership conflicts with another user's harnesses. harness_port_root() { - local root="${MOQ_TEST_PORTS:-/tmp}" + local root="${HARNESS_PORT_ROOT:-/tmp}" root="${root%/}" - [[ -n "${MOQ_TEST_PORTS:-}" ]] || root="$root/moq-test-ports-$(id -u)" + [[ -n "${HARNESS_PORT_ROOT:-}" ]] || root="$root/moq-test-ports-$(id -u)" echo "$root" } @@ -131,7 +131,7 @@ harness_valid_port() { # # `harness_port