diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index d39e5bf6..16162449 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -476,6 +476,8 @@ class Plans(unittest.TestCase): self.assertIn("waits", waits.why) self.assertIn("0.2.0", waits.why) self.assertIn("Permission denied", planned(Failure("Permission denied"), CUT, "origin/main").why) + self.assertEqual(planned(Failure("Permission denied"), CUT, "origin/main").why, "origin/main's todo.md cannot be read: Permission denied.") + self.assertEqual(planned(Failure("Permission denied"), CUT, "origin/main", pathlib.Path("/projects/acme/todo.md")).why, "/projects/acme/todo.md cannot be read: Permission denied.") self.assertIn("L 'x'", planned(TODO.replace("| 2 | 2 | 3 | 5 |", "| x | 2 | 3 | 5 |"), CUT, "origin/main").why) self.assertIn("details cannot be read", planned(TODO + "```\n", CUT, "origin/main").text) diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 894d0c39..3139ab43 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -568,6 +568,17 @@ class LarvReviewTool(unittest.TestCase): self.commit("Record a run", {"docs/comprehension-history.md": "# Comprehension history\n\n" + SCORING}) self.assertEqual(self.run_tool("scoring-run-owed").returncode, 0) + def test_reads_the_plan_and_the_decisions_where_the_config_puts_them_outside_the_checkout(self): + self.config.write_text(PROJECT_CONFIG.replace("checkout:todo.md", "folder:todo.md").replace("checkout:docs/decisions.md", "folder:decisions.md")) + row = "| 1 | 0.1.0 | | **Do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |" + (self.config.parent / "todo.md").write_text(todo(row, "| 2 | 0.2.0 | | **Reach the comprehension floor: do it.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |")) + due = self.run_tool("needs-scoring-run", "2") + self.assertEqual(due.returncode, 0, due.stderr) + self.assertTrue(due.stdout.startswith("Scoring run due:"), due.stdout) + self.assertIn("floor", due.stdout) + (self.config.parent / "decisions.md").write_text("# Decisions\n\n## review opt-out: the comprehension check\n\nServes goal 1.\n") + self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n") + ROW = "| 3 | 0.2.0 | | **And this.** | 1 | 1 | 3 | 1 | 1 | 1 | 9.0 |" def ship_item_1(self): diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 1b51eef8..ce636778 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1286,6 +1286,10 @@ class RouteSources(unittest.TestCase): config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"')) (folder / "todo.md").write_text(TODO) self.assertEqual(chunk_start.fetched_todo(loop), TODO) + unread = Failure("no git") + standing = a_loop(FakeEffects(git=["origin\n", "origin/main\n", unread, unread, unread, unread]).effects(), root=root, paths=paths.paths_from(folder.parents[1])) + held = chunk_start.fetched_plan(standing) + self.assertEqual((held.todo, held.cut.todos_since, held.cut.changelog), (TODO, [], ""), "the plan as it stands, whatever git answers") config.unlink() with contextlib.redirect_stderr(io.StringIO()) as stderr: self.assertIn("no config names the checkout", chunk_start.fetched_todo(loop).reason) diff --git a/bin/release_plan/test_release_standing.py b/bin/release_plan/test_release_standing.py index c6f64a72..63b56844 100644 --- a/bin/release_plan/test_release_standing.py +++ b/bin/release_plan/test_release_standing.py @@ -230,7 +230,25 @@ class ChunkItem(unittest.TestCase): self.assertEqual(held.todo, plan) self.assertEqual(held.cut, release_standing.LastCut(None, "# Changelog\n\n## 0.1.0 - 2026-10-03\n", 1, [plan], False)) (folder / "todo.md").write_bytes(b"\xff") - self.assertIsInstance(release_standing.default_plan(repo, "main", folder / "todo.md", "CHANGELOG.md").todo, Failure) + unreadable = release_standing.default_plan(repo, "main", folder / "todo.md", "CHANGELOG.md") + assert isinstance(unreadable.todo, Failure) and isinstance(unreadable.cut.todos_since, Failure), unreadable + self.assertTrue(unreadable.todo.reason.startswith(f"cannot read {folder}/todo.md: "), unreadable.todo.reason) + self.assertEqual(unreadable.cut.todos_since, unreadable.todo) + + def test_reads_the_checkout_only_through_the_git_it_is_given(self): + repo = tempfile.mkdtemp() + self.addCleanup(subprocess.run, ["rm", "-rf", repo]) + run = lambda *args: subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@t", *args], capture_output=True, check=True, cwd=repo, env=isolated_env(), text=True) + run("init", "-q", "-b", "main") + plan = HEADER + ROW.format(id=1, release="0.2.0") + pathlib.Path(repo, "todo.md").write_text(plan) + pathlib.Path(repo, "CHANGELOG.md").write_text("# Changelog\n\n## 0.1.0 - 2026-10-03\n") + run("add", ".") + run("commit", "-q", "-m", "Cut 0.1.0") + # Only this git knows where the checkout is, so a read that goes round it fails. + there = lambda *args, cwd: release_standing.git(*args, cwd=repo) + held = release_standing.default_plan("/nowhere", "main", "todo.md", "CHANGELOG.md", there) + self.assertEqual(held, release_standing.DefaultPlan(plan, release_standing.LastCut(None, "# Changelog\n\n## 0.1.0 - 2026-10-03\n", 0, [plan], False))) def test_counts_the_changes_unreleased_since_the_last_cut_by_unreleased_entries_and_else_by_commits(self): changelog = "# Changelog\n\n## Unreleased\n\n- One.\n - A nested line.\n- Two.\n\n## 0.1.0\n\n- Old.\n" diff --git a/bin/routing_figures/test_routing_figures.py b/bin/routing_figures/test_routing_figures.py index 0ac292a6..3f002460 100644 --- a/bin/routing_figures/test_routing_figures.py +++ b/bin/routing_figures/test_routing_figures.py @@ -18,6 +18,7 @@ from routing_figures import archive, state from branch_chunks.cut import BranchChunk from routing_figures.calls import Call, calls, totals from routing_figures.chunk import Chunk, chunk_figures, ChunkFigures, Reports, Subagent +from project_config.test_project_config import configured from routing_figures.state import due from claude_code.entries import entry_from from failure import Failure @@ -302,6 +303,17 @@ class Calls(unittest.TestCase): self.assertTrue(due(20, 0)) +class BranchHistory(unittest.TestCase): + def test_counts_no_chunk_of_a_project_whose_plan_is_outside_the_checkout(self): + checkout = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())).resolve() + folder = configured(self, checkout) + config = folder / "config.toml" + config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"')) + found = archive.branch_history(str(checkout), folder.parents[1], git_repo.git) + assert isinstance(found, Failure), found + self.assertEqual(found.reason, f"its chunks' items and later fixes are not counted: the project's config puts {folder}/todo.md elsewhere than todo.md, docs/comprehension-history.md, docs/reading-cost.md in the checkout, the only paths whose commits are read so far") + + class Archive(unittest.TestCase): def setUp(self): self.root = pathlib.Path(tempfile.mkdtemp()) diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index 29185874..be96531c 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -898,6 +898,10 @@ class TodoRankCheck(unittest.TestCase): def test_a_checkout_of_the_hooks_repo_runs_its_own_rank_todo(self): checkout = self.changed_plan(f"{self.folder}/clone", self.STUB) self.assertEqual(self.details(checkout), [f"own script checked {checkout}/todo.md"]) + top = str(pathlib.Path(checkout).resolve()) + self.assertEqual([(breach.rule, breach.directory) for breach in todo_breaches(checkout, pathlib.Path(self.own))], [("todo-rank-check", top)]) + self.config.unlink() + self.assertEqual([(breach.rule, breach.directory) for breach in todo_breaches(checkout, pathlib.Path(self.own))], [("todo-rank-check", top)], "a todo.md with no config") def test_its_own_rank_todo_passing_passes(self): self.assertEqual(self.details(self.changed_plan(f"{self.folder}/clone", "")), [])