From 983d2e5af5b8b96367faaef9b799eeeacfc3caab Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 13:06:25 -0800 Subject: [PATCH 1/7] chore(quest): claim quest/m0/ci/gate-quick.md Quest-Claim: e34ad65e191a50c9 From c9b5050e58742deaaed2011ead826851ba178779 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 13:10:00 -0800 Subject: [PATCH 2/7] fix(ci): admit cheap modules through quest gate --quick Co-Authored-By: GPT-6.1 Sol --- quest/m0/ci/README.md | 1 - quest/m0/ci/gate-quick.md | 20 -------------------- sh/dispatch-query.test.py | 33 +++++++++++++++++++++++++++++++++ sh/dispatch.sh | 33 +++++++++++++++++++++------------ sh/local.sh | 10 ++++++++-- sh/local.test.py | 25 +++++++++++++++++-------- 6 files changed, 79 insertions(+), 43 deletions(-) delete mode 100644 quest/m0/ci/gate-quick.md diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index 7c4a97918dd..62ed2f234bd 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -154,7 +154,6 @@ The historical samples locate candidates; they are not controlled benchmarks. - [Read-only pull-request CI](/quest/m0/ci/read-only-secrets.md) - write secrets and publisher identities reach only protected branches and tags, never a pushed branch - [Land main through GitHub's merge queue](/quest/m0/ci/land.md) - one PR at a time on the self-hosted runner; the host's Codex fixer fixes and re-enqueues every dropped PR - [A cache error is a miss](/quest/m0/ci/nix-cache-5xx.md) - a transient `nix.moq.dev` 5xx no longer fails `just ci` -- [Cheap checks skip the queue](/quest/m0/ci/gate-quick.md) - condition: quest ships `quest gate --quick`; then cheap modules wait at most a minute - [Gate each diff in under five minutes](/quest/m0/ci/five-minutes.md) - `just check` and `just test` each finish within a worker's 5-minute prompt cache, admission wait included - [Measure the parallel frontend](/quest/m0/ci/nightly-levers.md) - a pinned nightly's parallel frontend, adopted only if the numbers beat its risks; Cranelift is ruled out - [Verify the R2 Rust cache](/quest/m0/ci/mbx-r2-verify.md) - confirm the hosted Nightly jobs reuse the previous Nightly, then measure restore time and expiry diff --git a/quest/m0/ci/gate-quick.md b/quest/m0/ci/gate-quick.md deleted file mode 100644 index 2e231a3431e..00000000000 --- a/quest/m0/ci/gate-quick.md +++ /dev/null @@ -1,20 +0,0 @@ -# [XS] Cheap checks run through quest gate --quick - -## Goal - -moq's cheap checks, such as `check quest`, the formatters, and markdown, -wait at most a short bounded time for `quest gate` admission instead of -queuing behind agent builds. - -## Plan - -Decided 2026-10-31 (user, /quest-plan of the follow-ups from moq-dev/quest's host-gate cutover for moq.pro and rust2 and its fixer repairs). - -- Condition: [moq-dev/quest#324](https://github.com/moq-dev/quest/pull/324) - lands, adding `quest gate --quick` (at most 60 seconds of admission wait), - and moq's flake pins a quest that includes it. -- Cheap checks waited up to an hour behind load - ([#7250](https://github.com/moq-dev/moq/pull/7250), - [#7257](https://github.com/moq-dev/moq/pull/7257)). Mark them in the - dispatcher's module table, not by command name, and leave builds and - test suites under normal admission. diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index 4bfc8c3d9f6..a9902f4e8c2 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -296,6 +296,39 @@ def run_ci(self, base="origin/main"): self.assertEqual(result.returncode, 0, result.stderr) return (self.root / "calls").read_text().splitlines() + def test_module_admission_keeps_builds_and_tests_out_of_the_quick_queue(self): + self.env.pop("LOCAL_SUPERVISED") + quick = {"biome", "markdown", "quest", "python", "shell", "large_files", "text", "toml", "nix", "justfile"} + for action in ("check", "ci", "fix"): + with self.subTest(action=action): + self.stub_ci() + (self.repo / "sh/local.sh").write_text("""#!/usr/bin/env bash +[[ "${LOCAL_SUPERVISED:-}" == 1 ]] || printf 'admit %s\\n' "$*" >>"$CALLS" +export LOCAL_SUPERVISED=1 +[[ "$1" != --quick ]] || shift +exec "$@" +""") + result = subprocess.run( + ["bash", "sh/dispatch.sh", action, "--all"], + cwd=self.repo, + env=self.env, + text=True, + capture_output=True, + ) + self.assertEqual(result.returncode, 0, result.stderr) + calls = (self.root / "calls").read_text().splitlines() + admissions = [call.split() for call in calls if call.startswith("admit ")] + self.assertTrue(admissions, calls) + phases = {(call[-2], call[-1]) for call in admissions} + self.assertIn(("fix" if action == "fix" else "check", "markdown"), phases) + if action != "fix": + self.assertIn(("check", "quest"), phases) + self.assertIn(("test", "rs"), phases) + self.assertIn(("test", "gh"), phases) + for call in admissions: + phase, module = call[-2:] + self.assertEqual(call[1] == "--quick", module in quick and phase != "test", call) + def test_check_and_ci_reject_em_dashes_outside_the_diff(self): self.stub_ci() shutil.copy(ROOT / "sh/text.sh", self.repo / "sh/text.sh") diff --git a/sh/dispatch.sh b/sh/dispatch.sh index 60494879ad8..2773f06cc07 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -72,8 +72,9 @@ fi # run concurrently. # alone Its lane runs with no other lane beside it, so it waits for # the rest. +# quick Cheap phases wait at most a minute for host admission. # fix `just fix` runs it too; check and ci run every module. -declare -A scope=() tools=() compiles=([check]="" [fix]="") lane=() alone=() +declare -A scope=() tools=() compiles=([check]="" [fix]="") lane=() alone=() quick=() checks=() fixes=() module() { @@ -88,6 +89,7 @@ module() { compiles=*) for each in ${option#compiles=}; do compiles[$each]+=" $name"; done ;; lane=*) lane[$name]=${option#lane=} ;; alone) solo=1 ;; + quick) quick[$name]=1 ;; fix) fixes+=("$name") ;; *) echo "error: module $name has an unknown option '$option'" >&2 @@ -135,7 +137,7 @@ module obs_compile '^(\.cargo/config\.toml$|cpp/obs/|cpp/moq/|sh/obs/|rs/moq-ffi # that fix runs it first, since Biome can fix sources that the package build # rejects, such as a type-only export. module biome '' \ - tools='bun' lane=bun fix + tools='bun' lane=bun fix quick # The JS tests also read Rust's shared JSON vectors; sh/js/workspace.py # fails a check that reads a cross-tree input this pattern misses. # Root Nix inputs own the browser version every npm Playwright pin matches. @@ -163,7 +165,7 @@ module go '^(\.cargo/config\.toml$|go/|sh/go/|rs/moq-ffi/|doc/lib/go/|doc/lib/sa module drafts '^(drafts/|sh/drafts/|doc/\.vitepress/drafts\.ts$)' \ tools='bun kramdown-rfc xml2rfc' lane=bun module markdown '' \ - tools='bun' lane=bun fix + tools='bun' lane=bun fix quick module gh '' \ tools='actionlint zizmor bun python3 cargo release-plz clippy-driver dpkg-deb nfpm rpm' lane=bun # The drill mutations patch Rust source, so a Rust change can move the code @@ -177,7 +179,7 @@ module moq_sh '^infra/moq-sh/' \ # Quest documents form one graph, so any change validates the whole tree, # as does a bump of the flake-pinned validator. module quest '^(quest/|flake\.lock$)' \ - tools='quest' + tools='quest' quick # `obs check` compares the OBS pinned in buildspec.json, flake.nix, and # nixpkgs, and the last moves on a flake.lock bump alone. module obs '^(cpp/obs/|sh/obs/|flake\.(nix|lock)$)' \ @@ -188,17 +190,17 @@ module ts_paths '^(rs/.*Cargo\.toml$|Cargo\.(toml|lock)$|test/ts/run\.sh$|\.gith tools='cargo python3' # Ruff lints and formats every Python file under the nearest pyproject.toml. module python '(\.pyi?|(^|/)pyproject\.toml)$' \ - tools='ruff' fix + tools='ruff' fix quick module shell '' \ - tools='shellcheck shfmt' fix -module large_files '' -module text '' + tools='shellcheck shfmt' fix quick +module large_files '' quick +module text '' quick module toml '' \ - tools='taplo' fix + tools='taplo' fix quick module nix '' \ - tools='nixfmt' fix + tools='nixfmt' fix quick module justfile '' \ - fix + quick fix # dart builds moq-ffi with the filtered environment its build hook gets, then # checks that the hook finds that build fresh. Any other Cargo build in between # reruns the host build scripts in target/debug that track the environment, @@ -460,7 +462,14 @@ run_lane() { # processes. Trapped, it exits once they do, so a cancel # returns only after the whole tree has exited. trap 'exit 143' TERM - step "$phase" "$module" + # Export only the phase's inputs and functions to the launcher. + # Admission belongs to the module, not its command name or lane: + # the bun lane mixes formatters with builds and tooling tests. + export action rs_list js_list large_base + export -f files step + gate=() + [[ ! -v "quick[$module]" || "$phase" == test ]] || gate+=(--quick) + bash sh/local.sh "${gate[@]}" bash -euo pipefail -c 'step "$@"' -- "$phase" "$module" ) status=$? set -e diff --git a/sh/local.sh b/sh/local.sh index 6b065d8d648..7b6346e6211 100755 --- a/sh/local.sh +++ b/sh/local.sh @@ -2,8 +2,14 @@ # Admit a local suite once; cheap selection runs before calling this launcher. set -euo pipefail +gate=() +if [[ "${1:-}" == --quick ]]; then + gate+=(--quick) + shift +fi + if [[ $# == 0 ]]; then - echo 'usage: sh/local.sh COMMAND [ARGS...]' >&2 + echo 'usage: sh/local.sh [--quick] COMMAND [ARGS...]' >&2 exit 2 fi if [[ "${GITHUB_ACTIONS:-}" == true ]]; then @@ -16,4 +22,4 @@ fi if [[ "${QUEST_GATE_ADMITTED:-}" == 1 ]]; then exec bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" fi -exec quest gate bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" +exec quest gate "${gate[@]}" bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" diff --git a/sh/local.test.py b/sh/local.test.py index d496b1a36b9..a75a31d8505 100644 --- a/sh/local.test.py +++ b/sh/local.test.py @@ -24,14 +24,18 @@ def env(self, **changes): env.update(changes) return env - def run_command(self, script, **changes): + def run_command(self, script, quick=False, **changes): + options = ["--quick"] if quick else [] return subprocess.run( - [BASH, str(LAUNCHER), sys.executable, "-c", script], env=self.env(**changes), text=True, capture_output=True + [BASH, str(LAUNCHER), *options, sys.executable, "-c", script], + env=self.env(**changes), + text=True, + capture_output=True, ) def test_hosted_ci_bypasses_admission_and_worker_defaults(self): result = self.run_command( - 'import os; print(os.getenv("NEXTEST_TEST_THREADS")); exit(7)', GITHUB_ACTIONS="true", PATH="" + 'import os; print(os.getenv("NEXTEST_TEST_THREADS")); exit(7)', quick=True, GITHUB_ACTIONS="true", PATH="" ) self.assertEqual(result.returncode, 7, result.stderr) self.assertEqual(result.stdout.strip(), "None") @@ -39,6 +43,7 @@ def test_hosted_ci_bypasses_admission_and_worker_defaults(self): def test_nested_admission_preserves_failures_and_worker_override(self): result = self.run_command( 'import os; print(os.environ["NEXTEST_TEST_THREADS"]); exit(9)', + quick=True, LOCAL_SUPERVISED="1", NEXTEST_TEST_THREADS="2", PATH="", @@ -58,7 +63,9 @@ def test_admission_precedes_launch_and_nested_calls_skip_it(self): f"#!{sys.executable}\n" "import os, sys\n" 'assert sys.argv[1] == "gate"\n' - 'print("admitted", flush=True)\n' + 'quick = sys.argv[2:3] == ["--quick"]\n' + 'print("quick" if quick else "admitted", flush=True)\n' + "if quick: del sys.argv[2]\n" 'os.environ["QUEST_GATE_ADMITTED"] = "1"\n' "os.execvp(sys.argv[2], sys.argv[2:])\n" ) @@ -68,15 +75,17 @@ def test_admission_precedes_launch_and_nested_calls_skip_it(self): f"sys.exit(subprocess.call([{BASH!r}, {str(LAUNCHER)!r}, " 'sys.executable, "-c", "print(\'inner\'); exit(11)"]))' ) - result = self.run_command(script, PATH=directory) - self.assertEqual(result.returncode, 11, result.stderr) - self.assertEqual(result.stdout.splitlines(), ["admitted", "outer", "inner"]) + for quick in (False, True): + with self.subTest(quick=quick): + result = self.run_command(script, quick=quick, PATH=directory) + self.assertEqual(result.returncode, 11, result.stderr) + self.assertEqual(result.stdout.splitlines(), ["quick" if quick else "admitted", "outer", "inner"]) def test_external_admission_keeps_descendant_supervision(self): with tempfile.TemporaryDirectory() as directory: (Path(directory) / "bun").symlink_to(BUN) result = self.run_command( - 'import os; print(os.environ["LOCAL_SUPERVISED"])', QUEST_GATE_ADMITTED="1", PATH=directory + 'import os; print(os.environ["LOCAL_SUPERVISED"])', quick=True, QUEST_GATE_ADMITTED="1", PATH=directory ) self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.stdout.strip(), "1") From e2c427ff2492980aaa891a99a357cd25ea136fb8 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 13:12:28 -0800 Subject: [PATCH 3/7] fix(ci): preserve phase functions across systemd admission Co-Authored-By: GPT-6.1 Sol --- sh/dispatch-query.test.py | 4 +++- sh/dispatch.sh | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index a9902f4e8c2..c7bf54c9c53 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -303,7 +303,9 @@ def test_module_admission_keeps_builds_and_tests_out_of_the_quick_queue(self): with self.subTest(action=action): self.stub_ci() (self.repo / "sh/local.sh").write_text("""#!/usr/bin/env bash -[[ "${LOCAL_SUPERVISED:-}" == 1 ]] || printf 'admit %s\\n' "$*" >>"$CALLS" +[[ "${LOCAL_SUPERVISED:-}" == 1 ]] || printf 'admit %s %s %s\\n' "$1" "${@: -2:1}" "${@: -1}" >>"$CALLS" +# A systemd scope does not preserve exported Bash functions. +unset -f files step export LOCAL_SUPERVISED=1 [[ "$1" != --quick ]] || shift exec "$@" diff --git a/sh/dispatch.sh b/sh/dispatch.sh index 2773f06cc07..98579bdca7e 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -462,14 +462,15 @@ run_lane() { # processes. Trapped, it exits once they do, so a cancel # returns only after the whole tree has exited. trap 'exit 143' TERM - # Export only the phase's inputs and functions to the launcher. # Admission belongs to the module, not its command name or lane: # the bun lane mixes formatters with builds and tooling tests. export action rs_list js_list large_base - export -f files step gate=() [[ ! -v "quick[$module]" || "$phase" == test ]] || gate+=(--quick) - bash sh/local.sh "${gate[@]}" bash -euo pipefail -c 'step "$@"' -- "$phase" "$module" + # systemd scopes cannot carry exported Bash functions, so pass + # the phase's function source as the script instead. + script=$(declare -f files step) + bash sh/local.sh "${gate[@]}" bash -euo pipefail -c "$script"$'\n''step "$@"' -- "$phase" "$module" ) status=$? set -e From 85d7117de455c0cd06c13b36875a66f8522fe640 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 13:21:21 -0800 Subject: [PATCH 4/7] fix(ci): reap phase children before reporting cancellation Co-Authored-By: GPT-6.1 Sol --- sh/dispatch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sh/dispatch.sh b/sh/dispatch.sh index 98579bdca7e..b88bdcc9cc5 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -470,7 +470,7 @@ run_lane() { # systemd scopes cannot carry exported Bash functions, so pass # the phase's function source as the script instead. script=$(declare -f files step) - bash sh/local.sh "${gate[@]}" bash -euo pipefail -c "$script"$'\n''step "$@"' -- "$phase" "$module" + bash sh/local.sh "${gate[@]}" bash -euo pipefail -c "$script"$'\n''trap "exit 143" TERM; step "$@"' -- "$phase" "$module" ) status=$? set -e From 6d68f5ee66f6411703fe6daa6cbae34c70586167 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 13:36:07 -0800 Subject: [PATCH 5/7] fix(ci): limit quick admission to cheap phases Keep normal runners at their existing admission boundaries and include the launcher in the JS selection fixture. Co-Authored-By: GPT-6.1 Sol --- sh/dispatch-query.test.py | 80 ++++++++++++++++++++++----------------- sh/dispatch.sh | 20 +++++----- sh/js/workspace.test.py | 10 ++++- 3 files changed, 65 insertions(+), 45 deletions(-) diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index c7bf54c9c53..1ad653aec0e 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -321,15 +321,24 @@ def test_module_admission_keeps_builds_and_tests_out_of_the_quick_queue(self): calls = (self.root / "calls").read_text().splitlines() admissions = [call.split() for call in calls if call.startswith("admit ")] self.assertTrue(admissions, calls) - phases = {(call[-2], call[-1]) for call in admissions} + phases = {(call[-2], call[-1]) for call in admissions if call[1] == "--quick"} self.assertIn(("fix" if action == "fix" else "check", "markdown"), phases) if action != "fix": self.assertIn(("check", "quest"), phases) - self.assertIn(("test", "rs"), phases) - self.assertIn(("test", "gh"), phases) + self.assertIn("rs test-changed --all", calls) + self.assertIn("gh test", calls) for call in admissions: + if call[1] != "--quick": + self.assertIn(call[1], {"cargo", "nix"}, call) + continue phase, module = call[-2:] - self.assertEqual(call[1] == "--quick", module in quick and phase != "test", call) + self.assertEqual(call[1], "--quick", call) + self.assertIn(module, quick) + self.assertNotEqual(phase, "test") + self.assertEqual( + {module for _, module in phases}, + quick if action != "fix" else quick - {"quest", "large_files", "text"}, + ) def test_check_and_ci_reject_em_dashes_outside_the_diff(self): self.stub_ci() @@ -608,39 +617,42 @@ def test_terminating_the_run_stops_the_running_phase(self): os.mkfifo(started) pid = self.root / "pid" self.stub_ci(f'''case "$*" in - "rs lint-changed "*) echo $$ >"{pid}"; echo >"{started}"; exec sleep 600 ;; + "rs lint-changed "* | "biome") echo $$ >"{pid}"; echo >"{started}"; exec sleep 600 ;; esac ''') self.change("rs/kio/src/clock/mod.rs") - for jobs in ("1", "3"): - with self.subTest(jobs=jobs): - run = subprocess.Popen( - ["bash", "sh/dispatch.sh", "ci", "origin/main"], - cwd=self.repo, - env=dict(self.env, CHECK_JOBS=jobs), - stdout=subprocess.DEVNULL, - stderr=subprocess.PIPE, - ) - started.read_text() - # A job timeout can kill the run without a signal it traps, so - # a buffered lane names its running phase before the phase ends. - live = b"" - try: - if jobs != "1": - deadline = time.monotonic() + 60 - while b"ci: check rs started\n" not in live: - readable, _, _ = select.select([run.stderr], [], [], max(0, deadline - time.monotonic())) - self.assertTrue(readable, live.decode(errors="replace")) - chunk = os.read(run.stderr.fileno(), 4096) - self.assertTrue(chunk, live.decode(errors="replace")) - live += chunk - finally: - run.terminate() - stderr = (live + run.communicate(timeout=60)[1]).decode() - self.assertEqual(run.returncode, 143, stderr) - self.assertRegex(stderr, r"\d+ check rs \(cancelled\)") - with self.assertRaises(ProcessLookupError): - os.kill(int(pid.read_text()), 0) + for module in ("rs", "biome"): + for jobs in ("1", "3"): + with self.subTest(module=module, jobs=jobs): + run = subprocess.Popen( + ["bash", "sh/dispatch.sh", "ci", "origin/main"], + cwd=self.repo, + env=dict(self.env, CHECK_JOBS=jobs, CHECK_MODULES=module), + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE, + ) + started.read_text() + # A job timeout can kill the run without a signal it traps, so + # a buffered lane names its running phase before the phase ends. + live = b"" + try: + if jobs != "1": + deadline = time.monotonic() + 60 + while f"ci: check {module} started\n".encode() not in live: + readable, _, _ = select.select( + [run.stderr], [], [], max(0, deadline - time.monotonic()) + ) + self.assertTrue(readable, live.decode(errors="replace")) + chunk = os.read(run.stderr.fileno(), 4096) + self.assertTrue(chunk, live.decode(errors="replace")) + live += chunk + finally: + run.terminate() + stderr = (live + run.communicate(timeout=60)[1]).decode() + self.assertEqual(run.returncode, 143, stderr) + self.assertRegex(stderr, rf"\d+ check {module} \(cancelled\)") + with self.assertRaises(ProcessLookupError): + os.kill(int(pid.read_text()), 0) def test_ci_runs_one_lint_preamble_and_one_test_pass(self): self.change("rs/kio/src/clock/mod.rs") diff --git a/sh/dispatch.sh b/sh/dispatch.sh index b88bdcc9cc5..28df27a22d4 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -462,15 +462,17 @@ run_lane() { # processes. Trapped, it exits once they do, so a cancel # returns only after the whole tree has exited. trap 'exit 143' TERM - # Admission belongs to the module, not its command name or lane: - # the bun lane mixes formatters with builds and tooling tests. - export action rs_list js_list large_base - gate=() - [[ ! -v "quick[$module]" || "$phase" == test ]] || gate+=(--quick) - # systemd scopes cannot carry exported Bash functions, so pass - # the phase's function source as the script instead. - script=$(declare -f files step) - bash sh/local.sh "${gate[@]}" bash -euo pipefail -c "$script"$'\n''trap "exit 143" TERM; step "$@"' -- "$phase" "$module" + if [[ -v "quick[$module]" && "$phase" != test ]]; then + # The bun lane also runs builds and tests; only this phase + # gets quick admission. Keep the normal runners unchanged. + export action rs_list js_list large_base + # systemd scopes cannot carry exported Bash functions, so + # pass the phase's function source as the script instead. + script=$(declare -f files step) + bash sh/local.sh --quick bash -euo pipefail -c "$script"$'\n''trap "exit 143" TERM; step "$@"' -- "$phase" "$module" + else + step "$phase" "$module" + fi ) status=$? set -e diff --git a/sh/js/workspace.test.py b/sh/js/workspace.test.py index 281fbeec173..c202656e4f0 100644 --- a/sh/js/workspace.test.py +++ b/sh/js/workspace.test.py @@ -52,7 +52,8 @@ def plan(self, paths): def test_dispatcher_passes_only_js_impact_paths(self): sh = self.root / "sh" - shutil.copy(selector.ROOT / "sh/dispatch.sh", sh / "dispatch.sh") + for script in ("dispatch.sh", "local.sh"): + shutil.copy(selector.ROOT / "sh" / script, sh / script) changed = sh / "changed.sh" changed.write_text("#!/bin/sh\nprintf '%s\\n' js/auth/src/token.ts demo/pub/worker.ts quest/unrelated.md\n") changed.chmod(0o755) @@ -75,7 +76,12 @@ def test_dispatcher_passes_only_js_impact_paths(self): GITHUB_BASE_REF="missing", GITHUB_STEP_SUMMARY=str(summary), ): - env = dispatch_env(PATH=f"{tools}:{os.environ['PATH']}", ALLOW_HOST_TOOLCHAIN="1", SELECT_CALLS=str(calls)) + env = dispatch_env( + PATH=f"{tools}:{os.environ['PATH']}", + ALLOW_HOST_TOOLCHAIN="1", + LOCAL_SUPERVISED="1", + SELECT_CALLS=str(calls), + ) for script in ("markdown.sh", "shell.sh", "large-files.sh", "text.sh"): path = sh / script path.write_text("#!/bin/sh\nexit 0\n") From fb1ca0cd85f96db670a279aa7b6b828ff4ffb378 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 16:59:30 -0800 Subject: [PATCH 6/7] revert(ci): restore main's dispatcher and launcher The maintainer chose to drop the quick-admission implementation on 2026-11-03: cheap phases already bypass admission on main, and the recorded plan doesn't address the outer admission boundary. Co-Authored-By: Claude Opus 5.5 --- quest/m0/ci/README.md | 1 + quest/m0/ci/gate-quick.md | 20 +++++++ sh/dispatch-query.test.py | 107 +++++++++++--------------------------- sh/dispatch.sh | 36 +++++-------- sh/js/workspace.test.py | 10 +--- sh/local.sh | 10 +--- sh/local.test.py | 25 +++------ 7 files changed, 75 insertions(+), 134 deletions(-) create mode 100644 quest/m0/ci/gate-quick.md diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index f6f3f791834..32c131c796e 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -154,6 +154,7 @@ The historical samples locate candidates; they are not controlled benchmarks. - [Read-only pull-request CI](/quest/m0/ci/read-only-secrets.md) - write secrets and publisher identities reach only protected branches and tags, never a pushed branch - [Land main through GitHub's merge queue](/quest/m0/ci/land.md) - one PR at a time on the self-hosted runner; the host's Codex fixer fixes and re-enqueues every dropped PR - [A cache error is a miss](/quest/m0/ci/nix-cache-5xx.md) - a transient `nix.moq.dev` 5xx no longer fails `just ci` +- [Cheap checks skip the queue](/quest/m0/ci/gate-quick.md) - condition: quest ships `quest gate --quick`; then cheap modules wait at most a minute - [Gate each diff in under five minutes](/quest/m0/ci/five-minutes.md) - `just check`, test phases included, finishes within a worker's 5-minute prompt cache, admission wait included - [Measure the parallel frontend](/quest/m0/ci/nightly-levers.md) - a pinned nightly's parallel frontend, adopted only if the numbers beat its risks; Cranelift is ruled out - [Verify the R2 Rust cache](/quest/m0/ci/mbx-r2-verify.md) - confirm the hosted Nightly jobs reuse the previous Nightly, then measure restore time and expiry diff --git a/quest/m0/ci/gate-quick.md b/quest/m0/ci/gate-quick.md new file mode 100644 index 00000000000..2e231a3431e --- /dev/null +++ b/quest/m0/ci/gate-quick.md @@ -0,0 +1,20 @@ +# [XS] Cheap checks run through quest gate --quick + +## Goal + +moq's cheap checks, such as `check quest`, the formatters, and markdown, +wait at most a short bounded time for `quest gate` admission instead of +queuing behind agent builds. + +## Plan + +Decided 2026-10-31 (user, /quest-plan of the follow-ups from moq-dev/quest's host-gate cutover for moq.pro and rust2 and its fixer repairs). + +- Condition: [moq-dev/quest#324](https://github.com/moq-dev/quest/pull/324) + lands, adding `quest gate --quick` (at most 60 seconds of admission wait), + and moq's flake pins a quest that includes it. +- Cheap checks waited up to an hour behind load + ([#7250](https://github.com/moq-dev/moq/pull/7250), + [#7257](https://github.com/moq-dev/moq/pull/7257)). Mark them in the + dispatcher's module table, not by command name, and leave builds and + test suites under normal admission. diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index 1ad653aec0e..4bfc8c3d9f6 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -296,50 +296,6 @@ def run_ci(self, base="origin/main"): self.assertEqual(result.returncode, 0, result.stderr) return (self.root / "calls").read_text().splitlines() - def test_module_admission_keeps_builds_and_tests_out_of_the_quick_queue(self): - self.env.pop("LOCAL_SUPERVISED") - quick = {"biome", "markdown", "quest", "python", "shell", "large_files", "text", "toml", "nix", "justfile"} - for action in ("check", "ci", "fix"): - with self.subTest(action=action): - self.stub_ci() - (self.repo / "sh/local.sh").write_text("""#!/usr/bin/env bash -[[ "${LOCAL_SUPERVISED:-}" == 1 ]] || printf 'admit %s %s %s\\n' "$1" "${@: -2:1}" "${@: -1}" >>"$CALLS" -# A systemd scope does not preserve exported Bash functions. -unset -f files step -export LOCAL_SUPERVISED=1 -[[ "$1" != --quick ]] || shift -exec "$@" -""") - result = subprocess.run( - ["bash", "sh/dispatch.sh", action, "--all"], - cwd=self.repo, - env=self.env, - text=True, - capture_output=True, - ) - self.assertEqual(result.returncode, 0, result.stderr) - calls = (self.root / "calls").read_text().splitlines() - admissions = [call.split() for call in calls if call.startswith("admit ")] - self.assertTrue(admissions, calls) - phases = {(call[-2], call[-1]) for call in admissions if call[1] == "--quick"} - self.assertIn(("fix" if action == "fix" else "check", "markdown"), phases) - if action != "fix": - self.assertIn(("check", "quest"), phases) - self.assertIn("rs test-changed --all", calls) - self.assertIn("gh test", calls) - for call in admissions: - if call[1] != "--quick": - self.assertIn(call[1], {"cargo", "nix"}, call) - continue - phase, module = call[-2:] - self.assertEqual(call[1], "--quick", call) - self.assertIn(module, quick) - self.assertNotEqual(phase, "test") - self.assertEqual( - {module for _, module in phases}, - quick if action != "fix" else quick - {"quest", "large_files", "text"}, - ) - def test_check_and_ci_reject_em_dashes_outside_the_diff(self): self.stub_ci() shutil.copy(ROOT / "sh/text.sh", self.repo / "sh/text.sh") @@ -617,42 +573,39 @@ def test_terminating_the_run_stops_the_running_phase(self): os.mkfifo(started) pid = self.root / "pid" self.stub_ci(f'''case "$*" in - "rs lint-changed "* | "biome") echo $$ >"{pid}"; echo >"{started}"; exec sleep 600 ;; + "rs lint-changed "*) echo $$ >"{pid}"; echo >"{started}"; exec sleep 600 ;; esac ''') self.change("rs/kio/src/clock/mod.rs") - for module in ("rs", "biome"): - for jobs in ("1", "3"): - with self.subTest(module=module, jobs=jobs): - run = subprocess.Popen( - ["bash", "sh/dispatch.sh", "ci", "origin/main"], - cwd=self.repo, - env=dict(self.env, CHECK_JOBS=jobs, CHECK_MODULES=module), - stdout=subprocess.DEVNULL, - stderr=subprocess.PIPE, - ) - started.read_text() - # A job timeout can kill the run without a signal it traps, so - # a buffered lane names its running phase before the phase ends. - live = b"" - try: - if jobs != "1": - deadline = time.monotonic() + 60 - while f"ci: check {module} started\n".encode() not in live: - readable, _, _ = select.select( - [run.stderr], [], [], max(0, deadline - time.monotonic()) - ) - self.assertTrue(readable, live.decode(errors="replace")) - chunk = os.read(run.stderr.fileno(), 4096) - self.assertTrue(chunk, live.decode(errors="replace")) - live += chunk - finally: - run.terminate() - stderr = (live + run.communicate(timeout=60)[1]).decode() - self.assertEqual(run.returncode, 143, stderr) - self.assertRegex(stderr, rf"\d+ check {module} \(cancelled\)") - with self.assertRaises(ProcessLookupError): - os.kill(int(pid.read_text()), 0) + for jobs in ("1", "3"): + with self.subTest(jobs=jobs): + run = subprocess.Popen( + ["bash", "sh/dispatch.sh", "ci", "origin/main"], + cwd=self.repo, + env=dict(self.env, CHECK_JOBS=jobs), + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE, + ) + started.read_text() + # A job timeout can kill the run without a signal it traps, so + # a buffered lane names its running phase before the phase ends. + live = b"" + try: + if jobs != "1": + deadline = time.monotonic() + 60 + while b"ci: check rs started\n" not in live: + readable, _, _ = select.select([run.stderr], [], [], max(0, deadline - time.monotonic())) + self.assertTrue(readable, live.decode(errors="replace")) + chunk = os.read(run.stderr.fileno(), 4096) + self.assertTrue(chunk, live.decode(errors="replace")) + live += chunk + finally: + run.terminate() + stderr = (live + run.communicate(timeout=60)[1]).decode() + self.assertEqual(run.returncode, 143, stderr) + self.assertRegex(stderr, r"\d+ check rs \(cancelled\)") + with self.assertRaises(ProcessLookupError): + os.kill(int(pid.read_text()), 0) def test_ci_runs_one_lint_preamble_and_one_test_pass(self): self.change("rs/kio/src/clock/mod.rs") diff --git a/sh/dispatch.sh b/sh/dispatch.sh index 28df27a22d4..60494879ad8 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -72,9 +72,8 @@ fi # run concurrently. # alone Its lane runs with no other lane beside it, so it waits for # the rest. -# quick Cheap phases wait at most a minute for host admission. # fix `just fix` runs it too; check and ci run every module. -declare -A scope=() tools=() compiles=([check]="" [fix]="") lane=() alone=() quick=() +declare -A scope=() tools=() compiles=([check]="" [fix]="") lane=() alone=() checks=() fixes=() module() { @@ -89,7 +88,6 @@ module() { compiles=*) for each in ${option#compiles=}; do compiles[$each]+=" $name"; done ;; lane=*) lane[$name]=${option#lane=} ;; alone) solo=1 ;; - quick) quick[$name]=1 ;; fix) fixes+=("$name") ;; *) echo "error: module $name has an unknown option '$option'" >&2 @@ -137,7 +135,7 @@ module obs_compile '^(\.cargo/config\.toml$|cpp/obs/|cpp/moq/|sh/obs/|rs/moq-ffi # that fix runs it first, since Biome can fix sources that the package build # rejects, such as a type-only export. module biome '' \ - tools='bun' lane=bun fix quick + tools='bun' lane=bun fix # The JS tests also read Rust's shared JSON vectors; sh/js/workspace.py # fails a check that reads a cross-tree input this pattern misses. # Root Nix inputs own the browser version every npm Playwright pin matches. @@ -165,7 +163,7 @@ module go '^(\.cargo/config\.toml$|go/|sh/go/|rs/moq-ffi/|doc/lib/go/|doc/lib/sa module drafts '^(drafts/|sh/drafts/|doc/\.vitepress/drafts\.ts$)' \ tools='bun kramdown-rfc xml2rfc' lane=bun module markdown '' \ - tools='bun' lane=bun fix quick + tools='bun' lane=bun fix module gh '' \ tools='actionlint zizmor bun python3 cargo release-plz clippy-driver dpkg-deb nfpm rpm' lane=bun # The drill mutations patch Rust source, so a Rust change can move the code @@ -179,7 +177,7 @@ module moq_sh '^infra/moq-sh/' \ # Quest documents form one graph, so any change validates the whole tree, # as does a bump of the flake-pinned validator. module quest '^(quest/|flake\.lock$)' \ - tools='quest' quick + tools='quest' # `obs check` compares the OBS pinned in buildspec.json, flake.nix, and # nixpkgs, and the last moves on a flake.lock bump alone. module obs '^(cpp/obs/|sh/obs/|flake\.(nix|lock)$)' \ @@ -190,17 +188,17 @@ module ts_paths '^(rs/.*Cargo\.toml$|Cargo\.(toml|lock)$|test/ts/run\.sh$|\.gith tools='cargo python3' # Ruff lints and formats every Python file under the nearest pyproject.toml. module python '(\.pyi?|(^|/)pyproject\.toml)$' \ - tools='ruff' fix quick + tools='ruff' fix module shell '' \ - tools='shellcheck shfmt' fix quick -module large_files '' quick -module text '' quick + tools='shellcheck shfmt' fix +module large_files '' +module text '' module toml '' \ - tools='taplo' fix quick + tools='taplo' fix module nix '' \ - tools='nixfmt' fix quick + tools='nixfmt' fix module justfile '' \ - quick fix + fix # dart builds moq-ffi with the filtered environment its build hook gets, then # checks that the hook finds that build fresh. Any other Cargo build in between # reruns the host build scripts in target/debug that track the environment, @@ -462,17 +460,7 @@ run_lane() { # processes. Trapped, it exits once they do, so a cancel # returns only after the whole tree has exited. trap 'exit 143' TERM - if [[ -v "quick[$module]" && "$phase" != test ]]; then - # The bun lane also runs builds and tests; only this phase - # gets quick admission. Keep the normal runners unchanged. - export action rs_list js_list large_base - # systemd scopes cannot carry exported Bash functions, so - # pass the phase's function source as the script instead. - script=$(declare -f files step) - bash sh/local.sh --quick bash -euo pipefail -c "$script"$'\n''trap "exit 143" TERM; step "$@"' -- "$phase" "$module" - else - step "$phase" "$module" - fi + step "$phase" "$module" ) status=$? set -e diff --git a/sh/js/workspace.test.py b/sh/js/workspace.test.py index c202656e4f0..281fbeec173 100644 --- a/sh/js/workspace.test.py +++ b/sh/js/workspace.test.py @@ -52,8 +52,7 @@ def plan(self, paths): def test_dispatcher_passes_only_js_impact_paths(self): sh = self.root / "sh" - for script in ("dispatch.sh", "local.sh"): - shutil.copy(selector.ROOT / "sh" / script, sh / script) + shutil.copy(selector.ROOT / "sh/dispatch.sh", sh / "dispatch.sh") changed = sh / "changed.sh" changed.write_text("#!/bin/sh\nprintf '%s\\n' js/auth/src/token.ts demo/pub/worker.ts quest/unrelated.md\n") changed.chmod(0o755) @@ -76,12 +75,7 @@ def test_dispatcher_passes_only_js_impact_paths(self): GITHUB_BASE_REF="missing", GITHUB_STEP_SUMMARY=str(summary), ): - env = dispatch_env( - PATH=f"{tools}:{os.environ['PATH']}", - ALLOW_HOST_TOOLCHAIN="1", - LOCAL_SUPERVISED="1", - SELECT_CALLS=str(calls), - ) + env = dispatch_env(PATH=f"{tools}:{os.environ['PATH']}", ALLOW_HOST_TOOLCHAIN="1", SELECT_CALLS=str(calls)) for script in ("markdown.sh", "shell.sh", "large-files.sh", "text.sh"): path = sh / script path.write_text("#!/bin/sh\nexit 0\n") diff --git a/sh/local.sh b/sh/local.sh index 7b6346e6211..6b065d8d648 100755 --- a/sh/local.sh +++ b/sh/local.sh @@ -2,14 +2,8 @@ # Admit a local suite once; cheap selection runs before calling this launcher. set -euo pipefail -gate=() -if [[ "${1:-}" == --quick ]]; then - gate+=(--quick) - shift -fi - if [[ $# == 0 ]]; then - echo 'usage: sh/local.sh [--quick] COMMAND [ARGS...]' >&2 + echo 'usage: sh/local.sh COMMAND [ARGS...]' >&2 exit 2 fi if [[ "${GITHUB_ACTIONS:-}" == true ]]; then @@ -22,4 +16,4 @@ fi if [[ "${QUEST_GATE_ADMITTED:-}" == 1 ]]; then exec bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" fi -exec quest gate "${gate[@]}" bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" +exec quest gate bun --no-orphans "${BASH_SOURCE[0]%/*}/local.ts" "$@" diff --git a/sh/local.test.py b/sh/local.test.py index a75a31d8505..d496b1a36b9 100644 --- a/sh/local.test.py +++ b/sh/local.test.py @@ -24,18 +24,14 @@ def env(self, **changes): env.update(changes) return env - def run_command(self, script, quick=False, **changes): - options = ["--quick"] if quick else [] + def run_command(self, script, **changes): return subprocess.run( - [BASH, str(LAUNCHER), *options, sys.executable, "-c", script], - env=self.env(**changes), - text=True, - capture_output=True, + [BASH, str(LAUNCHER), sys.executable, "-c", script], env=self.env(**changes), text=True, capture_output=True ) def test_hosted_ci_bypasses_admission_and_worker_defaults(self): result = self.run_command( - 'import os; print(os.getenv("NEXTEST_TEST_THREADS")); exit(7)', quick=True, GITHUB_ACTIONS="true", PATH="" + 'import os; print(os.getenv("NEXTEST_TEST_THREADS")); exit(7)', GITHUB_ACTIONS="true", PATH="" ) self.assertEqual(result.returncode, 7, result.stderr) self.assertEqual(result.stdout.strip(), "None") @@ -43,7 +39,6 @@ def test_hosted_ci_bypasses_admission_and_worker_defaults(self): def test_nested_admission_preserves_failures_and_worker_override(self): result = self.run_command( 'import os; print(os.environ["NEXTEST_TEST_THREADS"]); exit(9)', - quick=True, LOCAL_SUPERVISED="1", NEXTEST_TEST_THREADS="2", PATH="", @@ -63,9 +58,7 @@ def test_admission_precedes_launch_and_nested_calls_skip_it(self): f"#!{sys.executable}\n" "import os, sys\n" 'assert sys.argv[1] == "gate"\n' - 'quick = sys.argv[2:3] == ["--quick"]\n' - 'print("quick" if quick else "admitted", flush=True)\n' - "if quick: del sys.argv[2]\n" + 'print("admitted", flush=True)\n' 'os.environ["QUEST_GATE_ADMITTED"] = "1"\n' "os.execvp(sys.argv[2], sys.argv[2:])\n" ) @@ -75,17 +68,15 @@ def test_admission_precedes_launch_and_nested_calls_skip_it(self): f"sys.exit(subprocess.call([{BASH!r}, {str(LAUNCHER)!r}, " 'sys.executable, "-c", "print(\'inner\'); exit(11)"]))' ) - for quick in (False, True): - with self.subTest(quick=quick): - result = self.run_command(script, quick=quick, PATH=directory) - self.assertEqual(result.returncode, 11, result.stderr) - self.assertEqual(result.stdout.splitlines(), ["quick" if quick else "admitted", "outer", "inner"]) + result = self.run_command(script, PATH=directory) + self.assertEqual(result.returncode, 11, result.stderr) + self.assertEqual(result.stdout.splitlines(), ["admitted", "outer", "inner"]) def test_external_admission_keeps_descendant_supervision(self): with tempfile.TemporaryDirectory() as directory: (Path(directory) / "bun").symlink_to(BUN) result = self.run_command( - 'import os; print(os.environ["LOCAL_SUPERVISED"])', quick=True, QUEST_GATE_ADMITTED="1", PATH=directory + 'import os; print(os.environ["LOCAL_SUPERVISED"])', QUEST_GATE_ADMITTED="1", PATH=directory ) self.assertEqual(result.returncode, 0, result.stderr) self.assertEqual(result.stdout.strip(), "1") From f85a0e5b9ccf03ee845664c23c2619b21aac848b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 16:59:54 -0800 Subject: [PATCH 7/7] quest(ci): delete the stale quick-admission quest Its plan marks cheap modules for `quest gate --quick`, but those phases already bypass admission; the wait happens at the outer `quest gate` around the whole run. The maintainer chose deletion over a rewrite on 2026-11-03. Co-Authored-By: Claude Opus 5.5 --- quest/m0/ci/README.md | 1 - quest/m0/ci/gate-quick.md | 20 -------------------- 2 files changed, 21 deletions(-) delete mode 100644 quest/m0/ci/gate-quick.md diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index 32c131c796e..f6f3f791834 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -154,7 +154,6 @@ The historical samples locate candidates; they are not controlled benchmarks. - [Read-only pull-request CI](/quest/m0/ci/read-only-secrets.md) - write secrets and publisher identities reach only protected branches and tags, never a pushed branch - [Land main through GitHub's merge queue](/quest/m0/ci/land.md) - one PR at a time on the self-hosted runner; the host's Codex fixer fixes and re-enqueues every dropped PR - [A cache error is a miss](/quest/m0/ci/nix-cache-5xx.md) - a transient `nix.moq.dev` 5xx no longer fails `just ci` -- [Cheap checks skip the queue](/quest/m0/ci/gate-quick.md) - condition: quest ships `quest gate --quick`; then cheap modules wait at most a minute - [Gate each diff in under five minutes](/quest/m0/ci/five-minutes.md) - `just check`, test phases included, finishes within a worker's 5-minute prompt cache, admission wait included - [Measure the parallel frontend](/quest/m0/ci/nightly-levers.md) - a pinned nightly's parallel frontend, adopted only if the numbers beat its risks; Cranelift is ruled out - [Verify the R2 Rust cache](/quest/m0/ci/mbx-r2-verify.md) - confirm the hosted Nightly jobs reuse the previous Nightly, then measure restore time and expiry diff --git a/quest/m0/ci/gate-quick.md b/quest/m0/ci/gate-quick.md deleted file mode 100644 index 2e231a3431e..00000000000 --- a/quest/m0/ci/gate-quick.md +++ /dev/null @@ -1,20 +0,0 @@ -# [XS] Cheap checks run through quest gate --quick - -## Goal - -moq's cheap checks, such as `check quest`, the formatters, and markdown, -wait at most a short bounded time for `quest gate` admission instead of -queuing behind agent builds. - -## Plan - -Decided 2026-10-31 (user, /quest-plan of the follow-ups from moq-dev/quest's host-gate cutover for moq.pro and rust2 and its fixer repairs). - -- Condition: [moq-dev/quest#324](https://github.com/moq-dev/quest/pull/324) - lands, adding `quest gate --quick` (at most 60 seconds of admission wait), - and moq's flake pins a quest that includes it. -- Cheap checks waited up to an hour behind load - ([#7250](https://github.com/moq-dev/moq/pull/7250), - [#7257](https://github.com/moq-dev/moq/pull/7257)). Mark them in the - dispatcher's module table, not by command name, and leave builds and - test suites under normal admission.