diff --git a/.gitignore b/.gitignore index e39d52e3..d33fdeaf 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ !bin/reading_cost/*.py !bin/repo_checks/ !bin/repo_checks/*.py +!bin/review_folder.py !bin/round_titles.py !bin/rule-hook !bin/routing_figures/ diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 3f7d755e..0bb425d2 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -467,6 +467,11 @@ class LarvReviewTool(unittest.TestCase): self.assertEqual(ran.returncode, 1) self.assertIn("could not make the review folder", ran.stderr) + def test_review_folder_fails_outside_a_checkout(self): + ran = subprocess.run([sys.executable, str(TOOL), "review-folder"], capture_output=True, cwd=self.checkout.parent, env=self.env, text=True) + self.assertEqual(ran.returncode, 1) + self.assertNotIn("Traceback", ran.stderr) + def test_review_folder_takes_no_arguments(self): self.assertIn("unknown arguments", self.run_tool("review-folder", "x").stderr) diff --git a/bin/repo_checks/test_gitignore.py b/bin/repo_checks/test_gitignore.py index ce70ee45..7b704a0f 100644 --- a/bin/repo_checks/test_gitignore.py +++ b/bin/repo_checks/test_gitignore.py @@ -41,6 +41,10 @@ class Gitignore(unittest.TestCase): ignored = subprocess.run(["git", "ls-files", "-ci", "--exclude-standard"], capture_output=True, check=True, cwd=ROOT, text=True).stdout self.assertEqual(ignored, "") + def test_ignores_no_python_module_or_test_under_bin(self): + ignored = subprocess.run(["git", "ls-files", "-oi", "--exclude-standard", "--", "bin/*.py", "bin/**/*.py"], capture_output=True, check=True, cwd=ROOT, text=True).stdout + self.assertEqual(ignored, "") + def test_ignores_every_private_file(self): ignored = subprocess.run(["git", "check-ignore", "--no-index", "--stdin"], capture_output=True, cwd=ROOT, input="\n".join(PRIVATE), text=True).stdout self.assertEqual(ignored.splitlines(), PRIVATE) diff --git a/bin/review_folder.py b/bin/review_folder.py new file mode 100644 index 00000000..46089c24 --- /dev/null +++ b/bin/review_folder.py @@ -0,0 +1,11 @@ +"""The chunk's review folder, where each reviewer writes its report: skills/larv-review/SKILL.md → "Reports".""" +import os + +# Under the home folder: outside every checkout, so no project sees a report; kept across a reboot, so a resumed chunk still reads its rounds. A fixed path, since a headless session has no scratchpad. +REPORTS = ".local/state/larv-review" + + +def review_folder(home: str, worktree: str) -> str: + """The review folder of the chunk whose worktree is at worktree: its path relative to home, or to / outside it, under REPORTS.""" + inside = worktree.startswith(home.rstrip("/") + "/") + return os.path.join(home, REPORTS, os.path.relpath(worktree, home) if inside else worktree.lstrip("/")) diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index 486e1b07..1e1067be 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -417,4 +417,4 @@ class Hook(unittest.TestCase): self.assertIn(f" {rule}\n The rule: ", helped) self.assertIn("reviewer-report\n The rule: a reviewer writes nothing but its report", helped) self.assertRegex(helped, r" reviewer-report\n( .*\n){2} Takes no override\.\n") - self.assertRegex(helped, r" image-pin\n( .*\n){2} ", "a rule a marker waives says nothing of overrides") + self.assertRegex(helped, r" image-pin\n( .*\n){2} \S", "a rule a marker waives says nothing of overrides") diff --git a/bin/stability_replay/test_stability_replay.py b/bin/stability_replay/test_stability_replay.py index 2d86e469..f623a09a 100644 --- a/bin/stability_replay/test_stability_replay.py +++ b/bin/stability_replay/test_stability_replay.py @@ -266,6 +266,15 @@ class Main(unittest.TestCase): self.assertEqual(sorted(path.name for path in folder.iterdir()), ["prose-round-1.md", "stability-round-1.md", "stability-round-2.md"]) self.assertEqual((folder / "stability-round-2.md").read_text(), "🔴 a.txt:1 wrong\n") + def test_points_the_review_folders_absolute_path_at_the_copy(self): + folder = self.review_folder_with_round_1() + self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to {folder}/stability-round-2.md.") + code, _, err = self.run_main(["claude-opus-5-5"], lambda rung: {"found": [0, 1]}) + self.assertEqual(code, 0, err) + prompt = self.reviews[0][4] + self.assertNotIn(str(folder), prompt) + self.assertRegex(prompt, rf"report to {folder.parents[1]}/stability-replay-\w+/stability-round-2\.md\.$") + def test_replays_no_round_whose_prompt_still_names_the_review_folder_after_the_rewrite(self): self.review_folder_with_round_1() self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to $HOME/.local/state/larv-review/code/proj-x/stability-round-2.md.")