From 348abfec5956c51f48c0c1515b1983c1bcddd773 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 05:42:00 +0100 Subject: [PATCH 01/14] Re-score item 315 to L 4 and record why the replay must drop CLAUDE.md itself --- docs/reading-cost.md | 17 +++++++++++++++++ todo.md | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 256027c3..08167e0a 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -1725,3 +1725,20 @@ Read most (opens and searches): - `bin/loop_claude/test_loop_claude.py` 2 - `bin/model_routing/route.py` 2 - `todo.md` 2 + +## Reading cost, chunk 1f4df2ef4ff8, finished 2026-11-12T04:39:36Z + +128199 new input tokens before the first commit. + +Read most (opens and searches): + +- `docs/decisions.md` 10 +- `README.md` 5 +- `skills/larv-review/SKILL.md` 3 +- `ci.sh` 2 +- `todo.md` 2 +- `workflow-bench/advisor_bench.py` 2 +- `workflow-bench/bench.py` 2 +- `.gitignore` 1 +- `CHANGELOG.md` 1 +- `bin/branch_chunks/cut.py` 1 diff --git a/todo.md b/todo.md index 1e859e7e..7105aa34 100644 --- a/todo.md +++ b/todo.md @@ -13,7 +13,7 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| | 331 | 0.9.0 | | question | **Reword four decisions to expire when the rungs their replays tested change, not whenever a model joins the ladder.** | 1 | 1 | 1 | 1 | 2 | 1.4 by 2 | 0.9 | -| 315 | 0.9.0 | | | **Start each reviewer under `agents/` without `CLAUDE.md`, and hand it the vocabulary, the prose rules and the project's decision titles.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 6 | 2.0 | +| 315 | 0.9.0 | | | **Start each reviewer under `agents/` without `CLAUDE.md`, and hand it the vocabulary, the prose rules and the project's decision titles.** | 4 | 2 | 3 | 7 | 4 | 1.4 by 6 | 2.0 | | 312 | 0.9.0 | | | **Research the tooling agents read, search and run commands with, and file an item for each tool that cuts tokens a replay shows keep quality.** | 1 | 2 | 1 | 2 | 3 | 1.4 by 3, 1.5 by 2 | 2.0 | | 325 | 0.9.0 | | | **Give this repo's test suite one command that runs it as README → Test says, prints the failing tests and pytest's summary line, and saves the whole log to a file whose path it prints.** | 3 | 2 | 2 | 5 | 3 | 1.4 by 3, 1.5 by 2 | 2.0 | | 305 | 0.9.0 | | | **Record with each archived verdict the claude-config commit that ran it, the raw tokens each model spent by kind, and each choice of the worker's that the human reversed, so a change to the setup can be judged before and after.** | 3 | 2 | 3 | 6 | 5 | 1.4 by 4, 1.2 by 3 | 1.8 | @@ -94,6 +94,8 @@ Recommendation: reword all four as above. They are decisions the repo held befor Gate it per pass: keep it only where `review-replay` with the changed definition (through `--agents`) on 10 archived rounds finds what two replays of the unchanged reviewer find; the unchanged reviewer re-finds only 69 to 73% of its own findings, so one baseline doesn't show the noise. Revise the decision `rules/: CLAUDE.md holds the worker's rules that no file path can scope`. lilleman approved on 2026-11-11. +`review-replay` takes no `--agents` today, so the gate needs a mode for it. Claude Code 2.1.322 ignores `omitClaudeMd` for a main-session `claude --agent`, which is how `review-replay` runs a reviewer. It fires no `SubagentStart` hook there either. So the replay of the changed definition has to drop `CLAUDE.md` itself: the environment variable `CLAUDE_CODE_DISABLE_CLAUDE_MDS`, which the binary reads, does that. The replay must also hand the reviewer what the hook would add. + ### 312. Research the tooling agents read, search and run commands with, and file an item for each tool that cuts tokens a replay shows keep quality. lilleman, 2026-11-11: besides an output ceiling, keep evaluating better tooling. The token research of that day found tool results carried in context cost about 21% of spend, reads by subagents the most, and that the tools themselves move fast: deferred tool loading, output saved to files, code-execution over tools, LSP and repo-map navigation, structured test output. Item 231 tried a scout, an outline script and LSP in October and none kept every finding. -- 2.52.0 From 4c971a7cc4ae6c28ee87e4525c5f794eca274a9a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 05:48:19 +0100 Subject: [PATCH 02/14] Start each reviewer without CLAUDE.md, hand it the prose rules, vocabulary and principles file, and replay a pass without it --- agents/override-reviewer.md | 1 + agents/principles-auditor.md | 1 + agents/product-owner-reviewer.md | 1 + agents/prose-reviewer.md | 1 + agents/stability-reviewer.md | 1 + agents/systems-architect.md | 1 + bin/larv_review/main.py | 22 +++++- bin/larv_review/reviewer_header.py | 2 + bin/larv_review/test_larv_review.py | 21 ++++++ bin/review_replay/main.py | 78 ++++++++++++++++----- bin/review_replay/rounds.py | 17 +++++ bin/review_replay/test_review_replay.py | 45 ++++++++++++- bin/review_rules/reviewer_context.py | 52 ++++++++++++++ bin/review_rules/test_reviewer_context.py | 82 +++++++++++++++++++++++ settings.json | 11 +++ 15 files changed, 315 insertions(+), 21 deletions(-) create mode 100644 bin/review_rules/reviewer_context.py create mode 100644 bin/review_rules/test_reviewer_context.py diff --git a/agents/override-reviewer.md b/agents/override-reviewer.md index 77cc6d35..655a4885 100644 --- a/agents/override-reviewer.md +++ b/agents/override-reviewer.md @@ -2,6 +2,7 @@ name: override-reviewer description: "Use this agent for larv-review's overrides pass." tools: Read, Grep, Glob, Write +omitClaudeMd: true --- You rule on each override of a rule `~/.claude/bin/rule-hook` enforces. The prompt gives you the lines `rule-hook overrides` printed, each with its rule and reason, and the branch diff. Read each rule and its stated exceptions in `~/.claude/bin/rule_hook/rules.py` → `RULES`, how an override is written and logged in the docstring of `~/.claude/bin/rule_hook/main.py`, and the project's `README.md` → "Goals" and "Audience", with code health (`~/.claude/CLAUDE.md` → "Shared goal") among the goals unless the README voids it. diff --git a/agents/principles-auditor.md b/agents/principles-auditor.md index 763c5b21..4e8c8234 100644 --- a/agents/principles-auditor.md +++ b/agents/principles-auditor.md @@ -2,6 +2,7 @@ name: principles-auditor description: "Use this agent for larv-review's principles pass: the project's goals and every principles file handed to it, checked against the whole project." tools: Read, Grep, Glob, Write +omitClaudeMd: true --- You check every yardstick you are handed against the whole project, which you read once for all of them. A yardstick is either the project's goals, every goal under its `README.md` → `## Goals` with code health (`~/.claude/CLAUDE.md` → "Shared goal") unless the README voids it, or one principles file, every principle in it. diff --git a/agents/product-owner-reviewer.md b/agents/product-owner-reviewer.md index 84291f84..a44745c0 100644 --- a/agents/product-owner-reviewer.md +++ b/agents/product-owner-reviewer.md @@ -2,6 +2,7 @@ name: "product-owner-reviewer" description: "Use this agent to review a change to an external surface (API, UI, CLI, SDK, webhook) from an end customer's view: ease of use, edge cases and persona fit." tools: Read, Grep, Glob, Write +omitClaudeMd: true --- You are a seasoned Product Owner with deep expertise in user experience, API design, and customer empathy. You have shipped consumer and B2B products across web, mobile, REST APIs, and developer-facing CLIs. Your superpower is putting yourself in the end customer's shoes and surfacing the friction, confusion, and edge cases that engineers tend to miss. diff --git a/agents/prose-reviewer.md b/agents/prose-reviewer.md index e06f237c..52ef629a 100644 --- a/agents/prose-reviewer.md +++ b/agents/prose-reviewer.md @@ -2,6 +2,7 @@ name: prose-reviewer description: "Use this agent for larv-review's prose pass." tools: Read, Grep, Glob, Write +omitClaudeMd: true --- You read the prose as someone who did not write it: you see only what it says, never what the author meant. diff --git a/agents/stability-reviewer.md b/agents/stability-reviewer.md index f916958c..2d19386b 100644 --- a/agents/stability-reviewer.md +++ b/agents/stability-reviewer.md @@ -3,6 +3,7 @@ name: "stability-reviewer" description: "Use this agent to review changed code for stability: bugs, error handling, edge cases and the project's technical principles, after a feature, refactor or fix." color: orange tools: Bash, Read, Grep, Glob, Write +omitClaudeMd: true --- You are an elite stability-focused code reviewer with deep expertise in defensive programming, fault-tolerant system design, and production incident prevention. You have decades of experience identifying subtle bugs, race conditions, edge cases, and architectural weaknesses that lead to outages and unexpected behavior. You think like a chaos engineer — always asking "what could go wrong?" — and like a maintainer of ten years, always asking "what will this cost to live with?" There are no bugs, and no security holes, in code that doesn't exist. diff --git a/agents/systems-architect.md b/agents/systems-architect.md index dc5aeb88..5fa51700 100644 --- a/agents/systems-architect.md +++ b/agents/systems-architect.md @@ -2,6 +2,7 @@ name: systems-architect description: "Use this agent to design a system or review architecture: patterns, component boundaries, fitness for purpose and long-term maintainability, not individual PR lines." tools: Read, Grep, Glob, WebFetch, WebSearch, Write +omitClaudeMd: true --- You are an elite Systems Architect with decades of experience designing software systems that endure for as long as their horizon demands. Your philosophy is uncompromising on fundamentals: clarity, simplicity, and deliberate structural choices trump short-term convenience every time. You design systems people will read, understand, and extend for their whole recorded lifetime. diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index bd41c576..6e7faa27 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -1,6 +1,6 @@ """Hold larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's rounds, the scoring run's trigger; the comprehension history's format, its latest places and its count of how often seats agree; and the header of each reviewer's prompt. -usage: larv-review review-folder | ruling-base | round-count | needs-scoring-run [...] | scoring-run-owed | record-ruling | record-scoring [...] | places | agreement | reviewer-header [--rerun] +usage: larv-review review-folder | ruling-base | round-count | needs-scoring-run [...] | scoring-run-owed | record-ruling | record-scoring [...] | places | agreement | reviewer-header [--rerun] | reviewer-context The comprehension check records how hard a project is to read, two ways, and no score blocks a merge. In a paired ruling, simulated readers, the seats, read the branch's head beside a base and vote better, @@ -112,13 +112,18 @@ reviewer-header takes the name of a pass that an agent under agents/ reviews, sp prints it, such as stability. It prints the header of the prompt that launches the pass's reviewer in its next round: the pass and round, the branch's open pull request at its pushed head, the worktree and branch, the merge base of HEAD and the default branch, and the paths of the reviewer's -report, the branch diff and, for architecture and stability, the places. It writes the diff, from +report, the branch diff and, for architecture and stability, the places, then the file that holds +the project principles and decision titles, where the project keeps one. It writes the diff, from that base to HEAD, into the chunk's review folder as branch-.diff, and writes what places prints into places.md; a file whose text is unchanged is left as it is. With --rerun, the header names the report of a relaunch one rung up, in the same round, and the report that asked for it. It exits 1 when the pass takes no more rounds, or, with --rerun, when the report that asked is missing. +reviewer-context is the SubagentStart hook. It reads the hook's input on stdin. For an agent under +agents/, which starts without CLAUDE.md, it prints the hook reply that hands the agent the Prose +and Vocabulary sections of ~/.claude/CLAUDE.md; for any other agent it doesn't print anything. + Exit 1, saying why, on unknown arguments, an unknown item ID, a seats file it cannot read or that breaks the shape above, a todo.md that fails rank_todo.py after record-scoring records a run, or when git cannot start, finds no checkout or no default branch, cannot fetch origin for ruling-base, @@ -135,6 +140,7 @@ from review_rules.round_titles import cap, CAP, RELEASE_REVIEW_CAP, round_counts from failure import Failure from review_rules.comprehension_history import FLOOR from larv_review.history_changes import history_changes +from review_rules.reviewer_context import hook_reply from review_rules.review_folder import made_review_folder from larv_review.ruling_base import measured_commit from larv_review.agreement import MIN_PAIRS @@ -144,7 +150,7 @@ from larv_review.plan import plan_reasons from larv_review.history_commands import record_ruling, record_scoring, show_agreement, show_places from larv_review.reviewer_header import reviewer_header -USAGE = "usage: larv-review review-folder | ruling-base | round-count | needs-scoring-run [...] | scoring-run-owed | record-ruling | record-scoring [...] | places | agreement | reviewer-header [--rerun]" +USAGE = "usage: larv-review review-folder | ruling-base | round-count | needs-scoring-run [...] | scoring-run-owed | record-ruling | record-scoring [...] | places | agreement | reviewer-header [--rerun] | reviewer-context" def main(argv: list[str]) -> int: @@ -172,6 +178,8 @@ def main(argv: list[str]) -> int: done = show_agreement() elif command == "reviewer-header" and given[:1] and given[0] in REVIEWERS and given[1:] in ([], ["--rerun"]): done = with_default_branch(lambda default: reviewer_header(default, given[0], given[1:] == ["--rerun"]), stale_ok=True) + elif command == "reviewer-context" and not given: + done = printed(hook_reply(sys.stdin.read(), pathlib.Path.home())) elif command in ("needs-scoring-run", "record-scoring") and given: named = given[1:] if command == "record-scoring" else given print(f"{command} takes item IDs, the numbers in todo.md's ID column, not {' '.join(id_ for id_ in named if not re.fullmatch(r'[0-9]+', id_))}; {USAGE}", file=sys.stderr) @@ -188,6 +196,14 @@ def main(argv: list[str]) -> int: return 0 +def printed(reply: str | Failure) -> Failure | None: + if isinstance(reply, Failure): + return reply + if reply: + print(reply) + return None + + def with_default_branch(command: typing.Callable[[str], Failure | None], stale_ok: bool) -> Failure | None: default = default_branch(stale_ok) if isinstance(default, Failure): diff --git a/bin/larv_review/reviewer_header.py b/bin/larv_review/reviewer_header.py index f8c9106c..c63f7599 100644 --- a/bin/larv_review/reviewer_header.py +++ b/bin/larv_review/reviewer_header.py @@ -9,6 +9,7 @@ from chunk_preflight.choices import forge_of from larv_review.history_commands import history_file, places_report from review_rules.review_folder import made_review_folder from deploy_release.forge import open_pull, runner +from review_rules.reviewer_context import principles_line # The passes whose reviewer is given the places: skills/larv-review/SKILL.md → "Comprehension check" → "Places". TAKE_PLACES = ("architecture", "stability") @@ -43,6 +44,7 @@ class Launch: f"Report: write it to {report}.", f"Diff: {self.diff}", *([f"Places: {self.folder / 'places.md'}"] if self.pass_ in TAKE_PLACES else []), + *([principles] if (principles := principles_line(self.worktree)) else []), ]) diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 194284de..f77e39a8 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -1,5 +1,6 @@ import decimal import itertools +import json import os import pathlib import subprocess @@ -990,5 +991,25 @@ class LarvReviewTool(unittest.TestCase): folder = self.checkout.parent / ".local" / "state" / "larv-review" / "proj" self.assertEqual(self.header_line("Places:", "architecture"), f"Places: {folder}/places.md") + def test_reviewer_header_names_the_file_that_holds_the_principles_last_where_the_project_keeps_one(self): + self.assertIsNone(self.header_line("Principles:", "prose")) + (self.checkout / "AGENTS.md").write_text("") + ran = self.run_tool("reviewer-header", "prose") + self.assertEqual(ran.stdout.splitlines()[-1], f"Principles: read {self.checkout}/AGENTS.md first, for the project principles and the decision titles.") + + def test_reviewer_context_hands_a_reviewer_the_sections_and_fails_without_them(self): + def hook(agent): + return subprocess.run([sys.executable, str(TOOL), "reviewer-context"], capture_output=True, env=self.env, input=json.dumps({"agent_type": agent}), text=True) + + missing = hook("prose-reviewer") + self.assertEqual((missing.returncode, missing.stdout), (1, "")) + self.assertIn("CLAUDE.md", missing.stderr) + (self.checkout.parent / ".claude").mkdir(exist_ok=True) + (self.checkout.parent / ".claude" / "CLAUDE.md").write_text("## Prose\n\nShort.\n\n## Vocabulary\n\nWords.\n") + ran = hook("prose-reviewer") + self.assertEqual(ran.returncode, 0, ran.stderr) + self.assertIn("## Prose\n\nShort.\n\n## Vocabulary\n\nWords.", json.loads(ran.stdout)["hookSpecificOutput"]["additionalContext"]) + self.assertEqual((hook("Explore").returncode, hook("Explore").stdout), (0, "")) + if __name__ == "__main__": unittest.main() diff --git a/bin/review_replay/main.py b/bin/review_replay/main.py index 8737db83..af9ca60f 100644 --- a/bin/review_replay/main.py +++ b/bin/review_replay/main.py @@ -1,6 +1,6 @@ """Replay a review pass's archived rounds on the rungs below the project's, to find which rungs may run its reviewer: docs/decisions.md → `routing: a review pass runs below the project's rung only on a rung that a replay of its rounds shows finding every 🔴 and 🟡 the project's rung finds`. -usage: review-replay +usage: review-replay [--without-claude-md] is one of architecture, principles, overrides, stability, product-owner or prose. is a project model on the routing ladder, such as claude-opus-5-5. The tool replays the @@ -25,6 +25,15 @@ and counts a finding only where the report raises it as 🔴 or 🟡. The tool p rung missed and the lowest rung that, like each rung above it, missed none. That rung is the evidence for running the pass's reviewer on it; the decision above records each run. +With --without-claude-md it tests instead whether the pass's reviewer may start without CLAUDE.md: +docs/decisions.md → `agents/: a reviewer starts without CLAUDE.md`. It replays every round three +times on the project's rung: twice as archived, then once without the instruction files. The +unchanged reviewer does not find the same findings twice, so the reviewer without CLAUDE.md is held +only to the findings both of those replays found. Claude Code ignores an agent's `omitClaudeMd` +where the agent runs the session, as it does in a replay, and runs no SubagentStart hook there. So +the third replay turns the instruction files off in its settings and opens the prompt with what the +hook hands a reviewer, and closes it with the header's line on the project principles. + Like the loop, it tries claude three times running before it counts a reply as failed. A failed review or match finds nothing. Exit 1, saying why, on bad arguments, an unreadable archive or models file, no archived round to replay, or a usage limit. @@ -40,20 +49,24 @@ import typing from transcript_archive.location import archive_root from rung_replay.command import arguments_or_exit, down_from, failed, limited_exit, projects_on -from review_replay.rounds import authored_by, lost_inputs, report, reviewed_path, Round, round_from, sample, stamp_seconds +from review_replay.rounds import authored_by, comparison, lost_inputs, report, reviewed_path, Round, round_from, sample, stamp_seconds from transcript_archive.project_key import checkout_of from claude_code.reply import claude_reply, Limited from loop_effects.effects import Effects from failure import Failure -from rung_replay.search import first_reply, replayed +from rung_replay.search import first_reply, replayed, replayed_on from claude_code.transcript import first_timestamped_line, read_transcript from model_routing.ladder import LADDER, project_rung, Rung from claude_code.entries import parse_entry, structured_output +from review_rules.reviewer_context import principles_line, reviewer_context from review_rules.review_folder import REPORTS, review_folder from review_rules.review_passes import ReviewedPass, REVIEWERS TOOL = "review-replay" -USAGE = f"{TOOL} , one of {', '.join(REVIEWERS)} and a model on the routing ladder" +WITHOUT = "--without-claude-md" +# Starts claude without its instruction files, as `omitClaudeMd` starts a subagent. +NO_CLAUDE_MD = ["--settings", json.dumps({"env": {"CLAUDE_CODE_DISABLE_CLAUDE_MDS": "1"}})] +USAGE = f"{TOOL} [{WITHOUT}], one of {', '.join(REVIEWERS)} and a model on the routing ladder" LATEST = 10 MATCH_SCHEMA = {"type": "object", "properties": {"found": {"type": "array", "items": {"type": "integer"}}}, "required": ["found"], "additionalProperties": False} @@ -71,7 +84,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff read = arguments_or_exit(TOOL, argv, __doc__, USAGE, pass_and_model) if isinstance(read, int): return read - reviewed, project = read + reviewed, project, without = read rounds = archived_rounds(REVIEWERS[reviewed], project.model, archive_root(home, env), home) if isinstance(rounds, Failure): return failed(TOOL, rounds.reason) @@ -79,6 +92,8 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff if not codes: return failed(TOOL, f"no archived {reviewed} round of projects on {project.model} in {archive_root(home, env)} holds a 🔴 or 🟡 on code it can find") chosen = sample(list(codes), LATEST) + if without: + return compared(reviewed, project, chosen, lambda found, bare: findings_found(found, codes[found], project, project, home, effects, bare)) # The project's rung is the reference, so the candidates start below it. They reach the ladder's lowest rung, below the lowest a worker routes to, since a pass may run below the worker's rung. candidates = down_from(project, LADDER[0])[1:] @@ -92,13 +107,28 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff return 0 -def pass_and_model(argv: list[str]) -> tuple[ReviewedPass, Rung] | None: - """The pass and the project's rung of the model argv names, as ` `; None for any other argv.""" - if len(argv) != 2: +def compared(reviewed: str, project: Rung, chosen: list[Round], found_on: typing.Callable[[Round, bool], set[int] | Limited]) -> int: + """Replays chosen twice with CLAUDE.md and once without, as found_on(round, bare) finds, and prints the comparison.""" + runs: list[list[set[int]]] = [] + for bare in (False, False, True): + def replay_one(one: Round, _: Rung, bare: bool = bare) -> set[int] | Limited: + return found_on(one, bare) + + found = replayed_on(chosen, project, replay_one, f"{reviewed} rounds {'without' if bare else 'with'} the instruction files") + if isinstance(found, Limited): + return limited_exit(TOOL, found) + runs.append(found) + print(comparison(reviewed, project, chosen, (runs[0], runs[1]), runs[2])) + return 0 + + +def pass_and_model(argv: list[str]) -> tuple[ReviewedPass, Rung, bool] | None: + """The pass, the project's rung of the model, and whether WITHOUT follows, as argv names them in ` [--without-claude-md]`; None for any other argv.""" + if argv[2:] not in ([], [WITHOUT]) or len(argv) < 2: return None reviewed = next((kind for kind in REVIEWERS if kind == argv[0]), None) project = project_rung(argv[1]) - return (reviewed, project) if reviewed and project else None + return (reviewed, project, argv[2:] == [WITHOUT]) if reviewed and project else None def codes_found(rounds: list[Round], effects: Effects) -> dict[Round, Code]: @@ -177,9 +207,9 @@ def commit_log(listed: str) -> list[tuple[str, float]]: return [(commit, float(authored)) for commit, authored in (line.split() for line in listed.splitlines())] -def findings_found(found: Round, code: Code, rung: Rung, project: Rung, home: pathlib.Path, effects: Effects) -> set[int] | Limited: - """The indexes of the round's findings that its replay on rung reports, as claude on the project's rung matches them.""" - reviewed: str | Failure | Limited = first_reply(lambda: review(found, code, rung, home, effects)) +def findings_found(found: Round, code: Code, rung: Rung, project: Rung, home: pathlib.Path, effects: Effects, bare: bool = False) -> set[int] | Limited: + """The indexes of the round's findings that its replay on rung reports, as claude on the project's rung matches them; where bare, the replay runs without CLAUDE.md, as `launch` says.""" + reviewed: str | Failure | Limited = first_reply(lambda: review(found, code, rung, home, effects, bare)) if isinstance(reviewed, Limited): return reviewed matched: set[int] | Failure | Limited = reviewed if isinstance(reviewed, Failure) else first_reply(lambda: match(found.findings, reviewed, found.root, project, effects)) @@ -197,17 +227,17 @@ class Copies: # The shell makes and removes the clone itself, and is tested on a temporary home as judge-replay's is; rounds.py's core takes the filesystem as an argument. -def review(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Effects) -> str | Failure | Limited: +def review(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Effects, bare: bool) -> str | Failure | Limited: try: (home / REPORTS).mkdir(mode=0o700, parents=True, exist_ok=True) with tempfile.TemporaryDirectory(prefix="review-replay-", ignore_cleanup_errors=True) as clone, tempfile.TemporaryDirectory(prefix="review-replay-", dir=home / REPORTS, ignore_cleanup_errors=True) as reports: - return reviewed_in(found, code, rung, Copies(clone, reports), home, effects) + return reviewed_in(found, code, rung, Copies(clone, reports), home, effects, bare) except OSError as failure: return Failure(f"could not prepare the replay: {failure}") -def reviewed_in(found: Round, code: Code, rung: Rung, copies: Copies, home: pathlib.Path, effects: Effects) -> str | Failure | Limited: - """The report of found's reviewer on rung, replayed on code cloned into copies.clone, with its review folder copied into copies.reports.""" +def reviewed_in(found: Round, code: Code, rung: Rung, copies: Copies, home: pathlib.Path, effects: Effects, bare: bool) -> str | Failure | Limited: + """The report of found's reviewer on rung, replayed on code cloned into copies.clone, with its review folder copied into copies.reports; without CLAUDE.md where bare.""" folder = pathlib.Path(review_folder(str(home), code.path)) copy_reports(found, folder, copies.reports) prompt = redirected(found.prompt, home, folder, code.path, copies) @@ -217,12 +247,26 @@ def reviewed_in(found: Round, code: Code, rung: Rung, copies: Copies, home: path return Failure(f"the prompt names {', '.join(lost)}, which the review folder did not hold from the chunk's start until the round's") if isinstance(cloned := clone_reviewed(found, code, copies.clone, effects), Failure): return cloned - reply = claude_reply(effects.claude, ["--agent", found.reviewer, *rung.flags()], copies.clone, prompt, "claude") + launched = launch(found.reviewer, rung, prompt, copies.clone, home, bare) + if isinstance(launched, Failure): + return launched + reply = claude_reply(effects.claude, launched[0], copies.clone, launched[1], "claude") if isinstance(reply, Failure | Limited): return reply return reply["result"] if isinstance(reply.get("result"), str) else Failure("the reviewer replied with no report") +def launch(reviewer: str, rung: Rung, prompt: str, clone: str, home: pathlib.Path, bare: bool) -> tuple[list[str], str] | Failure: + """claude's arguments and prompt for reviewer on rung. Where bare, it starts without CLAUDE.md, and the prompt holds what the SubagentStart hook and the header's last line hand such a reviewer.""" + args = ["--agent", reviewer, *rung.flags()] + if not bare: + return args, prompt + context = reviewer_context(home) + if isinstance(context, Failure): + return context + return [*args, *NO_CLAUDE_MD], "\n".join([f"{context}\n\n{prompt}", *([principles] if (principles := principles_line(clone)) else [])]) + + def copy_reports(found: Round, folder: pathlib.Path, reports: str) -> None: """Copies into reports each report written to folder after found's chunk began and before its round did.""" # The round's own report, any later one, and one from an earlier attempt at the item in the same worktree would each hand the reviewer the findings it is to find. diff --git a/bin/review_replay/rounds.py b/bin/review_replay/rounds.py index 9b897670..a21f6775 100644 --- a/bin/review_replay/rounds.py +++ b/bin/review_replay/rounds.py @@ -116,3 +116,20 @@ def report(reviewed: str, model: str, reference: Rung, rounds: list[Round], repl lowest = replay.lowest or "none below the project's rung" lines.append(f"Lowest rung that finds every finding the reference reviewer finds: {lowest}") return "\n".join(lines) + + +def comparison(reviewed: str, reference: Rung, rounds: list[Round], with_it: tuple[list[set[int]], list[set[int]]], without: list[set[int]]) -> str: + """What the two replays with CLAUDE.md and the one without found in rounds, and each finding the one without missed that both of the others found.""" + first, second = with_it + both = [one & other for one, other in zip(first, second)] + missed = [(found_round, index) for found_round, held, found in zip(rounds, both, without) for index in sorted(held - found)] + + def count(run: list[set[int]]) -> int: + return sum(len(found) for found in run) + + return "\n".join([ + f"Replayed {len(rounds)} {reviewed} rounds of {reference.model} projects three times on {reference}, holding {sum(len(found_round.findings) for found_round in rounds)} 🔴 and 🟡 findings.", + f"With CLAUDE.md the reviewer found {count(first)} and then {count(second)} of them, and {count(both)} both times.", + f"Without CLAUDE.md it found {count(without)} of them, and missed {len(missed)} that it found both times with it{':' if missed else '.'}", + *(f" {found_round.root} {found_round.at}: {found_round.findings[index].splitlines()[0]}" for found_round, index in missed), + ]) diff --git a/bin/review_replay/test_review_replay.py b/bin/review_replay/test_review_replay.py index 699ffac4..e4459283 100644 --- a/bin/review_replay/test_review_replay.py +++ b/bin/review_replay/test_review_replay.py @@ -20,6 +20,7 @@ from claude_code.entries import entry_from from failure import Failure from review_replay import main from rung_replay.search import Miss, Replay, Tried +from review_rules.reviewer_context import reviewer_context from review_rules.review_passes import REVIEWERS from model_routing.ladder import Rung @@ -130,6 +131,28 @@ class Report(unittest.TestCase): self.assertEqual(report("stability", "claude-opus-5-5", REFERENCE, rounds, Replay([set(), set()], [], None)).splitlines()[-1], "No rung tried: the reference reviewer found no finding to hold one to.") +class Launch(unittest.TestCase): + def setUp(self): + self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())) + (self.home / ".claude").mkdir() + (self.home / ".claude" / "CLAUDE.md").write_text("## Prose\n\nShort.\n\n## Vocabulary\n\nWords.\n") + self.clone = self.home / "clone" + self.clone.mkdir() + + def test_runs_the_reviewer_as_archived_with_claude_md(self): + self.assertEqual(main.launch("prose-reviewer", REFERENCE, "Review it.", str(self.clone), self.home, False), (["--agent", "prose-reviewer", *REFERENCE.flags()], "Review it.")) + + def test_drops_claude_md_and_hands_the_reviewer_what_the_hook_and_the_header_would(self): + (self.clone / "AGENTS.md").write_text("") + args, prompt = main.launch("prose-reviewer", REFERENCE, "Review it.", str(self.clone), self.home, True) + self.assertEqual(args, ["--agent", "prose-reviewer", *REFERENCE.flags(), "--settings", json.dumps({"env": {"CLAUDE_CODE_DISABLE_CLAUDE_MDS": "1"}})]) + self.assertEqual(prompt, f"{reviewer_context(self.home)}\n\nReview it.\nPrinciples: read {self.clone}/AGENTS.md first, for the project principles and the decision titles.") + + def test_fails_without_the_sections_to_hand_over(self): + (self.home / ".claude" / "CLAUDE.md").write_text("") + self.assertIsInstance(main.launch("prose-reviewer", REFERENCE, "Review it.", str(self.clone), self.home, True), Failure) + + class Match(unittest.TestCase): def run_match(self, stdout): self.asked = [] @@ -185,6 +208,7 @@ class Main(unittest.TestCase): run_git(self.checkout, "remote", "set-head", "origin", "main") for key in ("proj", "other"): self.write_chunk(key, "c1", "2026-10-14T10:00:00Z") + (self.home / ".claude" / "CLAUDE.md").write_text("## Prose\n\nShort.\n\n## Vocabulary\n\nWords.\n") self.reviews = [] self.agents = set() self.matched_in = [] @@ -236,6 +260,25 @@ class Main(unittest.TestCase): code = main.main(argv, {}, self.home, effects) return code, out.getvalue(), err.getvalue() + def test_without_claude_md_replays_each_round_twice_with_it_and_once_without_on_the_project_rung(self): + finds = iter(([0, 1], [0], [1])) + code, out, err = self.run_main(["stability", "claude-opus-5-5", "--without-claude-md"], lambda rung: {"found": next(finds)}) + self.assertEqual(code, 0, err) + self.assertEqual([rung for rung, *_ in self.reviews], [REFERENCE] * 3) + context = reviewer_context(self.home) + self.assertEqual([prompt.startswith(context) for *_, prompt, _ in self.reviews], [False, False, True]) + self.assertEqual(out, ( + f"Replayed 1 stability rounds of claude-opus-5-5 projects three times on {REFERENCE}, holding 2 🔴 and 🟡 findings.\n" + "With CLAUDE.md the reviewer found 2 and then 1 of them, and 1 both times.\n" + "Without CLAUDE.md it found 1 of them, and missed 1 that it found both times with it:\n" + f" {self.checkout} 2026-10-14T10:00:00Z: 🔴 a.txt:1 wrong\n" + )) + + def test_without_claude_md_stops_at_a_usage_limit(self): + code, out, _ = self.run_main(["stability", "claude-opus-5-5", "--without-claude-md"], lambda rung: {"type": "result", "api_error_status": 429, "result": "You've hit your limit"}) + self.assertEqual((code, out), (1, "")) + self.assertEqual(len(self.reviews), 1) + def test_replays_the_models_rounds_on_the_commit_reviewed_from_the_project_rung_down(self): code, out, err = self.run_main(["stability", "claude-opus-5-5"], lambda rung: {"found": [0] if rung == MIDDLE else [0, 1]}) self.assertEqual(code, 0, err) @@ -427,7 +470,7 @@ class Main(unittest.TestCase): def test_prints_the_help(self): code, out, _ = self.run_main(["-h"], unused) - self.assertEqual((code, out.splitlines()[2]), (0, "usage: review-replay ")) + self.assertEqual((code, out.splitlines()[2]), (0, "usage: review-replay [--without-claude-md]")) self.assertIn(f"{', '.join(list(REVIEWERS)[:-1])} or {list(REVIEWERS)[-1]}.", " ".join(out.split())) def test_the_launcher_prints_the_help(self): diff --git a/bin/review_rules/reviewer_context.py b/bin/review_rules/reviewer_context.py new file mode 100644 index 00000000..3d9fa03c --- /dev/null +++ b/bin/review_rules/reviewer_context.py @@ -0,0 +1,52 @@ +"""What a reviewer under agents/ is handed in place of the instruction files: `omitClaudeMd` starts it without them, and most of `~/.claude/CLAUDE.md` is the worker's. docs/decisions.md → `agents/: a reviewer starts without CLAUDE.md` says why.""" +import json +import pathlib + +from failure import Failure +from review_rules.review_passes import REVIEWERS + +# The sections of ~/.claude/CLAUDE.md a reviewer needs: the words its reports use and the bar its own prose meets. +SECTIONS = ("Prose", "Vocabulary") + + +def reviewer_context(home: pathlib.Path) -> str | Failure: + """SECTIONS of the CLAUDE.md under home, as a reviewer is told them; a Failure where the file or a section is missing.""" + path = home / ".claude" / "CLAUDE.md" + try: + text = path.read_text(encoding="utf-8") + except (OSError, UnicodeDecodeError) as failure: + return Failure(f"could not read {path}: {failure}") + found: dict[str, list[str]] = {} + lines: list[str] = [] + for line in text.splitlines(): + if line.startswith("## "): + lines = found.setdefault(line[3:].strip(), []) + lines.append(line) + if missing := [name for name in SECTIONS if name not in found]: + return Failure(f"{path} holds no section {', '.join(missing)}") + return "\n\n".join(["You start without `~/.claude/CLAUDE.md`. These sections of it hold for you:", *("\n".join(found[name]).strip() for name in SECTIONS)]) + + +def hook_reply(given: str, home: pathlib.Path) -> str | Failure: + """What the SubagentStart hook prints for its input given: the context for a reviewer under agents/, nothing for any other agent.""" + try: + read = json.loads(given) + except ValueError: + return "" + if not isinstance(read, dict) or read.get("agent_type") not in REVIEWERS.values(): + return "" + context = reviewer_context(home) + if isinstance(context, Failure): + return context + return json.dumps({"hookSpecificOutput": {"hookEventName": "SubagentStart", "additionalContext": context}}) + + +def principles_line(worktree: str) -> str | None: + """The line of a reviewer's header that names where the project in worktree keeps its principles and decision titles, or None where it keeps neither file.""" + # The header names the file rather than quoting it, since the worker types the header into each reviewer's prompt. + what = "for the project principles and the decision titles" + if (pathlib.Path(worktree) / "AGENTS.md").is_file(): + return f"Principles: read {worktree}/AGENTS.md first, {what}." + if (pathlib.Path(worktree) / "docs" / "decisions.md").is_file(): + return f"Principles: read {worktree}/docs/decisions.md first, up to `# Decisions`, {what}." + return None diff --git a/bin/review_rules/test_reviewer_context.py b/bin/review_rules/test_reviewer_context.py new file mode 100644 index 00000000..fb846060 --- /dev/null +++ b/bin/review_rules/test_reviewer_context.py @@ -0,0 +1,82 @@ +import json +import pathlib +import sys +import tempfile +import unittest + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) + +from failure import Failure +from review_rules.reviewer_context import hook_reply, principles_line, reviewer_context, SECTIONS +from review_rules.review_passes import REVIEWERS + +REPO = pathlib.Path(__file__).resolve().parents[2] +CLAUDE_MD = "# Global\n\n## Working loop\n\nThe worker's.\n\n## Prose\n\nWrite short.\n\n## Git\n\nOne line.\n\n## Vocabulary\n\n- **chunk** — a unit.\n" + + +class ReviewerContext(unittest.TestCase): + def setUp(self): + self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())) + (self.home / ".claude").mkdir() + (self.home / ".claude" / "CLAUDE.md").write_text(CLAUDE_MD) + + def test_holds_the_prose_and_vocabulary_sections_and_none_of_the_workers(self): + self.assertEqual(reviewer_context(self.home), "You start without `~/.claude/CLAUDE.md`. These sections of it hold for you:\n\n## Prose\n\nWrite short.\n\n## Vocabulary\n\n- **chunk** — a unit.") + + def test_fails_on_a_missing_section_or_file(self): + (self.home / ".claude" / "CLAUDE.md").write_text("## Prose\n\nWrite short.\n") + self.assertEqual(reviewer_context(self.home), Failure(f"{self.home / '.claude' / 'CLAUDE.md'} holds no section Vocabulary")) + (self.home / ".claude" / "CLAUDE.md").unlink() + self.assertIsInstance(reviewer_context(self.home), Failure) + + def test_the_repos_claude_md_holds_each_section(self): + headings = [line[3:] for line in (REPO / "CLAUDE.md").read_text().splitlines() if line.startswith("## ")] + self.assertEqual([name for name in SECTIONS if name not in headings], []) + + def test_the_hook_hands_a_reviewer_the_context_and_any_other_agent_nothing(self): + for agent in REVIEWERS.values(): + with self.subTest(agent=agent): + reply = hook_reply(json.dumps({"hook_event_name": "SubagentStart", "agent_type": agent}), self.home) + self.assertEqual(json.loads(reply), {"hookSpecificOutput": {"hookEventName": "SubagentStart", "additionalContext": reviewer_context(self.home)}}) + for given in (json.dumps({"agent_type": "Explore"}), json.dumps({}), json.dumps([]), "no json"): + with self.subTest(given=given): + self.assertEqual(hook_reply(given, self.home), "") + + def test_the_hook_fails_for_a_reviewer_when_a_section_is_missing(self): + (self.home / ".claude" / "CLAUDE.md").write_text("") + self.assertIsInstance(hook_reply(json.dumps({"agent_type": "prose-reviewer"}), self.home), Failure) + + +class PrinciplesLine(unittest.TestCase): + def setUp(self): + self.worktree = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())) + + def test_names_agents_md_where_the_project_keeps_one(self): + (self.worktree / "AGENTS.md").write_text("") + (self.worktree / "docs").mkdir() + (self.worktree / "docs" / "decisions.md").write_text("") + self.assertEqual(principles_line(str(self.worktree)), f"Principles: read {self.worktree}/AGENTS.md first, for the project principles and the decision titles.") + + def test_names_the_head_of_the_decision_log_where_the_project_keeps_no_agents_md(self): + (self.worktree / "docs").mkdir() + (self.worktree / "docs" / "decisions.md").write_text("") + self.assertEqual(principles_line(str(self.worktree)), f"Principles: read {self.worktree}/docs/decisions.md first, up to `# Decisions`, for the project principles and the decision titles.") + + def test_names_nothing_where_the_project_keeps_neither(self): + self.assertIsNone(principles_line(str(self.worktree))) + + +class Reviewers(unittest.TestCase): + def test_each_agent_starts_without_claude_md(self): + for path in sorted((REPO / "agents").glob("*.md")): + with self.subTest(agent=path.stem): + frontmatter = path.read_text().split("---\n")[1] + self.assertIn("omitClaudeMd: true\n", frontmatter) + + def test_settings_run_the_hook_as_each_subagent_starts(self): + hooks = json.loads((REPO / "settings.json").read_text())["hooks"]["SubagentStart"] + self.assertEqual(hooks, [{"hooks": [{"command": "~/.claude/bin/larv-review reviewer-context", "timeout": 30, "type": "command"}]}]) + + +if __name__ == "__main__": + unittest.main() diff --git a/settings.json b/settings.json index 6867d88a..d865a819 100644 --- a/settings.json +++ b/settings.json @@ -34,6 +34,17 @@ ], "matcher": "Agent|Bash|Edit|MultiEdit|Read|Skill|Write" } + ], + "SubagentStart": [ + { + "hooks": [ + { + "command": "~/.claude/bin/larv-review reviewer-context", + "timeout": 30, + "type": "command" + } + ] + } ] }, "includeCoAuthoredBy": false, -- 2.52.0 From 384b1bbc635c2620e39b4b0797462fea1a3413c1 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 05:50:19 +0100 Subject: [PATCH 03/14] Hand a reviewer the shared goal too, and describe the hook and the replay mode in the README --- README.md | 4 ++-- bin/larv_review/main.py | 5 +++-- bin/larv_review/test_larv_review.py | 2 +- bin/review_replay/test_review_replay.py | 4 ++-- bin/review_rules/reviewer_context.py | 4 ++-- bin/review_rules/test_reviewer_context.py | 8 ++++---- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f4115c9b..f3524368 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Install puts only `loop-claude` and `loop-inbox` on `PATH`; call the others by t - `command-patterns []` prints a table of the shell command patterns a release's archived chunks ran, such as `tea pr create`, for an audit of the release; `command-patterns --help` states its columns. - `deploy-release [--cut] []` moves `~/.claude`, or the checkout named, to the newest release, as Update says; with `--cut`, run in the development clone, it first cuts the next release, as Release says. - `judge-replay ` replays loop-claude's judge on archived verdicts of the projects run on the model, and prints what each rung a review climbs to misses, and the lowest rung below them that, like each candidate above it, returns them; `judge-replay --help` states the replay. -- `larv-review ` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count, the scoring run's trigger; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `larv-review --help` states them. +- `larv-review ` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count, the scoring run's trigger; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `settings.json` → `hooks` runs `larv-review reviewer-context` as each subagent starts: it hands a reviewer under `agents/`, which starts without `CLAUDE.md`, that file's "Shared goal", "Prose" and "Vocabulary" sections. `larv-review --help` states them. - `loop-claude ` runs a project's next chunk cycle after cycle; `loop-claude --help` states its contract. - `loop-inbox` shows the interrupts of every loop-claude on the machine, oldest first, takes each one's answer, `/talk` included, and lists every running loop with the `todo.md` items its chunk takes; `loop-inbox --help` states how. - `mattermost-dm []` sends a message, or else stdin, from the Mattermost bot to the human; `~/.claude/.env` names the server, the bot's token and the human, and `mattermost-dm --help` names its keys. `loop-claude --help` says when loop-claude sends one. @@ -110,7 +110,7 @@ Install puts only `loop-claude` and `loop-inbox` on `PATH`; call the others by t - `mutate-changes [--base ] [--prefix ] [--jobs ]` mutation-tests the lines a branch changes and prints each mutant its tests don't kill; `mutate-changes --help` says which tool it runs for each language. - `rank_todo.py [--check] [todo.md]` scores and ranks a project's `todo.md`; `rank_todo.py --help` states the format. - `reading-cost [--reset] [record]` appends a figure for each chunk `loop-claude` finished to a project's `docs/reading-cost.md`, and says whether the figures rise; `reading-cost --help` states the measure. -- `review-replay ` replays a review pass's archived rounds from the projects run on the model, on the code each reviewed, and prints the lowest rung below the project's that, like each rung above it, finds every 🔴 and 🟡 the project's rung finds again; `review-replay --help` states the replay. Each replayed reviewer skips every permission prompt, stability-reviewer has Bash, and an archived prompt may name paths on the host. +- `review-replay ` replays a review pass's archived rounds from the projects run on the model, on the code each reviewed, and prints the lowest rung below the project's that, like each rung above it, finds every 🔴 and 🟡 the project's rung finds again; `review-replay --help` states the replay. With `--without-claude-md` it tests instead whether the pass's reviewer may start without `CLAUDE.md`: it replays each round twice as archived and once without the instruction files, and prints each finding the last replay missed that both of the others found. Each replayed reviewer skips every permission prompt, stability-reviewer has Bash, and an archived prompt may name paths on the host. - `rule-hook [overrides]` blocks a tool call that breaks a rule a program can check, unless the call overrides the rule; `settings.json` → `hooks` runs it before each Agent, Bash, Edit, MultiEdit, Read, Skill and Write call, and `rule-hook --help` states the rules and the override. - `run-heavy ` runs a heavy command once it holds one of the machine's heavy slots, one per 4 CPUs, which every session shares; `run-heavy --help` states the slots, and the memory cap it gives a container that sets no limit. - `score-outcomes [L E I S]` shows what each finished item's chunk measured beside the scores the item was guessed at, to score a new item by, and code health's two counter-signals per chunk, misread findings and later fixes; `score-outcomes --help` states the report. diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index 6e7faa27..946cefd2 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -121,8 +121,9 @@ it. It exits 1 when the pass takes no more rounds, or, with --rerun, when the re missing. reviewer-context is the SubagentStart hook. It reads the hook's input on stdin. For an agent under -agents/, which starts without CLAUDE.md, it prints the hook reply that hands the agent the Prose -and Vocabulary sections of ~/.claude/CLAUDE.md; for any other agent it doesn't print anything. +agents/, which starts without CLAUDE.md, it prints the hook reply that hands the agent the Shared +goal, Prose and Vocabulary sections of ~/.claude/CLAUDE.md; for any other agent it doesn't print +anything. Exit 1, saying why, on unknown arguments, an unknown item ID, a seats file it cannot read or that breaks the shape above, a todo.md that fails rank_todo.py after record-scoring records a run, or diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index f77e39a8..07ad0cbf 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -1005,7 +1005,7 @@ class LarvReviewTool(unittest.TestCase): self.assertEqual((missing.returncode, missing.stdout), (1, "")) self.assertIn("CLAUDE.md", missing.stderr) (self.checkout.parent / ".claude").mkdir(exist_ok=True) - (self.checkout.parent / ".claude" / "CLAUDE.md").write_text("## Prose\n\nShort.\n\n## Vocabulary\n\nWords.\n") + (self.checkout.parent / ".claude" / "CLAUDE.md").write_text("## Shared goal\n\nHealth.\n\n## Prose\n\nShort.\n\n## Vocabulary\n\nWords.\n") ran = hook("prose-reviewer") self.assertEqual(ran.returncode, 0, ran.stderr) self.assertIn("## Prose\n\nShort.\n\n## Vocabulary\n\nWords.", json.loads(ran.stdout)["hookSpecificOutput"]["additionalContext"]) diff --git a/bin/review_replay/test_review_replay.py b/bin/review_replay/test_review_replay.py index e4459283..fc31fb9b 100644 --- a/bin/review_replay/test_review_replay.py +++ b/bin/review_replay/test_review_replay.py @@ -135,7 +135,7 @@ class Launch(unittest.TestCase): def setUp(self): self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())) (self.home / ".claude").mkdir() - (self.home / ".claude" / "CLAUDE.md").write_text("## Prose\n\nShort.\n\n## Vocabulary\n\nWords.\n") + (self.home / ".claude" / "CLAUDE.md").write_text("## Shared goal\n\nHealth.\n\n## Prose\n\nShort.\n\n## Vocabulary\n\nWords.\n") self.clone = self.home / "clone" self.clone.mkdir() @@ -208,7 +208,7 @@ class Main(unittest.TestCase): run_git(self.checkout, "remote", "set-head", "origin", "main") for key in ("proj", "other"): self.write_chunk(key, "c1", "2026-10-14T10:00:00Z") - (self.home / ".claude" / "CLAUDE.md").write_text("## Prose\n\nShort.\n\n## Vocabulary\n\nWords.\n") + (self.home / ".claude" / "CLAUDE.md").write_text("## Shared goal\n\nHealth.\n\n## Prose\n\nShort.\n\n## Vocabulary\n\nWords.\n") self.reviews = [] self.agents = set() self.matched_in = [] diff --git a/bin/review_rules/reviewer_context.py b/bin/review_rules/reviewer_context.py index 3d9fa03c..4dcf99f3 100644 --- a/bin/review_rules/reviewer_context.py +++ b/bin/review_rules/reviewer_context.py @@ -5,8 +5,8 @@ import pathlib from failure import Failure from review_rules.review_passes import REVIEWERS -# The sections of ~/.claude/CLAUDE.md a reviewer needs: the words its reports use and the bar its own prose meets. -SECTIONS = ("Prose", "Vocabulary") +# The sections of ~/.claude/CLAUDE.md a reviewer needs, in the file's order: the code-health goal the agents cite, the bar its own prose meets, and the words its reports use. +SECTIONS = ("Shared goal", "Prose", "Vocabulary") def reviewer_context(home: pathlib.Path) -> str | Failure: diff --git a/bin/review_rules/test_reviewer_context.py b/bin/review_rules/test_reviewer_context.py index fb846060..2c21c774 100644 --- a/bin/review_rules/test_reviewer_context.py +++ b/bin/review_rules/test_reviewer_context.py @@ -11,7 +11,7 @@ from review_rules.reviewer_context import hook_reply, principles_line, reviewer_ from review_rules.review_passes import REVIEWERS REPO = pathlib.Path(__file__).resolve().parents[2] -CLAUDE_MD = "# Global\n\n## Working loop\n\nThe worker's.\n\n## Prose\n\nWrite short.\n\n## Git\n\nOne line.\n\n## Vocabulary\n\n- **chunk** — a unit.\n" +CLAUDE_MD = "# Global\n\n## Working loop\n\nThe worker's.\n\n## Shared goal\n\nCode health.\n\n## Prose\n\nWrite short.\n\n## Git\n\nOne line.\n\n## Vocabulary\n\n- **chunk** — a unit.\n" class ReviewerContext(unittest.TestCase): @@ -20,12 +20,12 @@ class ReviewerContext(unittest.TestCase): (self.home / ".claude").mkdir() (self.home / ".claude" / "CLAUDE.md").write_text(CLAUDE_MD) - def test_holds_the_prose_and_vocabulary_sections_and_none_of_the_workers(self): - self.assertEqual(reviewer_context(self.home), "You start without `~/.claude/CLAUDE.md`. These sections of it hold for you:\n\n## Prose\n\nWrite short.\n\n## Vocabulary\n\n- **chunk** — a unit.") + def test_holds_the_shared_goal_prose_and_vocabulary_sections_and_none_of_the_workers(self): + self.assertEqual(reviewer_context(self.home), "You start without `~/.claude/CLAUDE.md`. These sections of it hold for you:\n\n## Shared goal\n\nCode health.\n\n## Prose\n\nWrite short.\n\n## Vocabulary\n\n- **chunk** — a unit.") def test_fails_on_a_missing_section_or_file(self): (self.home / ".claude" / "CLAUDE.md").write_text("## Prose\n\nWrite short.\n") - self.assertEqual(reviewer_context(self.home), Failure(f"{self.home / '.claude' / 'CLAUDE.md'} holds no section Vocabulary")) + self.assertEqual(reviewer_context(self.home), Failure(f"{self.home / '.claude' / 'CLAUDE.md'} holds no section Shared goal, Vocabulary")) (self.home / ".claude" / "CLAUDE.md").unlink() self.assertIsInstance(reviewer_context(self.home), Failure) -- 2.52.0 From 9c11fefe45e68f7f0aade071657763bc32c532a5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 05:50:37 +0100 Subject: [PATCH 04/14] Say in larv-review's Reports that the header names the principles file --- skills/larv-review/SKILL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 2035dbbe..bf5f8b89 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -63,7 +63,7 @@ Give a reviewer without Bash `git ls-files`'s output in its prompt, since some h `~/.claude/bin/larv-review` holds this section's mechanical rules: the chunk's review folder, the round count, the paired ruling's base and vote count, the scoring run's trigger; the history's format, its latest places and its count of how often seats agree; and the header of each reviewer's prompt. Run it in the chunk's worktree; `~/.claude/bin/larv-review --help` states each rule. On exit 1, repair what its message names and run it again; when you cannot, ask the user. -**Reports.** Run `~/.claude/bin/larv-review reviewer-header ` in the chunk's worktree, and open each prompt to an agent under `~/.claude/agents/` with what it prints; then say in a few lines what the change does and which files it touches. The command makes the chunk's review folder and writes the branch diff into it. The header names that diff and the reviewer's full report, `-round-.md`, in the folder, and for architecture and stability the places too. For a relaunch one rung up, add `--rerun`: the report becomes `-round--rerun.md`, and the header names the report that asked. Before you answer a 🔴 or 🟡, read its entry: Grep the report for the finding's place, with the lines after it, rather than Read the whole report. rule-hook refuses a reviewer's Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`. Keep the folder after the merge: `review-replay` replays a round from the reports its prompt names. +**Reports.** Run `~/.claude/bin/larv-review reviewer-header ` in the chunk's worktree, and open each prompt to an agent under `~/.claude/agents/` with what it prints; then say in a few lines what the change does and which files it touches. The command makes the chunk's review folder and writes the branch diff into it. The header names that diff and the reviewer's full report, `-round-.md`, in the folder, and for architecture and stability the places too. Its last line names the file that holds the project principles and decision titles, which a reviewer, started without `CLAUDE.md`, reads first. For a relaunch one rung up, add `--rerun`: the report becomes `-round--rerun.md`, and the header names the report that asked. Before you answer a 🔴 or 🟡, read its entry: Grep the report for the finding's place, with the lines after it, rather than Read the whole report. rule-hook refuses a reviewer's Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`. Keep the folder after the merge: `review-replay` replays a round from the reports its prompt names. **Precedent, then ask** — for the full scan: -- 2.52.0 From 07aa4b9f8314e51bfd7a4cfcecf68ba12010c7d5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 05:51:12 +0100 Subject: [PATCH 05/14] Spell the replay's flag --omit-claude-md, as a panel of three readers picked --- README.md | 2 +- bin/review_replay/main.py | 14 +++++++------- bin/review_replay/test_review_replay.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f3524368..515d9268 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Install puts only `loop-claude` and `loop-inbox` on `PATH`; call the others by t - `mutate-changes [--base ] [--prefix ] [--jobs ]` mutation-tests the lines a branch changes and prints each mutant its tests don't kill; `mutate-changes --help` says which tool it runs for each language. - `rank_todo.py [--check] [todo.md]` scores and ranks a project's `todo.md`; `rank_todo.py --help` states the format. - `reading-cost [--reset] [record]` appends a figure for each chunk `loop-claude` finished to a project's `docs/reading-cost.md`, and says whether the figures rise; `reading-cost --help` states the measure. -- `review-replay ` replays a review pass's archived rounds from the projects run on the model, on the code each reviewed, and prints the lowest rung below the project's that, like each rung above it, finds every 🔴 and 🟡 the project's rung finds again; `review-replay --help` states the replay. With `--without-claude-md` it tests instead whether the pass's reviewer may start without `CLAUDE.md`: it replays each round twice as archived and once without the instruction files, and prints each finding the last replay missed that both of the others found. Each replayed reviewer skips every permission prompt, stability-reviewer has Bash, and an archived prompt may name paths on the host. +- `review-replay ` replays a review pass's archived rounds from the projects run on the model, on the code each reviewed, and prints the lowest rung below the project's that, like each rung above it, finds every 🔴 and 🟡 the project's rung finds again; `review-replay --help` states the replay. With `--omit-claude-md` it tests instead whether the pass's reviewer may start without `CLAUDE.md`: it replays each round twice as archived and once without the instruction files, and prints each finding the last replay missed that both of the others found. Each replayed reviewer skips every permission prompt, stability-reviewer has Bash, and an archived prompt may name paths on the host. - `rule-hook [overrides]` blocks a tool call that breaks a rule a program can check, unless the call overrides the rule; `settings.json` → `hooks` runs it before each Agent, Bash, Edit, MultiEdit, Read, Skill and Write call, and `rule-hook --help` states the rules and the override. - `run-heavy ` runs a heavy command once it holds one of the machine's heavy slots, one per 4 CPUs, which every session shares; `run-heavy --help` states the slots, and the memory cap it gives a container that sets no limit. - `score-outcomes [L E I S]` shows what each finished item's chunk measured beside the scores the item was guessed at, to score a new item by, and code health's two counter-signals per chunk, misread findings and later fixes; `score-outcomes --help` states the report. diff --git a/bin/review_replay/main.py b/bin/review_replay/main.py index af9ca60f..03b44544 100644 --- a/bin/review_replay/main.py +++ b/bin/review_replay/main.py @@ -1,6 +1,6 @@ """Replay a review pass's archived rounds on the rungs below the project's, to find which rungs may run its reviewer: docs/decisions.md → `routing: a review pass runs below the project's rung only on a rung that a replay of its rounds shows finding every 🔴 and 🟡 the project's rung finds`. -usage: review-replay [--without-claude-md] +usage: review-replay [--omit-claude-md] is one of architecture, principles, overrides, stability, product-owner or prose. is a project model on the routing ladder, such as claude-opus-5-5. The tool replays the @@ -25,7 +25,7 @@ and counts a finding only where the report raises it as 🔴 or 🟡. The tool p rung missed and the lowest rung that, like each rung above it, missed none. That rung is the evidence for running the pass's reviewer on it; the decision above records each run. -With --without-claude-md it tests instead whether the pass's reviewer may start without CLAUDE.md: +With --omit-claude-md it tests instead whether the pass's reviewer may start without CLAUDE.md: docs/decisions.md → `agents/: a reviewer starts without CLAUDE.md`. It replays every round three times on the project's rung: twice as archived, then once without the instruction files. The unchanged reviewer does not find the same findings twice, so the reviewer without CLAUDE.md is held @@ -63,10 +63,10 @@ from review_rules.review_folder import REPORTS, review_folder from review_rules.review_passes import ReviewedPass, REVIEWERS TOOL = "review-replay" -WITHOUT = "--without-claude-md" +OMIT = "--omit-claude-md" # Starts claude without its instruction files, as `omitClaudeMd` starts a subagent. NO_CLAUDE_MD = ["--settings", json.dumps({"env": {"CLAUDE_CODE_DISABLE_CLAUDE_MDS": "1"}})] -USAGE = f"{TOOL} [{WITHOUT}], one of {', '.join(REVIEWERS)} and a model on the routing ladder" +USAGE = f"{TOOL} [{OMIT}], one of {', '.join(REVIEWERS)} and a model on the routing ladder" LATEST = 10 MATCH_SCHEMA = {"type": "object", "properties": {"found": {"type": "array", "items": {"type": "integer"}}}, "required": ["found"], "additionalProperties": False} @@ -123,12 +123,12 @@ def compared(reviewed: str, project: Rung, chosen: list[Round], found_on: typing def pass_and_model(argv: list[str]) -> tuple[ReviewedPass, Rung, bool] | None: - """The pass, the project's rung of the model, and whether WITHOUT follows, as argv names them in ` [--without-claude-md]`; None for any other argv.""" - if argv[2:] not in ([], [WITHOUT]) or len(argv) < 2: + """The pass, the project's rung of the model, and whether OMIT follows, as argv names them in ` [--omit-claude-md]`; None for any other argv.""" + if argv[2:] not in ([], [OMIT]) or len(argv) < 2: return None reviewed = next((kind for kind in REVIEWERS if kind == argv[0]), None) project = project_rung(argv[1]) - return (reviewed, project, argv[2:] == [WITHOUT]) if reviewed and project else None + return (reviewed, project, argv[2:] == [OMIT]) if reviewed and project else None def codes_found(rounds: list[Round], effects: Effects) -> dict[Round, Code]: diff --git a/bin/review_replay/test_review_replay.py b/bin/review_replay/test_review_replay.py index fc31fb9b..5346c35e 100644 --- a/bin/review_replay/test_review_replay.py +++ b/bin/review_replay/test_review_replay.py @@ -262,7 +262,7 @@ class Main(unittest.TestCase): def test_without_claude_md_replays_each_round_twice_with_it_and_once_without_on_the_project_rung(self): finds = iter(([0, 1], [0], [1])) - code, out, err = self.run_main(["stability", "claude-opus-5-5", "--without-claude-md"], lambda rung: {"found": next(finds)}) + code, out, err = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"found": next(finds)}) self.assertEqual(code, 0, err) self.assertEqual([rung for rung, *_ in self.reviews], [REFERENCE] * 3) context = reviewer_context(self.home) @@ -275,7 +275,7 @@ class Main(unittest.TestCase): )) def test_without_claude_md_stops_at_a_usage_limit(self): - code, out, _ = self.run_main(["stability", "claude-opus-5-5", "--without-claude-md"], lambda rung: {"type": "result", "api_error_status": 429, "result": "You've hit your limit"}) + code, out, _ = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"type": "result", "api_error_status": 429, "result": "You've hit your limit"}) self.assertEqual((code, out), (1, "")) self.assertEqual(len(self.reviews), 1) @@ -470,7 +470,7 @@ class Main(unittest.TestCase): def test_prints_the_help(self): code, out, _ = self.run_main(["-h"], unused) - self.assertEqual((code, out.splitlines()[2]), (0, "usage: review-replay [--without-claude-md]")) + self.assertEqual((code, out.splitlines()[2]), (0, "usage: review-replay [--omit-claude-md]")) self.assertIn(f"{', '.join(list(REVIEWERS)[:-1])} or {list(REVIEWERS)[-1]}.", " ".join(out.split())) def test_the_launcher_prints_the_help(self): -- 2.52.0 From 9196aeb5c7f36f77208f6e8a32ad6f09bf5473dd Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 05:51:27 +0100 Subject: [PATCH 06/14] File the reading-cost item its rise asks for --- todo.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/todo.md b/todo.md index 7105aa34..0d8ccac2 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 339` +`Next ID = 340` ## Items @@ -26,6 +26,7 @@ | 299 | 0.9.0 | | | **Replay the archived judge verdicts through code rules and a classifier trained locally on the archive, and file an item for each verdict kind one of them decides with no missed interrupt.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 1.2 | | 311 | 0.9.0 | | | **Hand each worker's claude a Bash output ceiling that saves longer output to a file, and refuse a Read of a session transcript under `~/.claude/projects`.** | 2 | 2 | 3 | 5 | 3 | 1.4 by 3 | 1.2 | | 316 | 0.9.0 | | | **Launch comprehension seats as an agent type of their own under `agents/`, without `CLAUDE.md` and the skill and agent listings a general-purpose subagent carries.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 3 | 1.2 | +| 339 | 0.9.0 | | | **Lower the reading cost of the files a chunk reads most before its first commit.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 1.2 | | 310 | 0.9.0 | | | **Compact a waiting worker's session shortly before its prompt cache expires, only when the human has not answered an interrupt by then.** | 3 | 2 | 3 | 6 | 4 | 1.4 by 3 | 1.0 | | 298 | 0.9.0 | | | **Send the judge only the decision entries and the transcript tail a verdict needs, and keep the cut only where `judge-replay` changes no verdict kind.** | 3 | 3 | 3 | 7 | 4 | 1.4 by 2, 1.5 by 1 | 1.0 | | 326 | 0.9.0 | | | **Let `chunk-pr ready` take the pull request's final title and set it as it marks the pull request ready.** | 2 | 1 | 3 | 4 | 2 | 1.4 by 1, 1.5 by 1 | 0.9 | @@ -174,6 +175,10 @@ Subagents inherit the variable, and the decision of 2026-10-27 found a 12k cap c Seats run as general-purpose subagents, so each starts with the skill and agent listings, about 7,500 tokens, at $9.00 per 1,000 prefix tokens over the archive measured from 2026-09-30 to 2026-11-11: about 1.3% of spend. An agent under `agents/` with Read, Grep, Glob and Bash, `omitClaudeMd: true`, and the seat's persona in its prompt drops both; a seat reads the project as a newcomer does, which is what it simulates. Keep each seat's prompt from `skills/comprehension-panel/seat-prompts.md`. Check that a scoring run's scores on one head stay within the spread two runs of today's seats show. lilleman approved on 2026-11-11. +### 339. Lower the reading cost of the files a chunk reads most before its first commit. + +`reading-cost` printed `Rising:` on 2026-11-12: the last 5 chunks' median is 128,199 new input tokens before their first commit, the 5 before them 101,795. Read most over the last 5, as opens and searches: `todo.md` 34, `docs/decisions.md` 26, `README.md` 19, `skills/larv-review/SKILL.md` 13, `bin/loop_claude/routing.py` 8, `CHANGELOG.md` 6. The chunk that ships this runs `reading-cost --reset`. + ### 310. Compact a waiting worker's session shortly before its prompt cache expires, only when the human has not answered an interrupt by then. 281 worker resumes after the 1-hour cache expired rewrote a whole context, $379 of the $9,154 measured from 2026-09-30 to 2026-11-11 (4.1%). A compaction while the cache is warm reads the context at a twentieth of the input price and leaves about 20k tokens to rewrite later. -- 2.52.0 From 2922d70a45336a1e5154028a2a2b53dd00f7878b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 05:51:54 +0100 Subject: [PATCH 07/14] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20the=20hook?= =?UTF-8?q?=20reads=20one=20fixed=20file=20and=20the=20replay=20adds=20a?= =?UTF-8?q?=20constant=20argument?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 4adcadcddb9e1b5637c99d1789558e718057acf3 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 06:03:31 +0100 Subject: [PATCH 08/14] Pin the replay's progress lines, its limit exit and the comparison without a miss in tests --- bin/review_replay/test_review_replay.py | 11 ++++++++++- bin/review_rules/test_reviewer_context.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/review_replay/test_review_replay.py b/bin/review_replay/test_review_replay.py index 5346c35e..791a148f 100644 --- a/bin/review_replay/test_review_replay.py +++ b/bin/review_replay/test_review_replay.py @@ -273,10 +273,19 @@ class Main(unittest.TestCase): "Without CLAUDE.md it found 1 of them, and missed 1 that it found both times with it:\n" f" {self.checkout} 2026-10-14T10:00:00Z: 🔴 a.txt:1 wrong\n" )) + with_them = f"replaying 1 stability rounds with the instruction files on {REFERENCE}\n" + self.assertEqual(err, with_them * 2 + f"replaying 1 stability rounds without the instruction files on {REFERENCE}\n") + + def test_without_claude_md_says_so_where_the_reviewer_missed_nothing_and_names_a_reviewer_that_printed_no_json(self): + code, out, err = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"found": [0]}) + self.assertEqual((code, out.splitlines()[-1]), (0, "Without CLAUDE.md it found 1 of them, and missed 0 that it found both times with it.")) + _, _, err = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"found": [0]}, review=lambda rung: []) + self.assertIn("found nothing: claude printed no json reply", err) def test_without_claude_md_stops_at_a_usage_limit(self): - code, out, _ = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"type": "result", "api_error_status": 429, "result": "You've hit your limit"}) + code, out, err = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"type": "result", "api_error_status": 429, "result": "You've hit your limit"}) self.assertEqual((code, out), (1, "")) + self.assertIn("review-replay: claude hit a usage limit: You've hit your limit", err) self.assertEqual(len(self.reviews), 1) def test_replays_the_models_rounds_on_the_commit_reviewed_from_the_project_rung_down(self): diff --git a/bin/review_rules/test_reviewer_context.py b/bin/review_rules/test_reviewer_context.py index 2c21c774..88a2ed30 100644 --- a/bin/review_rules/test_reviewer_context.py +++ b/bin/review_rules/test_reviewer_context.py @@ -27,7 +27,7 @@ class ReviewerContext(unittest.TestCase): (self.home / ".claude" / "CLAUDE.md").write_text("## Prose\n\nWrite short.\n") self.assertEqual(reviewer_context(self.home), Failure(f"{self.home / '.claude' / 'CLAUDE.md'} holds no section Shared goal, Vocabulary")) (self.home / ".claude" / "CLAUDE.md").unlink() - self.assertIsInstance(reviewer_context(self.home), Failure) + self.assertIn(f"could not read {self.home / '.claude' / 'CLAUDE.md'}: ", reviewer_context(self.home).reason) def test_the_repos_claude_md_holds_each_section(self): headings = [line[3:] for line in (REPO / "CLAUDE.md").read_text().splitlines() if line.startswith("## ")] -- 2.52.0 From 35911bde8f18286d0a7f3d107e4d6b1e92cff545 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 06:05:54 +0100 Subject: [PATCH 09/14] Keep the reviewer-context test clear of the citation check --- bin/review_rules/test_reviewer_context.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/review_rules/test_reviewer_context.py b/bin/review_rules/test_reviewer_context.py index 88a2ed30..f28699c2 100644 --- a/bin/review_rules/test_reviewer_context.py +++ b/bin/review_rules/test_reviewer_context.py @@ -27,7 +27,8 @@ class ReviewerContext(unittest.TestCase): (self.home / ".claude" / "CLAUDE.md").write_text("## Prose\n\nWrite short.\n") self.assertEqual(reviewer_context(self.home), Failure(f"{self.home / '.claude' / 'CLAUDE.md'} holds no section Shared goal, Vocabulary")) (self.home / ".claude" / "CLAUDE.md").unlink() - self.assertIn(f"could not read {self.home / '.claude' / 'CLAUDE.md'}: ", reviewer_context(self.home).reason) + path = self.home / ".claude" / "CLAUDE.md" + self.assertIn(f"could not read {path}: ", reviewer_context(self.home).reason) def test_the_repos_claude_md_holds_each_section(self): headings = [line[3:] for line in (REPO / "CLAUDE.md").read_text().splitlines() if line.startswith("## ")] -- 2.52.0 From 2db70062dc95dffbe2720053ef12f82b4fd57794 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 07:45:23 +0100 Subject: [PATCH 10/14] Keep omitClaudeMd on principles-auditor alone, the one pass that met the replay gate, record the gate's results and file item 340 --- README.md | 2 +- agents/override-reviewer.md | 1 - agents/product-owner-reviewer.md | 1 - agents/prose-reviewer.md | 1 - agents/stability-reviewer.md | 1 - agents/systems-architect.md | 1 - bin/larv_review/main.py | 13 +++++----- bin/larv_review/reviewer_header.py | 8 ++++--- bin/larv_review/test_larv_review.py | 7 ++++++ bin/review_replay/main.py | 4 ++-- bin/review_rules/reviewer_context.py | 18 +++++++++++--- bin/review_rules/test_reviewer_context.py | 27 ++++++++++++++++----- docs/decisions.md | 29 ++++++++++++++++++++++- skills/larv-review/SKILL.md | 2 +- todo.md | 11 ++++++++- 15 files changed, 97 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 515d9268..30f65be7 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Install puts only `loop-claude` and `loop-inbox` on `PATH`; call the others by t - `command-patterns []` prints a table of the shell command patterns a release's archived chunks ran, such as `tea pr create`, for an audit of the release; `command-patterns --help` states its columns. - `deploy-release [--cut] []` moves `~/.claude`, or the checkout named, to the newest release, as Update says; with `--cut`, run in the development clone, it first cuts the next release, as Release says. - `judge-replay ` replays loop-claude's judge on archived verdicts of the projects run on the model, and prints what each rung a review climbs to misses, and the lowest rung below them that, like each candidate above it, returns them; `judge-replay --help` states the replay. -- `larv-review ` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count, the scoring run's trigger; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `settings.json` → `hooks` runs `larv-review reviewer-context` as each subagent starts: it hands a reviewer under `agents/`, which starts without `CLAUDE.md`, that file's "Shared goal", "Prose" and "Vocabulary" sections. `larv-review --help` states them. +- `larv-review ` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count, the scoring run's trigger; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `settings.json` → `hooks` runs `larv-review reviewer-context` as each subagent starts: it hands a reviewer under `agents/` whose frontmatter has `omitClaudeMd: true`, and so starts without `CLAUDE.md`, that file's "Shared goal", "Prose" and "Vocabulary" sections. `larv-review --help` states them. - `loop-claude ` runs a project's next chunk cycle after cycle; `loop-claude --help` states its contract. - `loop-inbox` shows the interrupts of every loop-claude on the machine, oldest first, takes each one's answer, `/talk` included, and lists every running loop with the `todo.md` items its chunk takes; `loop-inbox --help` states how. - `mattermost-dm []` sends a message, or else stdin, from the Mattermost bot to the human; `~/.claude/.env` names the server, the bot's token and the human, and `mattermost-dm --help` names its keys. `loop-claude --help` says when loop-claude sends one. diff --git a/agents/override-reviewer.md b/agents/override-reviewer.md index 655a4885..77cc6d35 100644 --- a/agents/override-reviewer.md +++ b/agents/override-reviewer.md @@ -2,7 +2,6 @@ name: override-reviewer description: "Use this agent for larv-review's overrides pass." tools: Read, Grep, Glob, Write -omitClaudeMd: true --- You rule on each override of a rule `~/.claude/bin/rule-hook` enforces. The prompt gives you the lines `rule-hook overrides` printed, each with its rule and reason, and the branch diff. Read each rule and its stated exceptions in `~/.claude/bin/rule_hook/rules.py` → `RULES`, how an override is written and logged in the docstring of `~/.claude/bin/rule_hook/main.py`, and the project's `README.md` → "Goals" and "Audience", with code health (`~/.claude/CLAUDE.md` → "Shared goal") among the goals unless the README voids it. diff --git a/agents/product-owner-reviewer.md b/agents/product-owner-reviewer.md index a44745c0..84291f84 100644 --- a/agents/product-owner-reviewer.md +++ b/agents/product-owner-reviewer.md @@ -2,7 +2,6 @@ name: "product-owner-reviewer" description: "Use this agent to review a change to an external surface (API, UI, CLI, SDK, webhook) from an end customer's view: ease of use, edge cases and persona fit." tools: Read, Grep, Glob, Write -omitClaudeMd: true --- You are a seasoned Product Owner with deep expertise in user experience, API design, and customer empathy. You have shipped consumer and B2B products across web, mobile, REST APIs, and developer-facing CLIs. Your superpower is putting yourself in the end customer's shoes and surfacing the friction, confusion, and edge cases that engineers tend to miss. diff --git a/agents/prose-reviewer.md b/agents/prose-reviewer.md index 52ef629a..e06f237c 100644 --- a/agents/prose-reviewer.md +++ b/agents/prose-reviewer.md @@ -2,7 +2,6 @@ name: prose-reviewer description: "Use this agent for larv-review's prose pass." tools: Read, Grep, Glob, Write -omitClaudeMd: true --- You read the prose as someone who did not write it: you see only what it says, never what the author meant. diff --git a/agents/stability-reviewer.md b/agents/stability-reviewer.md index 2d19386b..f916958c 100644 --- a/agents/stability-reviewer.md +++ b/agents/stability-reviewer.md @@ -3,7 +3,6 @@ name: "stability-reviewer" description: "Use this agent to review changed code for stability: bugs, error handling, edge cases and the project's technical principles, after a feature, refactor or fix." color: orange tools: Bash, Read, Grep, Glob, Write -omitClaudeMd: true --- You are an elite stability-focused code reviewer with deep expertise in defensive programming, fault-tolerant system design, and production incident prevention. You have decades of experience identifying subtle bugs, race conditions, edge cases, and architectural weaknesses that lead to outages and unexpected behavior. You think like a chaos engineer — always asking "what could go wrong?" — and like a maintainer of ten years, always asking "what will this cost to live with?" There are no bugs, and no security holes, in code that doesn't exist. diff --git a/agents/systems-architect.md b/agents/systems-architect.md index 5fa51700..dc5aeb88 100644 --- a/agents/systems-architect.md +++ b/agents/systems-architect.md @@ -2,7 +2,6 @@ name: systems-architect description: "Use this agent to design a system or review architecture: patterns, component boundaries, fitness for purpose and long-term maintainability, not individual PR lines." tools: Read, Grep, Glob, WebFetch, WebSearch, Write -omitClaudeMd: true --- You are an elite Systems Architect with decades of experience designing software systems that endure for as long as their horizon demands. Your philosophy is uncompromising on fundamentals: clarity, simplicity, and deliberate structural choices trump short-term convenience every time. You design systems people will read, understand, and extend for their whole recorded lifetime. diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index 946cefd2..4fb90679 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -112,18 +112,19 @@ reviewer-header takes the name of a pass that an agent under agents/ reviews, sp prints it, such as stability. It prints the header of the prompt that launches the pass's reviewer in its next round: the pass and round, the branch's open pull request at its pushed head, the worktree and branch, the merge base of HEAD and the default branch, and the paths of the reviewer's -report, the branch diff and, for architecture and stability, the places, then the file that holds -the project principles and decision titles, where the project keeps one. It writes the diff, from +report, the branch diff and, for architecture and stability, the places. For a reviewer whose +definition under ~/.claude/agents/ has `omitClaudeMd: true`, it then names the file that holds the +project principles and decision titles, where the project keeps one. It writes the diff, from that base to HEAD, into the chunk's review folder as branch-.diff, and writes what places prints into places.md; a file whose text is unchanged is left as it is. With --rerun, the header names the report of a relaunch one rung up, in the same round, and the report that asked for it. It exits 1 when the pass takes no more rounds, or, with --rerun, when the report that asked is missing. -reviewer-context is the SubagentStart hook. It reads the hook's input on stdin. For an agent under -agents/, which starts without CLAUDE.md, it prints the hook reply that hands the agent the Shared -goal, Prose and Vocabulary sections of ~/.claude/CLAUDE.md; for any other agent it doesn't print -anything. +reviewer-context is the SubagentStart hook. It reads the hook's input on stdin. For a reviewer +whose definition under ~/.claude/agents/ has `omitClaudeMd: true`, and so starts without CLAUDE.md, +it prints the hook reply that hands the agent the Shared goal, Prose and Vocabulary sections of +~/.claude/CLAUDE.md; for any other agent it doesn't print anything. Exit 1, saying why, on unknown arguments, an unknown item ID, a seats file it cannot read or that breaks the shape above, a todo.md that fails rank_todo.py after record-scoring records a run, or diff --git a/bin/larv_review/reviewer_header.py b/bin/larv_review/reviewer_header.py index c63f7599..3f0191bd 100644 --- a/bin/larv_review/reviewer_header.py +++ b/bin/larv_review/reviewer_header.py @@ -9,7 +9,8 @@ from chunk_preflight.choices import forge_of from larv_review.history_commands import history_file, places_report from review_rules.review_folder import made_review_folder from deploy_release.forge import open_pull, runner -from review_rules.reviewer_context import principles_line +from review_rules.reviewer_context import principles_line, starts_bare +from review_rules.review_passes import REVIEWERS # The passes whose reviewer is given the places: skills/larv-review/SKILL.md → "Comprehension check" → "Places". TAKE_PLACES = ("architecture", "stability") @@ -28,6 +29,7 @@ class Launch: default: str folder: pathlib.Path diff: pathlib.Path + bare: bool def asked(self) -> pathlib.Path: """The round's report, which asks for the rerun where there is one.""" @@ -44,7 +46,7 @@ class Launch: f"Report: write it to {report}.", f"Diff: {self.diff}", *([f"Places: {self.folder / 'places.md'}"] if self.pass_ in TAKE_PLACES else []), - *([principles] if (principles := principles_line(self.worktree)) else []), + *([principles] if self.bare and (principles := principles_line(self.worktree)) else []), ]) @@ -72,7 +74,7 @@ def reviewer_header(default: str, pass_: str, rerun: bool) -> Failure | None: folder = made_review_folder(worktree) if isinstance(folder, Failure): return folder - launch = Launch(pass_, round_, rerun, pull_named(worktree, branch), worktree, branch, base, default, folder, folder / f"branch-{head}.diff") + launch = Launch(pass_, round_, rerun, pull_named(worktree, branch), worktree, branch, base, default, folder, folder / f"branch-{head}.diff", starts_bare(next((agent for name, agent in REVIEWERS.items() if name == pass_), ""), pathlib.Path.home())) if rerun and not launch.asked().exists(): return Failure(f"no report asked for a rerun of {pass_}'s round {round_}: {launch.asked()} is missing; relaunch before you commit the round's answers") written = write_inputs(launch, base) diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 07ad0cbf..eb93c3ce 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -994,13 +994,20 @@ class LarvReviewTool(unittest.TestCase): def test_reviewer_header_names_the_file_that_holds_the_principles_last_where_the_project_keeps_one(self): self.assertIsNone(self.header_line("Principles:", "prose")) (self.checkout / "AGENTS.md").write_text("") + self.assertIsNone(self.header_line("Principles:", "prose")) + self.bare("prose-reviewer") ran = self.run_tool("reviewer-header", "prose") self.assertEqual(ran.stdout.splitlines()[-1], f"Principles: read {self.checkout}/AGENTS.md first, for the project principles and the decision titles.") + def bare(self, agent): + (self.checkout.parent / ".claude" / "agents").mkdir(parents=True, exist_ok=True) + (self.checkout.parent / ".claude" / "agents" / f"{agent}.md").write_text("---\nomitClaudeMd: true\n---\n") + def test_reviewer_context_hands_a_reviewer_the_sections_and_fails_without_them(self): def hook(agent): return subprocess.run([sys.executable, str(TOOL), "reviewer-context"], capture_output=True, env=self.env, input=json.dumps({"agent_type": agent}), text=True) + self.bare("prose-reviewer") missing = hook("prose-reviewer") self.assertEqual((missing.returncode, missing.stdout), (1, "")) self.assertIn("CLAUDE.md", missing.stderr) diff --git a/bin/review_replay/main.py b/bin/review_replay/main.py index 03b44544..ad2d6520 100644 --- a/bin/review_replay/main.py +++ b/bin/review_replay/main.py @@ -26,8 +26,8 @@ rung missed and the lowest rung that, like each rung above it, missed none. That evidence for running the pass's reviewer on it; the decision above records each run. With --omit-claude-md it tests instead whether the pass's reviewer may start without CLAUDE.md: -docs/decisions.md → `agents/: a reviewer starts without CLAUDE.md`. It replays every round three -times on the project's rung: twice as archived, then once without the instruction files. The +docs/decisions.md → `agents/: a reviewer starts without CLAUDE.md only where a replay of its pass +missed none…`. It replays every round three times on the project's rung: twice as archived, then once without the instruction files. The unchanged reviewer does not find the same findings twice, so the reviewer without CLAUDE.md is held only to the findings both of those replays found. Claude Code ignores an agent's `omitClaudeMd` where the agent runs the session, as it does in a replay, and runs no SubagentStart hook there. So diff --git a/bin/review_rules/reviewer_context.py b/bin/review_rules/reviewer_context.py index 4dcf99f3..b4bc74d6 100644 --- a/bin/review_rules/reviewer_context.py +++ b/bin/review_rules/reviewer_context.py @@ -1,4 +1,4 @@ -"""What a reviewer under agents/ is handed in place of the instruction files: `omitClaudeMd` starts it without them, and most of `~/.claude/CLAUDE.md` is the worker's. docs/decisions.md → `agents/: a reviewer starts without CLAUDE.md` says why.""" +"""What a reviewer under agents/ is handed in place of the instruction files: `omitClaudeMd` starts it without them, and most of `~/.claude/CLAUDE.md` is the worker's. docs/decisions.md → `agents/: a reviewer starts without CLAUDE.md only where a replay of its pass missed none…` says why, and which reviewers.""" import json import pathlib @@ -27,13 +27,25 @@ def reviewer_context(home: pathlib.Path) -> str | Failure: return "\n\n".join(["You start without `~/.claude/CLAUDE.md`. These sections of it hold for you:", *("\n".join(found[name]).strip() for name in SECTIONS)]) +def starts_bare(agent: str, home: pathlib.Path) -> bool: + """Whether agent is a reviewer whose definition under home starts it without the instruction files.""" + if agent not in REVIEWERS.values(): + return False + try: + text = (home / ".claude" / "agents" / f"{agent}.md").read_text(encoding="utf-8") + except (OSError, UnicodeDecodeError): + return False + frontmatter = text.split("---\n")[1] if text.startswith("---\n") else "" + return "omitClaudeMd: true" in frontmatter.splitlines() + + def hook_reply(given: str, home: pathlib.Path) -> str | Failure: - """What the SubagentStart hook prints for its input given: the context for a reviewer under agents/, nothing for any other agent.""" + """What the SubagentStart hook prints for its input given: the context for a reviewer that starts without the instruction files, nothing for any other agent.""" try: read = json.loads(given) except ValueError: return "" - if not isinstance(read, dict) or read.get("agent_type") not in REVIEWERS.values(): + if not isinstance(read, dict) or not isinstance(agent := read.get("agent_type"), str) or not starts_bare(agent, home): return "" context = reviewer_context(home) if isinstance(context, Failure): diff --git a/bin/review_rules/test_reviewer_context.py b/bin/review_rules/test_reviewer_context.py index f28699c2..6cb7fa0f 100644 --- a/bin/review_rules/test_reviewer_context.py +++ b/bin/review_rules/test_reviewer_context.py @@ -7,7 +7,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from failure import Failure -from review_rules.reviewer_context import hook_reply, principles_line, reviewer_context, SECTIONS +from review_rules.reviewer_context import hook_reply, principles_line, reviewer_context, SECTIONS, starts_bare from review_rules.review_passes import REVIEWERS REPO = pathlib.Path(__file__).resolve().parents[2] @@ -19,6 +19,9 @@ class ReviewerContext(unittest.TestCase): self.home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())) (self.home / ".claude").mkdir() (self.home / ".claude" / "CLAUDE.md").write_text(CLAUDE_MD) + (self.home / ".claude" / "agents").mkdir() + for agent in REVIEWERS.values(): + (self.home / ".claude" / "agents" / f"{agent}.md").write_text(f"---\nname: {agent}\nomitClaudeMd: true\n---\n\nReview.\n") def test_holds_the_shared_goal_prose_and_vocabulary_sections_and_none_of_the_workers(self): self.assertEqual(reviewer_context(self.home), "You start without `~/.claude/CLAUDE.md`. These sections of it hold for you:\n\n## Shared goal\n\nCode health.\n\n## Prose\n\nWrite short.\n\n## Vocabulary\n\n- **chunk** — a unit.") @@ -43,6 +46,19 @@ class ReviewerContext(unittest.TestCase): with self.subTest(given=given): self.assertEqual(hook_reply(given, self.home), "") + def test_the_hook_hands_nothing_to_a_reviewer_whose_definition_keeps_the_instruction_files(self): + given = json.dumps({"agent_type": "prose-reviewer"}) + for kept in ("---\nname: prose-reviewer\n---\n\nomitClaudeMd: true\n", "---\nname: prose-reviewer\nomitClaudeMd: false\n---\n", "omitClaudeMd: true\n", b"\xff"): + with self.subTest(kept=kept): + path = self.home / ".claude" / "agents" / "prose-reviewer.md" + path.write_bytes(kept) if isinstance(kept, bytes) else path.write_text(kept) + self.assertEqual(hook_reply(given, self.home), "") + (self.home / ".claude" / "agents" / "prose-reviewer.md").unlink() + self.assertEqual(hook_reply(given, self.home), "") + self.assertTrue(starts_bare("stability-reviewer", self.home)) + (self.home / ".claude" / "agents" / "Explore.md").write_text("---\nomitClaudeMd: true\n---\n") + self.assertFalse(starts_bare("Explore", self.home)) + def test_the_hook_fails_for_a_reviewer_when_a_section_is_missing(self): (self.home / ".claude" / "CLAUDE.md").write_text("") self.assertIsInstance(hook_reply(json.dumps({"agent_type": "prose-reviewer"}), self.home), Failure) @@ -68,11 +84,10 @@ class PrinciplesLine(unittest.TestCase): class Reviewers(unittest.TestCase): - def test_each_agent_starts_without_claude_md(self): - for path in sorted((REPO / "agents").glob("*.md")): - with self.subTest(agent=path.stem): - frontmatter = path.read_text().split("---\n")[1] - self.assertIn("omitClaudeMd: true\n", frontmatter) + def test_only_the_reviewer_whose_pass_met_the_replay_gate_starts_without_claude_md(self): + # docs/decisions.md → `agents/: a reviewer starts without CLAUDE.md only where a replay of its pass missed none…` holds each pass's result. + bare = [path.stem for path in sorted((REPO / "agents").glob("*.md")) if "omitClaudeMd: true" in path.read_text().split("---\n")[1].splitlines()] + self.assertEqual(bare, ["principles-auditor"]) def test_settings_run_the_hook_as_each_subagent_starts(self): hooks = json.loads((REPO / "settings.json").read_text())["hooks"]["SubagentStart"] diff --git a/docs/decisions.md b/docs/decisions.md index 45c76ae0..91f77532 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -514,11 +514,38 @@ Valid while a model switch inside a session discards its prompt cache. 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. +## agents/: a reviewer starts without `CLAUDE.md` only where a replay of its pass missed none of the findings two unchanged replays both found + +2026-11-12, lilleman through todo item 315, implemented by claude. Serves goal 1.4, and applies project principle 1. About 77% of `CLAUDE.md` is the worker's, and each reviewer loaded it whole. `omitClaudeMd: true` in an agent's frontmatter starts it without the user, project and local instruction files. `settings.json` → `hooks.SubagentStart` runs `larv-review reviewer-context`, which hands such a reviewer the three sections of `~/.claude/CLAUDE.md` it needs: "Shared goal", which the agents cite, "Prose" and "Vocabulary". `larv-review reviewer-header` ends its header with a line naming the file that holds the project principles and decision titles, which the reviewer reads first. + +Three choices in it: + +- The sections come from a hook, not from the six agent bodies, so `CLAUDE.md` stays their one home. +- The header names the principles file and doesn't quote it, since the worker types the header into each reviewer's prompt. +- The frontmatter is the one switch. The hook and the header read it, so an agent that keeps `CLAUDE.md` gets neither twice. + +The gate: `review-replay --omit-claude-md` replays 10 archived rounds twice as archived and once without the instruction files. A pass keeps `omitClaudeMd` only where the last replay missed none of the findings both of the others found. The unchanged reviewer finds only about 70% of its own findings again, so one unchanged replay would not show the noise. Claude Code 2.1.322 ignores `omitClaudeMd` in a main session and fires no `SubagentStart` hook there, and a replay runs the reviewer as one. So the replay sets `CLAUDE_CODE_DISABLE_CLAUDE_MDS` and puts the hook's context and the header's line in the prompt itself. + +On 2026-11-12, on claude-opus-5-5 at medium effort: + +| Pass | 🔴 and 🟡 archived | Found with `CLAUDE.md`, twice | Both times | Found without | Missed of those found both times | +|------|------|------|------|------|------| +| architecture | 54 | 32, 33 | 27 | 30 | 4 | +| principles | 30 | 2, 9 | 2 | 3 | 0 | +| stability | 29 | 16, 13 | 11 | 18 | 1 | +| product-owner | 23 | 7, 4 | 4 | 8 | 1 | +| prose | 68 | 34, 36 | 24 | 39 | 1 | +| overrides | no archived round | | | | | + +Only principles-auditor met the gate, so only it has `omitClaudeMd`. Its evidence is thin: two rounds of each replay failed, and two findings were found both times. Without `CLAUDE.md` four of the five replayed reviewers found as many findings as with it, or more, so the misses may be the reviewer's own noise; todo item 340 asks lilleman whether a gate with a control may decide the other five. + +Valid while Claude Code honours `omitClaudeMd` for a subagent and passes `agent_type` to a `SubagentStart` hook, and until item 340 is answered. + ## 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 2026-10-13, lilleman through todo item 95, implemented by claude. Serves goals 1.3 and 1.4. Every session loaded `CLAUDE.md` whole, about 4,200 words. Anthropic's memory docs (code.claude.com/docs/en/memory) say a longer file "reduce[s] adherence", and IFScale (arxiv.org/abs/2507.11538) measures adherence falling as the instruction count grows. A rule goes in `CLAUDE.md` when no file path marks the moment it is needed: the working loop, prose that chat follows, commits, and API spec text, which may sit in code. Every other topic gets a file under `rules/` whose `paths:` name the files that topic is about. -A session that writes a file has read one first, since Edit needs a Read, except for a new file written before any read; the "Topic rules" line says to read the rule file first there. 2026-10-13, todo item 104: the rules a reviewer applies and the worker need not load, those for comments and READMEs among them, moved out of `rules/`, per the `worker:` decision. +A session that writes a file has read one first, since Edit needs a Read, except for a new file written before any read; the "Topic rules" line says to read the rule file first there. 2026-10-13, todo item 104: the rules a reviewer applies and the worker need not load, those for comments and READMEs among them, moved out of `rules/`, per the `worker:` decision. 2026-11-12, todo item 315: a reviewer whose pass met a replay gate no longer loads `CLAUDE.md` at all, per the decision `agents/: a reviewer starts without CLAUDE.md…`. Claude Code's user-level rules tie this repo to Claude Code, which "Prefer the vendor-neutral option" (`principles/technical-principles.md`) allows here because this repo configures Claude Code itself. The tie buys topic rules that load without a pointer the session must follow. diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index bf5f8b89..2d97ed05 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -63,7 +63,7 @@ Give a reviewer without Bash `git ls-files`'s output in its prompt, since some h `~/.claude/bin/larv-review` holds this section's mechanical rules: the chunk's review folder, the round count, the paired ruling's base and vote count, the scoring run's trigger; the history's format, its latest places and its count of how often seats agree; and the header of each reviewer's prompt. Run it in the chunk's worktree; `~/.claude/bin/larv-review --help` states each rule. On exit 1, repair what its message names and run it again; when you cannot, ask the user. -**Reports.** Run `~/.claude/bin/larv-review reviewer-header ` in the chunk's worktree, and open each prompt to an agent under `~/.claude/agents/` with what it prints; then say in a few lines what the change does and which files it touches. The command makes the chunk's review folder and writes the branch diff into it. The header names that diff and the reviewer's full report, `-round-.md`, in the folder, and for architecture and stability the places too. Its last line names the file that holds the project principles and decision titles, which a reviewer, started without `CLAUDE.md`, reads first. For a relaunch one rung up, add `--rerun`: the report becomes `-round--rerun.md`, and the header names the report that asked. Before you answer a 🔴 or 🟡, read its entry: Grep the report for the finding's place, with the lines after it, rather than Read the whole report. rule-hook refuses a reviewer's Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`. Keep the folder after the merge: `review-replay` replays a round from the reports its prompt names. +**Reports.** Run `~/.claude/bin/larv-review reviewer-header ` in the chunk's worktree, and open each prompt to an agent under `~/.claude/agents/` with what it prints; then say in a few lines what the change does and which files it touches. The command makes the chunk's review folder and writes the branch diff into it. The header names that diff and the reviewer's full report, `-round-.md`, in the folder, and for architecture and stability the places too. For a reviewer whose definition starts it without `CLAUDE.md`, its last line names the file that holds the project principles and decision titles, which the reviewer reads first. For a relaunch one rung up, add `--rerun`: the report becomes `-round--rerun.md`, and the header names the report that asked. Before you answer a 🔴 or 🟡, read its entry: Grep the report for the finding's place, with the lines after it, rather than Read the whole report. rule-hook refuses a reviewer's Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`. Keep the folder after the merge: `review-replay` replays a round from the reports its prompt names. **Precedent, then ask** — for the full scan: diff --git a/todo.md b/todo.md index 0d8ccac2..f548de22 100644 --- a/todo.md +++ b/todo.md @@ -6,12 +6,13 @@ `Bar = 0.1` -`Next ID = 340` +`Next ID = 341` ## Items | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| +| 340 | 0.9.0 | | question | **Decide whether a reviewer may start without `CLAUDE.md` where its replay misses no more findings than an unchanged replay does.** | 2 | 2 | 3 | 5 | 4 | 1.4 by 5 | 1.7 | | 331 | 0.9.0 | | question | **Reword four decisions to expire when the rungs their replays tested change, not whenever a model joins the ladder.** | 1 | 1 | 1 | 1 | 2 | 1.4 by 2 | 0.9 | | 315 | 0.9.0 | | | **Start each reviewer under `agents/` without `CLAUDE.md`, and hand it the vocabulary, the prose rules and the project's decision titles.** | 4 | 2 | 3 | 7 | 4 | 1.4 by 6 | 2.0 | | 312 | 0.9.0 | | | **Research the tooling agents read, search and run commands with, and file an item for each tool that cuts tokens a replay shows keep quality.** | 1 | 2 | 1 | 2 | 3 | 1.4 by 3, 1.5 by 2 | 2.0 | @@ -78,6 +79,14 @@ ## Details +### 340. Decide whether a reviewer may start without `CLAUDE.md` where its replay misses no more findings than an unchanged replay does. + +Item 315's gate kept `omitClaudeMd` only where a replay without `CLAUDE.md` found every finding that two unchanged replays both found. Read so, five passes failed it on 2026-11-12: stability missed 1 of 11, prose 1 of 24, product-owner 1 of 4, architecture 4 of 27, and overrides had no archived round to replay. The decision `agents/: a reviewer starts without CLAUDE.md only where a replay of its pass missed none of the findings two unchanged replays both found` holds the figures. + +The question for lilleman: does a miss that small show a loss, or the reviewer's own noise? The unchanged reviewer finds only about 70% of its findings again, so a third unchanged replay would also miss some that the other two found, and the gate as written can't tell the two apart. + +Recommended: give `review-replay --omit-claude-md` a control. It replays each round three times unchanged and once without `CLAUDE.md`, and prints for each unchanged replay how many findings it missed that the other two found. The reviewer may start without `CLAUDE.md` where its own count is no higher than the highest of those three. Then run it for the five passes, and add `omitClaudeMd: true` to each agent that passes; the hook and the header already serve any agent that has it. Each run costs four replays of 10 rounds on the project's model. + ### 331. Reword four decisions to expire when the rungs their replays tested change, not whenever a model joins the ladder. The architect's 🔀 answer on PR #493 (item 292): four decisions expire "when a new model joins the ladder". Fable 5.2 joined above every project model's rung, and none of these replays tested a rung above the project's, so the event fired with nothing new to test. Every later ladder rebuild would fire all four again. -- 2.52.0 From 9bc6abdf91728acabde5913a537696c87e910b3b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 07:57:04 +0100 Subject: [PATCH 11/14] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20the=20compa?= =?UTF-8?q?rison=20leaves=20out=20a=20round=20a=20replay=20failed=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/larv_review/main.py | 4 +- bin/larv_review/test_larv_review.py | 6 +-- bin/review_replay/main.py | 53 +++++++++++++++-------- bin/review_replay/rounds.py | 9 ++-- bin/review_replay/test_review_replay.py | 28 ++++++++++-- bin/review_rules/reviewer_context.py | 6 +-- bin/review_rules/test_reviewer_context.py | 8 ++-- 7 files changed, 78 insertions(+), 36 deletions(-) diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index 4fb90679..b0347500 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -124,7 +124,9 @@ missing. reviewer-context is the SubagentStart hook. It reads the hook's input on stdin. For a reviewer whose definition under ~/.claude/agents/ has `omitClaudeMd: true`, and so starts without CLAUDE.md, it prints the hook reply that hands the agent the Shared goal, Prose and Vocabulary sections of -~/.claude/CLAUDE.md; for any other agent it doesn't print anything. +~/.claude/CLAUDE.md; for any other agent it doesn't print anything. Where it cannot read the file +or a section, the reply tells the reviewer to open its report with that failure, and it exits 0, +since Claude Code starts the subagent whatever the hook exits with. Exit 1, saying why, on unknown arguments, an unknown item ID, a seats file it cannot read or that breaks the shape above, a todo.md that fails rank_todo.py after record-scoring records a run, or diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index eb93c3ce..13120f32 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -1003,14 +1003,14 @@ class LarvReviewTool(unittest.TestCase): (self.checkout.parent / ".claude" / "agents").mkdir(parents=True, exist_ok=True) (self.checkout.parent / ".claude" / "agents" / f"{agent}.md").write_text("---\nomitClaudeMd: true\n---\n") - def test_reviewer_context_hands_a_reviewer_the_sections_and_fails_without_them(self): + def test_reviewer_context_hands_a_reviewer_the_sections_or_what_kept_it_from_them(self): def hook(agent): return subprocess.run([sys.executable, str(TOOL), "reviewer-context"], capture_output=True, env=self.env, input=json.dumps({"agent_type": agent}), text=True) self.bare("prose-reviewer") missing = hook("prose-reviewer") - self.assertEqual((missing.returncode, missing.stdout), (1, "")) - self.assertIn("CLAUDE.md", missing.stderr) + self.assertEqual((missing.returncode, missing.stderr), (0, "")) + self.assertIn("failed: could not read", json.loads(missing.stdout)["hookSpecificOutput"]["additionalContext"]) (self.checkout.parent / ".claude").mkdir(exist_ok=True) (self.checkout.parent / ".claude" / "CLAUDE.md").write_text("## Shared goal\n\nHealth.\n\n## Prose\n\nShort.\n\n## Vocabulary\n\nWords.\n") ran = hook("prose-reviewer") diff --git a/bin/review_replay/main.py b/bin/review_replay/main.py index ad2d6520..6fa2705b 100644 --- a/bin/review_replay/main.py +++ b/bin/review_replay/main.py @@ -27,15 +27,19 @@ evidence for running the pass's reviewer on it; the decision above records each With --omit-claude-md it tests instead whether the pass's reviewer may start without CLAUDE.md: docs/decisions.md → `agents/: a reviewer starts without CLAUDE.md only where a replay of its pass -missed none…`. It replays every round three times on the project's rung: twice as archived, then once without the instruction files. The -unchanged reviewer does not find the same findings twice, so the reviewer without CLAUDE.md is held -only to the findings both of those replays found. Claude Code ignores an agent's `omitClaudeMd` -where the agent runs the session, as it does in a replay, and runs no SubagentStart hook there. So -the third replay turns the instruction files off in its settings and opens the prompt with what the -hook hands a reviewer, and closes it with the header's line on the project principles. +missed none…`. It replays every round three times on the project's rung: twice as archived, then +once without the instruction files. The unchanged reviewer does not find the same findings twice, +so the reviewer without CLAUDE.md is held only to the findings both of those replays found. It +prints how many findings each replay found, and each finding the third missed that the first two +both found; the reviewer passes where it missed none. A round that any of the three replays failed +on is left out, and where the first two share no finding the last line says there is no evidence. +Claude Code ignores an agent's `omitClaudeMd` where the agent runs the session, as it does in a +replay, and runs no SubagentStart hook there. So the third replay turns the instruction files off +in its settings and opens the prompt with what the hook hands a reviewer, and closes it with the +header's line on the project principles. Like the loop, it tries claude three times running before it counts a reply as failed. A failed -review or match finds nothing. Exit 1, saying why, on bad arguments, an unreadable archive or +review or match finds nothing, or with --omit-claude-md leaves its round out. Exit 1, saying why, on bad arguments, an unreadable archive or models file, no archived round to replay, or a usage limit. """ import dataclasses @@ -93,7 +97,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff return failed(TOOL, f"no archived {reviewed} round of projects on {project.model} in {archive_root(home, env)} holds a 🔴 or 🟡 on code it can find") chosen = sample(list(codes), LATEST) if without: - return compared(reviewed, project, chosen, lambda found, bare: findings_found(found, codes[found], project, project, home, effects, bare)) + return compared(reviewed, project, chosen, lambda found, bare: findings_replayed(found, codes[found], project, project, home, effects, bare)) # The project's rung is the reference, so the candidates start below it. They reach the ladder's lowest rung, below the lowest a worker routes to, since a pass may run below the worker's rung. candidates = down_from(project, LADDER[0])[1:] @@ -107,18 +111,24 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff return 0 -def compared(reviewed: str, project: Rung, chosen: list[Round], found_on: typing.Callable[[Round, bool], set[int] | Limited]) -> int: - """Replays chosen twice with CLAUDE.md and once without, as found_on(round, bare) finds, and prints the comparison.""" - runs: list[list[set[int]]] = [] +def compared(reviewed: str, project: Rung, chosen: list[Round], found_on: typing.Callable[[Round, bool], set[int] | Failure | Limited]) -> int: + """Replays chosen twice with CLAUDE.md and once without, as found_on(round, bare) finds, and prints the comparison of the rounds no replay failed on.""" + runs: list[list[set[int] | Failure]] = [] for bare in (False, False, True): - def replay_one(one: Round, _: Rung, bare: bool = bare) -> set[int] | Limited: - return found_on(one, bare) + def replay_one(one: Round, _: Rung, bare: bool = bare) -> set[int] | Failure | Limited: + found = found_on(one, bare) + if isinstance(found, Failure): + print(f" {one.root} {one.at} {'without' if bare else 'with'} the instruction files failed, so the round is left out: {found.reason}", file=sys.stderr, flush=True) + return found - found = replayed_on(chosen, project, replay_one, f"{reviewed} rounds {'without' if bare else 'with'} the instruction files") + found: list[set[int] | Failure] | Limited = replayed_on(chosen, project, replay_one, f"{reviewed} rounds {'without' if bare else 'with'} the instruction files") if isinstance(found, Limited): return limited_exit(TOOL, found) runs.append(found) - print(comparison(reviewed, project, chosen, (runs[0], runs[1]), runs[2])) + # A failed replay found nothing, which would lower the bar where it had CLAUDE.md and count as misses where it had none. + kept = [(one, *found) for one, *found in zip(chosen, *runs) if not any(isinstance(each, Failure) for each in found)] + first, second, without = ([typing.cast(set[int], found[run]) for _, *found in kept] for run in range(3)) + print(comparison(reviewed, project, [one for one, *_ in kept], (first, second), without, len(chosen) - len(kept))) return 0 @@ -207,12 +217,17 @@ def commit_log(listed: str) -> list[tuple[str, float]]: return [(commit, float(authored)) for commit, authored in (line.split() for line in listed.splitlines())] -def findings_found(found: Round, code: Code, rung: Rung, project: Rung, home: pathlib.Path, effects: Effects, bare: bool = False) -> set[int] | Limited: - """The indexes of the round's findings that its replay on rung reports, as claude on the project's rung matches them; where bare, the replay runs without CLAUDE.md, as `launch` says.""" +def findings_replayed(found: Round, code: Code, rung: Rung, project: Rung, home: pathlib.Path, effects: Effects, bare: bool) -> set[int] | Failure | Limited: + """The indexes of the round's findings that its replay on rung reports, as claude on the project's rung matches them, or the Failure of the review or the match; where bare, the replay runs without CLAUDE.md, as `launch` says.""" reviewed: str | Failure | Limited = first_reply(lambda: review(found, code, rung, home, effects, bare)) - if isinstance(reviewed, Limited): + if isinstance(reviewed, (Failure, Limited)): return reviewed - matched: set[int] | Failure | Limited = reviewed if isinstance(reviewed, Failure) else first_reply(lambda: match(found.findings, reviewed, found.root, project, effects)) + return first_reply(lambda: match(found.findings, reviewed, found.root, project, effects)) + + +def findings_found(found: Round, code: Code, rung: Rung, project: Rung, home: pathlib.Path, effects: Effects) -> set[int] | Limited: + """findings_replayed with CLAUDE.md, where a failed replay finds nothing and stderr says why.""" + matched = findings_replayed(found, code, rung, project, home, effects, False) if isinstance(matched, Failure): print(f" {found.root} {found.at} on {rung} found nothing: {matched.reason}", file=sys.stderr, flush=True) return set() diff --git a/bin/review_replay/rounds.py b/bin/review_replay/rounds.py index a21f6775..8ff65e4e 100644 --- a/bin/review_replay/rounds.py +++ b/bin/review_replay/rounds.py @@ -118,8 +118,8 @@ def report(reviewed: str, model: str, reference: Rung, rounds: list[Round], repl return "\n".join(lines) -def comparison(reviewed: str, reference: Rung, rounds: list[Round], with_it: tuple[list[set[int]], list[set[int]]], without: list[set[int]]) -> str: - """What the two replays with CLAUDE.md and the one without found in rounds, and each finding the one without missed that both of the others found.""" +def comparison(reviewed: str, reference: Rung, rounds: list[Round], with_it: tuple[list[set[int]], list[set[int]]], without: list[set[int]], left_out: int) -> str: + """What the two replays with CLAUDE.md and the one without found in rounds, and each finding the one without missed that both of the others found; left_out counts the rounds a replay failed on, which rounds leaves out.""" first, second = with_it both = [one & other for one, other in zip(first, second)] missed = [(found_round, index) for found_round, held, found in zip(rounds, both, without) for index in sorted(held - found)] @@ -128,8 +128,9 @@ def comparison(reviewed: str, reference: Rung, rounds: list[Round], with_it: tup return sum(len(found) for found in run) return "\n".join([ - f"Replayed {len(rounds)} {reviewed} rounds of {reference.model} projects three times on {reference}, holding {sum(len(found_round.findings) for found_round in rounds)} 🔴 and 🟡 findings.", + f"Replayed {len(rounds)} {reviewed} rounds of {reference.model} projects, which hold {sum(len(found_round.findings) for found_round in rounds)} 🔴 and 🟡 findings, three times on {reference}.", + *([f"Left out {left_out} more, which a replay failed on; stderr says why."] if left_out else []), f"With CLAUDE.md the reviewer found {count(first)} and then {count(second)} of them, and {count(both)} both times.", - f"Without CLAUDE.md it found {count(without)} of them, and missed {len(missed)} that it found both times with it{':' if missed else '.'}", + f"Without CLAUDE.md it found {count(without)} of them, and missed {len(missed)} that it found both times with it{':' if missed else '.'}" if count(both) else f"Without CLAUDE.md it found {count(without)} of them. No evidence: with CLAUDE.md it found none both times, so there is no finding to hold it to.", *(f" {found_round.root} {found_round.at}: {found_round.findings[index].splitlines()[0]}" for found_round, index in missed), ]) diff --git a/bin/review_replay/test_review_replay.py b/bin/review_replay/test_review_replay.py index 791a148f..70453513 100644 --- a/bin/review_replay/test_review_replay.py +++ b/bin/review_replay/test_review_replay.py @@ -268,7 +268,7 @@ class Main(unittest.TestCase): context = reviewer_context(self.home) self.assertEqual([prompt.startswith(context) for *_, prompt, _ in self.reviews], [False, False, True]) self.assertEqual(out, ( - f"Replayed 1 stability rounds of claude-opus-5-5 projects three times on {REFERENCE}, holding 2 🔴 and 🟡 findings.\n" + f"Replayed 1 stability rounds of claude-opus-5-5 projects, which hold 2 🔴 and 🟡 findings, three times on {REFERENCE}.\n" "With CLAUDE.md the reviewer found 2 and then 1 of them, and 1 both times.\n" "Without CLAUDE.md it found 1 of them, and missed 1 that it found both times with it:\n" f" {self.checkout} 2026-10-14T10:00:00Z: 🔴 a.txt:1 wrong\n" @@ -279,8 +279,30 @@ class Main(unittest.TestCase): def test_without_claude_md_says_so_where_the_reviewer_missed_nothing_and_names_a_reviewer_that_printed_no_json(self): code, out, err = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"found": [0]}) self.assertEqual((code, out.splitlines()[-1]), (0, "Without CLAUDE.md it found 1 of them, and missed 0 that it found both times with it.")) - _, _, err = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"found": [0]}, review=lambda rung: []) - self.assertIn("found nothing: claude printed no json reply", err) + + def test_without_claude_md_says_there_is_no_evidence_where_the_replays_with_it_share_no_finding(self): + finds = iter(([0], [1], [1])) + _, out, _ = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"found": next(finds)}) + self.assertEqual(out.splitlines()[-1], "Without CLAUDE.md it found 1 of them. No evidence: with CLAUDE.md it found none both times, so there is no finding to hold it to.") + + def test_without_claude_md_leaves_out_a_round_that_a_replay_failed_on(self): + failing = {} + + def review(rung): + # claude is tried three times running, so the first replay fails only where all three tries do. + failing["tries"] = failing.get("tries", 0) + 1 + return [] if failing["tries"] <= 3 else {"type": "result", "result": f"review on {rung.model} {rung.effort}"} + + code, out, err = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"found": [0, 1]}, review=review) + self.assertEqual(code, 0, err) + self.assertEqual(out, ( + f"Replayed 0 stability rounds of claude-opus-5-5 projects, which hold 0 🔴 and 🟡 findings, three times on {REFERENCE}.\n" + "Left out 1 more, which a replay failed on; stderr says why.\n" + "With CLAUDE.md the reviewer found 0 and then 0 of them, and 0 both times.\n" + "Without CLAUDE.md it found 0 of them. No evidence: with CLAUDE.md it found none both times, so there is no finding to hold it to.\n" + )) + self.assertIn(f" {self.checkout} 2026-10-14T10:00:00Z with the instruction files failed, so the round is left out: claude printed no json reply", err) + self.assertNotIn("without the instruction files failed", err) def test_without_claude_md_stops_at_a_usage_limit(self): code, out, err = self.run_main(["stability", "claude-opus-5-5", "--omit-claude-md"], lambda rung: {"type": "result", "api_error_status": 429, "result": "You've hit your limit"}) diff --git a/bin/review_rules/reviewer_context.py b/bin/review_rules/reviewer_context.py index b4bc74d6..4c938488 100644 --- a/bin/review_rules/reviewer_context.py +++ b/bin/review_rules/reviewer_context.py @@ -39,7 +39,7 @@ def starts_bare(agent: str, home: pathlib.Path) -> bool: return "omitClaudeMd: true" in frontmatter.splitlines() -def hook_reply(given: str, home: pathlib.Path) -> str | Failure: +def hook_reply(given: str, home: pathlib.Path) -> str: """What the SubagentStart hook prints for its input given: the context for a reviewer that starts without the instruction files, nothing for any other agent.""" try: read = json.loads(given) @@ -49,13 +49,13 @@ def hook_reply(given: str, home: pathlib.Path) -> str | Failure: return "" context = reviewer_context(home) if isinstance(context, Failure): - return context + # Claude Code starts the subagent whatever a SubagentStart hook exits with, and shows its stderr to no headless run, so the reviewer's report is where the worker can see the failure. + context = f"You start without `~/.claude/CLAUDE.md`, and the hook that hands you three of its sections failed: {context.reason}. Open your report by saying so." return json.dumps({"hookSpecificOutput": {"hookEventName": "SubagentStart", "additionalContext": context}}) def principles_line(worktree: str) -> str | None: """The line of a reviewer's header that names where the project in worktree keeps its principles and decision titles, or None where it keeps neither file.""" - # The header names the file rather than quoting it, since the worker types the header into each reviewer's prompt. what = "for the project principles and the decision titles" if (pathlib.Path(worktree) / "AGENTS.md").is_file(): return f"Principles: read {worktree}/AGENTS.md first, {what}." diff --git a/bin/review_rules/test_reviewer_context.py b/bin/review_rules/test_reviewer_context.py index 6cb7fa0f..6ce12d3c 100644 --- a/bin/review_rules/test_reviewer_context.py +++ b/bin/review_rules/test_reviewer_context.py @@ -59,9 +59,11 @@ class ReviewerContext(unittest.TestCase): (self.home / ".claude" / "agents" / "Explore.md").write_text("---\nomitClaudeMd: true\n---\n") self.assertFalse(starts_bare("Explore", self.home)) - def test_the_hook_fails_for_a_reviewer_when_a_section_is_missing(self): - (self.home / ".claude" / "CLAUDE.md").write_text("") - self.assertIsInstance(hook_reply(json.dumps({"agent_type": "prose-reviewer"}), self.home), Failure) + def test_the_hook_tells_a_reviewer_to_report_that_a_section_is_missing(self): + path = self.home / ".claude" / "CLAUDE.md" + path.write_text("## Prose\n\nWrite short.\n") + reply = json.loads(hook_reply(json.dumps({"agent_type": "prose-reviewer"}), self.home)) + self.assertEqual(reply["hookSpecificOutput"]["additionalContext"], f"You start without `~/.claude/CLAUDE.md`, and the hook that hands you three of its sections failed: {path} holds no section Shared goal, Vocabulary. Open your report by saying so.") class PrinciplesLine(unittest.TestCase): -- 2.52.0 From 0d05c9b2d878e099ac2316dbb9c1337582ce4da4 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 07:57:04 +0100 Subject: [PATCH 12/14] =?UTF-8?q?Answer=20product-owner=20round=201:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20the=20co?= =?UTF-8?q?mparison=20says=20when=20it=20holds=20no=20evidence,=20and=20th?= =?UTF-8?q?e=20hook=20reports=20its=20own=20failure=20through=20the=20revi?= =?UTF-8?q?ewer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 4132d8cf186b81922fb0c7d71bd3912e78f3a9ac Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 07:57:04 +0100 Subject: [PATCH 13/14] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=206=20=F0=9F=9F=A1=20(0=20misread);=20the=20decis?= =?UTF-8?q?ion's=20figures=20match=20its=20table=20and=20the=20hook's=20se?= =?UTF-8?q?ntences=20read=20once?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- docs/decisions.md | 8 ++++---- skills/larv-review/SKILL.md | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 30f65be7..6e888a9d 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Install puts only `loop-claude` and `loop-inbox` on `PATH`; call the others by t - `command-patterns []` prints a table of the shell command patterns a release's archived chunks ran, such as `tea pr create`, for an audit of the release; `command-patterns --help` states its columns. - `deploy-release [--cut] []` moves `~/.claude`, or the checkout named, to the newest release, as Update says; with `--cut`, run in the development clone, it first cuts the next release, as Release says. - `judge-replay ` replays loop-claude's judge on archived verdicts of the projects run on the model, and prints what each rung a review climbs to misses, and the lowest rung below them that, like each candidate above it, returns them; `judge-replay --help` states the replay. -- `larv-review ` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count, the scoring run's trigger; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `settings.json` → `hooks` runs `larv-review reviewer-context` as each subagent starts: it hands a reviewer under `agents/` whose frontmatter has `omitClaudeMd: true`, and so starts without `CLAUDE.md`, that file's "Shared goal", "Prose" and "Vocabulary" sections. `larv-review --help` states them. +- `larv-review ` holds larv-review's mechanical rules: the chunk's review folder, the paired ruling's base and vote count, each pass's round count, the scoring run's trigger; the comprehension history's format, its latest places and its count of how often seats agree; and each reviewer's prompt header. `larv-review --help` states them. `settings.json` → `hooks` runs `larv-review reviewer-context` as each subagent starts. A reviewer under `agents/` whose frontmatter has `omitClaudeMd: true` starts without `CLAUDE.md`, and the command hands it that file's "Shared goal", "Prose" and "Vocabulary" sections. - `loop-claude ` runs a project's next chunk cycle after cycle; `loop-claude --help` states its contract. - `loop-inbox` shows the interrupts of every loop-claude on the machine, oldest first, takes each one's answer, `/talk` included, and lists every running loop with the `todo.md` items its chunk takes; `loop-inbox --help` states how. - `mattermost-dm []` sends a message, or else stdin, from the Mattermost bot to the human; `~/.claude/.env` names the server, the bot's token and the human, and `mattermost-dm --help` names its keys. `loop-claude --help` says when loop-claude sends one. diff --git a/docs/decisions.md b/docs/decisions.md index 91f77532..7c27ad7c 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -522,9 +522,9 @@ Three choices in it: - The sections come from a hook, not from the six agent bodies, so `CLAUDE.md` stays their one home. - The header names the principles file and doesn't quote it, since the worker types the header into each reviewer's prompt. -- The frontmatter is the one switch. The hook and the header read it, so an agent that keeps `CLAUDE.md` gets neither twice. +- The frontmatter is the one switch. The hook and the header read it, so an agent that keeps `CLAUDE.md` is handed neither the sections nor the line. -The gate: `review-replay --omit-claude-md` replays 10 archived rounds twice as archived and once without the instruction files. A pass keeps `omitClaudeMd` only where the last replay missed none of the findings both of the others found. The unchanged reviewer finds only about 70% of its own findings again, so one unchanged replay would not show the noise. Claude Code 2.1.322 ignores `omitClaudeMd` in a main session and fires no `SubagentStart` hook there, and a replay runs the reviewer as one. So the replay sets `CLAUDE_CODE_DISABLE_CLAUDE_MDS` and puts the hook's context and the header's line in the prompt itself. +The gate: `review-replay --omit-claude-md` replays 10 archived rounds twice as archived and once without the instruction files. A pass's reviewer keeps `omitClaudeMd` only where the last replay missed none of the findings both of the others found. Two unchanged replays of one pass don't find the same findings: in the table below, each replay found between 22% and 100% of what the other found, and about 70% at the median. So one unchanged replay would not show the noise. A round that a replay fails on is left out of the comparison; the runs below predate that and counted such a replay as finding nothing. Claude Code 2.1.322 ignores `omitClaudeMd` in a main session and fires no `SubagentStart` hook there, and a replay runs the reviewer as one. So the replay sets `CLAUDE_CODE_DISABLE_CLAUDE_MDS` and puts the hook's context and the header's line in the prompt itself. On 2026-11-12, on claude-opus-5-5 at medium effort: @@ -537,7 +537,7 @@ On 2026-11-12, on claude-opus-5-5 at medium effort: | prose | 68 | 34, 36 | 24 | 39 | 1 | | overrides | no archived round | | | | | -Only principles-auditor met the gate, so only it has `omitClaudeMd`. Its evidence is thin: two rounds of each replay failed, and two findings were found both times. Without `CLAUDE.md` four of the five replayed reviewers found as many findings as with it, or more, so the misses may be the reviewer's own noise; todo item 340 asks lilleman whether a gate with a control may decide the other five. +Only principles-auditor met the gate, so only it has `omitClaudeMd`. Its evidence is thin: two rounds of each replay failed, and two findings were found both times. Without `CLAUDE.md` each replayed reviewer found more findings than it found both times with it, and three of the five found more than in either replay with it. So the misses may be the reviewer's own noise; todo item 340 asks lilleman whether a gate with a control may decide the other five. Valid while Claude Code honours `omitClaudeMd` for a subagent and passes `agent_type` to a `SubagentStart` hook, and until item 340 is answered. @@ -545,7 +545,7 @@ Valid while Claude Code honours `omitClaudeMd` for a subagent and passes `agent_ 2026-10-13, lilleman through todo item 95, implemented by claude. Serves goals 1.3 and 1.4. Every session loaded `CLAUDE.md` whole, about 4,200 words. Anthropic's memory docs (code.claude.com/docs/en/memory) say a longer file "reduce[s] adherence", and IFScale (arxiv.org/abs/2507.11538) measures adherence falling as the instruction count grows. A rule goes in `CLAUDE.md` when no file path marks the moment it is needed: the working loop, prose that chat follows, commits, and API spec text, which may sit in code. Every other topic gets a file under `rules/` whose `paths:` name the files that topic is about. -A session that writes a file has read one first, since Edit needs a Read, except for a new file written before any read; the "Topic rules" line says to read the rule file first there. 2026-10-13, todo item 104: the rules a reviewer applies and the worker need not load, those for comments and READMEs among them, moved out of `rules/`, per the `worker:` decision. 2026-11-12, todo item 315: a reviewer whose pass met a replay gate no longer loads `CLAUDE.md` at all, per the decision `agents/: a reviewer starts without CLAUDE.md…`. +A session that writes a file has read one first, since Edit needs a Read, except for a new file written before any read; the "Topic rules" line says to read the rule file first there. 2026-10-13, todo item 104: the rules a reviewer applies and the worker need not load, those for comments and READMEs among them, moved out of `rules/`, per the `worker:` decision. 2026-11-12, todo item 315: a reviewer whose pass met a replay gate starts without `CLAUDE.md` and is handed three of its sections, per the decision `agents/: a reviewer starts without CLAUDE.md…`. Claude Code's user-level rules tie this repo to Claude Code, which "Prefer the vendor-neutral option" (`principles/technical-principles.md`) allows here because this repo configures Claude Code itself. The tie buys topic rules that load without a pointer the session must follow. diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 2d97ed05..f9ea458a 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -63,7 +63,7 @@ Give a reviewer without Bash `git ls-files`'s output in its prompt, since some h `~/.claude/bin/larv-review` holds this section's mechanical rules: the chunk's review folder, the round count, the paired ruling's base and vote count, the scoring run's trigger; the history's format, its latest places and its count of how often seats agree; and the header of each reviewer's prompt. Run it in the chunk's worktree; `~/.claude/bin/larv-review --help` states each rule. On exit 1, repair what its message names and run it again; when you cannot, ask the user. -**Reports.** Run `~/.claude/bin/larv-review reviewer-header ` in the chunk's worktree, and open each prompt to an agent under `~/.claude/agents/` with what it prints; then say in a few lines what the change does and which files it touches. The command makes the chunk's review folder and writes the branch diff into it. The header names that diff and the reviewer's full report, `-round-.md`, in the folder, and for architecture and stability the places too. For a reviewer whose definition starts it without `CLAUDE.md`, its last line names the file that holds the project principles and decision titles, which the reviewer reads first. For a relaunch one rung up, add `--rerun`: the report becomes `-round--rerun.md`, and the header names the report that asked. Before you answer a 🔴 or 🟡, read its entry: Grep the report for the finding's place, with the lines after it, rather than Read the whole report. rule-hook refuses a reviewer's Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`. Keep the folder after the merge: `review-replay` replays a round from the reports its prompt names. +**Reports.** Run `~/.claude/bin/larv-review reviewer-header ` in the chunk's worktree, and open each prompt to an agent under `~/.claude/agents/` with what it prints; then say in a few lines what the change does and which files it touches. The command makes the chunk's review folder and writes the branch diff into it. The header names that diff and the reviewer's full report, `-round-.md`, in the folder, and for architecture and stability the places too. For a reviewer whose definition starts it without `CLAUDE.md`, the header's last line names the file that holds the project principles and decision titles, which the reviewer reads first. For a relaunch one rung up, add `--rerun`: the report becomes `-round--rerun.md`, and the header names the report that asked. Before you answer a 🔴 or 🟡, read its entry: Grep the report for the finding's place, with the lines after it, rather than Read the whole report. rule-hook refuses a reviewer's Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`. Keep the folder after the merge: `review-replay` replays a round from the reports its prompt names. **Precedent, then ask** — for the full scan: -- 2.52.0 From 5ccb51f76334e21595ab9c468bb674c24f4049a1 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 07:58:30 +0100 Subject: [PATCH 14/14] Finish item 315 --- CHANGELOG.md | 1 + todo.md | 9 --------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a17ba2d2..fb15e14e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- A reviewer under `agents/` can start without `CLAUDE.md`: `omitClaudeMd: true` in its frontmatter drops the file, a `SubagentStart` hook hands it the "Shared goal", "Prose" and "Vocabulary" sections, and `larv-review reviewer-header` names the project's principles file. `review-replay --omit-claude-md` tests whether a pass's reviewer finds as much without it; principles-auditor is the first to pass. - Add `workflow-bench/advisor_bench.py`, a bench of the advisor tool on six archived L 1 and L 2 chunks. Sonnet 5.5 alone passed all six, as Opus 5.5 at medium did, for 41% less, and its advisor ran in one of six runs, so workers stay without it. - loop-claude's judge on an Opus 5.5 project now runs on Opus 5.5 at xhigh in every chunk, never at medium: in replays medium sometimes closed a chunk whose worker had asked a question the README or records answer, where xhigh quoted the answer. The judge never runs on Fable 5.2 either, since each Fable 5.2 rung replayed missed an interrupt. `judge-replay` now also replays each rung above the project's that a review climbs to, and reports what each misses. diff --git a/todo.md b/todo.md index f548de22..f7a1fb3b 100644 --- a/todo.md +++ b/todo.md @@ -14,7 +14,6 @@ |---|---|---|---|---|---|---|---|---|---|---|---| | 340 | 0.9.0 | | question | **Decide whether a reviewer may start without `CLAUDE.md` where its replay misses no more findings than an unchanged replay does.** | 2 | 2 | 3 | 5 | 4 | 1.4 by 5 | 1.7 | | 331 | 0.9.0 | | question | **Reword four decisions to expire when the rungs their replays tested change, not whenever a model joins the ladder.** | 1 | 1 | 1 | 1 | 2 | 1.4 by 2 | 0.9 | -| 315 | 0.9.0 | | | **Start each reviewer under `agents/` without `CLAUDE.md`, and hand it the vocabulary, the prose rules and the project's decision titles.** | 4 | 2 | 3 | 7 | 4 | 1.4 by 6 | 2.0 | | 312 | 0.9.0 | | | **Research the tooling agents read, search and run commands with, and file an item for each tool that cuts tokens a replay shows keep quality.** | 1 | 2 | 1 | 2 | 3 | 1.4 by 3, 1.5 by 2 | 2.0 | | 325 | 0.9.0 | | | **Give this repo's test suite one command that runs it as README → Test says, prints the failing tests and pytest's summary line, and saves the whole log to a file whose path it prints.** | 3 | 2 | 2 | 5 | 3 | 1.4 by 3, 1.5 by 2 | 2.0 | | 305 | 0.9.0 | | | **Record with each archived verdict the claude-config commit that ran it, the raw tokens each model spent by kind, and each choice of the worker's that the human reversed, so a change to the setup can be judged before and after.** | 3 | 2 | 3 | 6 | 5 | 1.4 by 4, 1.2 by 3 | 1.8 | @@ -98,14 +97,6 @@ The architect's 🔀 answer on PR #493 (item 292): four decisions expire "when a Recommendation: reword all four as above. They are decisions the repo held before item 292, so the rewording is lilleman's call. -### 315. Start each reviewer under `agents/` without `CLAUDE.md`, and hand it the vocabulary, the prose rules and the project's decision titles. - -`omitClaudeMd: true` in an agent's frontmatter (Claude Code 2.1.271 or later) starts it without the user, project and local instruction files. About 77% of `CLAUDE.md` is the worker's: "Working loop", "Working with the codebase", "Git", "Handoffs", "Compact instructions". Over the archive, each 1,000 prefix tokens cost $31 across the six reviewers, so this saves about 1.9% of spend. A reviewer still needs "Vocabulary", "Prose" and the project's decision titles: put the first two in the agent bodies or a `SubagentStart` hook's `additionalContext`, and have `larv-review reviewer-header` print the titles. - -Gate it per pass: keep it only where `review-replay` with the changed definition (through `--agents`) on 10 archived rounds finds what two replays of the unchanged reviewer find; the unchanged reviewer re-finds only 69 to 73% of its own findings, so one baseline doesn't show the noise. Revise the decision `rules/: CLAUDE.md holds the worker's rules that no file path can scope`. lilleman approved on 2026-11-11. - -`review-replay` takes no `--agents` today, so the gate needs a mode for it. Claude Code 2.1.322 ignores `omitClaudeMd` for a main-session `claude --agent`, which is how `review-replay` runs a reviewer. It fires no `SubagentStart` hook there either. So the replay of the changed definition has to drop `CLAUDE.md` itself: the environment variable `CLAUDE_CODE_DISABLE_CLAUDE_MDS`, which the binary reads, does that. The replay must also hand the reviewer what the hook would add. - ### 312. Research the tooling agents read, search and run commands with, and file an item for each tool that cuts tokens a replay shows keep quality. lilleman, 2026-11-11: besides an output ceiling, keep evaluating better tooling. The token research of that day found tool results carried in context cost about 21% of spend, reads by subagents the most, and that the tools themselves move fast: deferred tool loading, output saved to files, code-execution over tools, LSP and repo-map navigation, structured test output. Item 231 tried a scout, an outline script and LSP in October and none kept every finding. -- 2.52.0