From e114012ae7fb0e3e3bcd4410e9bb1bd799846670 Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Sat, 14 Nov 2026 06:37:33 +0300 Subject: [PATCH 1/6] Harness: check-ports tokenizes only files that name a clock; DepGates batch two loops and share the real-tree run ci/check-ports.py lexed every file of its scopes and classified every scope's wholly-test files on each run (4.1 s of CPU of the ~25 s a ci/check-deps.sh run costs), once per DepGates test. It now reads a file's source first and tokenizes it only when it holds Instant, SystemTime or elapsed (the wall-clock regex and the alias test both need one), and computes a scope's wholly-test set only when a file of that scope has a wall-clock site. Verified byte-identical on the checkout and on trees with a planted production site, a wholly-test site, an Instant alias, an .elapsed ( site and an unlexable file. tests/test_harness.py: the two ui-owner loops plant their files in one copy and grade one gate run by file name (6 runs -> 2), and the two tests that grade the checkout share one run. Co-Authored-By: Claude Opus 5.5 --- ci/check-ports.py | 30 +++++++++++---- tests/test_harness.py | 87 +++++++++++++++++++++++++++++++++---------- 2 files changed, 90 insertions(+), 27 deletions(-) diff --git a/ci/check-ports.py b/ci/check-ports.py index f799bb17b4..434e7b791e 100644 --- a/ci/check-ports.py +++ b/ci/check-ports.py @@ -51,21 +51,35 @@ def ports(root, ini): result.add(name) return result +# `wall_sites` needs one of these words in the source: `WALL` spells `Instant::`, `SystemTime::` or +# `.elapsed(`, and the alias test needs the token `Instant` or `SystemTime`. A file without any of +# them cannot hold a wall-clock operation, so it is neither tokenized nor classified: lexing the +# ~690 files of the scopes (and the wholly-test classification of every scope) was most of this +# gate's 4.6 s of CPU, run once per `ci/check-deps.sh` and so ~100 times by tests/test_harness.py. +NEEDS_WALL_WORD = re.compile(r'Instant|SystemTime|elapsed') + def check(root=ROOT, ini=None): exempt = ports(root, ini or root / 'ci/ports.ini') - tests = set() - for scope in SCOPES: - path = root / scope - if path.is_dir(): tests.update(rtm.wholly_test_files(path)) + scope_paths = [root / scope for scope in SCOPES] + wholly_tests = {} + def is_wholly_test(path): + """`path` is in the union of `wholly_test_files(scope)` over the directory scopes holding it, + each computed on its first use: a scope whose files carry no wall-clock word never is.""" + for scope in scope_paths: + if scope.is_dir() and scope in path.parents: + if scope not in wholly_tests: wholly_tests[scope] = rtm.wholly_test_files(scope) + if path.resolve() in wholly_tests[scope]: return True + return False problems = [] files = set() - for scope in SCOPES: - path = root / scope + for path in scope_paths: files.update(path.rglob('*.rs') if path.is_dir() else ([path] if path.exists() else [])) for path in sorted(files): name = path.relative_to(root).as_posix() - if name in exempt or path.resolve() in tests: continue - if wall_sites(shape.production_tokens(path.read_text(encoding='utf-8'))): + if name in exempt: continue + source = path.read_text(encoding='utf-8') + if not NEEDS_WALL_WORD.search(source): continue + if wall_sites(shape.production_tokens(source)) and not is_wholly_test(path): problems.append(f'{name}: wall clock outside ci/ports.ini') return problems diff --git a/tests/test_harness.py b/tests/test_harness.py index dfa1b3b491..99f8fe40f4 100644 --- a/tests/test_harness.py +++ b/tests/test_harness.py @@ -8690,8 +8690,22 @@ def run(self, result=None): self.doCleanups() raise + _real_tree_lock = threading.Lock() + _real_tree_run = None + + @classmethod + def _real_tree(cls): + """One run of the gate over the CHECKOUT, shared by the two tests that read it. Nothing in + this class edits the checkout (`test_self_tests_never_touch_the_real_tree`), so the second + reader would only repeat the first's ~25 s of CPU.""" + with cls._real_tree_lock: + if cls._real_tree_run is None: + cls._real_tree_run = subprocess.run([os.path.join(cls.ROOT, "ci", "check-deps.sh")], + capture_output=True, text=True) + return cls._real_tree_run + def test_check_deps_is_green(self): - r = subprocess.run([os.path.join(self.ROOT, "ci", "check-deps.sh")], capture_output=True, text=True) + r = self._real_tree() self.assertEqual(r.returncode, 0, r.stdout + r.stderr) def test_self_tests_never_touch_the_real_tree(self): @@ -8708,7 +8722,7 @@ def test_self_tests_never_touch_the_real_tree(self): def test_the_private_copy_grades_exactly_like_the_real_tree(self): """The copy must carry every input `ci/check-deps.sh` reads: a missing one makes a gate see nothing and pass (or fail) for a reason the real tree would not share.""" - real = subprocess.run([os.path.join(self.ROOT, "ci", "check-deps.sh")], capture_output=True, text=True) + real = self._real_tree() copy = subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], capture_output=True, text=True) self.assertEqual((copy.returncode, copy.stdout), (real.returncode, real.stdout), copy.stderr) @@ -8749,9 +8763,7 @@ def _plant(self, name, content, crate_dir=None): it is invisible to cargo (nothing declares it part of the crate) but not to `find … -name '*.rs'`, which is all these gates scan with — so this is the cheapest way to prove a gate catches a shape without touching a real, permanent source file.""" - # `player/` and `route/` are the media layer crate's now (docs/module-layers.md, Split 11). - crate = crate_dir or ("media" if name.split("/")[0] in ("player", "route") else None) - target = os.path.join(self.tree, "rust-modules", *([crate] if crate else []), "src", name) + target = self._plant_target(name, crate_dir) self.assertFalse(os.path.exists(target), f"stale self-test artifact at {target} — remove it by hand") try: with open(target, "w", encoding="utf-8") as f: @@ -8762,6 +8774,34 @@ def _plant(self, name, content, crate_dir=None): if os.path.exists(target): os.remove(target) + def _plant_target(self, name, crate_dir=None): + """Where `_plant` writes `name` in the private copy.""" + # `player/` and `route/` are the media layer crate's now (docs/module-layers.md, Split 11). + crate = crate_dir or ("media" if name.split("/")[0] in ("player", "route") else None) + return os.path.join(self.tree, "rust-modules", *([crate] if crate else []), "src", name) + + def _plant_many(self, plants): + """`_plant` for several files at once, graded by ONE `ci/check-deps.sh` run. + + `plants` is a list of `(name, content, crate_dir)`, each with its own file name, so the one + run still shows which variants the gate caught: a gate prints the `path:line:text` (or the + path) of every file it flags, and the caller requires each variant's file by name. Run + one variant at a time, a test with N variants cost N runs (about 25 s of CPU apiece).""" + written = [] + try: + for name, content, crate_dir in plants: + target = self._plant_target(name, crate_dir) + self.assertFalse(os.path.exists(target), f"stale self-test artifact at {target} — remove it by hand") + written.append(target) + with open(target, "w", encoding="utf-8") as f: + f.write(content) + return subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], + capture_output=True, text=True) + finally: + for target in written: + if os.path.exists(target): + os.remove(target) + def _mutate(self, relpath, needle, replacement): """Temporarily replace ONE occurrence of `needle` with `replacement` in a REAL tracked file, run ci/check-deps.sh, then unconditionally restore the original bytes — even if the @@ -10012,27 +10052,36 @@ def test_dt_gate_catches_idle_dt_by_name(self): self.assertIn("_check_deps_selftest_dt_fn.rs", out) def test_ui_owner_gate_rejects_retired_global_readers(self): - for name, body in ( + readers = ( ("nav", "plx_ui::nav::page_alpha()"), ("press", "plx_ui::press::scale()"), ("idle", "plx_machine::idle::invalidate()"), - ): + ) + result = self._plant_many([ + (f"_check_deps_selftest_owner_{name}.rs", f"pub fn retired_reader() {{ {body}; }}\n", None) + for name, body in readers + ]) + output = result.stdout + result.stderr + self.assertNotEqual(result.returncode, 0, output) + for name, _ in readers: + rule = "nav" if name == "nav" else "ui-owner-legacy" with self.subTest(reader=name): - result = self._plant( - f"_check_deps_selftest_owner_{name}.rs", - f"pub fn retired_reader() {{ {body}; }}\n", - ) - output = result.stdout + result.stderr - self.assertNotEqual(result.returncode, 0, output) - self.assertIn("nav:" if name == "nav" else "ui-owner-legacy:", output) + # The rule's own report, `path:line:text`, names each planted file: a reader the + # gate missed is absent from the one run's output by name. + self.assertIn(f"{rule}:", output) + self.assertTrue( + any(f"_check_deps_selftest_owner_{name}.rs:" in line for line in output.splitlines()), + f"{rule} did not flag the {name} reader\n{output}") def test_ui_owner_gate_rejects_resurrected_modules(self): - for crate, name in (("ui", "nav.rs"), ("ui", "press.rs"), ("machine", "idle.rs")): + modules = (("ui", "nav.rs"), ("ui", "press.rs"), ("machine", "idle.rs")) + result = self._plant_many([(name, "// Retired module must remain absent.\n", crate) for crate, name in modules]) + output = result.stdout + result.stderr + self.assertNotEqual(result.returncode, 0, output) + self.assertIn("ui-owner-files:", output) + for crate, name in modules: with self.subTest(crate=crate, module=name): - result = self._plant(name, "// Retired module must remain absent.\n", crate_dir=crate) - output = result.stdout + result.stderr - self.assertNotEqual(result.returncode, 0, output) - self.assertIn("ui-owner-files:", output) + self.assertIn(f"ui-owner-files: retired module rust-modules/{crate}/src/{name} exists", output) def test_owned_damage_gate_rejects_a_retired_transport_call(self): result = self._plant("_check_deps_selftest_damage_adapter.rs", From d7a05b82fcfd20424f111e4e0e33ccfbbb8300af Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Sat, 14 Nov 2026 06:38:42 +0300 Subject: [PATCH 2/6] tv-sched-trace: --app's flavour check no longer depends on the locale's collation case "$flavor" in *[!a-z]* took "Debug" for lower case under macOS bash 3.2 with en_US.UTF-8 (the CI runner's locale), so --app=Debug exited 0 instead of 2 and the daily build bench's check row failed in ReadBack.test_bad_arguments on 2026-11-13. The class is spelled out; the test runs the argument under that locale too (red before the fix: 0 != 2). Co-Authored-By: Claude Opus 5.5 --- tools/test_tv_sched_trace.py | 4 ++++ tools/tv-sched-trace.sh | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/test_tv_sched_trace.py b/tools/test_tv_sched_trace.py index 933ad75c5c..eb2d1d1876 100755 --- a/tools/test_tv_sched_trace.py +++ b/tools/test_tv_sched_trace.py @@ -191,6 +191,10 @@ def test_bad_arguments(self): self.assertEqual(rig.run("--tid", "x").returncode, 2) self.assertEqual(rig.run("--read-timeout", "0").returncode, 2) self.assertEqual(rig.run("--app=Debug").returncode, 2) + # Locale-dependent: a bash range like `[a-z]` collates uppercase letters in between in a UTF-8 + # locale (macOS /bin/bash under en_US.UTF-8, the CI runner's), which accepted "Debug" there + # (the daily build bench failed on it, 2026-11-13). A host without that locale falls back to C. + self.assertEqual(rig.run("--app=Debug", env={"LC_ALL": "en_US.UTF-8", "LANG": "en_US.UTF-8"}).returncode, 2) def test_tid_and_app_are_exclusive(self): rig = self.rig(0) diff --git a/tools/tv-sched-trace.sh b/tools/tv-sched-trace.sh index 0057f85d0d..f80139d58c 100755 --- a/tools/tv-sched-trace.sh +++ b/tools/tv-sched-trace.sh @@ -100,7 +100,9 @@ case "$read_timeout" in ''|*[!0-9]*) echo "tv-sched-trace: --read-timeout needs [ "$read_timeout" -ge 1 ] || { echo "tv-sched-trace: --read-timeout must be >= 1" >&2; exit 2; } case "$tid" in *[!0-9]*) echo "tv-sched-trace: --tid needs a thread id" >&2; exit 2 ;; esac [ -z "$app" ] || [ -z "$tid" ] || { echo "tv-sched-trace: --tid and --app are mutually exclusive" >&2; exit 2; } -case "$flavor" in ''|*[!a-z]*) echo "tv-sched-trace: --app needs a flavour name (debug, stable, nightly)" >&2; exit 2 ;; esac +# Spelled out, not `[!a-z]`: a range collates by LOCALE, and in a UTF-8 one (macOS bash 3.2 under +# en_US.UTF-8) it takes "Debug" for lower case. +case "$flavor" in ''|*[!abcdefghijklmnopqrstuvwxyz]*) echo "tv-sched-trace: --app needs a flavour name (debug, stable, nightly)" >&2; exit 2 ;; esac [ -n "$out" ] || out="tv-sched-trace-$(date +%Y%m%d-%H%M%S).gz" HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" From 0203be084d7536248910dcf7c3cead4312b4c106 Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Sat, 14 Nov 2026 06:55:30 +0300 Subject: [PATCH 3/6] CI: start the slowest python-gate steps first; fix the ui-owner batch helper name ci/check-python-steps.txt: ORDER is the START order of a 4-lane runner, and test_check_machine_shape.py (225 s, one CPU-bound process) sat 110th, so it started ~190 s into the job and the job lasted 413 s. The nine slowest steps now start first; a list scheduler over the step durations of CI run 43537750750 gives 412 s for the old order (the job's own 413 s) and 317 s for the new one, the sum of all step times over four lanes. tests/test_harness.py: the helper that plants several files across crates in one gate run is _plant_all (a _plant_many for one crate already exists). Co-Authored-By: Claude Opus 5.5 --- ci/check-python-steps.txt | 98 ++++++++++++++++++++------------------- tests/test_harness.py | 6 +-- 2 files changed, 54 insertions(+), 50 deletions(-) diff --git a/ci/check-python-steps.txt b/ci/check-python-steps.txt index 6017d0aa3b..2b1479b9ac 100644 --- a/ci/check-python-steps.txt +++ b/ci/check-python-steps.txt @@ -26,6 +26,57 @@ # step goes at the END; move it up only after measuring (`make check-python-rest` prints each step's # wall and CPU time and the slowest three). +# The nine slowest steps (CI, 2026-11-14: machine-shape 225 s, build-gc 98 s, arm-profile 71 s, check-elf 56 s, +# transition-arguments 47 s, disk-budget 44 s, disk-preflight 44 s, tv-lock 43 s, collisions 40 s) start first: +# test_check_machine_shape.py sat 110th and ended the job at 413 s (it starts ~190 s in, then runs 225 s). + +# The machine-shape gate (ci/machines.ini, docs/sans-io.md): a state machine listed there keeps its state private (a `pub`, +# `pub(crate)` or `pub(super)` field of the listed struct fails, as does a stale entry), so its one writer stays `step` and a new +# way to change it is a new event. It also REPORTS, and never fails on, each machine's `bool` and `Option<..>` field counts: a +# report-only flag ratchet. Pure lexing, no cargo; the self-tests run on synthetic trees in a private temp dir. +python3 ci/test_check_machine_shape.py +# tools/build-gc.sh against disposable repositories, fleet dirs and caches: every OTHER reclaim mode refuses under a held FFmpeg lock, a +# live checkout is spared, `--auto`'s order is the planner's (and its `--worktrees` stage spares a lane inside the idle window, and one holding an ignored file that is not build output), +# `--worktrees` judges a lane against `origin/main` without refreshing its index, and `--evict PLAN` deletes exactly what the plan +# names after re-probing it: it refuses paths that are not derived build trees, skips a tree that turned live, goes on under an +# FFmpeg lock, and never takes a /tmp tree that only looks old. `--evict` runs only inside the fixture's own directories. +python3 ci/test_build_gc.py +# `ARM_PROFILE`: a plain local build compiles the ARM staticlib with the fast `tvdev` profile and +# everything that ships or runs in CI keeps fat-LTO `release`; resolved through print-bench-config. +python3 ci/test_arm_profile.py +python3 ci/test_check_elf.py +python3 ci/test_transition_arguments.py +# tools/disk-budget.py, the disk budget's inventory and planner (docs/disk-budget.md): the ladder's order, stopping at the line, +# refusing only when the whole ladder cannot free the build's estimate plus the reserve, and NEVER planning the current checkout +# below rung 6 (nor, there, the tree being built), a live, tracked, pkg/, vendor/ or non-PlxNative tree; private-byte accounting under hard links; `origin/main` merged detection +# (squash merges, a stale local main, nothing written to the repository); `report` changes nothing; the plan file `build-gc.sh --evict` +# reads (format, order, the stale slot, rung-6 `current`), `settle`, the cargo seed never planned, a /tmp tree aged by ctime so a +# backdated fixture is never a candidate, the probes (`probe`, `tmp-trees`), and that collecting an inventory never rewrites a +# lane's index. Synthetic inventories plus private temp repositories, a stubbed lsof, no real /tmp scan. +python3 ci/test_disk_budget.py +# The disk budget at every build entry: `make disk-preflight` is `tools/disk-budget.py preflight` and an ORDER-ONLY prerequisite of +# every Makefile target that runs cargo. Static: the Makefile is parsed and every target whose recipe runs cargo (directly or through a +# script) must be in `make -s print-disk-entries`, with the prerequisite after the `|`, before the build starts, and the recursive +# `$(MAKE)` lines carrying PLX_DISK_BUDGET_DONE. Dynamic, on a fixture repository with PLX_GC_TEST_FREE_KIB and stubbed lsof/pgrep: +# at comfort nothing starts and the planner is not imported; below the reserve with nothing to evict it refuses with the reason; below +# comfort it evicts idle trees and never the tree being built; the marker and PLX_MIN_FREE_MB=0 are no-ops; the auto lock is +# taken, a live holder is waited on for a bounded time (one --wait-secs deadline for the whole preflight) and no plan is made while it runs (a finished or stale holder is taken over); the inventory cache; a pretend emergency is never planned over real +# trees; the cold store's unpark of an absent parked tree: the cheap no-gos (config removed, volume unmounted) come before any lock wait, the +# lock is held to claim the copy and not across it (two trees restore at once), a claimed or dead-claimed tree, and the free-space rule. `make -n` and `make -s print-*` only, no cargo. +python3 ci/test_disk_preflight.py +# The TV lock's own protocol suite, with NO television: the device half runs under a local sh in a temp dir, and the +# HEADS-UP cases run the real `acquire`/`break` as children with their own lane, lease directory and lock path (one +# line on a new lease, including your own expired one, none on a live renew or a refusal). It also runs the pre-flight's +# verdict table (IDLE / IN USE / UNKNOWN) on fixture replies, cuts a hung probe off at PLX_TV_PREFLIGHT_SECS, and runs +# `with` for real: it refuses to start on IN USE, PLX_TV_IN_USE_OK overrides, and its renewer's whole process tree dies +# with it. That spawns and kills background processes, so it takes about 20 s, not milliseconds. Then the PostToolUse hook +# that turns the HEADS-UP and IN USE lines into reminders: payload shapes, the failure and unrelated cases, malformed +# stdin. Both host-only. +tools/tv-lock.sh selftest +# Nothing that runs at once may collide: two checkouts running the scratch-writing steps (test-compat.py, +# the C unit tests) at once, and a mix of different steps run together as the runner runs this file, +# each against one shared TMPDIR; and no test source binds a fixed port. +python3 ci/test_check_collisions.py # The `check` lock wrapper's own suite: two shared runs at once and a third waiting (naming both # holders), a SIGKILLed holder freeing its slot, PLX_CHECK_SLOTS=1 serializing, exclusive mode for # the benchmarks (blocks and is blocked by shared runs, not starved by a stream of them, two @@ -39,17 +90,6 @@ python3 ci/test_build_bench.py # one record per day (a same-day re-run replaces it), nothing written for a failed benchmark, a red `check` costing only # its own rows, a noisy day marked and kept, nothing identifying in the runner block. Synthetic documents, no cargo. python3 ci/test_build_history.py -# tools/build-gc.sh against disposable repositories, fleet dirs and caches: every OTHER reclaim mode refuses under a held FFmpeg lock, a -# live checkout is spared, `--auto`'s order is the planner's (and its `--worktrees` stage spares a lane inside the idle window, and one holding an ignored file that is not build output), -# `--worktrees` judges a lane against `origin/main` without refreshing its index, and `--evict PLAN` deletes exactly what the plan -# names after re-probing it: it refuses paths that are not derived build trees, skips a tree that turned live, goes on under an -# FFmpeg lock, and never takes a /tmp tree that only looks old. `--evict` runs only inside the fixture's own directories. -python3 ci/test_build_gc.py -python3 ci/test_check_elf.py -# Nothing that runs at once may collide: two checkouts running the scratch-writing steps (test-compat.py, -# the C unit tests) at once, and a mix of different steps run together as the runner runs this file, -# each against one shared TMPDIR; and no test source binds a fixed port. -python3 ci/test_check_collisions.py # `tools/tv-config.sh`, the ONE resolver for the TV address and Wake-on-LAN MAC (this checkout's # .tv-host/.tv-mac, the main checkout's, then ~/.config/plxnative/), and every reader of it # (tv-ssh, wake-tv, the Makefile's TV, tests/run.py, stream-screen.py), against a throwaway repo @@ -212,9 +252,6 @@ python3 tools/test_ci_test_results.py # a pass, every `test result:` line is printed), both against a fake cargo; nothing is compiled. python3 ci/test_test_crate.py python3 ci/test_cargo_test_parallel.py -# `ARM_PROFILE`: a plain local build compiles the ARM staticlib with the fast `tvdev` profile and -# everything that ships or runs in CI keeps fat-LTO `release`; resolved through print-bench-config. -python3 ci/test_arm_profile.py # `HOST_THREADS`: rustc's parallel front end for the local host test builds only; off for CI, RELEASE, # SYMBOLS and every non-debug flavour, and named by no ARM, simulator, clippy or workflow line. python3 ci/test_host_threads.py @@ -307,49 +344,17 @@ python3 ci/gen-third-party-notices.py --check # --skip-if-missing only so a runner without Rust is not red here: CI's host-lint job runs it strict. python3 ci/test_check_vfp.py python3 ci/check-vfp.py --skip-if-missing -# tools/disk-budget.py, the disk budget's inventory and planner (docs/disk-budget.md): the ladder's order, stopping at the line, -# refusing only when the whole ladder cannot free the build's estimate plus the reserve, and NEVER planning the current checkout -# below rung 6 (nor, there, the tree being built), a live, tracked, pkg/, vendor/ or non-PlxNative tree; private-byte accounting under hard links; `origin/main` merged detection -# (squash merges, a stale local main, nothing written to the repository); `report` changes nothing; the plan file `build-gc.sh --evict` -# reads (format, order, the stale slot, rung-6 `current`), `settle`, the cargo seed never planned, a /tmp tree aged by ctime so a -# backdated fixture is never a candidate, the probes (`probe`, `tmp-trees`), and that collecting an inventory never rewrites a -# lane's index. Synthetic inventories plus private temp repositories, a stubbed lsof, no real /tmp scan. -python3 ci/test_disk_budget.py -# The disk budget at every build entry: `make disk-preflight` is `tools/disk-budget.py preflight` and an ORDER-ONLY prerequisite of -# every Makefile target that runs cargo. Static: the Makefile is parsed and every target whose recipe runs cargo (directly or through a -# script) must be in `make -s print-disk-entries`, with the prerequisite after the `|`, before the build starts, and the recursive -# `$(MAKE)` lines carrying PLX_DISK_BUDGET_DONE. Dynamic, on a fixture repository with PLX_GC_TEST_FREE_KIB and stubbed lsof/pgrep: -# at comfort nothing starts and the planner is not imported; below the reserve with nothing to evict it refuses with the reason; below -# comfort it evicts idle trees and never the tree being built; the marker and PLX_MIN_FREE_MB=0 are no-ops; the auto lock is -# taken, a live holder is waited on for a bounded time (one --wait-secs deadline for the whole preflight) and no plan is made while it runs (a finished or stale holder is taken over); the inventory cache; a pretend emergency is never planned over real -# trees; the cold store's unpark of an absent parked tree: the cheap no-gos (config removed, volume unmounted) come before any lock wait, the -# lock is held to claim the copy and not across it (two trees restore at once), a claimed or dead-claimed tree, and the free-space rule. `make -n` and `make -s print-*` only, no cargo. -python3 ci/test_disk_preflight.py # RUST_INPUTS (the Makefile's hand-kept list of directories whose edits rebuild the app library) must search every crate # the app reaches through `path` dependencies: a crate left out is one whose edits `make` never sees, so `make ipk` packages # the previous library and says nothing. Reads manifests only, no cargo; the self-test plants a missing crate in a temp tree. python3 ci/test_check_rust_inputs.py python3 ci/check-rust-inputs.py -# The machine-shape gate (ci/machines.ini, docs/sans-io.md): a state machine listed there keeps its state private (a `pub`, -# `pub(crate)` or `pub(super)` field of the listed struct fails, as does a stale entry), so its one writer stays `step` and a new -# way to change it is a new event. It also REPORTS, and never fails on, each machine's `bool` and `Option<..>` field counts: a -# report-only flag ratchet. Pure lexing, no cargo; the self-tests run on synthetic trees in a private temp dir. -python3 ci/test_check_machine_shape.py python3 ci/test_check_machine_writer.py python3 ci/check-machine-shape.py # tools/pr-land.py (gate / wait / merge / restack) against a fake `gh` on PATH and an injected sleeper: a failed, pending, missing, draft, behind # or head-moved PR never reaches `gh pr merge` (#387), the polling and backoff, the head-oid race, the verify against a temporary # origin, and a planted secret refused before any `gh` call. Real gh JSON as fixtures; temp dirs only, no network, no sleeping on the poll or race timers (one test lets a hung gh hit a 1 s timeout). python3 tools/test_pr_land.py -# The TV lock's own protocol suite, with NO television: the device half runs under a local sh in a temp dir, and the -# HEADS-UP cases run the real `acquire`/`break` as children with their own lane, lease directory and lock path (one -# line on a new lease, including your own expired one, none on a live renew or a refusal). It also runs the pre-flight's -# verdict table (IDLE / IN USE / UNKNOWN) on fixture replies, cuts a hung probe off at PLX_TV_PREFLIGHT_SECS, and runs -# `with` for real: it refuses to start on IN USE, PLX_TV_IN_USE_OK overrides, and its renewer's whole process tree dies -# with it. That spawns and kills background processes, so it takes about 20 s, not milliseconds. Then the PostToolUse hook -# that turns the HEADS-UP and IN USE lines into reminders: payload shapes, the failure and unrelated cases, malformed -# stdin. Both host-only. -tools/tv-lock.sh selftest python3 .claude/hooks/tv-lock-notify-test.py # The custom agents' files (AGENTS.md, "Harness-specific files"): every `.agents/agents/.md` carries a matching frontmatter # `name`, an explicit `model:` (one documented exemption), a description, a RELATIVE `.claude/agents/.md` symlink that resolves @@ -398,7 +403,6 @@ python3 ci/test_step_scope.py python3 ci/test_machine_readonly.py python3 ci/test_readonly_dependencies.py python3 ci/test_readonly_generated.py -python3 ci/test_transition_arguments.py # tools/cold-store.py, the opt-in cold store that parks idle build trees on a second volume: unconfigured it creates no file anywhere; each # reason `available()` can give (no config, no ditto, an unmounted /Volumes root, the same device as the build tree, under min_free_gib, a diff --git a/tests/test_harness.py b/tests/test_harness.py index 99f8fe40f4..bec1db99a2 100644 --- a/tests/test_harness.py +++ b/tests/test_harness.py @@ -8780,7 +8780,7 @@ def _plant_target(self, name, crate_dir=None): crate = crate_dir or ("media" if name.split("/")[0] in ("player", "route") else None) return os.path.join(self.tree, "rust-modules", *([crate] if crate else []), "src", name) - def _plant_many(self, plants): + def _plant_all(self, plants): """`_plant` for several files at once, graded by ONE `ci/check-deps.sh` run. `plants` is a list of `(name, content, crate_dir)`, each with its own file name, so the one @@ -10057,7 +10057,7 @@ def test_ui_owner_gate_rejects_retired_global_readers(self): ("press", "plx_ui::press::scale()"), ("idle", "plx_machine::idle::invalidate()"), ) - result = self._plant_many([ + result = self._plant_all([ (f"_check_deps_selftest_owner_{name}.rs", f"pub fn retired_reader() {{ {body}; }}\n", None) for name, body in readers ]) @@ -10075,7 +10075,7 @@ def test_ui_owner_gate_rejects_retired_global_readers(self): def test_ui_owner_gate_rejects_resurrected_modules(self): modules = (("ui", "nav.rs"), ("ui", "press.rs"), ("machine", "idle.rs")) - result = self._plant_many([(name, "// Retired module must remain absent.\n", crate) for crate, name in modules]) + result = self._plant_all([(name, "// Retired module must remain absent.\n", crate) for crate, name in modules]) output = result.stdout + result.stderr self.assertNotEqual(result.returncode, 0, output) self.assertIn("ui-owner-files:", output) From c129430894a83a9a2eaf20fa86b1001648b7b2e2 Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Sat, 14 Nov 2026 07:34:30 +0300 Subject: [PATCH 4/6] Harness speed: keep an unlexable wholly-test file skipped, pin the wall rule's lex errors The wall rule's prefilter (a file without Instant/SystemTime/elapsed is not lexed) and its lazily computed wholly-test sets changed what an unlexable file does: - A wholly-test file holding a wall word that cannot be lexed used to be skipped (the wholly-test set was consulted before lexing) and failed after the prefilter. It is skipped again: only a file that fails to lex is classified, which costs nothing on a valid tree. Classifying every file with a wall word first was measured at about twice the gate's time. - A file with no wall word and an unterminated raw string, or a scope whose `wholly_test_files` hits an unbalanced token group and holds no wall site, no longer fails this rule. ci/check-list-caps.py lexes every production file under every rust-modules/*/src and rust-modules/src and computes wholly_test_files over each, and lets the ValueError fail its step; the comment at the prefilter says so. ci/test_check_ports.py pins each case, including that check-list-caps reports the files the wall rule no longer lexes. The ORDER header of ci/check-python-steps.txt now matches the file: the nine steps of the 2026-11-14 CI run first, then the thirteen others of the sixteen measured 2026-10-07. Co-Authored-By: Claude Opus 5.5 --- ci/check-ports.py | 20 ++++++++++++++++++-- ci/check-python-steps.txt | 9 +++++---- ci/test_check_ports.py | 22 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/ci/check-ports.py b/ci/check-ports.py index 434e7b791e..9569a27baf 100644 --- a/ci/check-ports.py +++ b/ci/check-ports.py @@ -53,9 +53,17 @@ def ports(root, ini): # `wall_sites` needs one of these words in the source: `WALL` spells `Instant::`, `SystemTime::` or # `.elapsed(`, and the alias test needs the token `Instant` or `SystemTime`. A file without any of -# them cannot hold a wall-clock operation, so it is neither tokenized nor classified: lexing the +# them cannot hold a wall-clock operation, so this rule does not lex or classify it: lexing the # ~690 files of the scopes (and the wholly-test classification of every scope) was most of this # gate's 4.6 s of CPU, run once per `ci/check-deps.sh` and so ~100 times by tests/test_harness.py. +# The skip changes what an UNLEXABLE file does here, never what a wall site does: a file with no +# wall word and an unterminated raw string no longer fails THIS rule. `ci/check-list-caps.py` (a step +# of ci/check-python-steps.txt) reports it instead: it runs `rtm.lex` over every production file under +# every `rust-modules/*/src` and `rust-modules/src` (all these scopes), and `rtm.wholly_test_files` over +# each of those roots, and lets the ValueError fail the step. Test-named files (`*_tests.rs`, `tests.rs`, +# a `tests/` directory) and wholly-test files are the ones it does not lex: test code, which rustc rejects +# when it is not Rust. `wholly_test_files(scope)` is computed only for a scope holding a wall site, so an +# unbalanced token group fails this rule only then (ci/test_check_ports.py pins both halves). NEEDS_WALL_WORD = re.compile(r'Instant|SystemTime|elapsed') def check(root=ROOT, ini=None): @@ -79,7 +87,15 @@ def is_wholly_test(path): if name in exempt: continue source = path.read_text(encoding='utf-8') if not NEEDS_WALL_WORD.search(source): continue - if wall_sites(shape.production_tokens(source)) and not is_wholly_test(path): + try: has_wall_site = wall_sites(shape.production_tokens(source)) + except ValueError: + # A file with a wall word that cannot be lexed fails this gate, EXCEPT a wholly-test file, + # which this rule never lexed (it skipped those first). Classifying before lexing every + # such file would compute all seven scopes' wholly-test sets (about twice this gate's time); + # classifying only the file that failed to lex costs nothing on a valid tree. + if is_wholly_test(path): continue + raise + if has_wall_site and not is_wholly_test(path): problems.append(f'{name}: wall clock outside ci/ports.ini') return problems diff --git a/ci/check-python-steps.txt b/ci/check-python-steps.txt index 2b1479b9ac..92c0ba9ce1 100644 --- a/ci/check-python-steps.txt +++ b/ci/check-python-steps.txt @@ -21,10 +21,11 @@ # `ci/test_check_collisions.py` runs these steps side by side to check the first rule; a step that # breaks one of them shows up there rather than as a flake in somebody else's `make check`. # -# ORDER is only the START order: the sixteen slowest steps (measured 2026-10-07) come first, so the -# last one to start is a short one; the run lasts as long as the longest step plus the queue. A new -# step goes at the END; move it up only after measuring (`make check-python-rest` prints each step's -# wall and CPU time and the slowest three). +# ORDER is only the START order: the nine slowest steps of the CI run measured 2026-11-14 (the first +# block below) come first, then the thirteen others of the sixteen slowest measured 2026-10-07 (three of +# those sixteen are among the nine), so the last one to start is a short one; the run lasts as long as +# the longest step plus the queue. A new step goes at the END; move it up only after measuring +# (`make check-python-rest` prints each step's wall and CPU time and the slowest three). # The nine slowest steps (CI, 2026-11-14: machine-shape 225 s, build-gc 98 s, arm-profile 71 s, check-elf 56 s, # transition-arguments 47 s, disk-budget 44 s, disk-preflight 44 s, tv-lock 43 s, collisions 40 s) start first: diff --git a/ci/test_check_ports.py b/ci/test_check_ports.py index 0323917733..0d06aa96e0 100644 --- a/ci/test_check_ports.py +++ b/ci/test_check_ports.py @@ -7,6 +7,10 @@ spec = importlib.util.spec_from_file_location('check_ports', Path(__file__).with_name('check-ports.py')) gate = importlib.util.module_from_spec(spec) spec.loader.exec_module(gate) +caps_spec = importlib.util.spec_from_file_location('check_list_caps', Path(__file__).with_name('check-list-caps.py')) +caps = importlib.util.module_from_spec(caps_spec) +caps_spec.loader.exec_module(caps) +UNTERMINATED = 'const S: &str = r#"never closed;\n' class Ports(unittest.TestCase): def fixture(self, name='rust-modules/data/src/job_ports.rs', source='fn run() { Instant::now(); }', ini=None): temp = tempfile.TemporaryDirectory() @@ -38,6 +42,24 @@ def test_spacing_and_noncall_clock_references_are_reads(self): for source in ('fn f() { let now = Instant :: now; }', 'fn f() { i . elapsed ( ); }'): root = self.fixture(ini='', source=source) self.assertTrue(gate.check(root)) + def test_unlexable_file_with_a_wall_word_fails_unless_it_is_wholly_test(self): + root = self.fixture(ini='', source='fn run() { Instant::now(); }\n' + UNTERMINATED) + with self.assertRaisesRegex(ValueError, 'unterminated Rust raw string'): gate.check(root) + root = self.fixture(name='rust-modules/session/src/lib.rs', ini='', source='#[cfg(test)] mod fixture;') + (root / 'rust-modules/session/src/fixture.rs').write_text('fn test() { Instant::now(); }\n' + UNTERMINATED) + self.assertEqual(gate.check(root), []) + def test_unlexable_file_without_a_wall_word_is_left_to_the_list_caps_gate(self): + root = self.fixture(ini='', source='fn run() {}\n' + UNTERMINATED) + self.assertEqual(gate.check(root), []) + with self.assertRaisesRegex(ValueError, 'unterminated Rust raw string'): caps.read_hits(root / 'rust-modules') + def test_unbalanced_token_group_fails_the_wall_rule_only_when_a_wall_site_needs_classifying(self): + root = self.fixture(name='rust-modules/data/src/lib.rs', ini='', source='mod other; fn f() { ( }') + other = root / 'rust-modules/data/src/other.rs' + other.write_text('fn run() {}') + self.assertEqual(gate.check(root), []) + with self.assertRaisesRegex(ValueError, 'unbalanced Rust token group'): caps.read_hits(root / 'rust-modules') + other.write_text('fn run() { Instant::now(); }') + with self.assertRaisesRegex(ValueError, 'unbalanced Rust token group'): gate.check(root) def test_directories_globs_traversal_and_absolute_paths_are_rejected(self): for name in ('rust-modules/data/src', 'rust-modules/data/src/*.rs', '../outside.rs', '/absolute.rs', 'rust-modules/data/src/../x.rs', 'rust-modules/data/src/./x.rs'): From e16d7f00d3bc6745581cec8c17b3fcaa21e92e75 Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Sat, 14 Nov 2026 08:00:08 +0300 Subject: [PATCH 5/6] Harness: each DepGates self-test runs only the rule it plants for `ci/check-deps.sh` gains `--only RULE[,RULE...]` and `--list-rules`. Each of its 43 rules is now a block guarded by `want `; with no argument every guard passes and the script is the one `make check` and CI run (same lines on stdout, same exit code, on a green and on a red tree). A name that is no rule, an empty list or another argument exits 2 before any rule runs. Three shared preludes (the owner-rule grep, the 17-run test-module classification and the ledger file prefilter) are computed only when a rule that reads them is selected; `is_wholly_test` exits 2 if asked before its prelude ran. RULES and the guards are cross-checked at the end of every run. The ~70 DepGates self-tests each ran the whole script (~25 s of CPU) to prove one planted violation is caught. Each now declares the rules it grades (`@_grades(...)`) and runs only those through one `_deps()`; the runner refuses an exit other than 0 or 1, an unbound-variable message on stderr, and a selected rule that printed no verdict line, and `_assert_flagged` refuses a rule the test did not select. The whole-script tests keep running every rule. New tests pin that the full run reports exactly the rules `--list-rules` names, that every rule alone prints what the full run prints for it, that a misspelt or empty selector is an error, and that a test selecting the wrong rule fails. Co-Authored-By: Claude Opus 5.5 --- ci/check-deps.sh | 183 +++++++++++++++++++++++++- ci/check-ports.py | 3 +- tests/test_harness.py | 298 ++++++++++++++++++++++++++++++++++++------ 3 files changed, 437 insertions(+), 47 deletions(-) diff --git a/ci/check-deps.sh b/ci/check-deps.sh index 1576294f36..c2b9ffb346 100755 --- a/ci/check-deps.sh +++ b/ci/check-deps.sh @@ -155,6 +155,80 @@ fails=0 fail() { echo "::error::check-deps: $*"; fails=$((fails+1)); } ok() { echo " ok — $*"; } +# ---- selecting rules --------------------------------------------------------------------------- +# `ci/check-deps.sh` with no argument runs EVERY rule: that is what `make check`, CI and +# ci/check-python-steps.txt run, and nothing but an argument changes it (an environment variable left +# exported in a shell would quietly shrink the gate; an argument cannot be inherited). The gate +# self-tests of tests/test_harness.py prove each rule still catches a planted violation, and each +# used to run the whole script for that, ~25 s of CPU a run and ~70 runs. So: +# ci/check-deps.sh --only blocking,workers run just those rules, the code the full run runs for +# them: their verdict lines, a summary, exit 0 or 1 +# ci/check-deps.sh --list-rules the rule names (RULES below), one a line, no rule run +# A name that is no rule, an empty list or any other argument exits 2 before any rule runs, so a +# misspelt selector is an error and never "ran nothing, green". A rule's NAME is what its verdict +# line starts with (`ok — ` / `check-deps: : ...`); `allowlist-counts` is the one rule that +# prints nothing when green. +# +# A rule is a block `if want ; then ... fi # ` (or `want && gate ...`) whose body +# is left at the margin, not indented, so the diff and blame of the rules stay what they were. Inside +# a block, use only what the block itself computes, a shared definition (a function, a constant, a +# pattern) outside every block, or one of the three PRELUDES below, which are computed only when a +# rule that reads them is selected (`any_wanted`; a rule that reads one is named in its list). Under +# `set -u` an unset prelude read inside `$( ... )` kills just that subshell and the rule reads +# green, so a rule that reads a prelude it was not named for is loud, not quiet: `is_wholly_test` +# exits 2 and the others print `unbound variable` on stderr (tests/test_harness.py fails on both). +# RULES must name the `want` calls in order; every run ends by checking that, whatever it selected. +RULES=(browse-owner viewstate-owner person-owner search-owner hubs-owner metadata-owner libm ticks wall + fpflags present effect mutators mutators-visibility nav ui-owner-legacy ui-owner-files owned-damage + owned-wake cards layer sessionwrite uistorage legacypage sibling textmeasure dt ladder hittest frame + sink route fnlen testmod threads blocking workers globals forks fxlanes tmppath paging allowlist-counts) +deps_usage() { + echo "check-deps: $*" >&2 + echo "usage: ci/check-deps.sh [--only RULE[,RULE...] | --list-rules]" >&2 + exit 2 +} +known_rule() { + local r + for r in "${RULES[@]}"; do [ "$r" = "$1" ] && return 0; done + return 1 +} +only="" # ",rule,rule," once --only was given, else empty: every rule +have_only=0 +only_arg="" +while [ $# -gt 0 ]; do + case "$1" in + --list-rules) printf '%s\n' "${RULES[@]}"; exit 0 ;; + --only) [ $# -ge 2 ] || deps_usage "--only needs a rule list"; have_only=1; only_arg="$2"; shift 2 ;; + --only=*) have_only=1; only_arg="${1#--only=}"; shift ;; + *) deps_usage "unknown argument '$1'" ;; + esac +done +if [ "$have_only" -eq 1 ]; then + [ -n "$only_arg" ] || deps_usage "--only needs at least one rule" + case "$only_arg" in ,*|*,|*,,*) deps_usage "--only '$only_arg' has an empty rule name" ;; esac + IFS=, read -r -a only_names <<< "$only_arg" + for only_rule in "${only_names[@]}"; do + known_rule "$only_rule" || deps_usage "--only names '$only_rule', which is no rule (--list-rules says which are)" + done + only=",$only_arg," +fi +rules_seen="" +# want : is this rule selected? The guard of every rule, always in the main shell. +want() { + known_rule "$1" || { echo "check-deps: internal: want '$1' names no rule of RULES" >&2; exit 2; } + rules_seen="$rules_seen $1" + case "$only" in "") return 0 ;; *",$1,"*) return 0 ;; esac + return 1 +} +# any_wanted ...: is no selector given, or is one of these rules selected? Gates a prelude. +any_wanted() { + local r + for r in "$@"; do known_rule "$r" || { echo "check-deps: internal: any_wanted '$r' names no rule" >&2; exit 2; }; done + [ -z "$only" ] && return 0 + for r in "$@"; do case "$only" in *",$r,"*) return 0 ;; esac; done + return 1 +} + # grep_code : matching lines, minus comment-only lines, as `path:line:text`. grep_code() { local pat="$1"; shift @@ -172,7 +246,10 @@ grep_code() { # filters that list with its real pattern. The verdict and the output are unchanged, but the # prefix alternation must stay a NECESSARY part of every owner pattern, never a loose sample. OWNER_PREFIX='(crate|plx_data)::(browse|viewstate|person|search|pms|metadata)::|stores::(browse|viewstate|person|search|hubs|metadata)::' +# PRELUDE 1 of 3 (see "selecting rules"): computed only when one of the six owner rules is selected. +if any_wanted browse-owner viewstate-owner person-owner search-owner hubs-owner metadata-owner; then OWNER_LINES="$(grep -HrnE --include='*.rs' "$OWNER_PREFIX" "$SRC" "$SRC_DATA" "$SRC_APPKIT" "$SRC_SCREENS" 2>/dev/null || true)" +fi grep_code_owner() { printf '%s\n' "$OWNER_LINES" | grep -E -- "$1" | grep -vE '^[^:]+:[0-9]+:[[:space:]]*//' || true } @@ -272,12 +349,19 @@ wholly_test_files() { # question once per candidate file or line with `echo "$wholly_test" | grep -qxF`, which is two # processes an answer. WHOLLY_TEST_INDEX="" +WHOLLY_TEST_READY=0 wholly_test_index_init() { WHOLLY_TEST_INDEX=" $1 " + WHOLLY_TEST_READY=1 } is_wholly_test() { + # a rule asking before the prelude ran would read an empty index, i.e. "no file is a test file" + [ "$WHOLLY_TEST_READY" -eq 1 ] || { + echo "check-deps: internal: is_wholly_test before the wholly_test prelude (name the rule in its any_wanted list)" >&2 + exit 2 + } case "$WHOLLY_TEST_INDEX" in *" $1 @@ -299,8 +383,13 @@ gate() { } echo "== check-deps ==" +# PRELUDE 2 of 3: the test-module classification, 17 `rust_test_modules.py` runs (~3.7 s of CPU), +# computed only when a rule that reads `$wholly_test` / `is_wholly_test` (directly, or through +# `ledger_scan`) is selected. A run with no selector computes it first, as it always did. +if any_wanted libm mutators cards sink threads blocking workers globals forks fxlanes paging; then wholly_test="$(wholly_test_files)" || { fail "Rust test-module classification failed"; exit 1; } wholly_test_index_init "$wholly_test" +fi # browse-owner: Browse has one physical owner per `Stores`; the migration allowlist ended at zero # and is deliberately gone. Reject both the old storage/selector machinery and every free @@ -472,6 +561,7 @@ owner_declarations() { ' "$file" || echo "$file:0:browse declaration scanner failed" done } +if want browse-owner; then browse_owner_matches=$({ owner_declarations "$browse_facades" 'ACTIVE|LEGACY_ADAPTER|BOOTSTRAP_AVAILABLE' \ 'BrowseState|BrowseAdapter|BrowseStore' "$SRC_DATA/browse/mod.rs" @@ -489,12 +579,14 @@ else echo "$browse_owner_matches" | sed 's/^/ /' fail "browse-owner: retired Browse compatibility surface returned" fi +fi # browse-owner # viewstate-owner: ViewState's physical state, Arc transport and notice live on ViewStateStore. # Zero tolerance, no allowlist: a free facade or storage/transport static can only select process # state, which would silently reconnect separate Bridges and let a retired worker cross reset. viewstate_facades='apply|run|run_with_browse|run_with_owners|pump|pump_with_owners|is_busy|take_landed_views|take_landed|request|request_with_browse|request_with_owners|reset|hold_inflight_for_test|owe_hubs_refresh_for_test|seed_ownership_fixture_for_test|ownership_fixture_for_test|late_completion_for_test|seed_post_reset_flight_for_test' viewstate_selectors='ACTIVE|OWNER|QUEUE|SENT|RETRY_CD|WANT_HUBS|LANDED|MAIL|VIEWSTATE|VIEW_STATE|LEGACY_ADAPTER' +if want viewstate-owner; then viewstate_owner_matches=$({ owner_declarations "$viewstate_facades" "$viewstate_selectors" \ 'ViewStateState|ViewStateAdapter|ViewStateStore|Req|Completion|Done' \ @@ -507,6 +599,7 @@ else echo "$viewstate_owner_matches" | sed 's/^/ /' fail "viewstate-owner: retired ViewState compatibility surface returned" fi +fi # viewstate-owner # person-owner: Person's model/generation/retry/dev seed live in PersonState, its indexed fetch # claims/mailboxes live in the rotated Arc, and both belong to one PersonStore per @@ -514,6 +607,7 @@ fi # owners and lets an unaddressed reset, pump or optimistic edit cross the Bridge boundary. person_facades='current|loading|run|pump|apply|install_for_test|install_source_for_test|install_credits_for_test' person_selectors='ACTIVE|OWNER|CURRENT|GEN|RETRY_CD|FETCH|MAIL|PERSON|PERSON_STATE|LEGACY_ADAPTER|HELD' +if want person-owner; then person_owner_matches=$({ owner_declarations "$person_facades" "$person_selectors" \ 'PersonState|PersonAdapter|PersonStore|Person|Fetch|Mail|Landing' \ @@ -526,6 +620,7 @@ else echo "$person_owner_matches" | sed 's/^/ /' fail "person-owner: retired Person compatibility surface returned" fi +fi # person-owner # search-owner: Search's query/generation/shelf model lives in SearchState, its per-source fetch # claims/mailboxes live in the rotated Arc, and both belong to one SearchStore per @@ -540,6 +635,7 @@ fi # rotates the adapter — only a bare, parameterless global `reset()` would be the retired shape. search_facades='apply|snapshot|snapshot_with_directory|run_with_directory|pump_with_directory|query|state|query_gen|publish_shelves_for_test|settling|debounce_elapsed_for_test' search_selectors='ACTIVE|OWNER|QUERY|GEN|STATE|SHELVES|SRC|ARMED|FAV_GEN|IN_FLIGHT|MAIL|SLOT|SEARCH|SEARCH_STATE|LEGACY_ADAPTER' +if want search-owner; then search_owner_matches=$({ owner_declarations "$search_facades" "$search_selectors" \ 'SearchState|SearchAdapter|SearchStore|Fetch|Projection|Shelf' \ @@ -552,6 +648,7 @@ else echo "$search_owner_matches" | sed 's/^/ /' fail "search-owner: retired Search compatibility surface returned" fi +fi # search-owner # hubs-owner: Home's hub catalog model (`PmsState`) and its rotated worker mailbox/minter # (`Arc`) belong to one `HubsStore` per Bridge (`app/bridge.rs`'s `hubs_run`/ @@ -566,6 +663,7 @@ fi # `state`/`adapter` in, exactly like search's own `reset(state, adapter)`. hubs_facades='apply|apply_with_directory|controlled|controlled_with_directory' hubs_selectors='RESULTS|NEXT_REQUEST|HUB_GEN|CATALOG_GEN|LAST_SECTIONS_GEN|ACTIVE|OWNER|LEGACY_ADAPTER' +if want hubs-owner; then hubs_owner_matches=$({ owner_declarations "$hubs_facades" "$hubs_selectors" \ 'PmsState|PmsAdapter|HubsStore|Landing|Src|SourceBuild' \ @@ -578,6 +676,7 @@ else echo "$hubs_owner_matches" | sed 's/^/ /' fail "hubs-owner: retired Hubs compatibility surface returned" fi +fi # hubs-owner # metadata-owner: Detail's item/season/playing model (`MetadataState`) and its worker adapter # (`Arc`, D3's `record::Tracker` included) belong to one `MetadataStore` per @@ -591,6 +690,7 @@ fi # hubs' and search's own owned stores. metadata_facades='apply' metadata_selectors='DETAIL_LANDING|SEASON_LANDING|ALT_LANDING|NOW|CURRENT|TRACKER|NOTICES' +if want metadata-owner; then metadata_owner_matches=$({ owner_declarations "$metadata_facades" "$metadata_selectors" \ 'MetadataState|MetadataAdapter|MetadataStore|Tracker' \ @@ -603,11 +703,13 @@ else echo "$metadata_owner_matches" | sed 's/^/ /' fail "metadata-owner: retired Metadata compatibility surface returned" fi +fi # metadata-owner # libm: the method-call spelling, OUTSIDE machine/src/motion.rs (which owns the integrators and their # table test); `.log(&…`/`.log("…` is a logger, not a logarithm. # Wholly-test files (see `wholly_test_files`) are skipped like inline `#[cfg(test)]` blocks: a # test's reference colour maths is not logical state. +if want libm; then libm_lines=$(grep_code '\.(exp|ln|log|powf|powi|cbrt|sin|cos|tan|atan2|hypot|mul_add|sin_cos)\(' "$SRC" "$SRC_BASE" "$SRC_MACHINE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS" \ | grep -vE '\.log\((&|")' | grep -v "^$SRC_MACHINE/motion.rs:") libm_bad=0 @@ -618,19 +720,28 @@ while IFS= read -r line; do if ! allowed libm "$p"; then echo " $line"; libm_bad=$((libm_bad+1)); fi done <<< "$libm_lines" if [ "$libm_bad" -eq 0 ]; then ok "libm"; else fail "libm: $libm_bad line(s) outside ci/allow/libm.txt"; fi +fi # libm -gate ticks 'SDL_GetTicks\(' "$SRC" "$SRC_BASE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS" +want ticks && gate ticks 'SDL_GetTicks\(' "$SRC" "$SRC_BASE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS" # Every data/session module is logic unless its exact reviewed IO/instrument file is in ports.ini. +if want wall; then if python3 ci/check-ports.py; then ok "wall"; else fail "wall: outside exact ci/ports.ini files"; fi +fi # wall +if want fpflags; then if grep -rnE 'fp-contract|fast-math|\+fma' rust-modules/Cargo.toml rust-modules/build.rs rust-modules/net/Cargo.toml rust-modules/plex/Cargo.toml rust-modules/telemetry/Cargo.toml rust-modules/data/Cargo.toml rust-modules/session/Cargo.toml rust-modules/media/Cargo.toml rust-modules/appkit/Cargo.toml rust-modules/screens/Cargo.toml rust-modules/platform/Cargo.toml rust-modules/platform/build.rs rust-modules/gfx/Cargo.toml rust-modules/gfx/build.rs rust-modules/ui/Cargo.toml rust-modules/ui/build.rs rust-modules/appkit/build.rs rust-modules/screens/build.rs rust-modules/storage/Cargo.toml rust-modules/storage/build.rs rust-modules/.cargo Makefile 2>/dev/null | grep -v '^[[:space:]]*#'; then fail "fpflags: a floating-point contraction flag is set (spec §4.2 assumes none)" else ok "fpflags"; fi +fi # fpflags +if want present; then n=$(grep -cE '^static [A-Z_]+: Atomic' "$SRC_MACHINE/present.rs"); d=$(grep -c 'pub fn wake_from_worker' "$SRC_MACHINE/present.rs") if [ "$n" -eq 1 ] && [ "$d" -eq 1 ]; then ok "present: one worker door"; else fail "present: $n atomic statics, $d doors (one of each)"; fi +fi # present +if want effect; then if [ -n "$(grep_code '\bEffect::' "$SRC" "$SRC_BASE" "$SRC_MACHINE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS")" ]; then fail "effect: \`Effect::\` is spelled (use Fx:: / AppFx::)"; else ok "effect"; fi +fi # effect # mutators: production lines of ui/, screens/ and app/ (everything before the file's first # `#[cfg(test)]` + `mod` pair, which is where every screen keeps its tests) — PLUS, since D3, every @@ -663,6 +774,7 @@ MUTATORS='\b(browse|pms|metadata|search|person|viewstate)::(set_cur|note_library # production lines of ui/detail.rs go unscanned. `stores::::apply(` lines are the new # spelling and are excluded by name; a SCREEN's own `crate::ui::person::open(` is not a store # call and is masked before the match. +if want mutators; then mut_bad=0 while IFS= read -r f; do if is_wholly_test "$f"; then continue; fi @@ -678,6 +790,7 @@ while IFS= read -r f; do # that can produce a hit. done < <(grep -rlE --include='*.rs' "$MUTATORS" "$SRC_UI" "$SRC_MACHINE" "$SRC_APPKIT" "$SRC_SCREENS" "$SRC/app" "$SRC_MEDIA/route" "$SRC_MEDIA/player" "$SRC/dev" 2>/dev/null | sort) if [ "$mut_bad" -eq 0 ]; then ok "mutators"; else fail "mutators: $mut_bad line(s) call a store mutator directly (use the owner's run/step method, e.g. Bridge::_run)"; fi +fi # mutators # mutators-visibility (D3): the call-site rule above can only ever prove "nobody currently calls # this directly" — it says nothing about whether they COULD. This reads the DECLARATION line of @@ -718,6 +831,7 @@ MUT_FNS_TABLE=( store_seamed() { grep -qE "^${1}::${2}( |$)" ci/allow/store-seams.txt 2>/dev/null } +if want mutators-visibility; then vis_bad=0 for entry in "${MUT_FNS_TABLE[@]}"; do relf="${entry%%|*}" @@ -732,15 +846,19 @@ for entry in "${MUT_FNS_TABLE[@]}"; do done done if [ "$vis_bad" -eq 0 ]; then ok "mutators-visibility"; else fail "mutators-visibility: $vis_bad fn(s) still crate-visible"; fi +fi # mutators-visibility -gate nav '(crate::ui|plx_ui)::nav::' "$SRC" "$SRC_UI" "$SRC_APPKIT" "$SRC_SCREENS" +want nav && gate nav '(crate::ui|plx_ui)::nav::' "$SRC" "$SRC_UI" "$SRC_APPKIT" "$SRC_SCREENS" # Completed ownership migration: legacy publications and the old gate cannot return. +if want ui-owner-legacy; then ui_owner_hits=$(grep_code '(plx_ui|crate::ui)::press::|(plx_machine|crate)::idle::' "$SRC" "$SRC_BASE" "$SRC_MACHINE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS") if [ -z "$ui_owner_hits" ]; then ok "ui-owner-legacy"; else printf '%s\n' "$ui_owner_hits" fail "ui-owner-legacy: retired global readers must not return" fi +fi # ui-owner-legacy +if want ui-owner-files; then legacy_owners=0 for legacy in "$SRC_UI/nav.rs" "$SRC_UI/press.rs" "$SRC_MACHINE/idle.rs"; do if [ -e "$legacy" ]; then @@ -749,21 +867,26 @@ for legacy in "$SRC_UI/nav.rs" "$SRC_UI/press.rs" "$SRC_MACHINE/idle.rs"; do fi done if [ "$legacy_owners" -eq 0 ]; then ok "ui-owner-files"; fi +fi # ui-owner-files # Motion collectors may not own generic damage or a second process-global notification adapter. +if want owned-damage; then owned_damage_hits=$(grep_code 'motion::report::(invalidate|take_damage|select_damage|take_page_damage|OwnScope)' "$SRC" "$SRC_UI" "$SRC_APPKIT" "$SRC_SCREENS" "$SRC_DATA" "$SRC_PLEX" "$SRC_MEDIA" "$SRC_PLATFORM") report_adapter=$(grep_code '\bAtomic[A-Za-z0-9_]*\b|pub fn (invalidate|take_damage|select_damage|take_page_damage|present_dirty|wake)\b' "$SRC_MACHINE/motion/report.rs") if [ -z "$owned_damage_hits$report_adapter" ]; then ok "owned-damage"; else printf '%s\n%s\n' "$owned_damage_hits" "$report_adapter" fail "owned-damage: presentation changes must reach the owned gate, never a global damage adapter" fi +fi # owned-damage # Main-thread render/deferred work must address its owner; only actual IO workers use the atomic door. +if want owned-wake; then main_wake_hits=$(grep_code 'motion::report::wake|wake_from_worker[[:space:]]*\(' "$SRC_UI" "$SRC/dev" "$SRC/app/run.rs") if [ -z "$main_wake_hits" ]; then ok "owned-wake"; else printf '%s\n' "$main_wake_hits" fail "owned-wake: main-thread work must request PresentEvent::Wake from its owner" fi +fi # owned-wake # cards: a screen's card shelves and grids come from `plx_ui::cards::{Shelf, Grid}` (the # shared-card-sections plan, layer L1), which own the pop, press, stops, restore and paging a @@ -781,6 +904,7 @@ fi # allowlist (empty) is the screens that still assemble their own, one line per file, and only # SHRINKS. cards_pat='cards::(paint_visible|draw_tile|draw_focused)\b|use [^;]*cards::\{[^}]*\b(paint_visible|draw_tile|draw_focused)\b|\bCardRow\b|\bGridPop\b|\bGridBands\b|press::scale\(\)' +if want cards; then cards_bad=0 while IFS= read -r line; do [ -z "$line" ] && continue @@ -795,6 +919,7 @@ while IFS= read -r line; do echo " $line"; cards_bad=$((cards_bad+1)) done < <(grep_code '\bAvatarRow\b' "$SRC_SCREENS") if [ "$cards_bad" -eq 0 ]; then ok "cards"; else fail "cards: $cards_bad line(s) outside ci/allow/cards.txt (or AvatarRow outside profiles.rs) — draw card sections with plx_ui::cards::Shelf / Grid"; fi +fi # cards # layer: a SCREEN never names the application. §2.1's table says `screens/` may name `ui/`, # `stores/`, `plex/` and `player/` and never `app/`, and until phase 10 that half of the rule was @@ -805,24 +930,28 @@ if [ "$cards_bad" -eq 0 ]; then ok "cards"; else fail "cards: $cards_bad line(s) # and nothing else) is only worth as much as the boundary underneath it. Count is zero, with no # allowlist: a screen that needs something of the loop's asks for it as an effect (`AppFx`, # `LoopReq`) — that is what the bundle in `registry.rs` is. +if want layer; then if [ -n "$(grep_code '(crate|super)::app::' "$SRC_SCREENS")" ]; then grep_code '(crate|super)::app::' "$SRC_SCREENS" | sed 's/^/ /' fail "layer: a screen names the application (§2.1) — ask for it as an AppFx/LoopReq instead" else ok "layer"; fi -gate sessionwrite 'session::load\(' "$SRC_SCREENS" "$SRC_UI" "$SRC_MACHINE" "$SRC_APPKIT" +fi # layer +want sessionwrite && gate sessionwrite 'session::load\(' "$SRC_SCREENS" "$SRC_UI" "$SRC_MACHINE" "$SRC_APPKIT" # uistorage: the LIBRARY (`ui/`) never names the storage layer (§2.1: `ui/` may name only # `crate::{gfx,text,paths,task}`). A ui-owned sweep that needs the app's removal rule takes it as an # injected `fn` (`ui::rec::erase_owned_artifacts`). Zero, no allowlist. The wider table is not a # grep yet: ui/ still names other application modules, mostly from tests and dev instruments. -gate uistorage '(crate|super|plx_platform)::storage::' "$SRC_UI" "$SRC_MACHINE" +want uistorage && gate uistorage '(crate|super|plx_platform)::storage::' "$SRC_UI" "$SRC_MACHINE" # legacypage: the word itself, anywhere under src — a doc that still describes the type is as much # a hit as a declaration, which is the point (nothing compiles the prose either). +if want legacypage; then legacy_hits=$(grep -rn --include='*.rs' 'LegacyPage' "$SRC" "$SRC_BASE" "$SRC_MACHINE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS" 2>/dev/null || true) if [ -z "$legacy_hits" ]; then ok "legacypage"; else echo "$legacy_hits" | sed 's/^/ /' fail "legacypage: $(echo "$legacy_hits" | wc -l | tr -d ' ') mention(s) — the type is retired (§15.2)" fi +fi # legacypage # sibling: one screen family per directory; `` is the first path component under screens/. # @@ -832,6 +961,7 @@ fi # gate that forbade it would forbid the structure the spec asks for. It was an allowlist entry # until phase 10 moved the mounter into it; an entry would have had to say "this file names all of # them, permanently", which is a rule and not a migration. +if want sibling; then sib_bad=0 while IFS= read -r f; do [ "$f" = "$SRC_SCREENS/registry.rs" ] && continue @@ -849,6 +979,7 @@ while IFS= read -r f; do done < <(grep -rlE --include='*.rs' 'crate::[a-z_]+' "$SRC_SCREENS" 2>/dev/null | sort) if [ "$sib_bad" -eq 0 ]; then ok "sibling" else fail "sibling: $sib_bad file(s) name a sibling screen (use crate::registry)"; fi +fi # sibling # ============================================================================================ # Phase 12 rules (spec §15.2, D4): the gates the earlier phases' own comments above never wrote, @@ -878,6 +1009,7 @@ else fail "sibling: $sib_bad file(s) name a sibling screen (use crate::registry) # `impl Measure for` added later still only exempts ITS OWN body, and any other raw call anywhere # in the tree fails. tm_seams="$SRC_UI/text_view.rs $SRC_UI/text_buffer.rs $SRC_GFX/text.rs" +if want textmeasure; then tm_bad=0 while IFS= read -r f; do is_seam=0 @@ -895,6 +1027,7 @@ while IFS= read -r f; do # an `impl … Measure for …` block, so a file with no raw call has nothing for it to find. done < <(grep -rlE --include='*.rs' '(crate|plx_gfx)::text::(text_width|elide|cap_h)\(' "$SRC" "$SRC_GFX" "$SRC_UI" "$SRC_APPKIT" "$SRC_SCREENS" 2>/dev/null | sort) if [ "$tm_bad" -eq 0 ]; then ok "textmeasure"; else fail "textmeasure: $tm_bad line(s) outside the Measure seam"; fi +fi # textmeasure # dt (phase 12, D4 — ZERO now, was an allowlist): idle::dt() (deleted from machine/src/idle.rs entirely — # card_row.rs's focused-title marquee, its last caller, now reads the absolute idle::now_ms() @@ -906,11 +1039,13 @@ if [ "$tm_bad" -eq 0 ]; then ok "textmeasure"; else fail "textmeasure: $tm_bad l # class this whole gate exists to catch. motion.rs currently has no hit either; the exclusion is # the documented intent (spec §4.2: the ONLY file licensed to touch a raw per-frame delta), not a # live carve-out. +if want dt; then dt_hits=$(grep_code 'idle::dt\(\)|(\+=|-=)\s*dt\b' "$SRC" "$SRC_MACHINE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS" | grep -v "^$SRC_MACHINE/motion.rs:") if [ -z "$dt_hits" ]; then ok "dt"; else echo "$dt_hits" | sed 's/^/ /' fail "dt: $(echo "$dt_hits" | wc -l | tr -d ' ') line(s) — see rule comment above" fi +fi # dt # ladder: the old per-screen focus/hit ladder shape, zero across ui/ + screens/ once every Screen # answers FocusSource::Engine/HitSource::Engine (D2). No allowlist: every remaining hit is a @@ -923,13 +1058,13 @@ gate_zero() { fail "$rule: $(echo "$hits" | wc -l | tr -d ' ') line(s) — see rule comment above" fi } -gate_zero ladder 'fn move_focus|fn pointer_focus|fn top_focus|fn zones\b|fn key\(sym|fn focus_is_card|fn focus_is_ctl' "$SRC_UI" "$SRC_MACHINE" "$SRC_APPKIT" "$SRC_SCREENS" +want ladder && gate_zero ladder 'fn move_focus|fn pointer_focus|fn top_focus|fn zones\b|fn key\(sym|fn focus_is_card|fn focus_is_ctl' "$SRC_UI" "$SRC_MACHINE" "$SRC_APPKIT" "$SRC_SCREENS" # hittest: the narrowed raw hit-tester call shape, zero in app/ once the player's HUD registers # its stops through DrawFrame::stop (D2) instead of app/run.rs testing raw coordinates against # player_hud's geometry by hand. Deliberately NOT a blanket `_at(` — that false-positives on # resume_at/memory_at/open_settings_at/write_at, which are unrelated lookups. -gate_zero hittest 'pointer_focus\(|\b(failure_quality|icon|scrub)_hit\(' "$SRC/app" +want hittest && gate_zero hittest 'pointer_focus\(|\b(failure_quality|icon|scrub)_hit\(' "$SRC/app" # frame: the three privileged OS-primitive calls, ZERO-TOLERANCE outside `app/run.rs` (D4) — no # allowlist file, because there is exactly one legitimate home once D1 lands: `app/run.rs` is the @@ -946,6 +1081,7 @@ gate_zero hittest 'pointer_focus\(|\b(failure_quality|icon|scrub)_hit\(' "$SRC/a # actual call typed outside a string still fails this gate. `// `-prefixed comment lines (`app/run.rs` keeps one, describing where a call # used to live) are stripped the same way `grep_code` above does for every other rule. frame_pat='(crate|plx_platform)::tv::window::(pump_bus|opaque_route|clear_opaque_region)\(' +if want frame; then frame_bad=0 while IFS= read -r f; do [ "$f" = "$SRC/app/run.rs" ] && continue @@ -964,6 +1100,7 @@ while IFS= read -r f; do done < <(grep -rlE --include='*.rs' "$frame_pat" "$SRC" "$SRC_BASE" "$SRC_MACHINE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS" 2>/dev/null | sort) if [ "$frame_bad" -eq 0 ]; then ok "frame" else fail "frame: $frame_bad line(s) of a privileged OS-primitive call outside app/run.rs"; fi +fi # frame # sink: the Starfish/ACB verbs (`tv::sink::VideoSink`) are the player's alone (step L15). Only # `player/`, `play-uri/`, the native `webos/` port, and `port.rs` (which installs one) @@ -972,6 +1109,7 @@ else fail "frame: $frame_bad line(s) of a privileged OS-primitive call outside a # ACB plane's boot and hands it on (it was `player/plane_boot.rs`; the composition root is where the # driver set is built). Every other module reaches the television through the narrower `tv` interfaces. Wholly-test files are skipped like inline # `#[cfg(test)]` blocks. Zero, no allowlist. +if want sink; then sink_bad=0 while IFS= read -r line; do [ -z "$line" ] && continue @@ -987,9 +1125,11 @@ while IFS= read -r line; do done < <(grep_code 'tv::sink::(installed|display_installed)|\b(VideoSink|DisplaySink)\b' "$SRC" "$SRC_PLATFORM" "$SRC_UI" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS") if [ "$sink_bad" -eq 0 ]; then ok "sink" else fail "sink: $sink_bad line(s) naming the video sink outside playback execution, port.rs, tv.rs and tv/"; fi +fi # sink # route: `Route::` in app/ = 0, and `enum Route` gone from the whole tree (D1/D4). No allowlist: # the type is meant to be retired, not narrowed. +if want route; then route_app=$(grep_code 'Route::' "$SRC/app") if [ -z "$route_app" ]; then ok "route: Route:: in app/" else fail "route: $(echo "$route_app" | wc -l | tr -d ' ') \`Route::\` use(s) in app/ — the page alphabet is \`AppArg\` (D1)"; fi @@ -999,6 +1139,7 @@ else echo "$route_enum" | sed 's/^/ /' fail "route: enum Route re-declared — the page alphabet is \`AppArg\` (D1)" fi +fi # route # fnlen: app/run.rs::run <= 200 lines, run_application (app/mod.rs, the D4 skeleton) <= 10 and # plex_run (port.rs: install, then hand over) <= 10 — counted by brace @@ -1014,6 +1155,7 @@ fn_body_lines() { } ' "$file" } +if want fnlen; then run_len=$(fn_body_lines "$SRC/app/run.rs" 'run') if [ -n "$run_len" ] && [ "$run_len" -le 200 ]; then ok "fnlen: app/run.rs::run ($run_len lines)" else fail "fnlen: app/run.rs::run is ${run_len:-unknown} lines, budget 200 — a phase of the frame belongs in its own function (see run.rs's own doc)"; fi @@ -1023,14 +1165,17 @@ else fail "fnlen: run_application (app/mod.rs) is ${runapp_len:-unknown} lines, plexrun_len=$(fn_body_lines "$SRC/port.rs" 'plex_run') if [ -n "$plexrun_len" ] && [ "$plexrun_len" -le 10 ]; then ok "fnlen: plex_run (port.rs) ($plexrun_len lines)" else fail "fnlen: plex_run (port.rs) is ${plexrun_len:-unknown} lines, budget 10"; fi +fi # fnlen # testmod: `#[cfg(test)] mod` count in app/mod.rs = 0 (D4/D8) — every test module named in D8's # table is meant to have moved to its subject's own file by the time this gate is added. +if want testmod; then testmod_n=$(grep -c '^#\[cfg(test)\]$' "$SRC/app/mod.rs" 2>/dev/null || echo 0) # only count ones immediately followed by `mod `, matching the mutators gate's own convention testmod_n=$(awk '/^#\[cfg\(test\)\]$/{p=1;next} p && /^mod /{c++} {p=0} END{print c+0}' "$SRC/app/mod.rs") if [ "$testmod_n" -eq 0 ]; then ok "testmod: app/mod.rs" else fail "testmod: $testmod_n \`#[cfg(test)] mod\` block(s) in app/mod.rs — a test lives beside its subject (D8)"; fi +fi # testmod # threads: `thread::spawn(` outside task.rs, PRODUCTION lines only, EVERY spelling — a # `#[cfg(test)] mod` block is skipped by brace depth, the same convention the `mutators` gate @@ -1049,6 +1194,7 @@ else fail "testmod: $testmod_n \`#[cfg(test)] mod\` block(s) in app/mod.rs — a # `use std::thread::{..spawn..}` lines outside task.rs itself), so this spelling adds nothing # to the count yet — it exists so a FUTURE import cannot go unmatched the way the bare # `thread::spawn(` spelling used to. +if want threads; then threads_bad=0 while IFS= read -r f; do # a wholly-test file is test code exactly like an inline `#[cfg(test)] mod` block, which the @@ -1071,6 +1217,7 @@ done < <(grep -rlE --include='*.rs' '\bspawn\(' "$SRC" "$SRC_BASE" "$SRC_MACHINE threads_declared=$(sed -n 's/^# count: *//p' ci/allow/threads.txt | head -1) if [ "$threads_bad" -eq "${threads_declared:-0}" ]; then ok "threads" else fail "threads: $threads_bad line(s) outside ci/allow/threads.txt (declared count is exactly ${threads_declared:-0}, not a ceiling)"; fi +fi # threads # ---- the ledger rules: blocking, workers, globals, forks, fxlanes ------------------------------- # A LEDGER is an exact multiset of production SITES, one line per site, held under ci/allow and only @@ -1209,6 +1356,7 @@ EOF_STALE # The enclosing fn is the innermost `fn ` whose body holds the call, tracked by # brace depth; a call in a closure belongs to the fn around the closure. The scan is the shared # `ci/ledger.awk` (the ledger machinery above). +if want blocking; then blocking_sites=$( grep -rlE --include='*.rs' 'allow_blocking' "$SRC" "$SRC_BASE" "$SRC_MACHINE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS" 2>/dev/null \ | grep -v "^$SRC_BASE/task/blocking.rs\$" | sort \ @@ -1224,6 +1372,7 @@ LG_LEDGERS=ci/allow/blocking.txt LG_COUNT_FILE=ci/allow/blocking.txt \ LG_NOUN='the frame-thread exception ledger' \ LG_TAIL='a new allow_blocking site moves its work to a worker instead; the list only shrinks' \ ledger_check blocking "$blocking_sites" +fi # blocking # ---- the Sans-IO ledgers (docs/sans-io.md): workers, globals, forks, fxlanes ------------------------ # The rule they prepare: logic never performs IO. A MACHINE (a screen, a data/ store, the session @@ -1268,6 +1417,8 @@ globals_pat='client_for|current_server|current_snapshot|keypin::(revision|blocke # candidate: an item under it is skipped whole. forks_pat='cfg.*test|test.*cfg|#!?\[cfg\([^]]*$|cfg!\([^)]*$' forks_plain_re='^[[:space:]]*#\[cfg\((test|any\(test, feature = "test-support"\)|all\((test|any\(test, feature = "test-support"\)), [^()]*\))\)\][[:space:]]*$' +# PRELUDE 3 of 3: computed only when workers, globals or forks is selected. +if any_wanted workers globals forks; then ledger_hits=$( find "$SRC_DATA" "$SRC_SESSION" "$SRC_PLEX" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_SCREENS" "$SRC_UI" "$SRC_APPKIT" "$SRC_MACHINE" "$SRC_PLATFORM/tv/plane.rs" \ -name '*.rs' -type f 2>/dev/null \ @@ -1283,6 +1434,7 @@ ledger_hits=$( !df && $0 ~ f && $0 !~ p { print "F\t" FILENAME; df = 1 } ' ) +fi # ledger_candidates : the files of that rule's scope the prefilter kept ledger_candidates() { printf '%s\n' "$ledger_hits" | awk -F'\t' -v r="$1" '$1 == r { print $2 }' | sort -u @@ -1299,6 +1451,7 @@ ledger_candidates() { # although no machine calls it today, because a machine that did would be starting a worker. A worker # named without a call (`.map(spawn_small)`) is a site too; only a rename (`use ... as`) is refused, # because the renamed calls are invisible. +if want workers; then workers_sites=$( ledger_candidates W \ | LG_MODE=call LG_KEYSPELL=1 LG_USE_OK=1 LG_REF_USE_ONLY=1 \ @@ -1315,6 +1468,7 @@ LG_LEDGERS="$(echo ci/allow/workers/*.txt)" LG_AREA_CHECK=1 \ LG_NOUN='the worker-start ledger' \ LG_TAIL='a machine starts no worker: its work leaves as a typed effect the app runs (docs/sans-io.md); the ledgers only shrink' \ ledger_check workers "$workers_sites" +fi # workers # globals: a production read of a process-global registry in a MACHINE — `client_for(`, `current_server(`, # `current_snapshot(`, `keypin::revision(`, `keypin::blocked_for(`, `session::peek(`, `grant::offers(`, the @@ -1358,6 +1512,7 @@ LG_LEDGERS="$(echo ci/allow/workers/*.txt)" LG_AREA_CHECK=1 \ # a call (`.and_then(client_for)`) reads the registry as surely as a call does, so it is a site too; only a # rename (`use ... as`) is refused, because the renamed calls are invisible. Each getter's own definition is # not a site. +if want globals; then globals_sites=$( { ledger_candidates G printf '%s\n' rust-modules/plex/src/plex/session.rs "$SRC_MEDIA/player/lifecycle.rs"; } \ @@ -1376,6 +1531,7 @@ LG_LEDGERS="$(echo ci/allow/globals/*.txt)" LG_AREA_CHECK=1 \ LG_NOUN='the process-global read ledger' \ LG_TAIL='a machine reads no registry: the value arrives in an event or an argument (docs/sans-io.md); the ledgers only shrink' \ ledger_check globals "$globals_sites" +fi # globals # forks: a production test/production fork across every machine crate (FORK_SCOPE: all of data/, plex/, media/, # session/, screens/, ui/, appkit/ and machine/) — a `#[cfg(..)]` @@ -1390,6 +1546,7 @@ LG_LEDGERS="$(echo ci/allow/globals/*.txt)" LG_AREA_CHECK=1 \ # it) — never a line number. A file can # hold a fork only if it has a cfg line that is not a plain test-only attribute (an item under one is # skipped whole), which is what the candidates are. +if want forks; then forks_sites=$( ledger_candidates F \ | LG_MODE=fork ledger_scan | sort @@ -1401,6 +1558,7 @@ LG_LEDGERS="$(echo ci/allow/forks/*.txt)" LG_AREA_CHECK=1 \ LG_NOUN='the test/production fork ledger' \ LG_TAIL='logic has no cfg(test) fork: the seam is a typed effect tests and replay deliver events through (docs/sans-io.md); the ledgers only shrink' \ ledger_check forks "$forks_sites" +fi # forks # fxlanes: in `Bridge::app_effect` every `AppFx::` arm either pushes `Fx::Deliver(` — the ordered # FIFO, where a result returns as one addressed event in the same drain — or is a ledger line: an arm that @@ -1408,6 +1566,7 @@ LG_LEDGERS="$(echo ci/allow/forks/*.txt)" LG_AREA_CHECK=1 \ # own timing. A NEW variant with a side queue fails; so does a new arm that is not on the FIFO. Keyed # `::AppFx::`, one line for EACH variant on an arm's head (`AppFx::A(r) | AppFx::B(r) => ..` # is two), and `::AppFx::_` for an arm whose head names none (`other => ..`, `_ => ..`). +if want fxlanes; then fxlanes_sites=$( grep -rlE --include='*.rs' 'fn app_effect' "$SRC" 2>/dev/null | sort \ | LG_MODE=arm LG_ARM_FN=app_effect LG_ARM_MATCH='(^|[^A-Za-z0-9_])match[[:space:]]+fx[[:space:]]*\{' LG_ARM_OK='Fx::Deliver\(' \ @@ -1420,6 +1579,7 @@ LG_LEDGERS="$(echo ci/allow/fxlanes/*.txt)" LG_AREA_CHECK=1 \ LG_NOUN='the Bridge::app_effect lane ledger' \ LG_TAIL='an AppFx arm pushes Fx::Deliver(..) onto the one ordered FIFO instead of a side queue (docs/sans-io.md); the ledgers only shrink' \ ledger_check fxlanes "$fxlanes_sites" +fi # fxlanes # tmppath: a literal `/tmp/plxnative-` string outside dev.rs and the log sinks, = 0 (D4). The # earlier version matched only a literal and a filesystem-open VERB co-occurring on the SAME @@ -1445,6 +1605,7 @@ LG_LEDGERS="$(echo ci/allow/fxlanes/*.txt)" LG_AREA_CHECK=1 \ # path through `paths::in_runtime_dir("plxnative-…")`, a bare filename with no `/tmp/` prefix, so # neither one is a `/tmp/plxnative-` literal in the first place and there is no second file to # name here (re-verify this if a log sink is ever given a hardcoded `/tmp/` path). +if want tmppath; then tmp_hits=$(python3 - "$SRC" "$SRC_BASE" "$SRC_MACHINE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS" <<'PY' import os, sys @@ -1536,6 +1697,7 @@ else echo "$tmp_hits" | sed 's/^/ /' fail "tmppath: $(echo "$tmp_hits" | grep -c . ) line(s) of a literal /tmp/plxnative- path outside dev.rs, not comment or log-message text" fi +fi # tmppath # paging: the two Plex paging parameter names are spelled in ONE non-test file, the `paged_path` @@ -1544,6 +1706,7 @@ fi # not counted (they cannot build a request), and test code is: whole test files (the `wholly_test` # classification above) and `#[cfg(test)]` items, found from tokens so a literal inside a string is # never mistaken for a comment. Zero, no allowlist. Scans every crate root, not only plex's. +if want paging; then paging_hits=$(WHOLLY_TEST="$wholly_test" python3 - "$SRC" "$SRC_BASE" "$SRC_MACHINE" "$SRC_PLATFORM" "$SRC_GFX" "$SRC_NET" "$SRC_UI" "$SRC_PLEX" "$SRC_TELEMETRY" "$SRC_DATA" "$SRC_SESSION" "$SRC_MEDIA" "$SRC_PLAYBACK_CONTRACT" "$SRC_PLAY_URI" "$SRC_PLAY_FEED" "$SRC_MEDIA_CODECS" "$SRC_APPKIT" "$SRC_SCREENS" <<'PY' import os, sys sys.path.insert(0, "ci") @@ -1609,15 +1772,23 @@ else echo "$paging_hits" | sed 's/^/ /' fail "paging: $(echo "$paging_hits" | grep -c . ) production literal(s) spell X-Plex-Container- outside rust-modules/plex/src/plex/paging.rs (use paged_path)" fi +fi # paging # every allowlist's declared count equals its entries — the flat lists, and the per-area ledger files # under ci/allow// (workers, globals, forks, fxlanes) +if want allowlist-counts; then for f in ci/allow/*.txt ci/allow/*/*.txt; do [ -f "$f" ] || continue declared=$(sed -n 's/^# count: *//p' "$f" | head -1) entries=$(grep -cvE '^[[:space:]]*(#|$)' "$f") [ "$declared" = "$entries" ] || fail "$f declares count $declared but has $entries entries" done +fi # allowlist-counts +# RULES and the `want` calls above must name the same rules in the same order, whatever was selected +# (every guard is visited whether or not its rule runs): a rule outside RULES cannot be selected by +# name, and a name without a guard would be "selected" and run nothing. +[ "$rules_seen" = " ${RULES[*]}" ] || fail "RULES and the want guards disagree: RULES is [${RULES[*]}], the guards are [${rules_seen# }]" +if [ -n "$only" ] && [ "$fails" -eq 0 ]; then echo "check-deps: the selected gates are green (--only $only_arg)"; exit 0; fi [ "$fails" -eq 0 ] && { echo "check-deps: all gates green"; exit 0; } echo "check-deps: $fails gate(s) failed"; exit 1 diff --git a/ci/check-ports.py b/ci/check-ports.py index 9569a27baf..dd1c4c002d 100644 --- a/ci/check-ports.py +++ b/ci/check-ports.py @@ -55,7 +55,8 @@ def ports(root, ini): # `.elapsed(`, and the alias test needs the token `Instant` or `SystemTime`. A file without any of # them cannot hold a wall-clock operation, so this rule does not lex or classify it: lexing the # ~690 files of the scopes (and the wholly-test classification of every scope) was most of this -# gate's 4.6 s of CPU, run once per `ci/check-deps.sh` and so ~100 times by tests/test_harness.py. +# gate's 4.6 s of CPU, run once per `ci/check-deps.sh` that selects `wall` (every full run; the +# harness's gate self-tests run only the rule they plant for, so only its whole-script tests run it). # The skip changes what an UNLEXABLE file does here, never what a wall site does: a file with no # wall word and an unterminated raw string no longer fails THIS rule. `ci/check-list-caps.py` (a step # of ci/check-python-steps.txt) reports it instead: it runs `rtm.lex` over every production file under diff --git a/tests/test_harness.py b/tests/test_harness.py index bec1db99a2..c13f4f99c2 100644 --- a/tests/test_harness.py +++ b/tests/test_harness.py @@ -8593,6 +8593,61 @@ def test_opt_out_and_a_cumulative_counter(self): # ends it: a `DepGates` test still running on the pool then starts no further gate run. _run_stopped = threading.Event() +# A rule of `ci/check-deps.sh` that prints nothing when it passes (`ci/check-deps.sh --list-rules` +# names every rule; `test_every_rule_is_selectable_and_nothing_else_reports` pins this set). +_DEPS_RULES_SILENT_WHEN_GREEN = frozenset({"allowlist-counts"}) + + +def _grades(*rules): + """The rules of `ci/check-deps.sh` a `DepGates` test runs: its self-test plants ONE violation, so + it runs the script with `--only ` (a few seconds) rather than every rule (~25 s of + CPU a run, which was ~70 runs and nine tenths of this module). Name the rule or rules whose + verdict the test asserts. `_run_check_deps` then refuses a run in which one of them printed no + verdict, and `_assert_flagged` refuses a rule the test did not select, so a test that selects + the wrong rule fails instead of passing against a rule that never ran.""" + assert rules and len(set(rules)) == len(rules), rules + + def mark(test): + test.deps_rules = rules + return test + return mark + + +def _grades_whole_script(test): + """For a `DepGates` test that grades `ci/check-deps.sh` as a whole (it reads the exit code or + the summary of every rule), not one planted violation: it runs every rule.""" + test.deps_rules = None + return test + + +def _check_deps_verdict(r, rules): + """`r`, a finished `ci/check-deps.sh` run that selected `rules` (None: all), if it is a verdict. + + It must exit 0 or 1 (2 is a usage or internal error), may not trip `set -u` (an unset prelude + read inside `$( ... )` kills only that subshell and its rule reads green), and must print a + verdict line for EVERY selected rule, so a selection that ran nothing, or not the rule the test + is about, is a failure here and not a quiet pass. The result carries `deps_rules`.""" + out = r.stdout + r.stderr + if r.returncode not in (0, 1): + raise AssertionError(f"ci/check-deps.sh exited {r.returncode}, which is no verdict\n{out}") + if "unbound variable" in r.stderr: + raise AssertionError(f"ci/check-deps.sh read an unset variable (a rule reading a prelude it was not named for?)\n{out}") + for rule in rules or (): + if rule in _DEPS_RULES_SILENT_WHEN_GREEN: + continue + if not re.search(rf"^( ok — |::error::check-deps: ){re.escape(rule)}(?=[ :(]|$)", r.stdout, re.M): + raise AssertionError(f"--only {rule} printed no verdict line for {rule}\n{out}") + r.deps_rules = rules + return r + + +def _run_check_deps(root, rules): + """Run `root`'s `ci/check-deps.sh`: every rule when `rules` is None, else `--only `.""" + cmd = [os.path.join(root, "ci", "check-deps.sh")] + if rules is not None: + cmd += ["--only", ",".join(rules)] + return _check_deps_verdict(subprocess.run(cmd, capture_output=True, text=True), rules) + class DepGates(unittest.TestCase): """Restructure spec §15.2: `ci/check-deps.sh` is green, and every allowlist under ci/allow/ @@ -8657,7 +8712,7 @@ class DepGates(unittest.TestCase): @property def tree(self): """The private copy of the gate's inputs. Every gate run builds its command from this, so a - stopped run (`_run_stopped`) raises here instead of starting one more ~11 s `check-deps.sh`: + stopped run (`_run_stopped`) raises here instead of starting one more `check-deps.sh` run: the one `make check`'s stop signal never reached would outlive its 10 s grace and be SIGKILLed with the copy still on disk.""" if _run_stopped.is_set(): @@ -8697,17 +8752,128 @@ def run(self, result=None): def _real_tree(cls): """One run of the gate over the CHECKOUT, shared by the two tests that read it. Nothing in this class edits the checkout (`test_self_tests_never_touch_the_real_tree`), so the second - reader would only repeat the first's ~25 s of CPU.""" + reader would only repeat the first's ~25 s of CPU (every rule runs).""" with cls._real_tree_lock: if cls._real_tree_run is None: - cls._real_tree_run = subprocess.run([os.path.join(cls.ROOT, "ci", "check-deps.sh")], - capture_output=True, text=True) + cls._real_tree_run = _run_check_deps(cls.ROOT, None) return cls._real_tree_run + def _deps(self): + """THE way a test runs `ci/check-deps.sh` over its private copy (every helper below ends here): + the rules its `_grades(...)` names, or all of them for `_grades_whole_script`. A test that + declares neither fails here, so none runs the whole script by default or a subset by accident.""" + test = getattr(type(self), self._testMethodName) + if not hasattr(test, "deps_rules"): + raise AssertionError(f"{self._testMethodName} runs ci/check-deps.sh without saying which rules it " + "grades: decorate it with @_grades(...) or @_grades_whole_script") + return _run_check_deps(self.tree, test.deps_rules) + def test_check_deps_is_green(self): r = self._real_tree() self.assertEqual(r.returncode, 0, r.stdout + r.stderr) + def _rule_names(self, root): + r = subprocess.run([os.path.join(root, "ci", "check-deps.sh"), "--list-rules"], capture_output=True, text=True) + self.assertEqual((r.returncode, r.stderr), (0, ""), r.stdout) + return r.stdout.split() + + def test_every_rule_is_selectable_and_nothing_else_reports(self): + """The full run reports exactly the rules `--list-rules` names (in that order), so no rule can + sit outside the selector: a rule that prints a verdict but has no `want` guard (it would run + in every `--only` run and could never be selected) or a name with no rule behind it fails + here. The one rule that prints nothing when green is `_DEPS_RULES_SILENT_WHEN_GREEN`.""" + known = self._rule_names(self.ROOT) + self.assertEqual(len(known), len(set(known)), known) + self.assertTrue(_DEPS_RULES_SILENT_WHEN_GREEN <= set(known), known) + reported = [] + for name in re.findall(r"^ ok — ([a-z][a-z-]*)(?=[ :(]|$)", self._real_tree().stdout, re.M): + if name not in reported: + reported.append(name) + self.assertEqual(reported, [n for n in known if n not in _DEPS_RULES_SILENT_WHEN_GREEN]) + + def test_every_rule_prints_the_same_alone_as_in_the_full_run(self): + """Each rule run ALONE (`--only `) prints exactly the lines the full run printed for it, + and nothing to stderr. A rule block that leans on a variable another rule's block computed + (a "trapped definition"), or on a prelude it was not named for, reads an unset variable + inside `$( ... )` and reports green, which only a run of that rule by itself shows; an + unguarded block shows as an extra line. The rules run on a small pool inside this test.""" + full = self._real_tree().stdout.splitlines() + self.assertEqual(full[0], "== check-deps ==") + segments, pending = {}, [] + for line in full[1:-1]: + pending.append(line) + m = re.match(r" ok — ([a-z][a-z-]*)(?=[ :(]|$)", line) + if m: + segments.setdefault(m.group(1), []).extend(pending) + pending = [] + self.assertEqual((pending, full[-1]), ([], "check-deps: all gates green")) # `wall`'s own line is in its segment + rules = self._rule_names(self.ROOT) + + def alone(rule): + try: + return rule, _run_check_deps(self.tree, (rule,)), None + except AssertionError as e: + return rule, None, e + self.tree # build the private copy once, here: its cached_property has no lock on Python 3.12+ + with concurrent.futures.ThreadPoolExecutor(max_workers=4) as pool: + results = list(pool.map(alone, rules)) + for rule, r, error in results: + with self.subTest(rule=rule): + self.assertIsNone(error) + self.assertEqual((r.returncode, r.stderr), (0, "")) + self.assertEqual(r.stdout.splitlines(), ["== check-deps =="] + segments.get(rule, []) + + [f"check-deps: the selected gates are green (--only {rule})"]) + + def test_a_selection_runs_its_rules_in_the_scripts_order(self): + r = _run_check_deps(self.tree, ("fpflags", "present", "ticks")) + self.assertEqual(r.stdout.splitlines(), + ["== check-deps ==", " ok — ticks", " ok — fpflags", " ok — present: one worker door", + "check-deps: the selected gates are green (--only fpflags,present,ticks)"]) + + def test_a_misspelt_or_empty_selector_is_an_error_not_a_green_run(self): + """A selector that names no rule must not run nothing and pass: exit 2, before any rule runs.""" + script = os.path.join(self.ROOT, "ci", "check-deps.sh") + for argv in (["--only", "bloking"], ["--only", "libm,nope"], ["--only", ""], ["--only", "libm,"], + ["--only", ",libm"], ["--only", "libm,,ticks"], ["--only"], ["--only=zzz"], ["--only=libm "], + ["--list"], ["libm"], ["--only", "libm", "--bogus"]): + with self.subTest(argv=argv): + r = subprocess.run([script] + argv, capture_output=True, text=True) + self.assertEqual(r.returncode, 2, r.stdout + r.stderr) + self.assertEqual(r.stdout, "", "a rule ran") + self.assertIn("usage: ci/check-deps.sh", r.stderr) + + @_grades("ticks") + def test_a_test_that_selects_the_wrong_rule_fails_instead_of_passing(self): + """The violation planted here is `libm`'s, and this test selects `ticks`: the run is green + because `libm` never ran, and grading it as `libm`'s verdict must fail.""" + name = "_check_deps_selftest_wrong_rule.rs" + r = self._plant(name, "pub fn f(x: f32) -> f32 { x.powf(2.0) }\n") + self.assertEqual(r.returncode, 0, r.stdout + r.stderr) + self.assertNotIn("libm", r.stdout) + with self.assertRaises(AssertionError): + self._assert_flagged(r, "libm", [(name, "powf")]) + + def test_the_gate_runner_refuses_a_run_that_is_no_verdict_for_its_rules(self): + def fake(code, stdout, stderr=""): + return subprocess.CompletedProcess([], code, stdout=stdout, stderr=stderr) + green = "== check-deps ==\n ok — ticks\n ok — mutators-visibility\n" + self.assertEqual(_check_deps_verdict(fake(0, green), ("ticks",)).deps_rules, ("ticks",)) + self.assertIsNone(_check_deps_verdict(fake(1, green), None).deps_rules) + # `mutators` is a prefix of the name of another rule, not a verdict line of it + for case, r, rules, why in ( + ("no verdict line", fake(0, green), ("ticks", "libm"), "no verdict line for libm"), + ("a prefix of another rule", fake(0, green), ("mutators",), "no verdict line for mutators"), + ("usage error", fake(2, ""), ("ticks",), "no verdict"), + ("unset variable", fake(0, green, "check-deps.sh: line 9: x: unbound variable"), ("ticks",), + "unset variable")): + with self.subTest(case): + with self.assertRaisesRegex(AssertionError, why): + _check_deps_verdict(r, rules) + failed = fake(1, "== check-deps ==\n::error::check-deps: libm: 1 line(s) outside ci/allow/libm.txt\n") + self.assertEqual(_check_deps_verdict(failed, ("libm",)).returncode, 1) + _check_deps_verdict(fake(0, "== check-deps ==\n"), ("allowlist-counts",)) # silent when green + + @_grades("browse-owner") def test_self_tests_never_touch_the_real_tree(self): """Red-first for the parallel gate self-tests: every planting helper below edits a private copy of the gate's inputs, never the checkout. A helper that wrote into the checkout @@ -8719,13 +8885,15 @@ def test_self_tests_never_touch_the_real_tree(self): self.assertEqual(self._prepend("browse/mod.rs", "\n").returncode, 0) self.assertEqual(os.stat(real).st_mtime_ns, before, "a self-test wrote into the real tree") + @_grades_whole_script def test_the_private_copy_grades_exactly_like_the_real_tree(self): """The copy must carry every input `ci/check-deps.sh` reads: a missing one makes a gate see nothing and pass (or fail) for a reason the real tree would not share.""" real = self._real_tree() - copy = subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], capture_output=True, text=True) + copy = self._deps() self.assertEqual((copy.returncode, copy.stdout), (real.returncode, real.stdout), copy.stderr) + @_grades("fpflags") def test_the_private_copy_carries_every_fpflags_input(self): """The untouched copy above cannot see an input that was left out of `TREE_INPUTS` -- a gate that scans nothing is green. So plant what the `fpflags` rule looks for in each file @@ -8734,8 +8902,7 @@ def test_the_private_copy_carries_every_fpflags_input(self): All of them are planted at once and graded by ONE run: the rule prints one `path:line:text` match per offending file, so a file the rule did not scan (or the copy did not carry) is missing from the output and that input's subtest fails by name. Run one file at a - time this was 17 of the 73 `ci/check-deps.sh` runs in this class (about a quarter of - the module's CPU).""" + time this was 17 of the 73 `ci/check-deps.sh` runs this class made when each ran every rule.""" inputs = ("rust-modules/Cargo.toml", "rust-modules/build.rs", "rust-modules/net/Cargo.toml", "rust-modules/plex/Cargo.toml", "rust-modules/telemetry/Cargo.toml", "rust-modules/data/Cargo.toml", "rust-modules/session/Cargo.toml", "rust-modules/media/Cargo.toml", "rust-modules/appkit/Cargo.toml", "rust-modules/appkit/build.rs", "rust-modules/screens/Cargo.toml", "rust-modules/screens/build.rs", "rust-modules/platform/Cargo.toml", "rust-modules/platform/build.rs", "rust-modules/gfx/Cargo.toml", "rust-modules/gfx/build.rs", "rust-modules/ui/Cargo.toml", "rust-modules/ui/build.rs", @@ -8746,8 +8913,7 @@ def test_the_private_copy_carries_every_fpflags_input(self): self.assertTrue(os.path.exists(target), f"{rel} is not in the private copy (TREE_INPUTS)") with open(target, "a", encoding="utf-8") as f: f.write("\nrustflags = [\"-C\", \"target-feature=+fma\"]\n") - r = subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], - capture_output=True, text=True) + r = self._deps() out = r.stdout + r.stderr self.assertNotEqual(r.returncode, 0, out) self.assertIn("fpflags:", out) @@ -8768,8 +8934,7 @@ def _plant(self, name, content, crate_dir=None): try: with open(target, "w", encoding="utf-8") as f: f.write(content) - return subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], - capture_output=True, text=True) + return self._deps() finally: if os.path.exists(target): os.remove(target) @@ -8786,7 +8951,7 @@ def _plant_all(self, plants): `plants` is a list of `(name, content, crate_dir)`, each with its own file name, so the one run still shows which variants the gate caught: a gate prints the `path:line:text` (or the path) of every file it flags, and the caller requires each variant's file by name. Run - one variant at a time, a test with N variants cost N runs (about 25 s of CPU apiece).""" + one variant at a time, a test with N variants cost N runs.""" written = [] try: for name, content, crate_dir in plants: @@ -8795,8 +8960,7 @@ def _plant_all(self, plants): written.append(target) with open(target, "w", encoding="utf-8") as f: f.write(content) - return subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], - capture_output=True, text=True) + return self._deps() finally: for target in written: if os.path.exists(target): @@ -8817,8 +8981,7 @@ def _mutate(self, relpath, needle, replacement): try: with open(target, "w", encoding="utf-8") as f: f.write(original.replace(needle, replacement, 1)) - return subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], - capture_output=True, text=True) + return self._deps() finally: with open(target, "w", encoding="utf-8") as f: f.write(original) @@ -8839,8 +9002,7 @@ def _prepend(self, relpath, content): try: with open(target, "w", encoding="utf-8") as f: f.write(content + original) - return subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], - capture_output=True, text=True) + return self._deps() finally: with open(target, "w", encoding="utf-8") as f: f.write(original) @@ -8851,8 +9013,8 @@ def _prepend_files(self, fixtures): `fixtures` maps a store-relative path to the module-level text to prepend. Each variant a self-test wants to prove is rejected gets its OWN declaration (a distinct name), so the one run still shows which variants the gate caught: `_assert_flagged` requires every one - by name. Run one variant at a time these were 34 of the 73 gate runs in this class, and a - run is ~7 s of CPU.""" + by name. Run one variant at a time these were 34 of the 73 gate runs this class made when + each ran every rule.""" originals = {} try: for relpath, content in fixtures.items(): @@ -8861,8 +9023,7 @@ def _prepend_files(self, fixtures): originals[target] = f.read() with open(target, "w", encoding="utf-8") as f: f.write(content + originals[target]) - return subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], - capture_output=True, text=True) + return self._deps() finally: for target, original in originals.items(): with open(target, "w", encoding="utf-8") as f: @@ -8873,6 +9034,8 @@ def _assert_flagged(self, r, rule, flagged): a `path:line:text` line of THAT file whose text holds `marker` -- so a variant the gate missed fails by name even though the others were caught in the same run.""" out = r.stdout + r.stderr + self.assertTrue(r.deps_rules is None or rule in r.deps_rules, + f"{rule} is not among the rules this test selected, {r.deps_rules}: it never ran\n{out}") self.assertNotEqual(r.returncode, 0, out) self.assertIn(f"{rule}:", out) for relpath, marker in flagged: @@ -8881,6 +9044,7 @@ def _assert_flagged(self, r, rule, flagged): any(f"/src/{relpath}:" in line and marker in line for line in out.splitlines()), f"{rule} did not flag {marker!r} in {relpath}\n{out}") + @_grades("browse-owner") def test_browse_owner_gate_rejects_a_republished_free_mutator(self): """A valid module-level declaration is rejected even without a call site.""" r = self._prepend("browse/mod.rs", "\npub(crate) fn set_cur(i: usize) {}\n") @@ -8889,6 +9053,7 @@ def test_browse_owner_gate_rejects_a_republished_free_mutator(self): self.assertIn("browse-owner:", out) self.assertIn("fn set_cur", out) + @_grades("browse-owner") def test_browse_owner_gate_rejects_all_free_declaration_modifiers(self): declarations = ( ("set_cur", " pub(super) fn set_cur(i: usize) {}\n"), @@ -8899,6 +9064,7 @@ def test_browse_owner_gate_rejects_all_free_declaration_modifiers(self): r = self._prepend_files({"browse/mod.rs": "".join("\n" + d for _, d in declarations)}) self._assert_flagged(r, "browse-owner", [("browse/mod.rs", f"fn {n}") for n, _ in declarations]) + @_grades("browse-owner") def test_browse_owner_gate_rejects_attributes_and_split_free_declarations(self): declarations = ( ("set_cur", "#[inline] pub(super) const fn set_cur(i: usize) {}\n"), @@ -8907,11 +9073,13 @@ def test_browse_owner_gate_rejects_attributes_and_split_free_declarations(self): r = self._prepend_files({"browse/mod.rs": "".join("\n" + d for _, d in declarations)}) self._assert_flagged(r, "browse-owner", [("browse/mod.rs", name) for name, _ in declarations]) + @_grades("browse-owner") def test_browse_owner_gate_is_nonvacuous_for_indented_free_declarations(self): r = self._prepend("browse/mod.rs", "\n pub fn set_cur(i: usize) {}\n") self.assertNotEqual(r.returncode, 0, r.stdout + r.stderr) self.assertIn("browse/mod.rs", r.stdout + r.stderr) + @_grades("browse-owner") def test_browse_owner_gate_ignores_normal_string_braces_before_a_free_const_fn(self): """Compiling counterexample for the old raw brace counter: the `{` belongs to LABEL, so the indented const fn after it is still a module-level retired facade and must fail.""" @@ -8924,6 +9092,7 @@ def test_browse_owner_gate_ignores_normal_string_braces_before_a_free_const_fn(s self.assertIn("browse-owner:", out) self.assertIn("const fn set_cur", out) + @_grades("browse-owner") def test_browse_owner_gate_ignores_every_rust_noncode_brace_before_a_free_fn(self): fixtures = ( '// {\n', @@ -8946,6 +9115,7 @@ def test_browse_owner_gate_ignores_every_rust_noncode_brace_before_a_free_fn(sel r = self._prepend_files({"browse/mod.rs": text}) self._assert_flagged(r, "browse-owner", [("browse/mod.rs", f"fn {n}(") for n in names]) + @_grades("browse-owner") def test_browse_owner_gate_ignores_noncode_closing_braces_inside_an_impl(self): """A compiling impl fixture remains receiver-bound even when every Rust literal/comment form contains `}`. The old counter escaped the impl and falsely reported `cur`.""" @@ -8968,6 +9138,7 @@ def test_browse_owner_gate_ignores_noncode_closing_braces_inside_an_impl(self): self.assertEqual(r.returncode, 0, r.stdout + r.stderr) self.assertIn("ok — browse-owner", r.stdout) + @_grades("browse-owner") def test_browse_owner_gate_rejects_retired_transport_declarations(self): declarations = ( ("browse/mod.rs", "LEGACY_ADAPTER", " pub(crate) static LEGACY_ADAPTER: () = ();\n"), @@ -8980,6 +9151,7 @@ def test_browse_owner_gate_rejects_retired_transport_declarations(self): r = self._prepend_files(by_file) self._assert_flagged(r, "browse-owner", [(relpath, name) for relpath, name, _ in declarations]) + @_grades("browse-owner") def test_browse_owner_gate_rejects_retired_thread_local_selectors(self): selectors = (("browse/mod.rs", "LEGACY_ADAPTER"), ("stores/browse.rs", "ACTIVE")) r = self._prepend_files({ @@ -8987,6 +9159,7 @@ def test_browse_owner_gate_rejects_retired_thread_local_selectors(self): for relpath, selector in selectors}) self._assert_flagged(r, "browse-owner", [(relpath, f"static {selector}") for relpath, selector in selectors]) + @_grades("browse-owner") def test_browse_owner_gate_accepts_unrelated_thread_local_state(self): r = self._prepend( "browse/mod.rs", @@ -8995,6 +9168,7 @@ def test_browse_owner_gate_accepts_unrelated_thread_local_state(self): self.assertEqual(r.returncode, 0, r.stdout + r.stderr) self.assertIn("ok — browse-owner", r.stdout) + @_grades("browse-owner") def test_browse_owner_gate_fails_closed_when_a_scanner_input_is_missing(self): target = self._store_file(os.path.join("browse", "view.rs")) hidden = target + ".check-deps-selftest" @@ -9002,11 +9176,7 @@ def test_browse_owner_gate_fails_closed_when_a_scanner_input_is_missing(self): self.assertFalse(os.path.exists(hidden), f"stale self-test artifact at {hidden}") try: os.replace(target, hidden) - r = subprocess.run( - [os.path.join(self.tree, "ci", "check-deps.sh")], - capture_output=True, - text=True, - ) + r = self._deps() finally: if os.path.exists(hidden): os.replace(hidden, target) @@ -9015,6 +9185,7 @@ def test_browse_owner_gate_fails_closed_when_a_scanner_input_is_missing(self): self.assertIn("browse declaration scanner failed", out) self.assertIn("browse-owner:", out) + @_grades("browse-owner") def test_browse_owner_gate_accepts_receiver_bound_owned_methods(self): """A BrowseState selector is safe when it requires an explicit receiver. GREEN: re-declare the owned `cur(&self)` method (already `pub` since the data crate split, so the @@ -9028,6 +9199,7 @@ def test_browse_owner_gate_accepts_receiver_bound_owned_methods(self): self.assertEqual(r.returncode, 0, r.stdout + r.stderr) self.assertIn("ok — browse-owner", r.stdout) + @_grades("viewstate-owner") def test_viewstate_owner_gate_rejects_a_republished_free_state_facade(self): """A free pump can only reach process state; the owned spelling requires a receiver.""" declarations = ( @@ -9037,6 +9209,7 @@ def test_viewstate_owner_gate_rejects_a_republished_free_state_facade(self): r = self._prepend_files({"viewstate.rs": "".join("\n" + d for _, d in declarations)}) self._assert_flagged(r, "viewstate-owner", [("viewstate.rs", name) for name, _ in declarations]) + @_grades("viewstate-owner") def test_viewstate_owner_gate_rejects_storage_transport_and_selector_statics(self): fixtures = ( ("viewstate.rs", "QUEUE", "static mut QUEUE: Vec<()> = Vec::new();\n"), @@ -9050,6 +9223,7 @@ def test_viewstate_owner_gate_rejects_storage_transport_and_selector_statics(sel r = self._prepend_files(by_file) self._assert_flagged(r, "viewstate-owner", [(relpath, name) for relpath, name, _ in fixtures]) + @_grades("viewstate-owner") def test_viewstate_owner_gate_accepts_receiver_bound_owned_methods(self): fixture = """ struct ViewStateOwnerGateFixture; @@ -9078,15 +9252,16 @@ def _module_path_fixture(self, production_reference): target = os.path.join(directory, "support.rs") with open(target, "w", encoding="utf-8") as output: output.write('pub fn helper() { std::thread::spawn(|| {}); let _ = 0.5f32.powf(2.4); }\n') - result = subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], - capture_output=True, text=True) + result = self._deps() return result, os.path.relpath(target, self.tree) + @_grades("threads", "libm") def test_cfg_test_path_modules_are_excluded_from_production_gates(self): result, target = self._module_path_fixture(False) self.assertEqual(result.returncode, 0, result.stdout + result.stderr) self.assertNotIn(target + ":", result.stdout) + @_grades("threads", "libm") def test_production_path_reference_prevents_test_file_exemption(self): result, target = self._module_path_fixture(True) self.assertNotEqual(result.returncode, 0, result.stdout + result.stderr) @@ -9094,6 +9269,7 @@ def test_production_path_reference_prevents_test_file_exemption(self): self.assertIn("libm:", result.stdout) self.assertIn(target + ":", result.stdout) + @_grades("person-owner") def test_person_owner_gate_rejects_free_read_and_mutation_facades(self): declarations = ( ("current", "pub(crate) fn current() -> Option<()> { None }\n"), @@ -9103,6 +9279,7 @@ def test_person_owner_gate_rejects_free_read_and_mutation_facades(self): r = self._prepend_files({"person.rs": "".join("\n" + d for _, d in declarations)}) self._assert_flagged(r, "person-owner", [("person.rs", name) for name, _ in declarations]) + @_grades("person-owner") def test_person_owner_gate_rejects_model_transport_and_selector_statics(self): fixtures = ( ("person.rs", "CURRENT", "static mut CURRENT: Option = None;\n"), @@ -9117,6 +9294,7 @@ def test_person_owner_gate_rejects_model_transport_and_selector_statics(self): r = self._prepend_files(by_file) self._assert_flagged(r, "person-owner", [(relpath, name) for relpath, name, _ in fixtures]) + @_grades("person-owner") def test_person_owner_gate_accepts_receiver_bound_owned_methods(self): fixture = """ struct PersonOwnerGateFixture; @@ -9130,6 +9308,7 @@ def test_person_owner_gate_accepts_receiver_bound_owned_methods(self): self.assertEqual(r.returncode, 0, r.stdout + r.stderr) self.assertIn("ok — person-owner", r.stdout) + @_grades("mutators") def test_metadata_pure_builder_allowed_but_mutator_rejected_in_dev(self): pure = "fn gate_fixture() { let _ = plx_data::metadata::alt_stand_in(); }\n" r = self._plant("dev/_check_deps_metadata_builder.rs", pure) @@ -9139,6 +9318,7 @@ def test_metadata_pure_builder_allowed_but_mutator_rejected_in_dev(self): self._assert_flagged(r, "mutators", [("dev/_check_deps_metadata_builder.rs", "alt_install(")]) self.assertNotIn("alt_stand_in(", r.stdout + r.stderr) + @_grades("threads") def test_threads_gate_catches_a_bare_thread_spawn_after_use_std_thread(self): """The gate used to match only the fully-qualified `std::thread::spawn(` spelling, so a file that does `use std::thread;` and then calls the bare `thread::spawn(` — exactly the @@ -9153,6 +9333,7 @@ def test_threads_gate_catches_a_bare_thread_spawn_after_use_std_thread(self): self.assertIn("threads:", out) self.assertIn("_check_deps_selftest_threads.rs", out) + @_grades("threads") def test_threads_gate_ignores_visible_test_modules_without_exempting_production(self): files = {} for i, visibility in enumerate(("pub", "pub(crate)", "pub(super)")): @@ -9167,6 +9348,7 @@ def test_threads_gate_ignores_visible_test_modules_without_exempting_production( self.assertIn("threads:", r.stdout + r.stderr) self.assertIn("_check_deps_visible_production.rs", r.stdout + r.stderr) + @_grades("globals") def test_globals_ledger_ignores_field_labels_without_hiding_value_reads(self): fields = ("struct Captured { current_server: u32, client_for: u32, screen_input_revision: u32 }\n" "fn captured() -> Captured { Captured { current_server: 1, client_for: 2, screen_input_revision: 3 } }\n") @@ -9180,6 +9362,7 @@ def test_globals_ledger_ignores_field_labels_without_hiding_value_reads(self): self.assertIn(key + "current_server", out) self.assertIn(key + "client_for", out) + @_grades("blocking") def test_blocking_gate_catches_a_new_allow_blocking_site(self): """A frame-thread blocking exception is a ledger entry in ci/allow/blocking.txt. RED: a new production `allow_blocking(` that the list does not name must fail `blocking`, naming the @@ -9192,6 +9375,7 @@ def test_blocking_gate_catches_a_new_allow_blocking_site(self): self.assertIn("blocking:", out) self.assertIn("_check_deps_selftest_blocking.rs::sneaky", out) + @_grades("blocking") def test_blocking_gate_ignores_tests_comments_and_declarations(self): """GREEN: the same call inside a `#[cfg(test)] mod`, in a comment, or as an `fn` declaration is not a call site.""" @@ -9204,6 +9388,7 @@ def test_blocking_gate_ignores_tests_comments_and_declarations(self): self.assertEqual(r.returncode, 0, r.stdout + r.stderr) self.assertIn("ok — blocking", r.stdout) + @_grades("blocking") def test_blocking_gate_catches_an_aliased_allow_blocking(self): """The call-site grep cannot see `use ...::allow_blocking as x; x(..)` or `let f = allow_blocking;`. RED: a production mention of the bare identifier that is not a call, the @@ -9216,6 +9401,7 @@ def test_blocking_gate_catches_an_aliased_allow_blocking(self): self.assertIn("blocking:", out) self.assertIn("_check_deps_selftest_blocking_alias.rs:1", out) + @_grades("blocking") def test_blocking_gate_catches_a_stale_entry(self): """The ledger only shrinks: an entry whose site is gone must fail `blocking`, so a migration has to delete its line (and a line cannot be left behind to excuse a later regrowth).""" @@ -9228,7 +9414,7 @@ def test_blocking_gate_catches_a_stale_entry(self): stale += "rust-modules/media/src/route/decision.rs::no_such_fn\tgone\n" with open(allow, "w", encoding="utf-8") as f: f.write(stale) - r = subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], capture_output=True, text=True) + r = self._deps() finally: with open(allow, "w", encoding="utf-8") as f: f.write(original) @@ -9243,13 +9429,12 @@ def test_blocking_gate_catches_a_stale_entry(self): # in different areas never edit the same `# count:` header. LEDGER_RULES = ("workers", "globals", "forks", "fxlanes") - def _deps(self): - return subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], capture_output=True, text=True) def _ledger_files(self, rule): root = os.path.join(self.tree, "ci", "allow", rule) return sorted(os.path.join(root, fn) for fn in os.listdir(root) if fn.endswith(".txt")) + @_grades("blocking") def test_blocking_ledger_keeps_its_multiset_shape_after_the_refactor(self): """`blocking` now runs on the shared ledger scanner and must grade as it always did: every call is its own ledger line (two calls in one fn are two lines), a call in a closure @@ -9268,6 +9453,7 @@ def test_blocking_ledger_keeps_its_multiset_shape_after_the_refactor(self): self.assertEqual(new, ["closure", "one_liner", "two", "two"], out) self.assertIn("new: 4, stale: 0, aliased: 0", out) + @_grades("workers") def test_workers_ledger_catches_a_new_worker_start_in_a_machine(self): """RED: a production worker start in a machine (a data/ store, a screen, the session owner ...) that no ci/allow/workers/.txt names must fail `workers`, keyed by file, enclosing fn @@ -9290,6 +9476,7 @@ def test_workers_ledger_catches_a_new_worker_start_in_a_machine(self): self.assertIn(f"{key}::{site}", out) self.assertIn("ci/allow/workers/data-_check_deps_selftest_workers.txt", out) + @_grades("globals") def test_globals_ledger_catches_a_new_registry_read_in_a_machine(self): """RED: a production read of a process-global registry in a machine fails `globals`: the getters, the qualified `session::peek`, and a bare `peek` only because this file imports it @@ -9317,6 +9504,7 @@ def test_globals_ledger_catches_a_new_registry_read_in_a_machine(self): self.assertEqual(out.count(f"{key}::peek (ledger: "), 1, "`it.peek()` is not a registry read\n" + out) self.assertIn("ci/allow/globals/screens.txt", out) + @_grades("forks") def test_forks_ledger_catches_a_new_production_test_fork(self): """RED: a `#[cfg(not(test))]` / `cfg!(not(test))` / `not(feature = \"test-support\")` fork in any machine crate (data/, plex/, media/, session/, screens/, ui/, appkit/, machine/) that no @@ -9340,6 +9528,7 @@ def test_forks_ledger_catches_a_new_production_test_fork(self): self.assertIn(f"{key}::{item} (ledger: ", out) self.assertIn("ci/allow/forks/session.txt", out) + @_grades("forks") def test_forks_ledger_reads_every_machine_crate_not_only_the_four_that_own_the_data(self): """RED: a machine in screens/, ui/, appkit/ or machine/ forks on `cfg(test)` as surely as one in data/ does (`screens/src/legal.rs` `build_sha`, `screens/src/login.rs` `harness_driven` were the live cases), so the @@ -9369,6 +9558,7 @@ def test_forks_ledger_reads_every_machine_crate_not_only_the_four_that_own_the_d with self.subTest(crate=crate, test_item=item): self.assertNotIn(f"{key}::{item}", out, "an item only a test can see is no fork\n" + out) + @_grades("fxlanes") def test_fxlanes_ledger_fails_a_new_appfx_side_queue_but_not_a_deliver_arm(self): """RED: in `Bridge::app_effect` an `AppFx` arm that pushes `Fx::Deliver(` rides the ordered FIFO and costs nothing; an arm that parks its request on a side queue must be a ledger line, @@ -9386,6 +9576,7 @@ def test_fxlanes_ledger_fails_a_new_appfx_side_queue_but_not_a_deliver_arm(self) self.assertNotIn("AppFx::Orderly", out) self.assertIn("ci/allow/fxlanes/app.txt", out) + @_grades("workers", "globals", "forks") def test_ledgers_ignore_tests_comments_strings_and_declarations(self): """GREEN: the same shapes inside a `#[cfg(test)] mod`, under a test-only `cfg(any(test, ..))` item, in a comment, a doc line or a string literal, are no site of any ledger -- so all @@ -9406,7 +9597,7 @@ def test_ledgers_ignore_tests_comments_strings_and_declarations(self): self.assertRegex(r.stdout, rf"ok — {rule} \(\d+ sites\)") def _plant_many(self, files, crate_dir): - """`_plant` for several orphan files of ONE crate, graded by a single gate run (a run is ~11 s): + """`_plant` for several orphan files of ONE crate, graded by a single gate run: each file isolates one import shape, because a `use` statement applies to its whole file.""" written = [] try: @@ -9430,6 +9621,7 @@ def _append_to(self, rel, text): f.write(text) return self._deps() + @_grades("globals") def test_globals_ledger_sees_renamed_and_bare_keypin_and_grant_getters(self): """RED: `keypin::revision`, `keypin::blocked_for` and `grant::offers` are registry reads like `session::peek`, so the two ways to hide one from the call-site scan are shut the same way: @@ -9463,6 +9655,7 @@ def test_globals_ledger_sees_renamed_and_bare_keypin_and_grant_getters(self): self.assertEqual(out.count(f"{base}bare.rs::bare::revision (ledger: "), 1, "`it.revision()` is not a registry read\n" + out) + @_grades("globals") def test_globals_ledger_sees_the_player_transport_readers_in_a_machine(self): """RED: `transport::viewer_paused` (the pause-hold claim) and `preview::paused` (the preview machine's process-global phase) still read process-wide state, so a machine that calls one is a site, as a @@ -9526,6 +9719,7 @@ def test_globals_ledger_sees_the_player_transport_readers_in_a_machine(self): self.assertNotIn(f"{base}{stem}.rs", out, "`..._preview::*` / `..._transport::{..}` is not `preview` / `transport`\n" + out) + @_grades("globals") def test_globals_ledger_sees_the_capability_answer_readers_in_a_machine(self): """RED: `devcaps::caps()` is the device's capability answer, a process-wide registry read. It has been write-once since #1047: it is the boot snapshot, a stored refusal never moves it, and the stored rows reach @@ -9591,6 +9785,7 @@ def test_globals_ledger_sees_the_capability_answer_readers_in_a_machine(self): self.assertNotIn(f"{base}{stem}.rs", out, "a `caps` parameter or an unimported `caps(` is not the capability answer\n" + out) + @_grades("globals") def test_globals_ledger_sees_screen_input_revision_without_allowance(self): r = self._plant_many({ "stores/_check_deps_screen_revision_direct.rs": "fn read() { plx_plex::plex::session::screen_input_revision(); }\n", @@ -9606,6 +9801,7 @@ def test_globals_ledger_sees_screen_input_revision_without_allowance(self): self.assertIn(base + "glob.rs::read::screen_input_revision", out) self.assertIn(base + "alias.rs:1", out) + @_grades("globals") def test_globals_ledger_sees_the_registry_readers_the_old_closed_list_missed(self): """RED: the server registry's roster readers (`server_ids`, `server_roster_gen`, `server_facts_gen`, `server_probe_result`), the session cache's two readers (`session::peek_settled`, `session::current_gen`) @@ -9618,7 +9814,7 @@ def test_globals_ledger_sees_the_registry_readers_the_old_closed_list_missed(sel `plex/src/plex/session.rs` calls its own `peek_settled()` / `current_gen()` with no `use` to say so, as it always did for `peek`; a bare call planted there is a site. `data/src/stores/tape.rs` is the registry the stores call through, not a machine, so its own bare `active()` is NOT one. All of it is - graded by ONE gate run (a run is ~14 s).""" + graded by ONE gate run.""" crate = "data" session = "rust-modules/plex/src/plex/session.rs" tape = "rust-modules/data/src/stores/tape.rs" @@ -9705,6 +9901,7 @@ def test_globals_ledger_sees_the_registry_readers_the_old_closed_list_missed(sel self.assertEqual(len(naming), 1, "`stores/tape.rs` is the registry, not a machine: its own bare `active()` is no site\n" + out) + @_grades("workers", "globals") def test_a_bare_name_that_ends_a_braced_import_is_still_imported(self): """RED: `use plx_base::task::{self, spawn};` imports `spawn` as surely as `{spawn, self}` does, and so for `submit` and `peek`; the import pattern used to eat the closing `}` of a group whose @@ -9736,6 +9933,7 @@ def test_a_bare_name_that_ends_a_braced_import_is_still_imported(self): self.assertIn(f"{base}{stem}.rs::{fn}::{spelling} (ledger: ", out) self.assertNotIn(f"{base}other.rs", out, "`{self, spawn_small}` imports no bare `spawn`\n" + out) + @_grades("fxlanes") def test_fxlanes_ledger_sees_every_variant_of_an_arm_and_a_catch_all_arm(self): """RED: an or-pattern arm (`AppFx::A(r) | AppFx::B(r) => ..`, on one line or wrapped) is a site for EVERY variant on its head, and an arm with no `AppFx::` head (`other => ..`, `_ => ..`) is a @@ -9758,6 +9956,7 @@ def test_fxlanes_ledger_sees_every_variant_of_an_arm_and_a_catch_all_arm(self): self.assertNotIn("PlantedOk", out) self.assertNotIn(f"{key}Loop", out, "the variant the ledger already holds is not new") + @_grades("globals") def test_globals_ledger_sees_every_spelling_of_the_player_transport_in_lifecycle(self): """RED: lifecycle.rs, the machine, reads no `crate::player::TX` (the transport contract lives in player/transport.rs), and the spellings stay pinned there as a zero-guard: planting `super::TX`, @@ -9784,6 +9983,7 @@ def test_globals_ledger_sees_every_spelling_of_the_player_transport_in_lifecycle rename_line = before + appended.split("\n").index("use super::TX as Transport2;") + 1 self.assertIn(f"{rel}:{rename_line}\n", out + "\n") + @_grades("workers", "globals", "forks") def test_a_cfg_test_fn_with_a_where_clause_is_skipped_whole(self): """RED: an item under `#[cfg(test)]` is skipped to the end of ITS body. A signature that spills over several lines -- a long parameter list, a `where` clause whose bounds end in a comma -- used @@ -9804,6 +10004,7 @@ def test_a_cfg_test_fn_with_a_where_clause_is_skipped_whole(self): self.assertNotIn(f"{key}::?", out, "a test fn's body was graded as production\n" + out) self.assertEqual(out.count(key), 1, out) + @_grades("forks") def test_forks_ledger_names_a_path_qualified_macro_item_and_counts_an_inline_cfg_test(self): """RED: `#[cfg(..)]` on `plx_base::devtrig::latched_flag!(..);` is an item named for its macro, like an unqualified `cache!` is, not the unnamed `?`. And `cfg!(test)` still counts as a fork whatever it @@ -9832,6 +10033,7 @@ def test_no_ledger_key_is_unnamed(self): self.assertFalse(key.endswith("::?") or "::?::" in key, f"{os.path.relpath(path, self.tree)}: {key}") + @_grades("workers", "globals") def test_worker_and_global_aliases_fail_because_the_scan_cannot_count_them(self): """RED: `use ...::spawn_small as go;` renames a worker start or a registry getter, so every `go(..)` after it is invisible to the call-site scan: the `use ... as` line fails its rule @@ -9853,6 +10055,7 @@ def test_worker_and_global_aliases_fail_because_the_scan_cannot_count_them(self) with self.subTest(site=site): self.assertIn(f"{path}::{site} (ledger: ", out) + @_grades("workers", "globals", "forks", "fxlanes") def test_ledger_files_must_be_exact_stale_lines_and_misfiled_lines_fail(self): """Every ledger only shrinks: a line whose site is gone fails its rule (so a migration has to delete it), and a line filed under the wrong area fails too, so the layout cannot drift.""" @@ -9885,6 +10088,7 @@ def test_ledger_files_must_be_exact_stale_lines_and_misfiled_lines_fail(self): self.assertIn("misfiled ledger line: rust-modules/gfx/src/_selftest_misfiled.rs::f", out) self.assertIn("belongs in ci/allow/forks/gfx.txt", out) + @_grades("allowlist-counts") def test_ledger_count_header_must_equal_its_entries_in_every_area_file(self): """The `# count:` header of every ci/allow//.txt is held to its entries, exactly like the flat allowlists: a line added or deleted without moving the header fails by name.""" @@ -9904,6 +10108,7 @@ def test_ledger_count_header_must_equal_its_entries_in_every_area_file(self): with self.subTest(rule=rule): self.assertIn(f"{rel} declares count", out) + @_grades("tmppath") def test_tmppath_gate_catches_a_path_built_on_one_line_and_opened_on_the_next(self): """The gate used to require the literal and a filesystem-open verb on the SAME line, so a value built on one line and opened on the next passed silently. RED: planting that split @@ -9918,6 +10123,7 @@ def test_tmppath_gate_catches_a_path_built_on_one_line_and_opened_on_the_next(se self.assertIn("tmppath:", out) self.assertIn("_check_deps_selftest_tmppath_open.rs", out) + @_grades("tmppath") def test_tmppath_gate_exempts_a_log_message_mention(self): """D4's own exemption: a `/tmp/plxnative-` literal that is only message text passed to `log`/`crate::eventlog::log`/`log!` must not fail the gate. GREEN: planting one, including a nested @@ -9932,6 +10138,7 @@ def test_tmppath_gate_exempts_a_log_message_mention(self): self.assertEqual(r.returncode, 0, out) self.assertIn("ok — tmppath", out) + @_grades("cards") def test_cards_gate_catches_a_screen_assembling_its_own_strip(self): """Shared-card-sections L1: a screen draws card sections with `plx_ui::cards::{Shelf, Grid}`. `card_row` / `poster_grid` are `pub(crate)`, so the gate polices what `plx_ui::cards` @@ -9955,6 +10162,7 @@ def test_cards_gate_catches_a_screen_assembling_its_own_strip(self): for line in (2, 4, 5, 6, 7, 8, 9): self.assertIn(f"_check_deps_selftest_cards_strip.rs:{line}", out) + @_grades("cards") def test_cards_gate_allows_the_shared_component(self): r = self._plant( "_check_deps_selftest_cards_ok.rs", @@ -9965,6 +10173,7 @@ def test_cards_gate_allows_the_shared_component(self): self.assertEqual(r.returncode, 0, out) self.assertIn("ok — cards", out) + @_grades("sink") def test_sink_gate_catches_the_video_sink_named_outside_the_player(self): """Step L15: the Starfish/ACB verbs are the player's alone. RED: a module outside `player/`, `port.rs` and `tv/` that reaches `tv::sink::installed()` must fail `sink`.""" @@ -9977,6 +10186,7 @@ def test_sink_gate_catches_the_video_sink_named_outside_the_player(self): self.assertIn("sink:", out) self.assertIn("_check_deps_selftest_sink_out.rs", out) + @_grades("sink") def test_sink_gate_allows_the_player_to_name_the_video_sink(self): """GREEN: the same call from a file under `player/` leaves `sink` (and the script) green.""" r = self._plant( @@ -9987,6 +10197,7 @@ def test_sink_gate_allows_the_player_to_name_the_video_sink(self): self.assertEqual(r.returncode, 0, out) self.assertIn("ok — sink", out) + @_grades("textmeasure") def test_textmeasure_gate_catches_a_bare_call_outside_the_seam(self): """Phase 12, D4: `textmeasure` went from an allowlist to zero-tolerance. RED: a raw `crate::text::text_width(` call in a file that is neither one of the three seam files @@ -10003,6 +10214,7 @@ def test_textmeasure_gate_catches_a_bare_call_outside_the_seam(self): self.assertIn("textmeasure:", out) self.assertIn("_check_deps_selftest_textmeasure_bare.rs", out) + @_grades("textmeasure") def test_textmeasure_gate_exempts_the_body_of_a_measure_impl(self): """The exemption is STRUCTURAL, not a path allowlist: any `impl … Measure for …` block, anywhere in the tree, may call the raw functions it wraps — `widgets.rs`'s `LegacyMeasure` @@ -10022,6 +10234,7 @@ def test_textmeasure_gate_exempts_the_body_of_a_measure_impl(self): self.assertEqual(r.returncode, 0, out) self.assertIn("ok — textmeasure", out) + @_grades("dt") def test_dt_gate_catches_a_raw_accumulator(self): """Phase 12, D4: `dt` went from a 12-file allowlist to zero-tolerance everywhere but `machine/src/motion.rs`. RED: a `self.t += dt;`-shaped accumulator in a new file must fail — this @@ -10038,6 +10251,7 @@ class comes from.""" self.assertIn("dt:", out) self.assertIn("_check_deps_selftest_dt_accum.rs", out) + @_grades("dt") def test_dt_gate_catches_idle_dt_by_name(self): """`idle::dt()` is deleted from `machine/src/idle.rs` — the accessor callers used to sum themselves. RED: a call spelled `idle::dt()` anywhere must fail even with no `+=`/`-=` beside it, since @@ -10051,6 +10265,7 @@ def test_dt_gate_catches_idle_dt_by_name(self): self.assertIn("dt:", out) self.assertIn("_check_deps_selftest_dt_fn.rs", out) + @_grades("nav", "ui-owner-legacy") def test_ui_owner_gate_rejects_retired_global_readers(self): readers = ( ("nav", "plx_ui::nav::page_alpha()"), @@ -10073,6 +10288,7 @@ def test_ui_owner_gate_rejects_retired_global_readers(self): any(f"_check_deps_selftest_owner_{name}.rs:" in line for line in output.splitlines()), f"{rule} did not flag the {name} reader\n{output}") + @_grades("ui-owner-files") def test_ui_owner_gate_rejects_resurrected_modules(self): modules = (("ui", "nav.rs"), ("ui", "press.rs"), ("machine", "idle.rs")) result = self._plant_all([(name, "// Retired module must remain absent.\n", crate) for crate, name in modules]) @@ -10083,6 +10299,7 @@ def test_ui_owner_gate_rejects_resurrected_modules(self): with self.subTest(crate=crate, module=name): self.assertIn(f"ui-owner-files: retired module rust-modules/{crate}/src/{name} exists", output) + @_grades("owned-damage") def test_owned_damage_gate_rejects_a_retired_transport_call(self): result = self._plant("_check_deps_selftest_damage_adapter.rs", "pub fn repaint() { plx_machine::motion::report::invalidate(); }\n") @@ -10090,6 +10307,7 @@ def test_owned_damage_gate_rejects_a_retired_transport_call(self): self.assertNotEqual(result.returncode, 0, output) self.assertIn("owned-damage:", output) + @_grades("owned-wake") def test_owned_wake_gate_rejects_worker_door_from_ui(self): result = self._plant("_check_deps_selftest_render_worker_door.rs", "pub fn deferred_draw() { plx_machine::present::wake_from_worker(); }\n", crate_dir="ui") @@ -10097,12 +10315,12 @@ def test_owned_wake_gate_rejects_worker_door_from_ui(self): self.assertNotEqual(result.returncode, 0, output) self.assertIn("owned-wake:", output) + @_grades("owned-damage") def test_owned_damage_gate_rejects_a_report_global(self): target = os.path.join(self.tree, "rust-modules", "machine", "src", "motion", "report.rs") with open(target, "a", encoding="utf-8") as stream: stream.write("\nstatic PAINT: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);\n") - result = subprocess.run([os.path.join(self.tree, "ci", "check-deps.sh")], - capture_output=True, text=True) + result = self._deps() output = result.stdout + result.stderr self.assertNotEqual(result.returncode, 0, output) self.assertIn("owned-damage:", output) @@ -10790,10 +11008,10 @@ class _ParallelSuite(unittest.TestSuite): """Runs its tests on a thread pool and replays each one's outcome into the real result. Only for tests whose work is a subprocess and that share no state (`DepGates`: each runs - `ci/check-deps.sh` over its own private copy of the tree, about 11 s apiece (a few of them run it - several times), - which was 630 of the 645 s this module took when they ran one after another). Threads are - enough because the time is spent waiting on the child. A test runs against a private + `ci/check-deps.sh` over its own private copy of the tree, which was 630 of the 645 s this + module took when they ran one after another and each ran every rule; now each selects only + the rule it plants for, `_grades`). Threads are enough because the time is spent waiting on + the child. A test runs against a private `TestResult`, then its counters and failure lists are folded into the shared one on the calling thread, so the shared result is only ever touched from one thread. From 740d75edabdf1b18714b03e47662a74c617de0e3 Mon Sep 17 00:00:00 2001 From: Gleb Linnik Date: Sat, 14 Nov 2026 08:28:16 +0300 Subject: [PATCH 6/6] check-deps: a repeated --only is a usage error; fix two stale comments A second --only used to overwrite the first, so `--only wall --only libm` ran just libm and reported green. It now exits 2 through deps_usage like the other bad selectors, and the bad-selector test lists the three spellings. The which-tier skill said the harness shells out to check-deps.sh (11 s a run) per self-test; each DepGates self-test now runs only its own rule(s) through --only, and only the whole-script tests and the shared real-tree run run every rule. The timing figure is dropped. check-ports.py's note on who runs the wall rule now names the every-rule sweep, which runs --only wall too. Co-Authored-By: Claude Opus 5.5 --- .agents/skills/which-tier/SKILL.md | 8 +++++--- ci/check-deps.sh | 16 ++++++++++++---- ci/check-ports.py | 3 ++- tests/test_harness.py | 7 +++++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.agents/skills/which-tier/SKILL.md b/.agents/skills/which-tier/SKILL.md index 752c288b1e..b49b6ba989 100644 --- a/.agents/skills/which-tier/SKILL.md +++ b/.agents/skills/which-tier/SKILL.md @@ -94,9 +94,11 @@ cargo can see a python file). everybody quotes is `cargo test --lib` alone, and that part is itself tens of seconds now (the per-crate test binaries, `UNIT_SUITE` in the Makefile, run side by side through `tools/cargo-test-parallel.py`; `make test-crate C=` runs just the one you touched); end to end the gate runs in MINUTES warm. The bulk of it is `python3 tests/test_harness.py`, which shells out to -`ci/check-deps.sh` (11 s a run) once or more per self-test to prove each structure gate still -catches a planted violation — 661 s of a 1100 s run, measured 2026-10-01 on a cold lane at load -~5, before those self-tests moved to private tree copies and a thread pool (175 s after). The lab selftest's **~7 s is mostly two DELIBERATE rate-limit waits** — so +`ci/check-deps.sh` to prove each structure gate still catches a planted violation: each DepGates +self-test runs only the rule or rules it plants for (`--only `), and only the whole-script +tests, with the one shared run over the real tree, run every rule. That was 661 s of a 1100 s run, +measured 2026-10-01 on a cold lane at load ~5, before those self-tests moved to private tree +copies and a thread pool (175 s after). The lab selftest's **~7 s is mostly two DELIBERATE rate-limit waits** — so a ten-second-plus pause there is the target working, not a hang. (That step also SSDP-probes the LAN to report whether a UPnP gateway is present; still no television, still no lock.) Do not write a new number here: measure it if you need one — this file has already carried a diff --git a/ci/check-deps.sh b/ci/check-deps.sh index c2b9ffb346..e0b4389980 100755 --- a/ci/check-deps.sh +++ b/ci/check-deps.sh @@ -164,8 +164,8 @@ ok() { echo " ok — $*"; } # ci/check-deps.sh --only blocking,workers run just those rules, the code the full run runs for # them: their verdict lines, a summary, exit 0 or 1 # ci/check-deps.sh --list-rules the rule names (RULES below), one a line, no rule run -# A name that is no rule, an empty list or any other argument exits 2 before any rule runs, so a -# misspelt selector is an error and never "ran nothing, green". A rule's NAME is what its verdict +# A name that is no rule, an empty list, a second --only or any other argument exits 2 before any +# rule runs, so a misspelt selector is an error and never "ran nothing (or less than asked), green". A rule's NAME is what its verdict # line starts with (`ok — ` / `check-deps: : ...`); `allowlist-counts` is the one rule that # prints nothing when green. # @@ -198,8 +198,16 @@ only_arg="" while [ $# -gt 0 ]; do case "$1" in --list-rules) printf '%s\n' "${RULES[@]}"; exit 0 ;; - --only) [ $# -ge 2 ] || deps_usage "--only needs a rule list"; have_only=1; only_arg="$2"; shift 2 ;; - --only=*) have_only=1; only_arg="${1#--only=}"; shift ;; + --only|--only=*) + # one way to say it: a second --only would overwrite the first and run a smaller set, green + [ "$have_only" -eq 0 ] || deps_usage "--only is given once; join the rules with commas (--only a,b)" + have_only=1 + if [ "$1" = "--only" ]; then + [ $# -ge 2 ] || deps_usage "--only needs a rule list" + only_arg="$2"; shift 2 + else + only_arg="${1#--only=}"; shift + fi ;; *) deps_usage "unknown argument '$1'" ;; esac done diff --git a/ci/check-ports.py b/ci/check-ports.py index dd1c4c002d..f37a9e32de 100644 --- a/ci/check-ports.py +++ b/ci/check-ports.py @@ -56,7 +56,8 @@ def ports(root, ini): # them cannot hold a wall-clock operation, so this rule does not lex or classify it: lexing the # ~690 files of the scopes (and the wholly-test classification of every scope) was most of this # gate's 4.6 s of CPU, run once per `ci/check-deps.sh` that selects `wall` (every full run; the -# harness's gate self-tests run only the rule they plant for, so only its whole-script tests run it). +# harness's gate self-tests run only the rule they plant for, so only its whole-script tests and +# its every-rule sweep, which runs `--only wall` too, run it). # The skip changes what an UNLEXABLE file does here, never what a wall site does: a file with no # wall word and an unterminated raw string no longer fails THIS rule. `ci/check-list-caps.py` (a step # of ci/check-python-steps.txt) reports it instead: it runs `rtm.lex` over every production file under diff --git a/tests/test_harness.py b/tests/test_harness.py index c13f4f99c2..c8fe95c038 100644 --- a/tests/test_harness.py +++ b/tests/test_harness.py @@ -8831,11 +8831,14 @@ def test_a_selection_runs_its_rules_in_the_scripts_order(self): "check-deps: the selected gates are green (--only fpflags,present,ticks)"]) def test_a_misspelt_or_empty_selector_is_an_error_not_a_green_run(self): - """A selector that names no rule must not run nothing and pass: exit 2, before any rule runs.""" + """A selector that names no rule, or a second --only, must not run less than asked and pass: exit 2, before any rule runs.""" script = os.path.join(self.ROOT, "ci", "check-deps.sh") for argv in (["--only", "bloking"], ["--only", "libm,nope"], ["--only", ""], ["--only", "libm,"], ["--only", ",libm"], ["--only", "libm,,ticks"], ["--only"], ["--only=zzz"], ["--only=libm "], - ["--list"], ["libm"], ["--only", "libm", "--bogus"]): + ["--list"], ["libm"], ["--only", "libm", "--bogus"], + # a repeated --only would overwrite the first and run the smaller set, green + ["--only", "wall", "--only", "libm"], ["--only=wall", "--only=libm"], + ["--only", "wall", "--only=libm"]): with self.subTest(argv=argv): r = subprocess.run([script] + argv, capture_output=True, text=True) self.assertEqual(r.returncode, 2, r.stdout + r.stderr)