feat: review_only input and an enumeration check in the monthly prompt
tests / unittest (push) Successful in 23s

review_only names listed documents the drafter may read but not edit. They stay
in stage 1, are listed separately in the prompt, and a change to one fails the
run like a change outside docs. Each entry must match a docs pattern.

The monthly prompt now makes checking every list and count in the top-level
documents against the repository the drafter's main job. Mode-specific text
moves to prompts/mode-pr.md and prompts/mode-monthly.md; the pr text is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-12 15:40:09 -05:00
1 parent f39409e62c
commit 9dea56ce98
15 files changed
+223 -29

No files matched your search

+52
View File
@@ -473,6 +473,58 @@ class SandboxTests(CliCase):
self.assertEqual(self.fake.prs, [])
class ReviewOnlyTests(CliCase):
"""docs/vision.md is a listed document the drafter may read but not edit."""
def setUp(self):
super().setUp()
git(self.seed, "checkout", "-q", "main")
self.write(self.seed, "docs/vision.md", "Where `R/a.R` is going.\n")
git(self.seed, "add", ".")
git(self.seed, "commit", "-q", "-m", "vision")
git(self.seed, "push", "-q", "origin", "main")
git(self.seed, "checkout", "-q", "feat")
git(self.seed, "merge", "-q", "--ff-only", "main")
git(self.seed, "push", "-q", "origin", "feat")
self.env["INPUT_REVIEW_ONLY"] = "docs/vision.md"
self.prompt_file = Path(self._tmp.name) / "drafter-prompt"
def test_prompt_lists_it_as_read_only(self):
self.claude(stdin_copy=str(self.prompt_file))
self.assertEqual(self.run_pr(self.feature_commit()), 0)
prompt = self.prompt_file.read_text()
editable = prompt.split("Documents you may edit:")[1].split("Edit only")[0]
self.assertIn("docs/README.md", editable)
self.assertNotIn("docs/vision.md", editable)
self.assertIn("Documents you may read but not edit:\n\ndocs/vision.md", prompt)
def test_it_is_still_flagged_in_stage1(self):
self.claude()
self.assertEqual(self.run_pr(self.feature_commit()), 0)
self.assertIn("docs/vision.md", self.comment_bodies()[0])
def test_editing_it_fails_and_commits_nothing(self):
self.claude(edit="docs/vision.md")
self.assertEqual(self.run_pr(self.feature_commit()), 1)
self.assertTrue(any("docs/vision.md" in b for b in self.comment_bodies()))
self.assertNotIn(BRANCH, " ".join(self.remote_branches()))
self.assertEqual(git(self.work, "status", "--porcelain"), "")
self.assertEqual(self.fake.prs, [])
def test_deleting_it_fails(self):
self.claude(delete="docs/vision.md")
self.assertEqual(self.run_pr(self.feature_commit()), 1)
self.assertTrue((self.work / "docs" / "vision.md").exists())
self.assertEqual(self.fake.prs, [])
def test_new_file_matching_a_review_only_glob_is_refused(self):
self.env["INPUT_REVIEW_ONLY"] = "docs/v*.md"
self.claude(edit="docs/vnew.md")
self.assertEqual(self.run_pr(self.feature_commit()), 1)
self.assertFalse((self.work / "docs" / "vnew.md").exists())
self.assertEqual(self.fake.prs, [])
class SystemPromptTests(CliCase):
def setUp(self):
super().setUp()