Compare commits
8 Commits
item-trigger
...
item-294
| Author | SHA1 | Date | |
|---|---|---|---|
| ed774a5fc1 | |||
| b99e362a8c | |||
| d183c81497 | |||
| 89bd9e86cc | |||
| 0b5a41fbf9 | |||
| 21bd753c5b | |||
| 47c10c4565 | |||
| 3e289c95d9 |
+2
-2
@@ -25,9 +25,9 @@
|
||||
!bin/branch_chunks/
|
||||
!bin/branch_chunks/*.py
|
||||
!bin/chunk-pr
|
||||
!bin/chunk-preflight
|
||||
!bin/chunk_pr/
|
||||
!bin/chunk_pr/*.py
|
||||
!bin/chunk-preflight
|
||||
!bin/chunk_preflight/
|
||||
!bin/chunk_preflight/*.py
|
||||
!bin/claude_code/
|
||||
@@ -50,12 +50,12 @@
|
||||
!bin/larv_review/
|
||||
!bin/larv_review/*.py
|
||||
!bin/loop-claude
|
||||
!bin/loop-inbox
|
||||
!bin/loop_claude/
|
||||
!bin/loop_claude/**/
|
||||
!bin/loop_claude/**/*.py
|
||||
!bin/loop_effects/
|
||||
!bin/loop_effects/*.py
|
||||
!bin/loop-inbox
|
||||
!bin/loop_inbox/
|
||||
!bin/loop_inbox/*.py
|
||||
!bin/loop_state/
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- `rule-hook` now checks files at `git commit`: each file that differs from HEAD or is untracked and not ignored, even one the commit leaves out. It holds each to `action-pin`, `image-pin`, `ignorefile-sorted` and `no-ai-attribution`, so a file a Bash command wrote is checked as an Edit or Write is. A `# rule-override` line in the file or the command overrides a breach.
|
||||
- `chunk-pr merge` now refuses while a scoring run the plan calls is unrecorded on the branch, and `larv-review needs-scoring-run` calls one after a release is cut with none.
|
||||
|
||||
## 0.7.0
|
||||
|
||||
@@ -81,7 +81,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i
|
||||
When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Open the subagent's prompt with the marker loop-claude's prompt gives, then the trigger's evidence. Each later subagent on that task runs on that rung or higher, and each further escalation trigger moves the task one rung higher, up to the highest rung loop-claude's prompt names. Ask the human before going higher. Where loop-claude's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread.
|
||||
- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits. A reviewer under `~/.claude/agents/` writes only its report, under `~/.local/state/larv-review/`, and rule-hook refuses it every other Write, every Edit and every MultiEdit. One that probes a build tags the image as throwaway and removes it afterwards, writes only to a folder it makes under the chunk's review folder (`~/.claude/bin/larv-review review-folder` prints it), and removes no image or file it did not create.
|
||||
- Check `README.md` first for build, test, install, and codegen commands, and fix one that misbehaves in the same change. Refresh `README.md` whenever you change what it describes, keeping it true, not longer.
|
||||
- Where `~/.claude/bin/rule-hook` does not check it, such as an image named in test code, a Kubernetes manifest, a `docker run` line or a file a Bash command writes, pin a container image to its full patch version and a GitHub Action to a semver tag.
|
||||
- Where `~/.claude/bin/rule-hook` does not check it, such as an image named in test code, a Kubernetes manifest or a `docker run` line, pin a container image to its full patch version and a GitHub Action to a semver tag.
|
||||
|
||||
## Naming files & folders
|
||||
- Name by what's inside. BANNED: `scripts`, `utils`, `helpers`, `misc`, `common`, `lib`, `stuff`. GOOD: `e2e-tests/`, `db-migrations/`, `release-tooling/`.
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import dataclasses
|
||||
import posixpath
|
||||
|
||||
from rule_hook.rules import Breach, file_breaches
|
||||
from failure import Failure
|
||||
from git_cli import git_repo
|
||||
from rule_hook.git import guarded_git
|
||||
from rule_hook.file_text import read
|
||||
|
||||
# settings.json gives rule-hook 30 seconds; a file past this size is not source code, and reading it would use them up.
|
||||
MAX_BYTES = 1_000_000
|
||||
|
||||
|
||||
def committed_file_breaches(directory: str) -> list[Breach]:
|
||||
"""The breaches of file_breaches in the files a commit in directory's checkout would commit.
|
||||
|
||||
A file a Bash command wrote reaches no Edit or Write check, so the commit checks the file instead. The files are those that differ from HEAD in the index or the work tree, or that are untracked and not ignored: the hook runs before a `git add` earlier in the same command, so the index alone would miss those files. A tracked file is checked as the index holds it and as the work tree does, since the commit takes the index. A deleted file, or one that is not UTF-8 text, has no added text. A breach carries the lines its file adds, so a marker among them overrides it, as in a Write; a marker the file already held doesn't."""
|
||||
top = guarded_git(directory, "rev-parse", "--show-toplevel")
|
||||
if isinstance(top, Failure):
|
||||
return []
|
||||
tracked = tracked_names(top)
|
||||
untracked = guarded_git(top, "ls-files", "-z", "--others", "--exclude-standard")
|
||||
breaches: list[Breach] = []
|
||||
for name in sorted(tracked | (set() if isinstance(untracked, Failure) else names_in(untracked))):
|
||||
path = posixpath.join(top, name)
|
||||
# An untracked file has neither a version in HEAD nor one in the index. A tracked file costs two git calls, about 4 ms each: a commit of 3000 changed files uses 13 of the hook's 30 seconds.
|
||||
before = blob(top, "HEAD", name) if name in tracked else ""
|
||||
for after in dict.fromkeys([read(path) if size(path) <= MAX_BYTES else "", blob(top, "", name) if name in tracked else ""]):
|
||||
known = set(before.splitlines())
|
||||
added = "\n".join(line for line in after.splitlines() if line not in known)
|
||||
breaches += [dataclasses.replace(breach, marked=added) for breach in file_breaches(path, before, added, after)]
|
||||
# The index copy and the work-tree copy of a file can breach the same way; the first stands.
|
||||
return list({(breach.rule, breach.detail): breach for breach in reversed(breaches)}.values())[::-1]
|
||||
|
||||
|
||||
def tracked_names(top: str) -> set[str]:
|
||||
"""The tracked files that differ from HEAD in the index or the work tree, deleted ones left out. It lists with diff-index, which neither hashes the work tree nor enters a submodule: either would run a clean filter that the checkout's config names, before the call is allowed."""
|
||||
listings = [guarded_git(top, "diff-index", "-z", "--name-only", "--no-renames", "--diff-filter=d", "--ignore-submodules", *cached, "HEAD") for cached in ([], ["--cached"])]
|
||||
if any(isinstance(listing, Failure) for listing in listings):
|
||||
# A checkout with no commit has no HEAD: every file in its index is new.
|
||||
listing = guarded_git(top, "ls-files", "-z")
|
||||
return set() if isinstance(listing, Failure) else names_in(listing)
|
||||
return {name for listing in listings if not isinstance(listing, Failure) for name in names_in(listing)}
|
||||
|
||||
|
||||
def names_in(listing: str) -> set[str]:
|
||||
return {name for name in listing.split("\0") if name}
|
||||
|
||||
|
||||
def blob(top: str, commit: str, name: str) -> str:
|
||||
"""name's text in the commit, or in the index where commit is empty; "" where there is none."""
|
||||
shown = git_repo.git("show", f"{commit}:{name}", cwd=top, guarded=True)
|
||||
return "" if isinstance(shown, Failure) or len(shown) > MAX_BYTES else shown
|
||||
|
||||
|
||||
def size(path: str) -> int:
|
||||
try:
|
||||
return posixpath.getsize(path)
|
||||
except OSError:
|
||||
return 0
|
||||
@@ -0,0 +1,12 @@
|
||||
import os
|
||||
import stat
|
||||
|
||||
|
||||
def read(path: str) -> str:
|
||||
"""path's text, or "" for anything but a regular file: a FIFO would hang the hook and a device such as /dev/zero would flood it."""
|
||||
try:
|
||||
# O_NONBLOCK opens a FIFO without waiting for a writer; fstat then judges the file opened, not one swapped in after a stat.
|
||||
with open(os.open(path, os.O_RDONLY | os.O_NONBLOCK), encoding="utf-8") as opened:
|
||||
return opened.read() if stat.S_ISREG(os.fstat(opened.fileno()).st_mode) else ""
|
||||
except (OSError, UnicodeDecodeError):
|
||||
return ""
|
||||
+11
-14
@@ -8,14 +8,18 @@ subagent. The rules:
|
||||
|
||||
{rules}
|
||||
|
||||
A file a Bash command writes, such as through `cat > Dockerfile`, is not checked.
|
||||
|
||||
A call overrides a rule with `# rule-override <rule>: <reason>`:
|
||||
|
||||
- anywhere in a Bash command, such as a trailing comment
|
||||
- in a file, as a comment line in the text the edit writes
|
||||
- in Markdown, as `<!-- rule-override <rule>: <reason> -->`
|
||||
|
||||
A file a Bash command writes, such as through `cat > Dockerfile`, is checked when a `git commit` runs, not when written.
|
||||
The commit checks every file that differs from HEAD, in the index or the work tree, and every untracked file that is
|
||||
not ignored, even one the commit leaves out. It holds each to the rules that name a file (action-pin, image-pin,
|
||||
ignorefile-sorted, no-ai-attribution), judged on the lines the file adds. A marker among those lines, or in the commit
|
||||
command, overrides the file's breach.
|
||||
|
||||
Each override that let a call through is appended to rule-overrides.tsv in the git directory of
|
||||
the checkout it touched: UTC time, branch, the commit checked out, rule, reason, and the file
|
||||
written or the command's first line. An override outside any git checkout is not logged.
|
||||
@@ -31,7 +35,6 @@ cannot read.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
import time
|
||||
import typing
|
||||
@@ -39,8 +42,10 @@ import typing
|
||||
from rule_hook.call import applied, Call, FILE_TOOLS, parsed_call, text
|
||||
from rule_hook.rules import Breach, check, Checked, command_breaches, file_breaches, rules_help
|
||||
from git_cli.git_command import commits
|
||||
from rule_hook.committed_files import committed_file_breaches
|
||||
from failure import Failure
|
||||
from rule_hook.override_log import Log, log_path, logged, print_overrides, write_override
|
||||
from rule_hook.file_text import read
|
||||
from rule_hook.repeat_read import read_breaches
|
||||
from rule_hook.reviewer_report import report_breaches
|
||||
from rule_hook.reviewer_rung import reviewer_breaches, skill_breaches
|
||||
@@ -110,14 +115,6 @@ def answer(checked: Checked, what: str, now: float) -> int:
|
||||
|
||||
def bash_breaches(command: str, cwd: str, home: str) -> list[Breach]:
|
||||
simples = simple_commands(command, cwd, home)
|
||||
return command_breaches(command, simples, home) + [breach for commit in commits(simples, home) for breach in round_cap_breaches(commit) + todo_breaches(commit.directory)]
|
||||
|
||||
|
||||
def read(path: str) -> str:
|
||||
"""path's text, or "" for anything but a regular file: a FIFO would hang the hook and a device such as /dev/zero would flood it."""
|
||||
try:
|
||||
# O_NONBLOCK opens a FIFO without waiting for a writer; fstat then judges the file opened, not one swapped in after a stat.
|
||||
with open(os.open(path, os.O_RDONLY | os.O_NONBLOCK), encoding="utf-8") as opened:
|
||||
return opened.read() if stat.S_ISREG(os.fstat(opened.fileno()).st_mode) else ""
|
||||
except (OSError, UnicodeDecodeError):
|
||||
return ""
|
||||
found = commits(simples, home)
|
||||
in_files = [breach for directory in dict.fromkeys(commit.directory for commit in found) for breach in committed_file_breaches(directory)]
|
||||
return command_breaches(command, simples, home) + [breach for commit in found for breach in round_cap_breaches(commit) + todo_breaches(commit.directory)] + in_files
|
||||
|
||||
@@ -104,6 +104,8 @@ class Breach:
|
||||
detail: str
|
||||
# The checkout whose log records an override of this breach.
|
||||
directory: str
|
||||
# The lines a commit adds to the breach's file: its markers override this breach, as a Write's text overrides its own file's.
|
||||
marked: str = ""
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -124,7 +126,9 @@ def overrides(written: str) -> tuple[dict[str, str], list[str]]:
|
||||
|
||||
def check(breaches: list[Breach], written: str, markdown: bool, bash: bool) -> Checked:
|
||||
granted, malformed = overrides(written)
|
||||
blocking = [breach for breach in breaches if breach.rule not in granted]
|
||||
# A marker overrides a breach when it is in the call's own text or in the breach's file.
|
||||
grants = [granted | overrides(breach.marked)[0] for breach in breaches]
|
||||
blocking = [breach for breach, grant in zip(breaches, grants) if breach.rule not in grant]
|
||||
messages = [f"`{marker}` names no rule below, or gives no reason." for marker in malformed] if blocking else []
|
||||
where = "the command" if bash else "the text you write, as a comment line"
|
||||
for rule in sorted({breach.rule for breach in blocking}):
|
||||
@@ -134,7 +138,7 @@ def check(breaches: list[Breach], written: str, markdown: bool, bash: bool) -> C
|
||||
continue
|
||||
marker = f"<!-- rule-override {rule}: <reason> -->" if markdown else f"# rule-override {rule}: <reason>"
|
||||
messages.append(f"Blocked by rule {rule}: {details}. The rule: {RULES[rule].holds}. Where it does not fit this case, add `{marker}` to {where}; larv-review rules on the reason.")
|
||||
return Checked(messages, bool(blocking), [(breach, granted[breach.rule]) for breach in breaches if breach.rule in granted])
|
||||
return Checked(messages, bool(blocking), [(breach, grant[breach.rule]) for breach, grant in zip(breaches, grants) if breach.rule in grant])
|
||||
|
||||
|
||||
def command_breaches(command: str, simples: list[Simple], home: str) -> list[Breach]:
|
||||
|
||||
@@ -913,6 +913,127 @@ class TodoRankCheck(unittest.TestCase):
|
||||
self.assertNotIn("own script", " ".join(reasons))
|
||||
|
||||
|
||||
class CommittedFiles(unittest.TestCase):
|
||||
"""A git commit holds the files it would commit to the file rules, as an Edit or Write of each would be."""
|
||||
UNPINNED = "jobs:\n a:\n steps:\n - uses: actions/checkout@main\n"
|
||||
|
||||
def setUp(self):
|
||||
self.repo = tempfile.mkdtemp()
|
||||
self.addCleanup(subprocess.run, ["rm", "-rf", self.repo])
|
||||
git(self.repo, "init", "-q", "-b", "main")
|
||||
git(self.repo, "commit", "-q", "--allow-empty", "-m", "base")
|
||||
|
||||
def write(self, name: str, content: str) -> None:
|
||||
path = pathlib.Path(self.repo, name)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(content)
|
||||
|
||||
def commit(self, command: str = "git add -A && git commit -m x") -> subprocess.CompletedProcess:
|
||||
return hook({"cwd": self.repo, "tool_input": {"command": command}, "tool_name": "Bash"}, self.repo)
|
||||
|
||||
def test_a_file_a_command_wrote_is_checked_at_the_commit(self):
|
||||
self.write(".github/workflows/ci.yml", self.UNPINNED)
|
||||
self.write("Dockerfile", "FROM node:24\n")
|
||||
self.write(".gitignore", "b\na\n")
|
||||
self.write("NOTES.md", "Co-Authored-" + "By: Claude <noreply@anthropic.com>\n")
|
||||
ran = self.commit()
|
||||
self.assertEqual(ran.returncode, 2)
|
||||
for rule in ["action-pin", "image-pin", "ignorefile-sorted", "no-ai-attribution"]:
|
||||
with self.subTest(rule):
|
||||
self.assertIn(f"Blocked by rule {rule}: ", ran.stderr)
|
||||
|
||||
def test_a_staged_file_is_checked_and_a_clean_tree_passes(self):
|
||||
self.assertEqual(self.commit().returncode, 0)
|
||||
self.write(".github/workflows/ci.yml", self.UNPINNED)
|
||||
git(self.repo, "add", "-A")
|
||||
self.assertEqual(self.commit("git commit -m x").returncode, 2)
|
||||
|
||||
def test_a_breach_the_head_already_holds_is_left_alone(self):
|
||||
self.write("Dockerfile", "FROM node:24\n")
|
||||
self.write(".gitignore", "b\na\n")
|
||||
git(self.repo, "add", "-A")
|
||||
git(self.repo, "commit", "-qm", "x", "--no-verify")
|
||||
self.write("Dockerfile", "FROM node:24\nRUN true\n")
|
||||
self.write(".gitignore", "b\na\n\n# more\nc\n")
|
||||
self.assertEqual(self.commit().returncode, 0)
|
||||
self.write("Dockerfile", "FROM node:24\nRUN true\nFROM node:25\n")
|
||||
self.assertIn("image-pin: ", self.commit().stderr)
|
||||
|
||||
def test_a_marker_in_the_command_or_the_file_lets_the_commit_through(self):
|
||||
self.write("Dockerfile", "FROM vendor/tool:2\n")
|
||||
self.assertEqual(self.commit("git add -A && git commit -m x # rule-override image-pin: the vendor tags no patch versions").returncode, 0)
|
||||
self.write("Dockerfile", "# rule-override image-pin: the vendor tags no patch versions\nFROM vendor/tool:2\n")
|
||||
self.assertEqual(self.commit().returncode, 0)
|
||||
|
||||
def test_a_staged_breach_blocks_the_commit_after_the_work_tree_is_fixed(self):
|
||||
self.write("Dockerfile", "FROM node:24\n")
|
||||
git(self.repo, "add", "Dockerfile")
|
||||
self.write("Dockerfile", "FROM node:24.18.1\n")
|
||||
self.assertIn("image-pin: ", self.commit("git commit -m x").stderr)
|
||||
|
||||
def test_a_stat_dirty_file_runs_no_clean_filter(self):
|
||||
self.write("a.txt", "a\n")
|
||||
self.write(".gitattributes", "a.txt filter=planted\n")
|
||||
git(self.repo, "add", "-A")
|
||||
git(self.repo, "commit", "-qm", "x", "--no-verify")
|
||||
git(self.repo, "config", "filter.planted.clean", f"touch {self.repo}/ran; cat")
|
||||
pathlib.Path(self.repo, "ran").unlink(missing_ok=True)
|
||||
os.utime(pathlib.Path(self.repo, "a.txt"), (1, 1))
|
||||
self.assertEqual(self.commit("git commit -m x").returncode, 0)
|
||||
self.assertFalse(pathlib.Path(self.repo, "ran").exists())
|
||||
|
||||
def test_a_submodule_runs_no_clean_filter(self):
|
||||
inner = tempfile.mkdtemp()
|
||||
self.addCleanup(subprocess.run, ["rm", "-rf", inner])
|
||||
git(inner, "init", "-q", "-b", "main")
|
||||
pathlib.Path(inner, "b.txt").write_text("b\n")
|
||||
pathlib.Path(inner, ".gitattributes").write_text("b.txt filter=planted\n")
|
||||
git(inner, "add", "-A")
|
||||
git(inner, "commit", "-qm", "x", "--no-verify")
|
||||
git(self.repo, "-c", "protocol.file.allow=always", "submodule", "add", "-q", inner, "sub")
|
||||
git(self.repo, "commit", "-qm", "x", "--no-verify")
|
||||
git(f"{self.repo}/sub", "config", "filter.planted.clean", f"touch {self.repo}/ran; cat")
|
||||
os.utime(pathlib.Path(self.repo, "sub", "b.txt"), (1, 1))
|
||||
self.assertEqual(self.commit("git commit -m x").returncode, 0)
|
||||
self.assertFalse(pathlib.Path(self.repo, "ran").exists())
|
||||
|
||||
def test_a_checkout_with_no_commit_checks_its_index_and_untracked_files(self):
|
||||
fresh = tempfile.mkdtemp()
|
||||
self.addCleanup(subprocess.run, ["rm", "-rf", fresh])
|
||||
git(fresh, "init", "-q", "-b", "main")
|
||||
pathlib.Path(fresh, "Dockerfile").write_text("FROM node:24\n")
|
||||
git(fresh, "add", "Dockerfile")
|
||||
pathlib.Path(fresh, "NOTES.md").write_text(TRAILER + "\n")
|
||||
ran = hook({"cwd": fresh, "tool_input": {"command": "git commit -m x"}, "tool_name": "Bash"}, fresh)
|
||||
for rule in ["image-pin", "no-ai-attribution"]:
|
||||
self.assertIn(f"Blocked by rule {rule}: ", ran.stderr)
|
||||
|
||||
def test_a_change_that_only_reorders_an_ignore_file_is_checked(self):
|
||||
self.write(".gitignore", "a\nb\nc\n")
|
||||
git(self.repo, "add", "-A")
|
||||
git(self.repo, "commit", "-qm", "x", "--no-verify")
|
||||
self.write(".gitignore", "c\nb\na\n")
|
||||
self.assertIn("ignorefile-sorted: ", self.commit().stderr)
|
||||
|
||||
def test_a_marker_the_head_already_holds_does_not_override_a_new_breach(self):
|
||||
self.write("Dockerfile", "# rule-override image-pin: the vendor tags no patch versions\nFROM vendor/tool:2\n")
|
||||
git(self.repo, "add", "-A")
|
||||
git(self.repo, "commit", "-qm", "x", "--no-verify")
|
||||
self.write("Dockerfile", "# rule-override image-pin: the vendor tags no patch versions\nFROM vendor/tool:2\nFROM node:24\n")
|
||||
self.assertIn("image-pin: ", self.commit().stderr)
|
||||
|
||||
def test_a_marker_in_another_file_does_not_override_a_breach(self):
|
||||
self.write("Dockerfile", "FROM vendor/tool:2\n")
|
||||
self.write("NOTES.md", "# rule-override image-pin: quoted in a note\n")
|
||||
self.assertIn("Blocked by rule image-pin: ", self.commit().stderr)
|
||||
|
||||
def test_an_ignored_or_binary_file_is_left_alone(self):
|
||||
self.write(".gitignore", "build/\n")
|
||||
self.write("build/Dockerfile", "FROM node:24\n")
|
||||
pathlib.Path(self.repo, "image.png").write_bytes(b"\xff\xfe\x00FROM node:24\n")
|
||||
self.assertEqual(self.commit().returncode, 0)
|
||||
|
||||
|
||||
class RuleNames(unittest.TestCase):
|
||||
def test_every_rule_name_has_a_rule_and_every_rule_a_name(self):
|
||||
self.assertEqual(set(RULES), set(typing.get_args(RuleName)))
|
||||
|
||||
+1
-1
@@ -412,7 +412,7 @@ Valid while a model switch inside a session discards its prompt cache.
|
||||
|
||||
## rule-hook: a PreToolUse hook enforces each rule a program can check, a `# rule-override <rule>: <reason>` marker overrides any rule but those `rule-hook --help` marks as taking none, and larv-review's overrides pass rules on each override before merge
|
||||
|
||||
2026-10-12, lilleman. Serves goals 1.2 and 1.3. Anthropic's best-practices page calls `CLAUDE.md` advisory and hooks deterministic, so a rule that must hold every time moves into `bin/rule-hook`, and `CLAUDE.md` keeps it only where the hook cannot check it. A Claude Code hook ties the check to one vendor ("Prefer the vendor-neutral option", `principles/technical-principles.md`), which is the target itself here: this repo configures Claude Code. What the tie buys: the hook blocks before a write lands, Edit and Write calls included, in every project with no per-repo install; a git `commit-msg` hook sees only commits, and CI sees them only after the push. The hook checks each write, so the agent fixes the line it just wrote; checking the staged diff at commit time would also cover files a Bash command writes, at the cost of later feedback. The marker's spelling was picked by a panel of three fresh readers, two to one. Each override is logged in the checkout's git directory, which is never pushed (goal 4). The plan had loop-claude's judge to rule on overrides inside a loop; lilleman approved larv-review's overrides pass in every run, because it rules before merge and an outrageous override still reaches the human through its ask. 2026-10-16, lilleman, answering plan item 166: no marker overrides `reviewer-rung`. 2026-11-04, lilleman: the title points at `rule-hook --help`, which lists every rule no marker overrides from the code, so the title can't drift from it; the comment above each in `bin/rule_hook/rules.py` says why. Valid while a PreToolUse hook that exits 2 blocks the call and hands its stderr to the model, and while an agent commits through Claude Code's Bash tool.
|
||||
2026-10-12, lilleman. Serves goals 1.2 and 1.3. Anthropic's best-practices page calls `CLAUDE.md` advisory and hooks deterministic, so a rule that must hold every time moves into `bin/rule-hook`, and `CLAUDE.md` keeps it only where the hook cannot check it. A Claude Code hook ties the check to one vendor ("Prefer the vendor-neutral option", `principles/technical-principles.md`), which is the target itself here: this repo configures Claude Code. What the tie buys: the hook blocks before a write lands, Edit and Write calls included, in every project with no per-repo install; a git `commit-msg` hook sees only commits, and CI sees them only after the push. The hook checks each write, so the agent fixes the line it just wrote; checking the staged diff at commit time would also cover files a Bash command writes, at the cost of later feedback. The marker's spelling was picked by a panel of three fresh readers, two to one. Each override is logged in the checkout's git directory, which is never pushed (goal 4). The plan had loop-claude's judge to rule on overrides inside a loop; lilleman approved larv-review's overrides pass in every run, because it rules before merge and an outrageous override still reaches the human through its ask. 2026-10-16, lilleman, answering plan item 166: no marker overrides `reviewer-rung`. 2026-11-04, lilleman: the title points at `rule-hook --help`, which lists every rule no marker overrides from the code, so the title can't drift from it; the comment above each in `bin/rule_hook/rules.py` says why. Valid while a PreToolUse hook that exits 2 blocks the call and hands its stderr to the model, and while an agent commits through Claude Code's Bash tool. 2026-11-11, lilleman: the hook also checks, at a `git commit`, each file the commit would commit against the rules that name a file, since a file a Bash command writes reaches no write check; the feedback comes at the commit, not at the write.
|
||||
|
||||
## rules/: `CLAUDE.md` holds the worker's rules that no file path can scope, and each topic's rules for the worker live in a `rules/` file that Claude Code loads by its `paths:` frontmatter
|
||||
|
||||
|
||||
@@ -1536,3 +1536,20 @@ Read most (opens and searches):
|
||||
Read most (opens and searches):
|
||||
|
||||
- `todo.md` 1
|
||||
|
||||
## Reading cost, chunk 4a0a495957fb, finished 2026-11-11T13:02:21Z
|
||||
|
||||
146184 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `bin/larv_review/main.py` 9
|
||||
- `bin/larv_review/plan.py` 5
|
||||
- `bin/larv_review/test_larv_review.py` 5
|
||||
- `bin/chunk_pr/test_chunk_pr.py` 4
|
||||
- `bin/larv_review/history_commands.py` 4
|
||||
- `bin/review_rules/comprehension_history.py` 4
|
||||
- `bin/chunk_pr/main.py` 3
|
||||
- `bin/chunk_preflight/main.py` 3
|
||||
- `bin/release_plan/release_standing.py` 3
|
||||
- `CHANGELOG.md` 2
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
`Bar = 0.1`
|
||||
|
||||
`Next ID = 303`
|
||||
`Next ID = 304`
|
||||
|
||||
## Items
|
||||
|
||||
| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| 294 | 0.8.0 | | | **Check the files a commit stages against rule-hook's file rules, so a file a Bash command wrote is held to them as an Edit or Write is.** | 2 | 2 | 3 | 5 | 4 | 1.3 by 5 | 5.2 |
|
||||
| 303 | 0.8.0 | | defect | **Archive each judge run's prompt and json reply beside the verdict it gave, so judge cost, replays and backups cover the judge as they cover the worker.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3, 3 by 2 | 4.8 |
|
||||
| 297 | 0.8.0 | | | **Have loop-claude compute the judge's taken-in items, release-ready and escalation fields from `chunk-preflight`, git and the worker's structured lines, and leave the judge only the verdict kind.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 2, code health by 2 | 3.7 |
|
||||
| 302 | 0.8.0 | | | **Call a scoring run for an item whose tagline makes the comprehension floor its target, and not for one that only names the floor, such as in a quoted decision title.** | 2 | 2 | 3 | 5 | 3 | code health by 2 | 3.6 |
|
||||
| 293 | 0.8.0 | | | **Run mutation tests on a chunk's changed lines in the worker's pre-review gate, through one command that picks the tool by language, and hand stability-reviewer the surviving mutants.** | 3 | 2 | 3 | 6 | 5 | 1.1 by 5, 1.4 by 4, 1.5 by 2 | 2.8 |
|
||||
@@ -48,7 +48,6 @@
|
||||
| 187 | 0.9.0 | | | **Count the tokens a worker spends reading reviewers' reports, so goal 1.4's signal shows whether report files lowered what a review costs the worker's context.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 1.2 |
|
||||
| 266 | 0.9.0 | | | **Move the chunks archived under the key `home/lilleman/.claude` to the key `claude-config`, so the routing figures and `score-outcomes` count this repo's chunks as one project.** | 3 | 2 | 2 | 5 | 3 | 1.4 by 3 | 1.2 |
|
||||
| 181 | 0.9.0 | | principle | **Have the test of a quoted answer's step-up assert the stepped rung's facts as literals, not through `prompts.rungs_held`.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 1.0 |
|
||||
| 192 | 0.9.0 | | principle | **Sort `.gitignore`'s allowlist block, from `!.claude/` to `!workflow-bench/test_review_git.py`, by code point, so rule-hook's `ignorefile-sorted` checks later edits to it again.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 1.0 |
|
||||
| 193 | 0.9.0 | | | **Narrow `readme_goals`'s mark to `Mark` by a typed lookup in place of `typing.cast`, so a mark added to the regex but not the lookup fails at run time, and one added to the lookup but not `Mark` fails mypy.** | 1 | 1 | 3 | 3 | 1 | 1.1 by 2 | 1.0 |
|
||||
| 194 | 0.9.0 | | | **Make `test_waits_out_a_usage_limit_which_ends_a_run_of_failures` expect a usage-limit wait independent of the wall-clock time that passes during the run.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 2 | 1.0 |
|
||||
| 202 | 0.9.0 | | | **Add `CLAUDE.md` → "Prose"'s rule "Write negations as people say them", with its examples, to `skills/larv-review/standards/prose.md`, so the prose reviewer holds prose to it.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 2 | 1.0 |
|
||||
@@ -60,9 +59,11 @@
|
||||
|
||||
## Details
|
||||
|
||||
### 294. Check the files a commit stages against rule-hook's file rules, so a file a Bash command wrote is held to them as an Edit or Write is.
|
||||
### 303. Archive each judge run's prompt and json reply beside the verdict it gave, so judge cost, replays and backups cover the judge as they cover the worker.
|
||||
|
||||
From 2026-11-08 to 2026-11-10, workers in other projects wrote 1,266 files through Bash (a python heredoc, `sed -i`, `cat >`) against 260 through Edit and Write, and `rule-hook --help` says it doesn't check a file a Bash command writes. So `action-pin`, `image-pin`, `ignorefile-sorted` and the attribution check miss most edits. rule-hook already checks at `git commit` for `todo-rank-check`, so checking staged files there follows a pattern the repo has. Ship item 192 in the same chunk: its unsorted `.gitignore` block is one symptom of this gap.
|
||||
Today no judge transcript reaches loop-claude's archive. `bin/claude_code/reply.py` runs every headless reply, the judge's included, with `--no-session-persistence`, so its runs stay out of the session picker; Claude Code then writes no session file for the archive to copy. No decision chose to leave the judge out: `loop-claude: the archive keeps the raw transcript` was written for the worker's `.jsonl`. Goal 3 asks for the transcripts of unattended runs to be backed up, and the judge is one. The gap also leaves the judge's spend measurable only from the `Judge cost:` lines, which older verdicts lack ($136 recorded over 2026-09-30 to 2026-11-11), and leaves `judge-replay` rebuilding each prompt from today's records: of the 39 verdicts it replayed on 2026-10-15, 8 may rest on records that had changed since.
|
||||
|
||||
The judge runs with no tools and one turn (`judge_args` in `bin/loop_claude/cycle/judge.py`), so its whole transcript is the prompt it read and the json reply. Recommended: keep `--no-session-persistence`, and have the archive write the prompt and the reply beside the outcomes entry of the verdict, interrupt or rejected reply they produced, deduplicated by content hash as the worker's copies are. A failed write stops the loop, as that decision says. Persisting the session and copying its file would also work, but fills the picker and needs a cleanup. The prompt repeats the worker's transcript, which the archive already holds: measure the size per cycle first, and if it outgrows "small enough to copy whole", keep the prompt without the transcript part and name the worker copy and entry range it held. Then let `judge-replay` read the archived prompt where one exists, and price the judge from the archived reply's usage. Update that decision entry to say the judge's runs are archived too.
|
||||
|
||||
### 297. Have loop-claude compute the judge's taken-in items, release-ready and escalation fields from `chunk-preflight`, git and the worker's structured lines, and leave the judge only the verdict kind.
|
||||
|
||||
@@ -285,10 +286,6 @@ The archive holds 277 chunk folders under `home/lilleman/.claude`, from 2026-09-
|
||||
|
||||
`bin/loop_claude/test_loop_claude.py`'s `test_a_quoted_answer_that_cites_an_escalation_trigger_steps_the_worker_up_before_it_resumes_and_archives_the_step` builds its expected prompt from `prompts.rungs_held`, the code under test, so a bug there passes it. The technical principles' test bullet bans that shape. Assert the new rung and one review launch as literals, as the typed answer's step-up test does. Raised by the principles audit of PR #308.
|
||||
|
||||
### 192. Sort `.gitignore`'s allowlist block, from `!.claude/` to `!workflow-bench/test_review_git.py`, by code point, so rule-hook's `ignorefile-sorted` checks later edits to it again.
|
||||
|
||||
Found by review of PR #317. The block, `.gitignore:17-142` on 2026-11-10, is out of order in several places: `!bin/chunk-preflight` sits below `!bin/chunk_pr/`, and `!bin/loop-inbox` below `!bin/loop_claude/`, though `-` sorts before `_`. `LC_ALL=C sort -c` on the block names the first one. `ignore_breaches` in `bin/rule_hook/rules.py` skips a block that was already unsorted before an edit, so while this one stays unsorted no later edit to it is checked. The unsorted block breaches the technical principle "Deterministic order wherever order carries no meaning".
|
||||
|
||||
### 193. Narrow `readme_goals`'s mark to `Mark` by a typed lookup in place of `typing.cast`, so a mark added to the regex but not the lookup fails at run time, and one added to the lookup but not `Mark` fails mypy.
|
||||
|
||||
Found by review of PR #317. `bin/release_plan/ranking.py`'s `readme_goals` writes `typing.cast(Mark, mark or None)`, which asserts the type `goal_weights` branches on without checking it: a mark added to the regex reaches `goal_weights` as a value `Mark` lacks. mypy does not read the regex, so no lookup lets it catch that. Replace the cast with a lookup typed `dict[str, Mark]`, from each mark the regex captures, and `""` for none, to its `Mark` value. A mark added to the regex but not the lookup then raises `KeyError` at run time, and a value added to the lookup but not `Mark` fails mypy.
|
||||
|
||||
Reference in New Issue
Block a user