diff --git a/README.md b/README.md index 92b6c8bc..58a53742 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ pytest_add_cli_args=-k not ScoreOutcomesTool ``` -Then, in the copy: `uvx --with pytest 'mutmut>=3,<4' run && uvx --with pytest 'mutmut>=3,<4' results`, and `uvx --with pytest 'mutmut>=3,<4' show ` to see a mutant's change. The config keys are mutmut 3's. +Then, in the copy: `uvx --with pytest==9.2.0 'mutmut>=3,<4' run && uvx --with pytest==9.2.0 'mutmut>=3,<4' results`, and `uvx --with pytest==9.2.0 'mutmut>=3,<4' show ` to see a mutant's change. The config keys are mutmut 3's. `bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests; `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them, `rule_hook` imports `rank_todo.py`'s check, `larv_review` imports `rank_todo.py`'s ranking, `score_outcomes` imports `reading_cost`'s record path, `judge_replay` imports `loop_claude`'s judge, and `loop_claude` runs `chunk-preflight` as a process of its own. `judge_replay` and `review_replay` share `rung_replay/`: the rung search, the argument reader, the candidate rungs and the exits. `rung_replay/` reads `loop_claude`'s retry count and models file. The other non-test modules at `bin/`'s root, `claude_code/` and `transcript_archive/` serve more than one tool; `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read. `routing_figures/` measures loop-claude's archive for loop-claude's routing calls. `machine_load/` takes the machine's heavy slots, its shared lock files, for `run_heavy`, and reads the memory share that loop-claude waits for. `test_env.py` serves the tests, and `repo_checks/` tests the repo itself. diff --git a/bin/repo_checks/test_readme_test_line.py b/bin/repo_checks/test_readme_test_line.py new file mode 100644 index 00000000..1cd46c08 --- /dev/null +++ b/bin/repo_checks/test_readme_test_line.py @@ -0,0 +1,16 @@ +import pathlib +import re +import sys +import unittest + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) + +from machine_load.slots import CPUS_PER_SLOT +from repo_checks import ROOT + + +class TestLine(unittest.TestCase): + def test_the_readme_runs_the_tests_in_one_heavy_slots_cpus(self): + workers = re.search(r"pytest==\S+ -n (\d+) bin`", (ROOT / "README.md").read_text(encoding="utf-8")) + self.assertIsNotNone(workers, "README.md's Test line runs `pytest==X -n N bin`") + self.assertEqual(int(workers.group(1)), CPUS_PER_SLOT) diff --git a/bin/repo_checks/test_types.py b/bin/repo_checks/test_types.py index 8e8b24b3..ab4065c2 100644 --- a/bin/repo_checks/test_types.py +++ b/bin/repo_checks/test_types.py @@ -1,4 +1,5 @@ import pathlib +import re import shutil import subprocess import sys @@ -8,10 +9,26 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from repo_checks import ROOT +SUPPORTED = re.compile(r"the latest stable Python, today (3\.\d+)") + + +def tools() -> list[str]: + """mypy's arguments naming every package and module under bin/ but the repo checks, so a new tool is checked without being listed.""" + bin_folder = ROOT / "bin" + packages = sorted(init.parent.name for init in bin_folder.glob("*/__init__.py") if init.parent.name != "repo_checks") + modules = sorted(path.stem for path in bin_folder.glob("*.py") if not path.name.startswith("test_")) + return [*(word for package in packages for word in ("-p", package)), *(word for module in modules for word in ("-m", module))] + class Types(unittest.TestCase): - def test_mypy_passes_on_the_tools_for_the_python_running_the_tests(self): + def test_mypy_passes_on_the_tools_for_the_python_readme_install_names(self): + supported = SUPPORTED.search((ROOT / "README.md").read_text(encoding="utf-8")) + self.assertIsNotNone(supported, "README.md's Install names `the latest stable Python, today 3.N`") if shutil.which("uv") is None: self.fail("uv on PATH fetches mypy; see README.md's Test line") - ran = subprocess.run(["uv", "tool", "run", "--python", sys.executable, "mypy==2.3.1", "--cache-dir=/dev/null", "--check-untyped-defs", "--disallow-untyped-defs", "--exclude", "/test_", "-p", "chunk_preflight", "-p", "claude_code", "-m", "comprehension_history", "-m", "git_repo", "-p", "judge_replay", "-p", "larv_review", "-p", "loop_claude", "-m", "markdown_text", "-p", "metric_bench", "-m", "project_key", "-m", "rank_todo", "-p", "reading_cost", "-m", "review_passes", "-p", "review_replay", "-m", "round_titles", "-p", "rule_hook", "-p", "rung_replay", "-p", "score_outcomes", "-m", "settings_filter", "-m", "shell_command", "-m", "statusline", "-p", "subagent_rung", "-m", "todo_table", "-p", "transcript_archive", "-m", "utc_stamp"], capture_output=True, cwd=ROOT / "bin", text=True) + ran = subprocess.run(["uv", "tool", "run", "--python", sys.executable, "mypy==2.3.1", "--python-version", supported.group(1), "--cache-dir=/dev/null", "--check-untyped-defs", "--disallow-untyped-defs", "--exclude", "/test_", *tools()], capture_output=True, cwd=ROOT / "bin", text=True) self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr) + + def test_mypy_checks_run_heavy_and_each_root_module(self): + self.assertLessEqual({("-p", "run_heavy"), ("-p", "machine_load"), ("-m", "chunk_pick"), ("-m", "docker_command")}, set(zip(tools()[::2], tools()[1::2]))) + self.assertNotIn("repo_checks", tools()) diff --git a/docs/decisions.md b/docs/decisions.md index dc0ab570..79d30191 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -16,7 +16,7 @@ Valid while the archive's file names, the Vocabulary and the panel keep these wo ## bin/: the tools support only the latest stable Python, and the tests, written in plain unittest, run once on it in four pytest-xdist workers -2026-10-28, lilleman, through todo item 245. Serves goal 1.5: the suite gates every chunk. It took 198 s, 102 s of which reran it on the oldest Python README Install named, 3.11. README Install now asks for the latest stable Python as `python3`, and mypy checks the tools for the Python running the tests. README's Test line runs the tests in four pytest-xdist workers through `uvx`: 29 s on a 16-CPU machine. Four is one heavy slot's CPUs, `CPUS_PER_SLOT` in `bin/machine_load/slots.py`, so a gate under `run-heavy` loads only the slot it waits for. The line pins pytest and pytest-xdist, as `test_types.py` pins mypy, so every machine runs the gate the same way. It passes the path of `python3`, since `uvx --python python3` picks a Python uv installed itself, which may be older. The tests use stdlib `unittest` alone, and pytest only runs them, so plain `python3 -m unittest` runs the same tests one at a time and another runner can replace pytest. Valid while every machine taking the checkout gets the latest stable Python soon after its release. +2026-10-28, lilleman, through todo item 245. Serves goal 1.5: the suite gates every chunk. It took 198 s, 102 s of which reran it on the oldest Python README Install named, 3.11. README Install now asks for the latest stable Python as `python3`, and mypy checks every tool under `bin/` for the version it names. README's Test line runs the tests in four pytest-xdist workers through `uvx`: 29 s on a 16-CPU machine. Four is one heavy slot's CPUs, `CPUS_PER_SLOT` in `bin/machine_load/slots.py`, so a gate under `run-heavy` loads only the slot it waits for. The line pins pytest and pytest-xdist, as `test_types.py` pins mypy, so every machine runs the gate the same way. It passes the path of `python3`, since `uvx --python python3` picks a Python uv installed itself, which may be older. The tests use stdlib `unittest` alone, and pytest only runs them, so plain `python3 -m unittest` runs the same tests one at a time and another runner can replace pytest. Valid while every machine taking the checkout gets the latest stable Python soon after its release. ## chunks: a chunk takes every unblocked item of its release that fires the same review passes, whatever its purpose, and an item above R 5 ships alone