diff --git a/README.md b/README.md index 3b5caed1..c23cfa32 100644 --- a/README.md +++ b/README.md @@ -240,9 +240,9 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a ## Test -Test on the host with `bin/run-tests`, which runs pytest through `uvx`, pinned in `bin/run_tests/main.py`. It prints each failing test with its error and pytest's summary line, and saves the whole output to a file whose path it prints. It passes on any test paths or pytest options it is given, such as `bin/run-tests bin/chunk_pr -x`. It needs `uv` on `PATH`, which fetches pytest, pytest-xdist and mypy. pytest-xdist runs the tests in one worker per CPU of a heavy slot (`docs/decisions.md` → `bin/: the tools support only the latest stable Python, …`). `python3 -m unittest discover -s bin -p 'test_*.py'` runs the same tests one at a time. Test the bench's scripts with `python3 -m unittest discover -s workflow-bench -p 'test_*.py'`. +Test on the host with `bin/run-tests`, which runs pytest through `uvx`, pinned in `bin/run_tests/main.py`. It prints each failing test with its error and pytest's summary line, and saves the whole output to a file whose path it prints. It passes on any test paths or pytest options it is given, such as `bin/run-tests bin/chunk_pr -x`. It needs `uv` on `PATH`, which fetches pytest, pytest-xdist and mypy, a Docker daemon, Linux, and a user other than root; a test that lacks one fails, naming it. pytest-xdist runs the tests in one worker per CPU of a heavy slot (`docs/decisions.md` → `bin/: the tools support only the latest stable Python, …`). `python3 -m unittest discover -s bin -p 'test_*.py'` runs the same tests one at a time, with the same needs. Test the bench's scripts with `python3 -m unittest discover -s workflow-bench -p 'test_*.py'`. -CI runs `ci.sh` on every pull request, and `main` doesn't merge anything until it passes. The script runs the same tests on the committed HEAD in a pinned Python container; run it under `run-heavy` to reproduce a CI failure, with Docker on `PATH`. +CI runs `ci.sh` on every pull request, and `main` doesn't merge anything until it passes. The script runs the same tests on the committed HEAD in a pinned Python container. Run it under `run-heavy` to reproduce a CI failure, with Docker on `PATH` and its socket at `/var/run/docker.sock`, which the container shares. To mutation-test the lines a branch changes, run `~/.claude/bin/run-heavy ~/.claude/bin/mutate-changes --prefix 'uvx --python "$(command -v python3)" --with pytest==9.2.0 --from "mutmut>=3,<4"'` in its checkout. diff --git a/bin/adf_codec/test_adf_codec.py b/bin/adf_codec/test_adf_codec.py index b264cc24..c1f79f42 100644 --- a/bin/adf_codec/test_adf_codec.py +++ b/bin/adf_codec/test_adf_codec.py @@ -1,7 +1,6 @@ import contextlib import json import os -import shutil import subprocess import pytest @@ -296,10 +295,10 @@ def test_container_run_passes_an_image_failure_through(tmp_path): assert convert.container_run("to-adf", "text", scripted(down), shim_dir(tmp_path)) == down -@pytest.mark.skipif(shutil.which("docker") is None or subprocess.run(["docker", "info"], capture_output=True, timeout=20).returncode != 0, reason="needs a docker daemon") def test_round_trip_through_the_real_container(): doc = convert.markdown_to_adf("# Title\n\nSome **bold** text.\n") - assert isinstance(doc, dict) and doc["type"] == "doc" and doc["content"][0]["type"] == "heading" + assert isinstance(doc, dict), doc + assert doc["type"] == "doc" and doc["content"][0]["type"] == "heading" markdown = convert.adf_to_markdown(doc) assert isinstance(markdown, str) and markdown.startswith("# Title") and "**bold**" in markdown refused = convert.adf_to_markdown({"type": "nope"}) @@ -324,10 +323,9 @@ JIRA_DESCRIPTION = { } -@pytest.mark.skipif(shutil.which("docker") is None or subprocess.run(["docker", "info"], capture_output=True, timeout=20).returncode != 0, reason="needs a docker daemon") def test_the_lossless_pair_gives_back_a_jira_description_identical_and_the_portable_pair_does_not(): markdown = convert.adf_to_markdown_lossless(JIRA_DESCRIPTION) - assert isinstance(markdown, str) + assert isinstance(markdown, str), markdown assert convert.markdown_to_adf_lossless(markdown) == JIRA_DESCRIPTION assert convert.adfs_to_markdown_lossless([JIRA_DESCRIPTION, JIRA_DESCRIPTION]) == [markdown, markdown] portable = convert.markdown_to_adf(convert.adf_to_markdown(JIRA_DESCRIPTION)) diff --git a/bin/loop_claude/test_black_box.py b/bin/loop_claude/test_black_box.py index ff4fdb3d..8e26f551 100644 --- a/bin/loop_claude/test_black_box.py +++ b/bin/loop_claude/test_black_box.py @@ -18,7 +18,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from test_env import isolated_env +from test_env import assert_not_root, isolated_env from project_config.test_project_config import write_config BIN = pathlib.Path(__file__).resolve().parents[1] @@ -753,8 +753,8 @@ class Cycles(unittest.TestCase): self.assertIn("past the noise", run.stdout) self.assertIn("past the noise", run.calls[1]["stdin"]) - @unittest.skipIf(os.geteuid() == 0, "root reads an unreadable file") def test_exits_1_when_the_transcript_cannot_be_read(self): + assert_not_root(self) checkout = Checkout(self) run = checkout.run([worker(unreadable=True)]) self.assertEqual((run.code, run.roles()), (1, ["worker"])) @@ -1000,8 +1000,8 @@ class Interrupt(unittest.TestCase): self.assertFalse(run.calls[2]["ctrl_c_ignored"]) self.assertIn("[human] B", run.calls[3]["stdin"]) - @unittest.skipIf(os.geteuid() == 0, "root reads an unreadable file") def test_exits_1_when_the_transcript_cannot_be_read_after_the_interrupt(self): + assert_not_root(self) checkout = Checkout(self) run = checkout.run([worker(say="A or B?"), judge(interrupt=True, evidence="A or B?", question="A or B?"), interrupt(type="B", unreadable=True)], terminal_input="/talk\n", before_typing=ANSWERING) self.assertEqual((run.code, run.roles()), (1, ["worker", "judge", "interrupt"])) @@ -1082,8 +1082,8 @@ class Models(unittest.TestCase): self.assertIn("no model catalog cached", run.stderr) self.assertEqual(argument(run.calls[0], "--model"), "1") - @unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory") def test_exits_1_when_the_models_file_cannot_be_written(self): + assert_not_root(self) checkout = Checkout(self) del checkout.env["LOOP_CLAUDE_JUDGE_MODEL"], checkout.env["LOOP_CLAUDE_WORKER_MODEL"] checkout.models_file().parent.mkdir(parents=True, mode=0o500) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 873ae18d..0b93fd86 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -19,6 +19,7 @@ import uuid sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from routing_figures import archive, state +from test_env import assert_not_root from claude_code.output_limits import BASH_CEILING_CHARACTERS from routing_figures.calls import Call from loop_claude.project import checkout, model_choice, records @@ -519,8 +520,8 @@ Spent since 2026-09-21T14:13:20Z, in tokens of input, cache write 5m, cache writ [next_chunk] = set(self.archive.iterdir()) - {chunk} self.assertEqual(sorted(path.read_text() for path in (next_chunk / "session" / str(self.session.id)).glob("custom-title.json*")), ["third"]) - @unittest.skipIf(os.geteuid() == 0, "root reads an unreadable folder") def test_stops_on_a_session_folder_it_cannot_read_whole(self): + assert_not_root(self) locked = self.paths.claude_code_transcripts / "-fake" / str(self.session.id) / "subagents" locked.mkdir(parents=True) locked.chmod(0) @@ -689,8 +690,8 @@ Spent since 2026-09-21T14:13:20Z, in tokens of input, cache write 5m, cache writ self.assertIn(f"\n{STAMP} Which one?\a\n", said.getvalue()) self.assertNotIn("Use ... A.", said.getvalue()) - @unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory") def test_stops_keeping_the_transcript_when_the_finished_chunks_session_cannot_be_deleted(self): + assert_not_root(self) folder = self.paths.claude_code_transcripts / "-fake" / str(self.session.id) (folder / "subagents").mkdir(parents=True) folder.chmod(0o500) @@ -967,8 +968,8 @@ class RoutingCheck(unittest.TestCase): stop, _ = self.check(FakeEffects(on_terminal_claude=[OSError(2, "No such file or directory")], git=[UNREAD] * 3)) self.assertEqual(stop, Stop(1, f"could not start claude for the routing calls in {self.home / 'code' / 'claude-config'}, the setup's development clone: No such file or directory")) - @unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory") def test_says_a_figure_it_cannot_write_and_goes_on(self): + assert_not_root(self) self.chunks(5, 4) (self.root / "routing-figures.lock").touch() self.root.chmod(0o555) diff --git a/bin/plan/test_touches.py b/bin/plan/test_touches.py index d0e0b18d..75966665 100644 --- a/bin/plan/test_touches.py +++ b/bin/plan/test_touches.py @@ -1,6 +1,4 @@ import pathlib -import shutil -import subprocess import sys import unittest @@ -22,9 +20,6 @@ Touches: More prose, with `bin/b.py` named. """ -needs_docker = unittest.skipIf(shutil.which("docker") is None or subprocess.run(["docker", "info"], capture_output=True, timeout=20).returncode != 0, "adf_codec runs in a container, which needs a docker daemon") - - def text(words: str, code: bool = False) -> dict: return {"type": "text", "text": words, **({"marks": [{"type": "code"}]} if code else {})} @@ -90,15 +85,14 @@ class PredictedTest(unittest.TestCase): def test_a_longer_run_with_a_space_at_one_end_only_keeps_it(self) -> None: self.assertEqual(predicted("Touches:\n- `a.md`: `` x``, ``y ``, `` a ``\n"), {"a.md": (Part(" x"), Part("y "), Part("a"))}) - @needs_docker def test_a_list_written_in_markdown_and_read_back_from_a_jira_description_reads_as_written(self) -> None: description = convert.markdown_to_adf(DETAIL) - assert isinstance(description, dict) + assert isinstance(description, dict), description self.assertEqual(predicted(convert.adf_to_markdown(description)), predicted(DETAIL)) - @needs_docker def test_a_list_typed_in_jiras_editor_reads_as_its_files_and_parts(self) -> None: read = convert.adf_to_markdown(JIRA_TOUCHES) + assert isinstance(read, str), read self.assertEqual(predicted(read), { "bin/a.py": (Part("main"), Part("Plan.branch", small=True)), "a`b.md": (Part("## The `foo` tool", small=True), Part("`x`")), diff --git a/bin/plan_store/test_stores.py b/bin/plan_store/test_stores.py index 755d6c9e..af711edb 100644 --- a/bin/plan_store/test_stores.py +++ b/bin/plan_store/test_stores.py @@ -1,6 +1,5 @@ import dataclasses import decimal -import os import pathlib import sys import tempfile @@ -8,6 +7,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) +from test_env import assert_not_root from project_config.settings import DEFAULT_FLOOR, Epic, Finish, JiraScoring, ProjectConfig, SETTINGS from failure import Failure from record_store.stores import FileStore, goals_store, store as record_store @@ -136,8 +136,8 @@ class FilePlan(FilePlanContract): self.assertEqual(store.edit(id_, {}, "### Why\n"), Failure(split)) self.assertEqual((self.folder / "todo.md").read_text(), before) - @unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory") def test_a_file_it_cannot_write_fails_naming_it(self): + assert_not_root(self) store = self.new_store() self.folder.chmod(0o555) self.addCleanup(self.folder.chmod, 0o755) diff --git a/bin/routing_figures/test_routing_figures.py b/bin/routing_figures/test_routing_figures.py index 71d90647..61803e64 100644 --- a/bin/routing_figures/test_routing_figures.py +++ b/bin/routing_figures/test_routing_figures.py @@ -15,6 +15,7 @@ import unittest.mock sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from routing_figures import archive, state +from test_env import assert_not_root, isolated_env from project_config.templates import BARE, Titles from branch_chunks.cut import BranchChunk from routing_figures.calls import Call, calls, totals @@ -25,7 +26,6 @@ from routing_figures.state import due from claude_code.entries import entry_from from failure import Failure from git_cli import git_repo -from test_env import isolated_env from plan.todo_table import Item from transcript_archive import outcomes, write from model_routing.ladder_file import read_ladder, SHIPPED @@ -495,8 +495,8 @@ class Archive(unittest.TestCase): self.assertIsNone(state.mark_raised(self.root, [a], "2026-10-15T02:00:00Z")) self.assertEqual(state.raised(self.root), state.Raised("2026-10-15T01:00:00Z", frozenset({a}))) - @unittest.skipIf(os.geteuid() == 0, "root writes into a read-only directory") def test_fails_when_it_cannot_keep_the_state(self): + assert_not_root(self) self.root.chmod(0o555) self.addCleanup(self.root.chmod, 0o755) self.assertIsInstance(state.mark_measured(self.root, 40), Failure) diff --git a/bin/run_heavy/test_run_heavy.py b/bin/run_heavy/test_run_heavy.py index f028d6b7..c64b55b7 100644 --- a/bin/run_heavy/test_run_heavy.py +++ b/bin/run_heavy/test_run_heavy.py @@ -94,8 +94,7 @@ class RunHeavy(unittest.TestCase): def test_a_docker_run_without_limits_gets_three_quarters_of_the_memory_split_across_the_slots(self): memory = read_memory() - if memory is None: - self.skipTest("no /proc/meminfo to read the share from") + assert memory is not None, "this test needs MemTotal and MemAvailable from /proc/meminfo: run it on Linux" share = f"{memory.total * 3 // 4 // slot_count(usable_cpus()) // 1024}m" result = self.run_tool("docker", "run", "--rm", "img", "true", env=self.fake_docker()) self.assertEqual((result.returncode, result.stdout), (0, f"run --memory {share} --memory-swap {share} --rm img true\n")) diff --git a/bin/run_tests/test_run_tests.py b/bin/run_tests/test_run_tests.py index 139f316e..538385b1 100644 --- a/bin/run_tests/test_run_tests.py +++ b/bin/run_tests/test_run_tests.py @@ -1,5 +1,4 @@ import contextlib -import importlib.util import io from unittest import mock import os @@ -14,10 +13,8 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from run_tests import main BIN = pathlib.Path(__file__).resolve().parents[1] -# The suite runs under pytest, and `python3 -m unittest` may run it where pytest is not installed. -HAS_PYTEST = importlib.util.find_spec("pytest") is not None -HAS_XDIST = importlib.util.find_spec("xdist") is not None -PYTEST_HERE = [sys.executable, "-m", "pytest", "-p", "no:cacheprovider"] +# run-tests' own pytest command, without its worker count. uvx fetches pytest for it, so the Run tests need no pytest installed. +PYTEST_PINNED = [*main.PYTEST[:main.PYTEST.index("-n")], "-p", "no:cacheprovider"] class PytestArgs(unittest.TestCase): @@ -109,7 +106,6 @@ class RunWithAStandIn(unittest.TestCase): self.assertEqual(err.getvalue(), "run-tests: cannot start /no/such/uvx: No such file or directory\n") -@unittest.skipUnless(HAS_PYTEST, "needs pytest importable") class Run(unittest.TestCase): def run_in(self, folder: str, pytest: list[str], *args: str) -> tuple[int, str]: out = io.StringIO() @@ -127,8 +123,8 @@ class Run(unittest.TestCase): def test_a_passing_run_prints_the_summary_line_and_the_log_path(self): with tempfile.TemporaryDirectory() as folder: pathlib.Path(folder, "test_ok.py").write_text("def test_ok():\n\tprint('noise from a passing test')\n") - code, output = self.run_in(folder, PYTEST_HERE, "-s", folder) - self.assertEqual(code, 0) + code, output = self.run_in(folder, PYTEST_PINNED, "-s", folder) + self.assertEqual(code, 0, output) lines = output.rstrip("\n").splitlines() self.assertEqual(len(lines), 2, output) self.assertRegex(lines[0], r"^=+ 1 passed in .* =+$") @@ -136,10 +132,9 @@ class Run(unittest.TestCase): def test_a_failing_run_prints_each_failing_test_with_its_error(self): # pytest-xdist drops the error from the short summary's lines, so the run takes it from the FAILURES section. - workers = ["-n", "2"] if HAS_XDIST else [] with tempfile.TemporaryDirectory() as folder: pathlib.Path(folder, "test_bad.py").write_text("def test_ok():\n\tpass\n\ndef test_bad():\n\tassert 1 == 2, 'one is not two'\n\ndef test_long():\n\traise ValueError('\\n'.join(map(str, range(30))))\n") - code, output = self.run_in(folder, PYTEST_HERE, *workers, folder) + code, output = self.run_in(folder, PYTEST_PINNED, "-n", "2", folder) self.assertEqual(code, 1) self.assertRegex(output, r"(?m)^_+ test_bad _+\nE +AssertionError: one is not two\n(E .*\n)*.*test_bad\.py:5: AssertionError$") self.assertRegex(output, r"(?m)^FAILED .*test_bad\.py::test_bad\b") @@ -158,7 +153,7 @@ class Run(unittest.TestCase): def test_a_run_that_prints_no_summary_line_shows_the_logs_last_lines(self): with tempfile.TemporaryDirectory() as folder: - code, output = self.run_in(folder, PYTEST_HERE, "--no-such-option", folder) + code, output = self.run_in(folder, PYTEST_PINNED, "--no-such-option", folder) self.assertEqual(code, 1) self.assertIn("run-tests: pytest printed no summary line; the log ends:", output) self.assertIn("--no-such-option", output) diff --git a/bin/test_env.py b/bin/test_env.py index 528ac255..09106e0d 100644 --- a/bin/test_env.py +++ b/bin/test_env.py @@ -1,7 +1,13 @@ import os +import unittest # A git hook's GIT_DIR, the host's LOOP_CLAUDE_* or PYTHONPATH would point the program under test at the host's own state, # and the host's CLAUDE_CODE_SANDBOXED would hide whether loop-claude sets it. def isolated_env() -> dict[str, str]: return {name: value for name, value in os.environ.items() if not name.startswith(("GIT_", "LOOP_CLAUDE_", "PYTHON")) and name != "CLAUDE_CODE_SANDBOXED"} + + +# Call it first in a test that takes a file's or a folder's permissions away. +def assert_not_root(test: unittest.TestCase) -> None: + test.assertNotEqual(os.geteuid(), 0, "root ignores file permissions, which this test checks: run the tests as a user other than root") diff --git a/ci.sh b/ci.sh index d9ddcd76..1551c2bc 100755 --- a/ci.sh +++ b/ci.sh @@ -1,10 +1,15 @@ #!/bin/sh -# Runs the test suite on the committed HEAD as CI does: in a pinned Python container, as the caller's uid, so the tests that skip under root still run. +# Runs the test suite on the committed HEAD as CI does: in a pinned Python container, as the caller's uid, since root ignores file permissions and the tests that check them would fail. # It is sh, not Python, since it runs on the CI runner's host, which needs only git and docker. -# The repo goes in as a git bundle rather than a bind mount, so the script works whether the CI runner shares the docker daemon's filesystem or not. +# The repo goes in as a git bundle rather than a bind mount, so the runner need not share the docker daemon's filesystem. +# The adf-codec tests, which convert Jira descriptions, start a container of their own. So the test container holds a docker client and the daemon's socket. +# The daemon mounts the socket from its own host, while stat reads its group on the runner: both need it at /var/run/docker.sock. set -eu cd "$(dirname "$0")" -git bundle create - HEAD | docker run --rm -i --memory 4g --memory-swap 4g --user "$(id -u):$(id -g)" -e HOME=/tmp python:3.14.8 sh -euc ' +socket=/var/run/docker.sock +# An untagged image, which docker image prune removes, since a cancelled run skips any cleanup. +image=$(printf 'FROM docker:29.1.3-cli AS docker\nFROM python:3.14.8\nCOPY --from=docker /usr/local/bin/docker /usr/local/bin/docker\n' | docker build --quiet --memory 1g --memory-swap 1g -) +git bundle create - HEAD | docker run --rm -i --memory 4g --memory-swap 4g --user "$(id -u):$(id -g)" --group-add "$(stat -c %g "$socket")" -v "$socket:$socket" -e HOME=/tmp "$image" sh -euc ' cat >/tmp/head.bundle git -c init.defaultBranch=main -c advice.detachedHead=false clone --quiet /tmp/head.bundle /tmp/repo cd /tmp/repo diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 1c136508..97294917 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -2725,3 +2725,47 @@ Read most (opens and searches): - `bin/loop_claude/test_loop_claude.py` 2 - `bin/review_replay/main.py` 2 - `bin/rule_hook/main.py` 2 + +## Reading cost, chunk 755c22e12ace, finished 2026-11-18T16:10:53Z + +114613 new input tokens before the first commit. + +Read most (opens and searches): + +- `bin/plan/ranking.py` 6 +- `bin/plan_store/jira_epic.py` 5 +- `rules/todo-items.md` 4 +- `bin/plan/goals_file.py` 2 +- `bin/do_epic/backend/jira.py` 1 +- `bin/do_epic/backend/protocol.py` 1 +- `bin/do_epic/config.py` 1 +- `bin/plan/blockers.py` 1 +- `bin/plan/todo_table.py` 1 +- `docs/decisions.md` 1 + +## Reading cost, chunk 5178e8fcc756, finished 2026-11-18T16:16:09Z + +240957 new input tokens before the first commit. + +Read most (opens and searches): + +- `bin/loop_claude/test_loop_claude.py` 11 +- `README.md` 6 +- `bin/agent_cycle/routing.py` 3 +- `docs/decisions.md` 3 +- `.gitignore` 2 +- `bin/agent_cycle/test_quotes.py` 2 +- `bin/loop_claude/cycle/__init__.py` 2 +- `bin/loop_claude/cycle/prompts.py` 2 +- `bin/loop_claude/loop/main.py` 2 +- `ci.sh` 2 + +## Reading cost, chunk 26709555b08d, finished 2026-11-18T16:28:37Z + +50266 new input tokens before the first commit. + +Read most (opens and searches): + +- `principles/technical-principles.md` 2 +- `README.md` 1 +- `agents/stability-reviewer.md` 1 diff --git a/todo.md b/todo.md index 98e56fb8..1d48eaca 100644 --- a/todo.md +++ b/todo.md @@ -12,7 +12,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| -| 428 | 0.12.0 | | principle | **Make each test that skips at run time create the state it needs or fail naming what is missing, so no test in the repo skips at run time.** | 3 | 2 | 1 | 4 | 4 | code health by 3, 1.1 by 3 | 4.8 | | 426 | 0.12.0 | | | **Read each epic issue's scores, its blockers and whether the loop filed it through `EpicStore`, from both backends.** | 2 | 2 | 2 | 4 | 3 | 1 by 5 | 1.9 | | 427 | 0.12.0 | 426 | | **Re-rank Jira's backlog to match an epic's ranking, moving only the issues the loop filed, so people's issues keep their rank.** | 3 | 2 | 3 | 6 | 3 | 1 by 5 | 1.9 | | 410 | 0.12.0 | 427 | | **Run `do-epic `: one tmux session per epic, a window per chunk, up to the epic's cap of running chunks and each repo's `parallel-chunks`, and never in a repo a loop-claude is running chunks in.** | 3 | 2 | 3 | 6 | 6 | 1 by 5 | 0.8 | @@ -83,29 +82,6 @@ ## Details -### 428. Make each test that skips at run time create the state it needs or fail naming what is missing, so no test in the repo skips at run time. - -Follows item 400's bullet in `principles/technical-principles.md` → the tests principle: "A test doesn't decide at run time whether to check anything: no conditional skip, early return, or catch around its assertions. A test that needs a state creates it, or fails and names what is missing." Stability review found the repo's own tests break it in 13 places, each a skip decided at run time: - -- root-less permission checks, `skipIf(os.geteuid() == 0, ...)`: 3 in `bin/loop_claude/test_black_box.py`, 3 in `bin/loop_claude/test_loop_claude.py`, 1 in `bin/routing_figures/test_routing_figures.py`, 1 in `bin/plan_store/test_stores.py`; -- pytest: `skipUnless(HAS_PYTEST, ...)` on the class `Run` in `bin/run_tests/test_run_tests.py`; -- docker: the `docker info` skipif on 2 tests in `bin/adf_codec/test_adf_codec.py`, and `needs_docker` in `bin/plan/test_touches.py`; -- /proc: `self.skipTest("no /proc/meminfo ...")` in `bin/run_heavy/test_run_heavy.py`. - -The choice per case is the implementer's: for example, run the permission tests as a non-root user or drop the permission check in favour of an injected failure, take the docker or /proc state from an injected fake, or let the test fail naming what is missing. Done when a grep for `skipIf`, `skipUnless`, `skipTest` and `mark.skip` in the repo's tests finds none. - -Touches: - -- `bin/loop_claude/test_black_box.py`: `Cycles.test_exits_1_when_the_transcript_cannot_be_read`, `Interrupt.test_exits_1_when_the_transcript_cannot_be_read_after_the_interrupt`, `Models.test_exits_1_when_the_models_file_cannot_be_written` -- `bin/loop_claude/test_loop_claude.py`: `Cycles.test_stops_on_a_session_folder_it_cannot_read_whole`, `Cycles.test_stops_keeping_the_transcript_when_the_finished_chunks_session_cannot_be_deleted`, `RoutingCheck.test_says_a_figure_it_cannot_write_and_goes_on` -- `bin/routing_figures/test_routing_figures.py`: `Archive.test_fails_when_it_cannot_keep_the_state` (small) -- `bin/plan_store/test_stores.py`: `FilePlan.test_a_file_it_cannot_write_fails_naming_it` (small) -- `bin/run_tests/test_run_tests.py`: `HAS_PYTEST`, `Run` (small) -- `bin/adf_codec/test_adf_codec.py`: `test_round_trip_through_the_real_container`, `test_the_lossless_pair_gives_back_a_jira_description_identical_and_the_portable_pair_does_not` -- `bin/plan/test_touches.py`: `needs_docker`, `PredictedTest.test_a_list_written_in_markdown_and_read_back_from_a_jira_description_reads_as_written`, `PredictedTest.test_a_list_typed_in_jiras_editor_reads_as_its_files_and_parts` -- `bin/run_heavy/test_run_heavy.py`: `RunHeavy.test_a_docker_run_without_limits_gets_three_quarters_of_the_memory_split_across_the_slots` (small) -- `bin/machine_load/memory.py`: `read_memory` (small) - ### 426. Read each epic issue's scores, its blockers and whether the loop filed it through `EpicStore`, from both backends. Today `EpicIssue` holds none of the three, so do-epic cannot score or order an epic's items (item 408) or tell a person's issue from its own (item 427). The Jira backend reads them as `plan_store/jira_epic.py` does: the `plan-item` issue property, its `Filed by` key, and the "is blocked by" links. The contract tests in `contract.py` cover both backends.