Name each file of the setup as the setup's, and a config's as setup:<path>
CI / tests (pull_request) Successful in 4m42s

This commit is contained in:
2026-12-04 04:23:17 +01:00
parent eff57c1dfd
commit 6dd2787e7b
41 changed files with 220 additions and 156 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ STANDARDS = "skills/larv-review/standards"
RULE_DIRS = (HUMAN_RULE_DIR, STANDARDS)
RULE_PATH = rf"(?:{'|'.join(map(re.escape, RULE_DIRS))})/[\w-]+\.md"
NAMES = r'("[^"]+"(?:,? (?:and )?"[^"]+")*)'
CITATION = re.compile(rf'`?(?:~/\.claude/)?(CLAUDE\.md|{RULE_PATH})`? → {NAMES}')
CITATION = re.compile(rf'`?(CLAUDE\.md|{RULE_PATH})`? → {NAMES}')
# A citation of a file in whichever folder the project's config names as `standards`, checked against the folder this repo ships.
STANDARD_CITATION = re.compile(rf"the review standards' `([\w-]+\.md)` → {NAMES}")
HEADING = re.compile(r"^#+ (.+?)(?: \(.*\))?$", re.MULTILINE)
@@ -24,7 +24,7 @@ DECISION_CITATION = re.compile(r"`?docs/decisions\.md`? → `([^`]+)`")
DECISION_TITLE = re.compile(r"^## (.+)$", re.MULTILINE)
LISTED_TITLE = re.compile(r"^- (.+)$", re.MULTILINE)
NAME = re.compile(r'"([^"]+)"')
RULE_FILE = re.compile(rf"(?<![\w/.-])(?:~/\.claude/)?({RULE_PATH})")
RULE_FILE = re.compile(rf"(?<![\w/.-])({RULE_PATH})")
STRAY = re.compile(rf'(?:CLAUDE\.md|{RULE_PATH})(?!`? → "|:\d)[^\n"]{{1,5}}"')
+29
View File
@@ -0,0 +1,29 @@
import re
import unittest
from git_cli.git_repo import git
from repo_checks import ROOT
# A file of the setup spelled by a place in the person's own Claude home, where no release lies: a tool, or an instruction file. A session the loop starts has the release's tools on PATH, so prose names a tool bare, and names any other file as the setup's `CLAUDE.md` → "Vocabulary", "setup" says. Both hold wherever the release is cloned.
BY_ITS_FOLDER = re.compile(r"(?:~|\$HOME)/\.claude/(?:CLAUDE\.md|(?:agents|bin|principles|rules|skills)\b[\w.<>*/-]*)")
# The plan, the changelog and the records, then the dated benches and trials: their text names a file as it was spelled when the line was written, and nobody rewrites it.
HISTORY = ("CHANGELOG.md", "docs/", "todo.md", "reviewer-merge-trials/", "workflow-bench/")
class SetupFilesNamedWhereverTheCloneLies(unittest.TestCase):
def test_no_tracked_file_names_a_file_of_the_setup_by_the_persons_own_claude_home(self) -> None:
tracked = git("ls-files", cwd=str(ROOT))
self.assertIsInstance(tracked, str, tracked)
found = []
for name in str(tracked).splitlines():
path = ROOT / name
if name.startswith(HISTORY) or name == "bin/repo_checks/test_setup_files_named.py" or not path.is_file():
continue
for number, line in enumerate(path.read_text(encoding="utf-8", errors="replace").splitlines(), 1):
found += [f"{name}:{number}: {spelled}" for spelled in BY_ITS_FOLDER.findall(line)]
self.assertEqual(found, [], "name a tool bare, as in `todo-item`, and any other file as the setup's: the setup's `rules/todo-items.md`, never a path into `~/.claude`")
if __name__ == "__main__":
unittest.main()
-37
View File
@@ -1,37 +0,0 @@
import re
import unittest
from git_cli.git_repo import git
from repo_checks import ROOT
# A tool spelled by its place in an install folder, as opposed to a source file under bin/, which a reader opens by its path. A session the loop starts has the release's tools on PATH, so prose names a tool bare, and works wherever the release is installed.
BY_ITS_FOLDER = re.compile(r"(?:~|\$HOME)/\.claude/bin/[\w.<>-]+(?![\w.<>/-])")
# The plan, the changelog and the records: their text names a tool as it was spelled when the line was written, and nobody rewrites it.
HISTORY = ("CHANGELOG.md", "docs/", "todo.md")
# The lines a person runs in their own shell or a crontab, which lack the tools: no step puts one on their `PATH`.
BY_HAND = {
"README.md": {"$HOME/.claude/bin/compress-archives", "~/.claude/bin/<tool>", "~/.claude/bin/build-release", "~/.claude/bin/deploy-release", "~/.claude/bin/notify", "~/.claude/bin/project-config", "~/.claude/bin/self-update"},
"presentation/README.md": {"~/.claude/bin/run-heavy"},
"presentation/build-pdf.py": {"~/.claude/bin/run-heavy"},
}
# settings.json names its hooks and its status line by their folder, and the test of the reviewer hook quotes it. Claude Code reads the file in every session, also one the human starts without the tools on PATH. A hook it cannot find doesn't refuse anything, so a bare name there would switch rule-hook off in that session.
SETTINGS = ("settings.json", "bin/review_rules/test_reviewer_context.py")
class ToolsNamedBare(unittest.TestCase):
def test_no_tracked_file_names_a_tool_by_its_install_folder(self) -> None:
tracked = git("ls-files", cwd=str(ROOT))
self.assertIsInstance(tracked, str, tracked)
found = []
for name in str(tracked).splitlines():
path = ROOT / name
if name.startswith(HISTORY) or name in SETTINGS or name == "bin/repo_checks/test_tools_named_bare.py" or not path.is_file():
continue
for number, line in enumerate(path.read_text(encoding="utf-8", errors="replace").splitlines(), 1):
found += [f"{name}:{number}: {spelled}" for spelled in BY_ITS_FOLDER.findall(line) if spelled not in BY_HAND.get(name, ())]
self.assertEqual(found, [], "name each tool bare, as in `todo-item`")
if __name__ == "__main__":
unittest.main()