From 92075663281a802c09a4d5b6ebe081f9ca09b434 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 00:11:08 +0200 Subject: [PATCH 01/13] Have each reviewer write its full report to a file and return the worker only its findings' one-line summaries --- AGENTS.md | 1 + CHANGELOG.md | 1 + CLAUDE.md | 2 +- agents/override-reviewer.md | 2 +- agents/principles-auditor.md | 2 +- agents/product-owner-reviewer.md | 2 +- agents/prose-reviewer.md | 2 +- agents/stability-reviewer.md | 2 +- agents/systems-architect.md | 2 +- bin/rule_hook/call.py | 5 +++- bin/rule_hook/main.py | 3 ++- bin/rule_hook/reviewer_report.py | 19 +++++++++++++++ bin/rule_hook/rules.py | 8 ++++++- bin/rule_hook/test_rule_hook.py | 34 ++++++++++++++++++++++++++- docs/decisions.md | 10 ++++++++ docs/reading-cost.md | 9 +++++++ skills/larv-review/SKILL.md | 8 ++++--- skills/larv-review/review-findings.md | 15 ++++++++++-- todo.md | 14 ----------- 19 files changed, 111 insertions(+), 30 deletions(-) create mode 100644 bin/rule_hook/reviewer_report.py diff --git a/AGENTS.md b/AGENTS.md index e3c42093..435bb180 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,6 +36,7 @@ Decisions live in `docs/decisions.md`: - 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 - worker: a chunk's worker writes the simplest change that solves its item, test first wherever a test can check the change, and reads a technical principle only where the item, a finding or its own record names it; larv-review's reviewers hold the change to the principles and to the standards in `skills/larv-review/standards/` - tests: each test earns its keep as the technical principles' test bullet says, and the worker takes a test's expected values from its item, never from the code +- review: each reviewer under `agents/` writes its full report under `/tmp/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses any other file call from it - review: stability and product-owner report only a defect, a broken requirement of the plan or the goals, a breach of a technical principle, or for stability a hard place the change touches; each architect finding names a later change the PR makes harder; prose runs only on a chunk that changes prose - review: the stability pass mutation-tests the lines a chunk changes, in place of measuring test coverage - routing: one ladder of (model, effort) rungs, ordered by the Artificial Analysis Intelligence Index with Fable 5.1 at max on top; a task's L picks its worker's rung and its E + I its reviewers', by fixed steps counted from the cheapest rung of the project's model diff --git a/CHANGELOG.md b/CHANGELOG.md index 3024ff3a..3bf22395 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- Each reviewer under `agents/` writes its full report to a file under `/tmp/larv-review/`, which larv-review names in its prompt, and returns only its verdict and one line per finding, so a review takes less of the worker's context. The worker reads a finding's full entry before it fixes or answers a πŸ”΄ or 🟑. Each reviewer now holds Write. `rule-hook` refuses a reviewer's Edit and MultiEdit, and any Write outside that folder, and takes no override. - `loop-claude` asks an interrupt's question on its own terminal and resumes the worker headless with your one-line answer, so the loop no longer waits for you to leave a claude session. Type `/talk` instead to open the worker's session in claude, as every interrupt did before, to read the diff or discuss first. A release ready to cut opens that session at once. Pressing Enter on an empty answer stops the loop, exit 2. Keys typed before the question shows are dropped, and a pasted answer keeps only its first line; type `/talk` for a longer one. The judge counts that answer as yours, like one typed in claude: the chunk stays open until the answer is recorded, where a later chunk could need it. - When a worker's run ends with a question and a request for a higher rung, `loop-claude` now steps the worker one rung up as the judge interrupts, or as it answers the question with a quote from `README.md` or another file it may quote. The judge must quote a passage showing that the escalation trigger the run cites fired. Before, the step was lost for an answered question, and the worker carried on from the answer on its old rung. The step has the same limits as the step on an unfinished verdict, and no later ruling of that cycle carries a second escalation. The archive's interrupt and quoted-answer outcomes now name the worker's rung. - A scoring run due because a release's items ran out costs four more seats: it is done twice on one head. `larv-review agreement` compares how often Mid A and the inherited architect vote alike in paired rulings with how often their overall scores move the same way between the two runs. After 10 such pairs it gives a verdict, and on `Assumption fails:` larv-review asks you whether to keep the paired ruling. diff --git a/CLAUDE.md b/CLAUDE.md index 727e162d..4325e0af 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -66,7 +66,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i 4. A review rules the work below standard: systems-architect's BLOCK, a finding against larv-review's `standards/quality.md`, or a vote `record-ruling` counts as worse, in the report that stands after any relaunch one rung up (`larv-review` Β§3 β†’ "Rung up"). When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Open the subagent's prompt with the marker loop-claude's prompt gives, then the trigger's evidence. Each later subagent on that task runs on that rung or higher, and each further escalation trigger moves the task one rung higher, up to the highest rung loop-claude's prompt names. Ask the human before going higher. Where loop-claude's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread. -- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits. One that probes a build tags the image as throwaway and removes it afterwards, writes only to the session scratchpad, and removes no image or file it did not create. +- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits; a reviewer under `agents/` also writes its report, under `/tmp/larv-review/`, where rule-hook confines it. One that probes a build tags the image as throwaway and removes it afterwards, writes only to the session scratchpad, and removes no image or file it did not create. - Check `README.md` first for build, test, install, and codegen commands, and fix one that misbehaves in the same change. Refresh `README.md` whenever you change what it describes, keeping it true, not longer. - Where `~/.claude/bin/rule-hook` does not check it, such as an image named in test code, a Kubernetes manifest, a `docker run` line or a file a Bash command writes, pin a container image to its full patch version and a GitHub Action to a semver tag. diff --git a/agents/override-reviewer.md b/agents/override-reviewer.md index fcc6ac58..b0a43dce 100644 --- a/agents/override-reviewer.md +++ b/agents/override-reviewer.md @@ -1,7 +1,7 @@ --- name: override-reviewer description: "Use this agent for larv-review's overrides pass." -tools: Read, Grep, Glob +tools: Read, Grep, Glob, Write --- 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". diff --git a/agents/principles-auditor.md b/agents/principles-auditor.md index 3efcb059..462e4fb3 100644 --- a/agents/principles-auditor.md +++ b/agents/principles-auditor.md @@ -1,7 +1,7 @@ --- name: principles-auditor description: "Use this agent for larv-review's principles pass: one yardstick checked against the whole project." -tools: Read, Grep, Glob +tools: Read, Grep, Glob, Write --- You check one yardstick against the whole project: every principle in the file you are handed, or every goal under the project's `README.md` β†’ `## Goals`. diff --git a/agents/product-owner-reviewer.md b/agents/product-owner-reviewer.md index dd5b281b..e5c61376 100644 --- a/agents/product-owner-reviewer.md +++ b/agents/product-owner-reviewer.md @@ -1,7 +1,7 @@ --- name: "product-owner-reviewer" description: "Use this agent when you need a product-focused review of changes that affect external-facing surfaces (REST APIs, web UIs, CLI commands, public SDKs, webhooks, etc.) from an end-customer perspective. This agent evaluates ease of use, edge cases, persona fit, and reasonableness of usage paths β€” not internal implementation details unless they leak into the external experience. Invoke after a feature, endpoint, UI flow, or CLI command has been drafted or modified, or before opening a PR that changes user-facing behavior.\\n\\n\\nContext: The developer just added a new REST endpoint for cancelling a subscription.\\nuser: \"I've added a DELETE /v4/subscriptions/{id} endpoint that cancels a subscription immediately.\"\\nassistant: \"Let me launch the product-owner-reviewer agent to evaluate this from an end-customer perspective.\"\\n\\nA new external API surface was introduced. Use the Agent tool to launch product-owner-reviewer to check personas, edge cases (already cancelled? pending invoices? refund expectations?), and usability of the contract.\\n\\n\\n\\n\\nContext: The developer added a new CLI subcommand.\\nuser: \"Added `mytool deploy --env prod --force` to skip confirmation.\"\\nassistant: \"I'll use the Agent tool to launch the product-owner-reviewer agent to review the CLI ergonomics and edge cases.\"\\n\\nCLI usage is an external surface. The product-owner-reviewer should evaluate persona fit (who uses --force? is it discoverable? what happens on partial failure?).\\n\\n\\n\\n\\nContext: The developer modified a checkout flow in the web UI.\\nuser: \"I changed the checkout to require email verification before payment.\"\\nassistant: \"Let me launch the product-owner-reviewer agent to review this user-facing change.\"\\n\\nWeb UI flow change directly affects end customers. Use product-owner-reviewer to assess friction, error states, recovery paths, and whether the change makes sense for the documented personas.\\n\\n" -tools: Read, Grep, Glob +tools: Read, Grep, Glob, Write --- 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 b8c6f304..e8b3793f 100644 --- a/agents/prose-reviewer.md +++ b/agents/prose-reviewer.md @@ -1,7 +1,7 @@ --- name: prose-reviewer description: "Use this agent for larv-review's prose pass." -tools: Read, Grep, Glob +tools: Read, Grep, Glob, Write --- 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 153d2282..38561ff4 100644 --- a/agents/stability-reviewer.md +++ b/agents/stability-reviewer.md @@ -2,7 +2,7 @@ name: "stability-reviewer" description: "Use this agent when code has been written or modified and needs review for stability, bug prevention, and adherence to coding best practices. This includes after implementing new features, refactoring existing code, or fixing bugs. The agent focuses on defensive programming, error handling, edge cases, and compliance with the project's technical principles.\\n\\nExamples:\\n\\n- user: \"Please implement a retry mechanism for our API client\"\\n assistant: \"Here is the retry mechanism implementation: [code written]\"\\n Since significant code was written, use the Agent tool to launch the stability-reviewer agent to review the new code for stability and best practices.\\n assistant: \"Now let me use the stability-reviewer agent to review this implementation for stability concerns.\"\\n\\n- user: \"Refactor the payment processing module to use the new gateway\"\\n assistant: \"I've refactored the payment processing module. Let me now use the Agent tool to launch the stability-reviewer agent to check for any stability issues or violations of our technical principles.\"\\n\\n- user: \"Can you review what I just wrote?\"\\n assistant: \"I'll use the Agent tool to launch the stability-reviewer agent to thoroughly review your recent changes.\"\\n\\n- After any significant code change, proactively launch the stability-reviewer agent to catch issues before they reach production." color: orange -tools: Bash, Read, Grep, Glob +tools: Bash, Read, Grep, Glob, Write --- 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 06a052dc..9b5af68b 100644 --- a/agents/systems-architect.md +++ b/agents/systems-architect.md @@ -1,7 +1,7 @@ --- name: systems-architect description: "Use this agent when designing new systems, planning major features, reviewing architectural decisions in PRs, or evaluating the high-level structure of a codebase. It runs as a periodic, deliberate alignment review β€” not a per-PR reviewer; the stability-reviewer is the per-PR, code-level companion. This agent focuses on architectural patterns (functional core/imperative shell), the external contract with consumers, component boundaries, internal API design, testability seams and verification strategy (never individual tests), delivery strategy (merge gate with tests and static analysis, deployment path, dependency automation β€” as architecture, never pipeline configs or lint rules), naming, file system organization, the simplicity and reasonability of the core (questioning unjustified duplication and accidental complexity, demanding a stated reason for every repeated or complex structure), quantitative fits-in-your-head guardrails (per Code That Fits in Your Head), simpler near-equivalent solutions (trading a small, named behavior delta for a large complexity reduction), and long-term maintainability rather than implementation details. It also evaluates fitness for purpose β€” whether the chosen language, frameworks, and overall solution approach are the best fit for the project's goals and priorities β€” and treats missing or contradictory goals, priorities, audience, problem statement, scale and horizon, or domain vocabulary as the first thing to fix. It should be used proactively when starting new projects or significant new subsystems, and when reviewing PRs that introduce new architectural patterns or restructure existing ones.\\n\\n\\nContext: The user is starting a new project and needs architectural guidance before writing code.\\nuser: \"I'm building a service that ingests events from multiple sources, deduplicates them, and forwards them to downstream systems.\"\\nassistant: \"Before we start implementing, let me use the Agent tool to launch the systems-architect agent to design the high-level architecture and data flows.\"\\n\\nA new project is being started β€” use the systems-architect agent to deliberately design the architecture before any code is written.\\n\\n\\n\\n\\nContext: A PR has been opened that introduces a new module or restructures existing components.\\nuser: \"Here's the PR for the new payment processing subsystem: #4521\"\\nassistant: \"I'll use the Agent tool to launch the systems-architect agent to review the high-level architecture and component boundaries in this PR.\"\\n\\nA PR introduces a new subsystem β€” the systems-architect agent should review architectural choices, not line-level details.\\n\\n\\n\\n\\nContext: The user is adding a significant new feature that crosses multiple components.\\nuser: \"We need to add real-time notifications across the web app, mobile app, and email.\"\\nassistant: \"This crosses several system boundaries. Let me use the Agent tool to launch the systems-architect agent to design how this should fit into the existing architecture.\"\\n\\nA feature crossing multiple components needs deliberate architectural design β€” use the systems-architect agent proactively.\\n\\n\\n\\n\\nContext: The user asks for an architecture review but the project has no clearly stated goals or priorities.\\nuser: \"Can you review the architecture of our new sync service?\"\\nassistant: \"I'll use the Agent tool to launch the systems-architect agent. Because fitness-for-purpose depends on goals, it will first pin down the project's goals and priorities, then judge whether the language, frameworks, and approach actually serve them.\"\\n\\nJudging whether an implementation is the best one requires explicit goals and priorities β€” the systems-architect agent drafts the missing goals and priorities and asks the user to confirm them before evaluating fitness.\\n\\n" -tools: Read, Grep, Glob, WebFetch, WebSearch +tools: Read, Grep, Glob, WebFetch, WebSearch, Write --- 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/rule_hook/call.py b/bin/rule_hook/call.py index c622a14c..54042c72 100644 --- a/bin/rule_hook/call.py +++ b/bin/rule_hook/call.py @@ -11,6 +11,8 @@ class Call: tool: str given: dict[str, typing.Any] cwd: str + # The subagent the call comes from, such as prose-reviewer; empty for the session's own agent. + agent: str = "" def parsed_call(hook_input: object) -> Call | Failure: @@ -19,7 +21,8 @@ def parsed_call(hook_input: object) -> Call | Failure: tool, given, cwd = hook_input.get("tool_name"), hook_input.get("tool_input"), hook_input.get("cwd") if not isinstance(tool, str) or not isinstance(given, dict) or not isinstance(cwd, str): return Failure("the hook input has no string tool_name and cwd and object tool_input") - return Call(tool, given, cwd) + agent = hook_input.get("agent_type") + return Call(tool, given, cwd, agent if isinstance(agent, str) else "") def text(given: dict[str, typing.Any], key: str) -> str: diff --git a/bin/rule_hook/main.py b/bin/rule_hook/main.py index 8b3d72ef..ef39a2be 100644 --- a/bin/rule_hook/main.py +++ b/bin/rule_hook/main.py @@ -41,6 +41,7 @@ from rule_hook.rules import Breach, command_breaches, file_breaches, Outcome, ru from git_command import commits from failure import Failure from rule_hook.override_log import Log, log_path, logged, print_overrides, write_override +from rule_hook.reviewer_report import report_breaches from rule_hook.reviewer_rung import reviewer_breaches from shell_command import simple_commands from rule_hook.todo_check import todo_breaches @@ -81,7 +82,7 @@ def breaches_of(call: Call, home: str, environ: typing.Mapping[str, str]) -> tup return None before = read(path) added, after = applied(call, before) - return added, path, file_breaches(path, before, added, after) + return added, path, report_breaches(call, path) + file_breaches(path, before, added, after) def answer(judged: Outcome, what: str, now: float) -> int: diff --git a/bin/rule_hook/reviewer_report.py b/bin/rule_hook/reviewer_report.py new file mode 100644 index 00000000..c6822244 --- /dev/null +++ b/bin/rule_hook/reviewer_report.py @@ -0,0 +1,19 @@ +"""Refuse a reviewer's file call other than a Write of its report into the reports folder: skills/larv-review/review-findings.md β†’ "Report".""" +import os + +from rule_hook.call import Call +from rule_hook.reviewer_rung import REVIEWERS +from rule_hook.rules import Breach + +# Outside every checkout, so no project sees a report. A fixed path, since a headless session has no scratchpad. +REPORTS = "/tmp/larv-review" + + +def report_breaches(call: Call, path: str) -> list[Breach]: + """The breach of a file call from a reviewer that is not a Write under REPORTS; none from any other agent.""" + if call.agent not in REVIEWERS: + return [] + written = os.path.realpath(os.path.join(call.cwd, path)) + if call.tool == "Write" and written.startswith(os.path.realpath(REPORTS) + "/"): + return [] + return [Breach("reviewer-report", f"{call.agent} would {call.tool.lower()} {written}; write your report with Write to the path your prompt names, under {REPORTS}/", call.cwd)] diff --git a/bin/rule_hook/rules.py b/bin/rule_hook/rules.py index 8bbb9cdd..1ffe64fd 100644 --- a/bin/rule_hook/rules.py +++ b/bin/rule_hook/rules.py @@ -7,7 +7,7 @@ from git_command import commits from round_titles import lacks_counts from shell_command import Simple -RuleName = typing.Literal["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "reviewer-rung", "round-title-counts", "todo-rank-check"] +RuleName = typing.Literal["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "reviewer-report", "reviewer-rung", "round-title-counts", "todo-rank-check"] @dataclasses.dataclass(frozen=True) @@ -39,6 +39,12 @@ RULES: dict[RuleName, Rule] = { "no commit, PR, issue comment or file carries a Claude or Anthropic attribution, such as a co-author trailer or a generated-with line", "a git, gh or tea command, and any file written", ), + # A reviewer only reports, so no marker waives it. + "reviewer-report": Rule( + "a reviewer writes nothing but its report, with Write, into a file under /tmp/larv-review/, outside every checkout", + "a Write, Edit or MultiEdit call from inside an agent under agents/", + overridable=False, + ), # A rung is not a judgment call, and the refusal names the arguments to pass, so no marker waives it. "reviewer-rung": Rule( "a reviewer, a comprehension seat or the security pass's subagent runs on the rung loop-claude names for it: for a seat or the security pass the project's rung, and for a reviewer the highest of the project's rung, the worker's and the one the chunk's item's E + I picks, so a worker below the project's rung cannot hand a review to its own cheaper model", diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index ab0e9eec..988dbb70 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -233,6 +233,30 @@ class ReviewerRung(unittest.TestCase): self.assertEqual(self.refused({"subagent_type": "stability-reviewer", "model": "haiku", "effort": "low"}, {}), []) +class ReviewerReport(unittest.TestCase): + def breached(self, tool: str, path: str, agent: str = "prose-reviewer", cwd: str = "/r") -> list[str]: + given = {"file_path": path, "content": "BLOCK\n"} if tool == "Write" else {"file_path": path, "old_string": "a", "new_string": "b"} + found = breaches_of(Call(tool, given, cwd, agent), "/h", {}) + return rules(found[2]) if found else [] + + def test_a_reviewer_writes_its_report_into_the_reports_folder(self): + self.assertEqual(self.breached("Write", "/tmp/larv-review/.claude-item-73/prose-round-1.md"), []) + self.assertEqual(self.breached("Write", "prose-round-1.md", cwd="/tmp/larv-review/x"), [], "a relative path resolves against the call's cwd") + + def test_a_reviewer_writing_anywhere_else_is_refused(self): + for path in ["/r/README.md", "/tmp/larv-review", "/tmp/larv-review-x/a.md", "/tmp/larv-review/../etc/a.md", "/tmp/a.md"]: + with self.subTest(path): + self.assertEqual(self.breached("Write", path), ["reviewer-report"]) + + def test_a_reviewer_edits_no_file_even_in_the_reports_folder(self): + self.assertEqual(self.breached("Edit", "/tmp/larv-review/x/prose-round-1.md"), ["reviewer-report"]) + self.assertEqual(self.breached("MultiEdit", "/r/a.py", "stability-reviewer"), ["reviewer-report"]) + + def test_the_worker_and_other_subagents_write_anywhere(self): + self.assertEqual(self.breached("Write", "/r/README.md", ""), []) + self.assertEqual(self.breached("Write", "/r/README.md", "general-purpose"), []) + + class Hook(unittest.TestCase): def setUp(self): self.repo = tempfile.mkdtemp() @@ -307,6 +331,14 @@ class Hook(unittest.TestCase): call = {"cwd": self.repo, "tool_input": {"subagent_type": "stability-reviewer", "model": "opus", "effort": "medium", "prompt": "Review."}, "tool_name": "Agent"} self.assertEqual(hook(call, self.repo, ReviewerRung.ENVIRON).returncode, 0) + def test_a_reviewers_write_outside_the_reports_folder_is_refused_and_offers_no_override(self): + call = {"agent_type": "prose-reviewer", "cwd": self.repo, "tool_input": {"file_path": f"{self.repo}/a.md", "content": "\n"}, "tool_name": "Write"} + ran = hook(call, self.repo) + self.assertEqual(ran.returncode, 2) + self.assertIn("Blocked by rule reviewer-report: prose-reviewer would write ", ran.stderr) + self.assertIn("/tmp/larv-review/", ran.stderr) + self.assertNotIn("rule-override", ran.stderr) + def test_a_commit_override_is_logged_in_the_commit_s_checkout(self): outside = tempfile.mkdtemp() self.addCleanup(subprocess.run, ["rm", "-rf", outside]) @@ -370,5 +402,5 @@ class Hook(unittest.TestCase): def test_help_lists_every_rule(self): helped = subprocess.run([str(HOOK), "--help"], capture_output=True, check=True, env=isolated_env(), text=True).stdout - for rule in ["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "round-title-counts", "todo-rank-check"]: + for rule in ["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "reviewer-report", "round-title-counts", "todo-rank-check"]: self.assertIn(f" {rule}\n The rule: ", helped) diff --git a/docs/decisions.md b/docs/decisions.md index 7c561df5..38752eb0 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -218,6 +218,16 @@ The decision `worker: a chunk's worker writes the simplest change…` has the wo Valid while the worker writes the tests that larv-review's reviewers hold to the principles. +## review: each reviewer under `agents/` writes its full report under `/tmp/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses any other file call from it + +2026-10-18, the agent, shipping lilleman's plan item. Serves goal 1.4: a report the worker does not need line by line no longer fills its context. Goal 1.1 holds because the worker reads a finding's full entry before it answers a πŸ”΄ or 🟑. + +The worker names each report's file in the reviewer's prompt, per `skills/larv-review/SKILL.md` β†’ "Reports", and `skills/larv-review/review-findings.md` β†’ "Report" sets what the reviewer returns. Each reviewer holds Write for that. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`, so `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit, MultiEdit, and Write outside the folder; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. The folder is fixed, since loop-claude's headless sessions have no scratchpad, and sits outside every checkout, so no project sees a report. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. + +Before this change, reports took a median 19k tokens per chunk, 8% of the worker's peak context, and lines carrying a severity mark were 9–24% of a report (2026-10-08, over 68 archived transcripts). `stability-replay` still counts each πŸ”΄ and 🟑 by its line in the reviewer's reply. + +Valid while Claude Code passes `agent_type` to hooks inside a subagent. + ## review: stability and product-owner report only a defect, a broken requirement of the plan or the goals, a breach of a technical principle, or for stability a hard place the change touches; each architect finding names a later change the PR makes harder; prose runs only on a chunk that changes prose 2026-10-13, lilleman through todo item 97, implemented by claude. Serves goals 1.4 and 1.5. Anthropic's Claude Code best practices: "A reviewer prompted to find gaps will usually report some, even when the work is sound… Chasing every finding leads to over-engineering." 320 of this repo's 876 commits answered a review round. So stability and product-owner drop a finding that is none of these, and stability leaves the style of comments to prose, which reads every comment a chunk touches. An architect finding that names no later change it makes harder cannot be checked, so it is dropped. The architecture pass and the comprehension check keep their whole-project view, which guards goal 1.1 as a project grows. Valid while the findings these rules drop keep changing nothing a user would notice. diff --git a/docs/reading-cost.md b/docs/reading-cost.md index ee66058d..05db8f14 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -636,3 +636,12 @@ Read most (opens and searches): ## Reading cost, chunk 055546870eaf, finished 2026-10-17T20:46:45Z 100998 new input tokens before the first commit. + +## Reading cost, chunk 6ab072ca20a3, finished 2026-10-17T22:04:13Z + +248782 new input tokens before the first commit. + +Read most (opens and searches): + +- `todo.md` 4 +- `rules/todo-items.md` 1 diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 7914b031..15eec9eb 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -45,6 +45,8 @@ A comment is prose, not code. Passes run in this order: line-level polish on cod Give a reviewer without Bash the branch diff and `git ls-files`'s output in its prompt: some harnesses grant it Read alone. +**Reports.** Name in each prompt to an agent under `~/.claude/agents/` the file its full report goes to: `/tmp/larv-review//-round-.md`, with the yardstick's name after the pass's for a principles-auditor, and `-rerun` before `.md` for a relaunch one rung up. It writes the report there and returns only its verdict and one line per finding. Read the report's entry for each πŸ”΄ and 🟑 before you answer it. rule-hook refuses a reviewer's write anywhere else. + `~/.claude/bin/larv-review` holds this section's mechanical rules: the round count, the paired ruling's base and vote count, the scoring run's trigger, and the history's format and latest places, and its count of how often seats agree. 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. **Precedent, then ask** β€” for the architecture pass and the full scan: @@ -64,7 +66,7 @@ Give a reviewer without Bash the branch diff and `git ls-files`'s output in its - **Round.** A round is one review by a pass's reviewer: the first, each re-entry, and the rerun after the architect returns Stage 0 questions ("Architecture" below). A relaunch one rung up ("Rung up" below) stays in its round. - **Auto-reviewer.** The external auto-reviewer (Β§4) is a pass of its own, each review it posts a round. - **Count.** Close each round with one commit that holds the round's fixes. Title it `Answer round : πŸ”΄, 🟑; …`: `` is the pass's name in lower case, such as `full scan`, and `` and `` are the πŸ”΄ and 🟑 findings all the round's reviewers reported. Example: `Answer stability round 1: 1 πŸ”΄, 2 🟑; flag a deleted test`. A round that changed nothing gets an empty commit (`git commit --allow-empty`). Push the commits when Β§4 runs next, where there is a remote. `~/.claude/bin/larv-review round-count` prints each pass's count and marks a pass at the cap. The auto-reviewer's count is the number of its reviews on the PR, less its reviews of a `Record the comprehension check:` commit. -- **Later rounds.** From round 2, an agent under `~/.claude/agents/` reviews only the answers to its last round's findings, and each fix from another pass that re-entered its pass. Prompt it with its last round's findings verbatim, each with its answer: the fix's diff, or the reason it was dismissed. Give it each other pass's fix as `git diff `, since the fixes may be unpushed, with the finding it answered. It reports only an answer that is plainly wrong or worse than the change it answered, so its pass converges in its second round. Other reviewers review the branch as their tool does. +- **Later rounds.** From round 2, an agent under `~/.claude/agents/` reviews only the answers to its last round's findings, and each fix from another pass that re-entered its pass. Prompt it with the path of its last round's report and each finding's answer: the fix's diff, or the reason it was dismissed. Give it each other pass's fix as `git diff `, since the fixes may be unpushed, with the finding it answered. It reports only an answer that is plainly wrong or worse than the change it answered, so its pass converges in its second round. Other reviewers review the branch as their tool does. - **Done.** A pass is done when its latest round leaves no πŸ”΄ or 🟑 standing: none was reported, or each was shown factually wrong, declined, filed, or named under the bar per "Findings", or settled in the PR summary per "Comprehension check" β†’ "Places", or, for the prose pass, fixed. Resolve that round's 🟒s and ❓s per "Findings" too. - **Cap.** A pass takes at most three rounds per chunk. Instead of a fourth, list what is open and ask the user. For the auto-reviewer, ask before the push that would summon its fourth, and hold the fixes unpushed until the answer. - **Answer.** A yes grants that pass one more round, after which the ask repeats; a no leaves the PR unmerged. @@ -78,7 +80,7 @@ Give a reviewer without Bash the branch diff and `git ls-files`'s output in its **Rung up.** A reviewer rules the work below standard when its report holds systems-architect's BLOCK or a finding against `standards/quality.md`. A comprehension seat does when `record-ruling` counts one of its votes as worse. - **Ask.** Such a reviewer or seat may end its report asking for a rerun one rung up. Relaunch it only on the rung loop-claude's prompt names for it; where the prompt names none, the report stands. -- **Relaunch.** Relaunch a reviewer on that rung with the same prompt and the report that asked; its report stands in place of that one, in the same round. Relaunch a seat with the same prompt alone; its line replaces the one that asked in the votes file, before `record-ruling` runs. A relaunch cannot ask again. +- **Relaunch.** Relaunch a reviewer on that rung with the same prompt and the path of the report that asked; its report stands in place of that one, in the same round. Relaunch a seat with the same prompt alone; its line replaces the one that asked in the votes file, before `record-ruling` runs. A relaunch cannot ask again. - **Escalate.** A below-standard ruling in the report that stands is escalation trigger 4 in `~/.claude/CLAUDE.md` β†’ "Working with the codebase". **Findings.** A reviewer rates each finding πŸ”΄ must fix, 🟑 should fix, 🟒 nit, ❓ question, or πŸ”€ escalation naming the reviewer whose concern it is. @@ -161,7 +163,7 @@ Launch prose-reviewer with what the diff touched and every section this review c 1. Read the finished PR against the README goals: does anything in it work against one? It breaks a maintain goal β†’ do not merge; redesign the change or drop its item. It works against an achieve goal β†’ do not merge; ask the human, stating the conflict. 2. Run the comprehension check (Β§3) where it runs; it runs once. When `origin/` moves after that, return to Β§4, and keep the ruling and scoring run already recorded. 3. Aligned, every pass done and everything green β†’ **merge**. Follow the repo's merge method (`AGENTS.md`; ff-only where that is the convention). A repo withholds this in its `AGENTS.md` β†’ leave the PR ready and unmerged, and say which line withheld it. -4. Merged β†’ remove the chunk's items from `todo.md` per `~/.claude/CLAUDE.md` β†’ "Working loop". +4. Merged β†’ remove the chunk's items from `todo.md` per `~/.claude/CLAUDE.md` β†’ "Working loop", and the chunk's folder under `/tmp/larv-review/`. 5. Stop. The next chunk gets a fresh session. ## 6. Wrap up diff --git a/skills/larv-review/review-findings.md b/skills/larv-review/review-findings.md index d024ebd7..07c8d26e 100644 --- a/skills/larv-review/review-findings.md +++ b/skills/larv-review/review-findings.md @@ -2,7 +2,7 @@ Words: `~/.claude/CLAUDE.md` β†’ "Vocabulary". -A reviewer reads and reports; it edits nothing. Read `docs/decisions.md` and `todo.md` first: a finding declined or disproved in `docs/decisions.md` or in a comment at the code it concerns, or filed in `todo.md`, is not raised again, unless the decline works against a goal or a technical principle and names no `todo.md` item ending it. +A reviewer reads and reports; it edits nothing, and writes only its report. Read `docs/decisions.md` and `todo.md` first: a finding declined or disproved in `docs/decisions.md` or in a comment at the code it concerns, or filed in `todo.md`, is not raised again, unless the decline works against a goal or a technical principle and names no `todo.md` item ending it. ## Severity @@ -14,6 +14,17 @@ A reviewer reads and reports; it edits nothing. Read `docs/decisions.md` and `to A finding against a technical principle names it and the file under `~/.claude/principles/` it lives in. A finding against `~/.claude/skills/larv-review/standards/quality.md` names that file and the rule it breaks. +## Report + +Write your full report with the Write tool to the file your prompt names, under `/tmp/larv-review/`: the verdict, then every finding with its place, its evidence and its fix, as your agent file shapes them. Then return only: + +- the verdict line +- one line per finding: its severity mark, its place, and what is wrong in one sentence, such as `🟑 bin/rank_todo.py:311 place: a cycle among blockers recurses forever` +- `Rerun one rung up`, where your report ends with it +- the report's path + +A prompt that names no file gets the full report as your reply. + ## Verdict A review's first line, derived from the findings: @@ -29,6 +40,6 @@ Where your report holds a finding against `~/.claude/skills/larv-review/standard ## Rounds - Handed neither earlier findings nor another pass's fix: surface everything. -- Handed an earlier round's findings, each with its fix or the reason it was dismissed: review only those answers. Check each fix β€” re-run the scenario, never trust the claim β€” and each dismissal's reason. Report only a fix or a dismissal that is plainly wrong, or worse than the change it answered; a fix you would have written differently is not a finding. +- Handed an earlier round's report, with each finding's fix or the reason it was dismissed: review only those answers. Check each fix β€” re-run the scenario, never trust the claim β€” and each dismissal's reason. Report only a fix or a dismissal that is plainly wrong, or worse than the change it answered; a fix you would have written differently is not a finding. - Handed a fix from another pass: review its diff as a first round would, limited to its lines. - Handed a report that asked to `Rerun one rung up`: confirm or dismiss each of its findings, with a reason, then review the rest of what your prompt scopes, as the round you rerun would. Do not ask again. diff --git a/todo.md b/todo.md index e7e9ca39..a78871bd 100644 --- a/todo.md +++ b/todo.md @@ -13,7 +13,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| | 180 | 0.2.0 | | question | **Settle how a trigger that fires after a step-up at an interrupt or a quoted answer steps the worker, which today it never does.** | 2 | 2 | 2 | 4 | 3 | 1.1 by 3 | 4.1 | -| 73 | 0.2.0 | | | **Have each reviewer write its full report to a file and return the worker only its findings' one-line summaries.** | 3 | 2 | 3 | 6 | 5 | 1.4 by 4 | 1.1 | | 159 | 0.2.0 | | decision | **Run each review pass on the lowest rung that a replay of its archived rounds shows finding every πŸ”΄ and 🟑 the project's rung finds, even below the worker's rung.** | 4 | 2 | 3 | 7 | 6 | 1.4 by 7 | 1.1 | | 80 | 0.3.0 | | defect | **State in README β†’ Install that every machine taking this checkout must be a sandbox, as `settings.json`'s auto mode assumes.** | 1 | 2 | 1 | 2 | 1 | 2 by 4 | 17.5 | | 21 | 0.3.0 | | defect | **Give `settings.json`'s model one writer, and sort its keys.** | 3 | 3 | 3 | 7 | 3 | 2 by 5 | 13.7 | @@ -98,19 +97,6 @@ Options: Only the human can choose, and the answer revises that decision. Found by the stability review of PR #307. -### 73. Have each reviewer write its full report to a file and return the worker only its findings' one-line summaries. - -2026-10-08, lilleman: rescored from A10/G8 to A4/G4 on the measurement below, so other items that lower token use go first. - -Measured over the 68 transcripts in loop-claude's archive on 2026-10-08, matching each Agent call to its tool result and to any `` naming its tool-use id. No report reached the worker twice: 813 arrived once as the hand-back, and 363 once as a notification after Claude Code ran the agent in the background. Reports took a median 19k tokens per chunk, 8% of the worker's peak context (24% at most). Lines carrying a severity mark are 9–24% of a reviewer's report, and the worker would still open the file for each πŸ”΄ or 🟑 it fixes. A third of the report volume is the comprehension seats', whose votes and places the worker copies into the history. File reads fill more of the worker's context: `sed -n` output is 30% of its Bash results and `grep` output 11%, which `reading-cost` targets. - -The reports would live in the session's scratchpad, such as `/larv-review/prose-round-1.md`, so no project's checkout sees them. A later round gets the path of that pass's earlier report in place of the findings pasted in. How a report reaches the file: - -- **Write access.** Grant each reviewer Write. No reviewer under `agents/` holds it today, an agent's tool list cannot confine Write to one folder, and `~/.claude/CLAUDE.md` β†’ "Working with the codebase" denies edits to a reviewer that only reads. Check whether a PreToolUse hook can tell a subagent's call from the worker's and deny a Write outside the scratchpad. -- **A wrapper.** A general-purpose subagent launches the reviewer, saves the report and returns only the summary lines. Claude Code's documentation says a subagent cannot start another; drop this route unless a test shows one can. - -This risks goal 1.1: a worker fixing from a one-line summary can miss context it needs. - ### 159. Run each review pass on the lowest rung that a replay of its archived rounds shows finding every πŸ”΄ and 🟑 the project's rung finds, even below the worker's rung. lilleman asked, on 2026-10-16, for the prose pass to run on the worker's rung or lower, and the same day, answering PR #296, for every pass to drop below the project's rung only where a replay shows it may. Today `bin/loop_claude/cycle/prompts.py`'s `review_launches` keeps every reviewer at or above the project's rung whatever the item's E + I, so a docs-only chunk such as item 140's, routed to Haiku 5.5, runs its reviewers on Opus 5.5. -- 2.52.0 From 8df46e3a85734f2de840d1c179f578645e15a047 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 00:20:13 +0200 Subject: [PATCH 02/13] =?UTF-8?q?Answer=20architecture=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=207=20=F0=9F=9F=A1;=20move=20the=20reports=20to?= =?UTF-8?q?=20a=20durable=20review=20folder=20under=20~/.local/state,=20ca?= =?UTF-8?q?rry=20the=20yardstick,=20the=20named=20reviewer=20and=20the=20t?= =?UTF-8?q?est=20status=20in=20each=20reply=20line,=20read=20an=20entry=20?= =?UTF-8?q?by=20Grep,=20name=20the=20folder=20once,=20print=20which=20rule?= =?UTF-8?q?s=20take=20no=20override,=20and=20file=20items=20185=20and=2018?= =?UTF-8?q?6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 +- CHANGELOG.md | 2 +- CLAUDE.md | 2 +- bin/rule_hook/main.py | 4 ++-- bin/rule_hook/reviewer_report.py | 14 ++++++-------- bin/rule_hook/rules.py | 6 ++++-- bin/rule_hook/test_rule_hook.py | 13 ++++++++----- docs/decisions.md | 4 ++-- skills/larv-review/SKILL.md | 6 +++--- skills/larv-review/review-findings.md | 5 +++-- todo.md | 12 +++++++++++- 11 files changed, 42 insertions(+), 28 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 435bb180..a0033b34 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,7 +36,7 @@ Decisions live in `docs/decisions.md`: - 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 - worker: a chunk's worker writes the simplest change that solves its item, test first wherever a test can check the change, and reads a technical principle only where the item, a finding or its own record names it; larv-review's reviewers hold the change to the principles and to the standards in `skills/larv-review/standards/` - tests: each test earns its keep as the technical principles' test bullet says, and the worker takes a test's expected values from its item, never from the code -- review: each reviewer under `agents/` writes its full report under `/tmp/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses any other file call from it +- review: each reviewer under `agents/` writes its full report into the chunk's review folder under `~/.local/state/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses any other file call from it - review: stability and product-owner report only a defect, a broken requirement of the plan or the goals, a breach of a technical principle, or for stability a hard place the change touches; each architect finding names a later change the PR makes harder; prose runs only on a chunk that changes prose - review: the stability pass mutation-tests the lines a chunk changes, in place of measuring test coverage - routing: one ladder of (model, effort) rungs, ordered by the Artificial Analysis Intelligence Index with Fable 5.1 at max on top; a task's L picks its worker's rung and its E + I its reviewers', by fixed steps counted from the cheapest rung of the project's model diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bf22395..2f42eaf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Each reviewer under `agents/` writes its full report to a file under `/tmp/larv-review/`, which larv-review names in its prompt, and returns only its verdict and one line per finding, so a review takes less of the worker's context. The worker reads a finding's full entry before it fixes or answers a πŸ”΄ or 🟑. Each reviewer now holds Write. `rule-hook` refuses a reviewer's Edit and MultiEdit, and any Write outside that folder, and takes no override. +- Each reviewer under `agents/` writes its full report to a file under `~/.local/state/larv-review/`, which larv-review names in its prompt, and returns only its verdict and one line per finding, so a review takes less of the worker's context. The worker reads a finding's full entry before it fixes or answers a πŸ”΄ or 🟑. Each reviewer now holds Write. `rule-hook` refuses a reviewer's Edit and MultiEdit, and any Write outside that folder, and takes no override. - `loop-claude` asks an interrupt's question on its own terminal and resumes the worker headless with your one-line answer, so the loop no longer waits for you to leave a claude session. Type `/talk` instead to open the worker's session in claude, as every interrupt did before, to read the diff or discuss first. A release ready to cut opens that session at once. Pressing Enter on an empty answer stops the loop, exit 2. Keys typed before the question shows are dropped, and a pasted answer keeps only its first line; type `/talk` for a longer one. The judge counts that answer as yours, like one typed in claude: the chunk stays open until the answer is recorded, where a later chunk could need it. - When a worker's run ends with a question and a request for a higher rung, `loop-claude` now steps the worker one rung up as the judge interrupts, or as it answers the question with a quote from `README.md` or another file it may quote. The judge must quote a passage showing that the escalation trigger the run cites fired. Before, the step was lost for an answered question, and the worker carried on from the answer on its old rung. The step has the same limits as the step on an unfinished verdict, and no later ruling of that cycle carries a second escalation. The archive's interrupt and quoted-answer outcomes now name the worker's rung. - A scoring run due because a release's items ran out costs four more seats: it is done twice on one head. `larv-review agreement` compares how often Mid A and the inherited architect vote alike in paired rulings with how often their overall scores move the same way between the two runs. After 10 such pairs it gives a verdict, and on `Assumption fails:` larv-review asks you whether to keep the paired ruling. diff --git a/CLAUDE.md b/CLAUDE.md index 4325e0af..245600db 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -66,7 +66,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i 4. A review rules the work below standard: systems-architect's BLOCK, a finding against larv-review's `standards/quality.md`, or a vote `record-ruling` counts as worse, in the report that stands after any relaunch one rung up (`larv-review` Β§3 β†’ "Rung up"). When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Open the subagent's prompt with the marker loop-claude's prompt gives, then the trigger's evidence. Each later subagent on that task runs on that rung or higher, and each further escalation trigger moves the task one rung higher, up to the highest rung loop-claude's prompt names. Ask the human before going higher. Where loop-claude's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread. -- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits; a reviewer under `agents/` also writes its report, under `/tmp/larv-review/`, where rule-hook confines it. One that probes a build tags the image as throwaway and removes it afterwards, writes only to the session scratchpad, and removes no image or file it did not create. +- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits; a reviewer under `agents/` also writes its report to the file larv-review names, and rule-hook refuses it any other write. One that probes a build tags the image as throwaway and removes it afterwards, writes only to the session scratchpad, and removes no image or file it did not create. - Check `README.md` first for build, test, install, and codegen commands, and fix one that misbehaves in the same change. Refresh `README.md` whenever you change what it describes, keeping it true, not longer. - Where `~/.claude/bin/rule-hook` does not check it, such as an image named in test code, a Kubernetes manifest, a `docker run` line or a file a Bash command writes, pin a container image to its full patch version and a GitHub Action to a semver tag. diff --git a/bin/rule_hook/main.py b/bin/rule_hook/main.py index ef39a2be..5ef23a0a 100644 --- a/bin/rule_hook/main.py +++ b/bin/rule_hook/main.py @@ -8,7 +8,7 @@ subagent. The rules: {rules} -A file a Bash command writes, such as through `cat > Dockerfile`, is not checked. The reviewer-rung rule takes no override. +A file a Bash command writes, such as through `cat > Dockerfile`, is not checked. A call overrides a rule with `# rule-override : `: @@ -82,7 +82,7 @@ def breaches_of(call: Call, home: str, environ: typing.Mapping[str, str]) -> tup return None before = read(path) added, after = applied(call, before) - return added, path, report_breaches(call, path) + file_breaches(path, before, added, after) + return added, path, report_breaches(call, path, home) + file_breaches(path, before, added, after) def answer(judged: Outcome, what: str, now: float) -> int: diff --git a/bin/rule_hook/reviewer_report.py b/bin/rule_hook/reviewer_report.py index c6822244..a8913ee3 100644 --- a/bin/rule_hook/reviewer_report.py +++ b/bin/rule_hook/reviewer_report.py @@ -3,17 +3,15 @@ import os from rule_hook.call import Call from rule_hook.reviewer_rung import REVIEWERS -from rule_hook.rules import Breach - -# Outside every checkout, so no project sees a report. A fixed path, since a headless session has no scratchpad. -REPORTS = "/tmp/larv-review" +from rule_hook.rules import Breach, REPORTS -def report_breaches(call: Call, path: str) -> list[Breach]: - """The breach of a file call from a reviewer that is not a Write under REPORTS; none from any other agent.""" +def report_breaches(call: Call, path: str, home: str) -> list[Breach]: + """The breach of a file call from a reviewer that is not a Write under REPORTS in home; none from any other agent.""" if call.agent not in REVIEWERS: return [] written = os.path.realpath(os.path.join(call.cwd, path)) - if call.tool == "Write" and written.startswith(os.path.realpath(REPORTS) + "/"): + reports = os.path.realpath(os.path.join(home, REPORTS)) + if call.tool == "Write" and written.startswith(reports + "/"): return [] - return [Breach("reviewer-report", f"{call.agent} would {call.tool.lower()} {written}; write your report with Write to the path your prompt names, under {REPORTS}/", call.cwd)] + return [Breach("reviewer-report", f"{call.agent} would {call.tool.lower()} {written}; write your report with Write to the path your prompt names, under {reports}/", call.cwd)] diff --git a/bin/rule_hook/rules.py b/bin/rule_hook/rules.py index 1ffe64fd..f69ea09f 100644 --- a/bin/rule_hook/rules.py +++ b/bin/rule_hook/rules.py @@ -18,6 +18,8 @@ class Rule: overridable: bool = True +# The reviewers' reports folder, under the home folder: outside every checkout, so no project sees a report, and kept across a reboot, so a resumed chunk still reads its rounds. A fixed path, since a headless session has no scratchpad. +REPORTS = ".local/state/larv-review" RULES: dict[RuleName, Rule] = { "action-pin": Rule( "a GitHub or Gitea Action is pinned to a semver tag, such as @v3 or @v3.1.2, never to a branch, and to a commit SHA only in a pipeline that tests our own specific builds", @@ -41,7 +43,7 @@ RULES: dict[RuleName, Rule] = { ), # A reviewer only reports, so no marker waives it. "reviewer-report": Rule( - "a reviewer writes nothing but its report, with Write, into a file under /tmp/larv-review/, outside every checkout", + f"a reviewer writes nothing but its report, with Write, into a file under ~/{REPORTS}/", "a Write, Edit or MultiEdit call from inside an agent under agents/", overridable=False, ), @@ -186,4 +188,4 @@ def blocks(written: str) -> list[list[str]]: def rules_help() -> str: - return "\n".join(f" {name}\n The rule: {rule.holds}.\n Checked in: {rule.checked}." for name, rule in RULES.items()) + return "\n".join(f" {name}\n The rule: {rule.holds}.\n Checked in: {rule.checked}." + ("" if rule.overridable else "\n Takes no override.") for name, rule in RULES.items()) diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index 988dbb70..fb7390fc 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -240,16 +240,16 @@ class ReviewerReport(unittest.TestCase): return rules(found[2]) if found else [] def test_a_reviewer_writes_its_report_into_the_reports_folder(self): - self.assertEqual(self.breached("Write", "/tmp/larv-review/.claude-item-73/prose-round-1.md"), []) - self.assertEqual(self.breached("Write", "prose-round-1.md", cwd="/tmp/larv-review/x"), [], "a relative path resolves against the call's cwd") + self.assertEqual(self.breached("Write", "/h/.local/state/larv-review/.claude-item-73/prose-round-1.md"), []) + self.assertEqual(self.breached("Write", "prose-round-1.md", cwd="/h/.local/state/larv-review/x"), [], "a relative path resolves against the call's cwd") def test_a_reviewer_writing_anywhere_else_is_refused(self): - for path in ["/r/README.md", "/tmp/larv-review", "/tmp/larv-review-x/a.md", "/tmp/larv-review/../etc/a.md", "/tmp/a.md"]: + for path in ["/r/README.md", "/h/.local/state/larv-review", "/h/.local/state/larv-review-x/a.md", "/h/.local/state/larv-review/../a.md", "/tmp/larv-review/a.md"]: with self.subTest(path): self.assertEqual(self.breached("Write", path), ["reviewer-report"]) def test_a_reviewer_edits_no_file_even_in_the_reports_folder(self): - self.assertEqual(self.breached("Edit", "/tmp/larv-review/x/prose-round-1.md"), ["reviewer-report"]) + self.assertEqual(self.breached("Edit", "/h/.local/state/larv-review/x/prose-round-1.md"), ["reviewer-report"]) self.assertEqual(self.breached("MultiEdit", "/r/a.py", "stability-reviewer"), ["reviewer-report"]) def test_the_worker_and_other_subagents_write_anywhere(self): @@ -336,7 +336,7 @@ class Hook(unittest.TestCase): ran = hook(call, self.repo) self.assertEqual(ran.returncode, 2) self.assertIn("Blocked by rule reviewer-report: prose-reviewer would write ", ran.stderr) - self.assertIn("/tmp/larv-review/", ran.stderr) + self.assertIn("/.local/state/larv-review/", ran.stderr) self.assertNotIn("rule-override", ran.stderr) def test_a_commit_override_is_logged_in_the_commit_s_checkout(self): @@ -404,3 +404,6 @@ class Hook(unittest.TestCase): helped = subprocess.run([str(HOOK), "--help"], capture_output=True, check=True, env=isolated_env(), text=True).stdout for rule in ["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "reviewer-report", "round-title-counts", "todo-rank-check"]: self.assertIn(f" {rule}\n The rule: ", helped) + self.assertIn("reviewer-report\n The rule: a reviewer writes nothing but its report", helped) + self.assertRegex(helped, r" reviewer-report\n( .*\n){2} Takes no override\.\n") + self.assertRegex(helped, r" image-pin\n( .*\n){2} ", "a rule a marker waives says nothing of overrides") diff --git a/docs/decisions.md b/docs/decisions.md index 38752eb0..ae3830ad 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -218,11 +218,11 @@ The decision `worker: a chunk's worker writes the simplest change…` has the wo Valid while the worker writes the tests that larv-review's reviewers hold to the principles. -## review: each reviewer under `agents/` writes its full report under `/tmp/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses any other file call from it +## review: each reviewer under `agents/` writes its full report into the chunk's review folder under `~/.local/state/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses any other file call from it 2026-10-18, the agent, shipping lilleman's plan item. Serves goal 1.4: a report the worker does not need line by line no longer fills its context. Goal 1.1 holds because the worker reads a finding's full entry before it answers a πŸ”΄ or 🟑. -The worker names each report's file in the reviewer's prompt, per `skills/larv-review/SKILL.md` β†’ "Reports", and `skills/larv-review/review-findings.md` β†’ "Report" sets what the reviewer returns. Each reviewer holds Write for that. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`, so `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit, MultiEdit, and Write outside the folder; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. The folder is fixed, since loop-claude's headless sessions have no scratchpad, and sits outside every checkout, so no project sees a report. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. +The worker names each report's file in the reviewer's prompt, per `skills/larv-review/SKILL.md` β†’ "Reports", and `skills/larv-review/review-findings.md` β†’ "Report" sets what the reviewer returns. Each reviewer holds Write for that. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`, so `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit, MultiEdit, and Write outside the folder; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. The folder is fixed, since loop-claude's headless sessions have no scratchpad. It sits outside every checkout, so no project sees a report. It survives a reboot, unlike `/tmp`, so a resumed chunk still reads its earlier rounds. And it is in the user's home, so no other local user reads a report, which may quote a secret, or plants a symlink that widens the folder. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. Before this change, reports took a median 19k tokens per chunk, 8% of the worker's peak context, and lines carrying a severity mark were 9–24% of a report (2026-10-08, over 68 archived transcripts). `stability-replay` still counts each πŸ”΄ and 🟑 by its line in the reviewer's reply. diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 15eec9eb..29047a76 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -45,7 +45,7 @@ A comment is prose, not code. Passes run in this order: line-level polish on cod Give a reviewer without Bash the branch diff and `git ls-files`'s output in its prompt: some harnesses grant it Read alone. -**Reports.** Name in each prompt to an agent under `~/.claude/agents/` the file its full report goes to: `/tmp/larv-review//-round-.md`, with the yardstick's name after the pass's for a principles-auditor, and `-rerun` before `.md` for a relaunch one rung up. It writes the report there and returns only its verdict and one line per finding. Read the report's entry for each πŸ”΄ and 🟑 before you answer it. rule-hook refuses a reviewer's write anywhere else. +**Reports.** The chunk's review folder is `~/.local/state/larv-review//`. Name in each prompt to an agent under `~/.claude/agents/` the file there that its full report goes to: `-round-.md`, with the yardstick's name after the pass's for a principles-auditor, and `-rerun` before `.md` for a relaunch one rung up. It writes the report there and returns only its verdict and one line per finding. 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 write anywhere else. `~/.claude/bin/larv-review` holds this section's mechanical rules: the round count, the paired ruling's base and vote count, the scoring run's trigger, and the history's format and latest places, and its count of how often seats agree. 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. @@ -112,7 +112,7 @@ The comprehension check records how hard the project is to read, and blocks no m - **Base.** The last measured commit, which `~/.claude/bin/larv-review ruling-base` prints. - **Head.** The head holds `origin/`, merged in at Β§4 step 1, so it differs from the default branch only by this branch's change. -- **Seats.** Mid A and the inherited architect. Write what they read and their replies into a votes file in your scratchpad, in the shape `~/.claude/bin/larv-review --help` shows, and run `~/.claude/bin/larv-review record-ruling `. On `Split:`, launch the maintainability senior and Junior A together, add their lines, and run it again. +- **Seats.** Mid A and the inherited architect. Write what they read and their replies into a votes file in the chunk's review folder, in the shape `~/.claude/bin/larv-review --help` shows, and run `~/.claude/bin/larv-review record-ruling `. On `Split:`, launch the maintainability senior and Junior A together, add their lines, and run it again. **Scoring run**, when `~/.claude/bin/larv-review needs-scoring-run ` prints `Scoring run due:`. Run `needs-scoring-run` before removing the chunk's items from `todo.md`. @@ -163,7 +163,7 @@ Launch prose-reviewer with what the diff touched and every section this review c 1. Read the finished PR against the README goals: does anything in it work against one? It breaks a maintain goal β†’ do not merge; redesign the change or drop its item. It works against an achieve goal β†’ do not merge; ask the human, stating the conflict. 2. Run the comprehension check (Β§3) where it runs; it runs once. When `origin/` moves after that, return to Β§4, and keep the ruling and scoring run already recorded. 3. Aligned, every pass done and everything green β†’ **merge**. Follow the repo's merge method (`AGENTS.md`; ff-only where that is the convention). A repo withholds this in its `AGENTS.md` β†’ leave the PR ready and unmerged, and say which line withheld it. -4. Merged β†’ remove the chunk's items from `todo.md` per `~/.claude/CLAUDE.md` β†’ "Working loop", and the chunk's folder under `/tmp/larv-review/`. +4. Merged β†’ remove the chunk's items from `todo.md` per `~/.claude/CLAUDE.md` β†’ "Working loop", and the chunk's review folder. 5. Stop. The next chunk gets a fresh session. ## 6. Wrap up diff --git a/skills/larv-review/review-findings.md b/skills/larv-review/review-findings.md index 07c8d26e..f7c4518b 100644 --- a/skills/larv-review/review-findings.md +++ b/skills/larv-review/review-findings.md @@ -16,10 +16,11 @@ A finding against a technical principle names it and the file under `~/.claude/p ## Report -Write your full report with the Write tool to the file your prompt names, under `/tmp/larv-review/`: the verdict, then every finding with its place, its evidence and its fix, as your agent file shapes them. Then return only: +Write your full report with the Write tool to the file your prompt names: the verdict, then every finding with its place, its evidence and its fix, as your agent file shapes them. Then return only: - the verdict line -- one line per finding: its severity mark, its place, and what is wrong in one sentence, such as `🟑 bin/rank_todo.py:311 place: a cycle among blockers recurses forever` +- one line per finding: its severity mark, its place, what is wrong in one sentence, and the file it breaks where that is `standards/quality.md` or a file under `~/.claude/principles/`, or for a πŸ”€ the reviewer it names, such as `🟑 bin/rank_todo.py:311 place: a cycle among blockers recurses forever (technical-principles.md)` +- for stability-reviewer, whether the tests passed, and at which commit - `Rerun one rung up`, where your report ends with it - the report's path diff --git a/todo.md b/todo.md index a78871bd..b28c7b0b 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 185` +`Next ID = 187` ## Items @@ -33,6 +33,7 @@ | 106 | 0.3.0 | | | **Make larv-review's "Do not over-read a clean result" cite a rule that says Renovate or Dependabot owns dependency CVEs, or drop the citation.** | 1 | 2 | 1 | 2 | 1 | 1.1 by 5 | 10.9 | | 167 | 0.3.0 | | | **Refuse a `/security-review` or `/claude-security` Skill call below the project's rung, as rule-hook refuses such an Agent call.** | 3 | 2 | 3 | 6 | 2 | 1.1 by 4 | 7.3 | | 176 | 0.3.0 | | | **Give `loop-claude --help`'s routing paragraph sub-headings, such as Routing, Judge rung and Routing figures, so a reader finds a rule without reading 39 lines.** | 1 | 2 | 1 | 2 | 2 | 1.1 by 3, 1.4 by 2 | 7.3 | +| 185 | 0.3.0 | | | **Point every file a session parks outside its checkout, such as the comprehension panel's detached worktree and a build probe's output, at a folder a headless session has, since loop-claude's sessions have no scratchpad.** | 1 | 2 | 2 | 3 | 2 | 1.1 by 3, 1.5 by 2 | 6.9 | | 172 | 0.3.0 | | | **Name the project's rung `project` across `bin/loop_claude`, in place of `anchor`, as `bin/model_routing/ladder.py` names it.** | 2 | 1 | 3 | 4 | 3 | 1.1 by 3, 1.4 by 3 | 6.2 | | 82 | 0.3.0 | | principle | **Sort `AGENTS.md`'s decision titles and `docs/decisions.md`'s entries by title.** | 2 | 2 | 1 | 3 | 4 | 1.1 by 4, 1.4 by 4 | 5.5 | | 173 | 0.3.0 | | | **Have rule-hook's `todo-rank-check` run a worktree's own `bin/rank_todo.py` when the worktree is of this repo, so a branch that changes `todo.md`'s shape commits without an override.** | 2 | 1 | 3 | 4 | 2 | 1.1 by 2, 1.4 by 2 | 5.5 | @@ -46,6 +47,7 @@ | 169 | 0.3.0 | | | **Have rule-hook's `todo-rank-check` catch a `todo.md` that the same Bash call edits and then commits.** | 3 | 1 | 3 | 5 | 3 | 1.1 by 2 | 2.7 | | 183 | 0.3.0 | | | **Merge the two 2026-10-13 paragraphs of `docs/decisions.md` β†’ `loop-claude: a judge decides each interrupt …` into one.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 1 | 2.2 | | 184 | 0.3.0 | | | **Rewrap the lines of `loop-claude --help` that run past the column the rest of it wraps at.** | 1 | 1 | 1 | 1 | 1 | 1.1 by 1 | 2.2 | +| 186 | 0.3.0 | | | **Count the tokens a worker spends reading reviewers' reports, so goal 1.4's signal shows whether report files lowered what a review costs the worker's context.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 3 | 2.1 | | 174 | 0.3.0 | | | **In a chunk no item routed, ask the worker to name each todo.md item it takes, with its L and E + I, so loop-claude can route on an item it takes in.** | 1 | 2 | 3 | 4 | 2 | 1.1 by 1 | 1.8 | | 122 | 0.4.0 | | | **Assemble the judge's prompt in `bin/loop_claude/cycle/judge.py`, importing only wording the worker also sees, and call the worker "the worker" in it.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5, 1.4 by 5 | 10.3 | | 158 | 0.4.0 | | decision | **Measure the fixed cost of a chunk from loop-claude's archive, in tokens and hours against its items' S, and set F in `Score = 100 * V / (2**S + F)` to it.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 5, 1.4 by 5 | 10.3 | @@ -183,6 +185,10 @@ rule-hook checks Agent calls (item 163) but no Skill calls. A worker that invoke Raised by the prose pass of PR #302: the help, the docstring of `bin/loop_claude/loop/main.py`, is 145 lines, and its routing paragraph one block of 39, from the ladder through the judge's rung to the routing figures. A reader looking for one rule, such as when the worker steps up, reads it all. The comprehension seats already found the help hard (`larv-review places`: "loop-claude --help": a 120-line contract with no pointers to the modules it maps onto). +### 185. Point every file a session parks outside its checkout, such as the comprehension panel's detached worktree and a build probe's output, at a folder a headless session has, since loop-claude's sessions have no scratchpad. + +`skills/comprehension-panel/SKILL.md` puts the base version's detached worktree "in your scratchpad", and `CLAUDE.md` β†’ "Working with the codebase" lets a build-probing subagent write "only to the session scratchpad". A probe on 2026-10-18 found no `scratchpad_dir` in a headless `claude -p` session's hook input, and neither the session nor its subagent knew a scratchpad path. larv-review now parks its reports and votes file in the chunk's review folder under `~/.local/state/larv-review/`, per `docs/decisions.md` β†’ `review: each reviewer under agents/ writes its full report into the chunk's review folder`. Found by the architecture review of PR #310. + ### 172. Name the project's rung `project` across `bin/loop_claude`, in place of `anchor`, as `bin/model_routing/ladder.py` names it. The architecture pass of PR #296 found one rung under two names: `bin/model_routing/ladder.py` calls it `project`, while `bin/loop_claude/routing.py`, `cycle/prompts.py`, `cycle/run.py`'s `Cycle.anchor` and `loop/main.py` call it `anchor`, and gloss it as "anchor, the project's rung" in docstring after docstring. A reader works out that the two are one rung each time. Make `bin/loop_claude/routing.py`'s `first_route` easier to read. @@ -243,6 +249,10 @@ They say the same thing for `~/.claude/rules/` (item 95) and `~/.claude/skills/l In `bin/loop_claude/loop/main.py`'s docstring, the line holding "of one PR, is finished" and the one ending "Each of these opens with its UTC time." run to 107 and 159 columns. Raised by the prose review of PR #308. +### 186. Count the tokens a worker spends reading reviewers' reports, so goal 1.4's signal shows whether report files lowered what a review costs the worker's context. + +Before PR #310, reports reached the worker as the Agent call's result, a median 19k tokens per chunk (2026-10-08, 68 archived transcripts). Now a reviewer returns its verdict and one line per finding, and the worker reads a πŸ”΄ or 🟑 finding's entry from the report file. `reading-cost` counts only tracked files (`bin/reading_cost/measure.py`), and `routing-figures` counts only the Agent call's result (`bin/routing_figures/measure.py`), so neither sees the report reads. Found by the architecture review of PR #310. + ### 174. In a chunk no item routed, ask the worker to name each todo.md item it takes, with its L and E + I, so loop-claude can route on an item it takes in. The principles pass of PR #301 found that only `routed_by` in `bin/loop_claude/cycle/prompts.py` asks the worker to name each item it takes with its L and E + I, and `fresh` uses it only where an item routed the chunk. In an unrouted chunk the judge has no levels to report, so neither the taken-in L nor the taken-in E + I lifts the worker, the reviewers or the judge, and the first prompt names no reviewers' rung for a higher E + I. -- 2.52.0 From 3adf58c61958a894fc0f311384cc2c13e95a0fa7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 00:21:28 +0200 Subject: [PATCH 03/13] =?UTF-8?q?Answer=20architecture=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20the=20architect=20approved?= =?UTF-8?q?=20the=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 3928d84acbcf52ff07dc3c948cc6238e4ffa335f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 00:37:24 +0200 Subject: [PATCH 04/13] =?UTF-8?q?Answer=20principles=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=207=20=F0=9F=9F=A1;=20sort=20the=20new=20imports,?= =?UTF-8?q?=20test=20a=20symlink=20in=20the=20reports=20folder,=20own=20th?= =?UTF-8?q?e=20folder's=20path=20in=20review=5Ffolder.py=20and=20check=20S?= =?UTF-8?q?KILL.md=20names=20it,=20redirect=20stability-replay's=20reviewe?= =?UTF-8?q?r=20to=20a=20copy=20of=20the=20chunk's=20folder=20and=20keep=20?= =?UTF-8?q?folders=20after=20the=20merge,=20keep=20the=20folder=20private,?= =?UTF-8?q?=20override=20the=20harness's=20no-report-files=20note,=20and?= =?UTF-8?q?=20state=20what=20a=20reviewer=20may=20write?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- CLAUDE.md | 2 +- agents/stability-reviewer.md | 2 +- bin/repo_checks/test_reviewer_launches.py | 4 ++++ bin/rule_hook/reviewer_report.py | 3 ++- bin/rule_hook/rules.py | 3 +-- bin/rule_hook/test_rule_hook.py | 15 +++++++++++-- bin/stability_replay/main.py | 19 +++++++++++----- bin/stability_replay/test_stability_replay.py | 22 +++++++++++++++++++ bin/test_review_folder.py | 16 ++++++++++++++ docs/decisions.md | 6 ++--- skills/larv-review/SKILL.md | 6 ++--- skills/larv-review/review-findings.md | 4 ++-- 13 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 bin/test_review_folder.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f42eaf7..3b3683e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Each reviewer under `agents/` writes its full report to a file under `~/.local/state/larv-review/`, which larv-review names in its prompt, and returns only its verdict and one line per finding, so a review takes less of the worker's context. The worker reads a finding's full entry before it fixes or answers a πŸ”΄ or 🟑. Each reviewer now holds Write. `rule-hook` refuses a reviewer's Edit and MultiEdit, and any Write outside that folder, and takes no override. +- Each reviewer under `agents/` writes its full report to a file under `~/.local/state/larv-review/`, which larv-review names in its prompt, and returns only its verdict and one line per finding, so a review takes less of the worker's context. The worker reads a finding's full entry before it fixes or answers a πŸ”΄ or 🟑. Each reviewer now holds Write. `rule-hook` refuses a reviewer's Edit and MultiEdit, and any Write outside that folder, and takes no override. Each chunk's folder stays after the merge, so `stability-replay` can replay a later round, which it does on a copy of the folder. - `loop-claude` asks an interrupt's question on its own terminal and resumes the worker headless with your one-line answer, so the loop no longer waits for you to leave a claude session. Type `/talk` instead to open the worker's session in claude, as every interrupt did before, to read the diff or discuss first. A release ready to cut opens that session at once. Pressing Enter on an empty answer stops the loop, exit 2. Keys typed before the question shows are dropped, and a pasted answer keeps only its first line; type `/talk` for a longer one. The judge counts that answer as yours, like one typed in claude: the chunk stays open until the answer is recorded, where a later chunk could need it. - When a worker's run ends with a question and a request for a higher rung, `loop-claude` now steps the worker one rung up as the judge interrupts, or as it answers the question with a quote from `README.md` or another file it may quote. The judge must quote a passage showing that the escalation trigger the run cites fired. Before, the step was lost for an answered question, and the worker carried on from the answer on its old rung. The step has the same limits as the step on an unfinished verdict, and no later ruling of that cycle carries a second escalation. The archive's interrupt and quoted-answer outcomes now name the worker's rung. - A scoring run due because a release's items ran out costs four more seats: it is done twice on one head. `larv-review agreement` compares how often Mid A and the inherited architect vote alike in paired rulings with how often their overall scores move the same way between the two runs. After 10 such pairs it gives a verdict, and on `Assumption fails:` larv-review asks you whether to keep the paired ruling. diff --git a/CLAUDE.md b/CLAUDE.md index 245600db..ce26affa 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -66,7 +66,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i 4. A review rules the work below standard: systems-architect's BLOCK, a finding against larv-review's `standards/quality.md`, or a vote `record-ruling` counts as worse, in the report that stands after any relaunch one rung up (`larv-review` Β§3 β†’ "Rung up"). When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Open the subagent's prompt with the marker loop-claude's prompt gives, then the trigger's evidence. Each later subagent on that task runs on that rung or higher, and each further escalation trigger moves the task one rung higher, up to the highest rung loop-claude's prompt names. Ask the human before going higher. Where loop-claude's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread. -- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits; a reviewer under `agents/` also writes its report to the file larv-review names, and rule-hook refuses it any other write. One that probes a build tags the image as throwaway and removes it afterwards, writes only to the session scratchpad, and removes no image or file it did not create. +- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits; a reviewer under `agents/` also writes its report to the file larv-review names, and rule-hook refuses it any other Write, Edit or MultiEdit. One that probes a build tags the image as throwaway and removes it afterwards, writes only to the session scratchpad, and removes no image or file it did not create. - Check `README.md` first for build, test, install, and codegen commands, and fix one that misbehaves in the same change. Refresh `README.md` whenever you change what it describes, keeping it true, not longer. - Where `~/.claude/bin/rule-hook` does not check it, such as an image named in test code, a Kubernetes manifest, a `docker run` line or a file a Bash command writes, pin a container image to its full patch version and a GitHub Action to a semver tag. diff --git a/agents/stability-reviewer.md b/agents/stability-reviewer.md index 38561ff4..7196a0e9 100644 --- a/agents/stability-reviewer.md +++ b/agents/stability-reviewer.md @@ -12,7 +12,7 @@ You are an elite stability-focused code reviewer with deep expertise in defensiv 1. **Scope the change.** You review every PR; a fresh invocation has no prior context, so determine the diff yourself. Diff the PR branch against its base (`gh pr diff`, or `git merge-base HEAD` then `git diff`), and review the changed lines **plus enough surrounding code and callers** to judge correctness β€” read the whole changed file when practical; a diff alone hides whether a caller breaks. Read the PR description and, when the project uses an issue tracker (project-specific β€” check its docs) and the change references a ticket, that ticket: the diff is judged against its stated intent, and a scope mismatch in either direction is a finding β€” claimed-but-unimplemented, and implemented-but-unasked (#2). 2. **Read every file under `~/.claude/principles/`**, the shared principles, and `~/.claude/skills/larv-review/standards/quality.md`. These are mandatory org guidelines; all code MUST comply with each that applies. A file's `Applies to` line says what it covers; one without the line covers every change. Re-read each time β€” they change. Flag violations prominently. 3. **Read README.md, AGENTS.md and `docs/decisions.md`** in the current project for project-specific conventions, build instructions, tooling, and the accepted trade-offs a reviewer should honor rather than re-flag. Note the documented test, lint, and static-analysis commands β€” you will run them. -4. **Verify, don't just read.** Run the test suite and static analysis/linters through the project's container tooling, unless a decision puts them on the host; tear down test containers afterwards. A full-suite run catches broken callers that diff-reading misses. When a suspected bug is cheap to confirm, reproduce it β€” a scratch script, a targeted test run β€” before reporting it. Put scratch work in a directory you create for this run, and delete it when done; delete nothing else, since a directory the prompt names may hold other agents' files. Leave the working tree exactly as you found it. Anything you could not run goes in Coverage & Verification, never silently skipped. +4. **Verify, don't just read.** Run the test suite and static analysis/linters through the project's container tooling, unless a decision puts them on the host; tear down test containers afterwards. A full-suite run catches broken callers that diff-reading misses. When a suspected bug is cheap to confirm, reproduce it β€” a scratch script, a targeted test run β€” before reporting it. Put scratch work in a directory you create for this run, through Bash, since Write is for your report alone, and delete it when done; delete nothing else, since a directory the prompt names may hold other agents' files. Leave the working tree exactly as you found it. Anything you could not run goes in Coverage & Verification, never silently skipped. 5. **Mutation-test the changed lines.** Run the project's documented mutation command, or else a widely deployed mutation tool for the language: cargo-mutants for Rust, Infection for PHP, mutmut for Python, Stryker for JavaScript and TypeScript. Limit it to the lines the change adds or modifies, through the tool's own option where it has one (cargo-mutants `--in-diff `, Infection `--git-diff-lines`, Stryker `--mutate :`); otherwise mutate only the changed files and keep only the mutants on changed lines. Run it through the project's tooling, as in step 4, on a scratch copy: the tools write files. Report its wall time and mutant count in Coverage & Verification, or why nothing was mutated. Ignore a surviving mutant that leaves behaviour unchanged, or changes only message or log text no caller or user depends on. Report one 🟑 per test to add or strengthen, naming the surviving mutants it would catch. 6. **Two passes minimum, then hunt absences.** - *Breadth:* every hunk in every changed file, no skimming. Track which files you have covered; batch large diffs, never truncate the review. diff --git a/bin/repo_checks/test_reviewer_launches.py b/bin/repo_checks/test_reviewer_launches.py index 6d43c920..7658af39 100644 --- a/bin/repo_checks/test_reviewer_launches.py +++ b/bin/repo_checks/test_reviewer_launches.py @@ -5,6 +5,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) +from review_folder import REPORTS from rule_hook.reviewer_rung import REVIEWERS, SEAT, SECURITY_OPENER from repo_checks.test_python_floor import ROOT @@ -28,3 +29,6 @@ class ReviewerLaunches(unittest.TestCase): def test_the_security_opening_is_the_sentence_larv_review_has_the_security_pass_open_with(self): security = LARV_REVIEW.split("### Security", 1)[1].split("### Overrides", 1)[0] self.assertIn(SECURITY_OPENER, security) + + def test_larv_review_names_the_reports_folder_rule_hook_lets_a_reviewer_write_into(self): + self.assertIn(f"`~/{REPORTS}/ list[Breach]: diff --git a/bin/rule_hook/rules.py b/bin/rule_hook/rules.py index f69ea09f..f8822339 100644 --- a/bin/rule_hook/rules.py +++ b/bin/rule_hook/rules.py @@ -5,6 +5,7 @@ import typing from git_command import commits from round_titles import lacks_counts +from review_folder import REPORTS from shell_command import Simple RuleName = typing.Literal["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "reviewer-report", "reviewer-rung", "round-title-counts", "todo-rank-check"] @@ -18,8 +19,6 @@ class Rule: overridable: bool = True -# The reviewers' reports folder, under the home folder: outside every checkout, so no project sees a report, and kept across a reboot, so a resumed chunk still reads its rounds. A fixed path, since a headless session has no scratchpad. -REPORTS = ".local/state/larv-review" RULES: dict[RuleName, Rule] = { "action-pin": Rule( "a GitHub or Gitea Action is pinned to a semver tag, such as @v3 or @v3.1.2, never to a branch, and to a commit SHA only in a pipeline that tests our own specific builds", diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index fb7390fc..f0eee8c2 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -241,7 +241,16 @@ class ReviewerReport(unittest.TestCase): def test_a_reviewer_writes_its_report_into_the_reports_folder(self): self.assertEqual(self.breached("Write", "/h/.local/state/larv-review/.claude-item-73/prose-round-1.md"), []) - self.assertEqual(self.breached("Write", "prose-round-1.md", cwd="/h/.local/state/larv-review/x"), [], "a relative path resolves against the call's cwd") + + def test_a_relative_path_resolves_against_the_calls_cwd(self): + self.assertEqual(self.breached("Write", "prose-round-1.md", cwd="/h/.local/state/larv-review/x"), []) + + def test_a_symlink_in_the_reports_folder_is_followed_to_where_it_points(self): + home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())) + (home / ".local" / "state" / "larv-review").mkdir(parents=True) + (home / ".local" / "state" / "larv-review" / "out").symlink_to(home) + found = breaches_of(Call("Write", {"file_path": f"{home}/.local/state/larv-review/out/a.md", "content": "x"}, "/r", "prose-reviewer"), str(home), {}) + self.assertEqual(rules(found[2]) if found else [], ["reviewer-report"]) def test_a_reviewer_writing_anywhere_else_is_refused(self): for path in ["/r/README.md", "/h/.local/state/larv-review", "/h/.local/state/larv-review-x/a.md", "/h/.local/state/larv-review/../a.md", "/tmp/larv-review/a.md"]: @@ -250,6 +259,8 @@ class ReviewerReport(unittest.TestCase): def test_a_reviewer_edits_no_file_even_in_the_reports_folder(self): self.assertEqual(self.breached("Edit", "/h/.local/state/larv-review/x/prose-round-1.md"), ["reviewer-report"]) + + def test_a_reviewers_multiedit_is_refused(self): self.assertEqual(self.breached("MultiEdit", "/r/a.py", "stability-reviewer"), ["reviewer-report"]) def test_the_worker_and_other_subagents_write_anywhere(self): @@ -402,7 +413,7 @@ class Hook(unittest.TestCase): def test_help_lists_every_rule(self): helped = subprocess.run([str(HOOK), "--help"], capture_output=True, check=True, env=isolated_env(), text=True).stdout - for rule in ["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "reviewer-report", "round-title-counts", "todo-rank-check"]: + for rule in ["action-pin", "commit-one-line", "ignorefile-sorted", "image-pin", "no-ai-attribution", "reviewer-report", "reviewer-rung", "round-title-counts", "todo-rank-check"]: self.assertIn(f" {rule}\n The rule: ", helped) self.assertIn("reviewer-report\n The rule: a reviewer writes nothing but its report", helped) self.assertRegex(helped, r" reviewer-report\n( .*\n){2} Takes no override\.\n") diff --git a/bin/stability_replay/main.py b/bin/stability_replay/main.py index c40dacd2..04a269e3 100644 --- a/bin/stability_replay/main.py +++ b/bin/stability_replay/main.py @@ -46,6 +46,7 @@ from failure import Failure from rung_replay.search import first_reply, replayed from claude_code.transcript import first_timestamped_line, read_transcript from claude_code.entries import parse_entry, structured_output +from review_folder import REPORTS, review_folder from model_routing.ladder import Rung TOOL = "stability-replay" @@ -80,7 +81,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff return failed(TOOL, f"no archived stability round of projects on {anchor.model} in {archive_root(home, env)} holds a πŸ”΄ or 🟑 on code it can find") chosen = sample(list(codes), LATEST) # The project's rung is the reference, so the candidates start below it. - replay = replayed(chosen, anchor, down_from(anchor)[1:], lambda found, rung: findings_found(found, codes[found], rung, anchor, effects), lambda _, found: sorted(found), "stability rounds") + replay = replayed(chosen, anchor, down_from(anchor)[1:], lambda found, rung: findings_found(found, codes[found], rung, anchor, home, effects), lambda _, found: sorted(found), "stability rounds") if isinstance(replay, Limited): return limited_exit(TOOL, replay) print(report(anchor.model, anchor, chosen, replay)) @@ -147,9 +148,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, anchor: Rung, effects: Effects) -> set[int] | Limited: +def findings_found(found: Round, code: Code, rung: Rung, anchor: Rung, home: pathlib.Path, effects: Effects) -> set[int] | Limited: """The indexes of the round's findings that its replay on rung reports, as the reviewer on anchor matches them.""" - reviewed: str | Failure | Limited = first_reply(lambda: review(found, code, rung, effects)) + reviewed: str | Failure | Limited = first_reply(lambda: review(found, code, rung, home, effects)) 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, anchor, effects)) @@ -160,8 +161,15 @@ def findings_found(found: Round, code: Code, rung: Rung, anchor: Rung, effects: # 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, effects: Effects) -> str | Failure | Limited: +def review(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Effects) -> str | Failure | Limited: clone = tempfile.mkdtemp(prefix="stability-replay-") + # The reviewer writes its report into a copy of the chunk's review folder, so it leaves the chunk's reports as they were and still reads the earlier rounds its prompt names. + folder = pathlib.Path(review_folder(str(home), code.path)) + (home / REPORTS).mkdir(mode=0o700, parents=True, exist_ok=True) + reports = tempfile.mkdtemp(prefix="stability-replay-", dir=home / REPORTS) + if folder.is_dir(): + shutil.copytree(folder, reports, dirs_exist_ok=True) + prompt = found.prompt.replace(str(folder), reports).replace(f"~/{folder.relative_to(home)}", reports).replace(code.path, clone) try: for command in ( ("clone", "--quiet", "--shared", "--no-checkout", found.root, clone), @@ -172,12 +180,13 @@ def review(found: Round, code: Code, rung: Rung, effects: Effects) -> str | Fail if isinstance(ran := git(effects, found.root, *command), Failure): return ran args = ["--agent", REVIEWER, *rung.flags()] - reply = claude_reply(effects.claude, args, clone, found.prompt.replace(code.path, clone), "claude") + reply = claude_reply(effects.claude, args, clone, prompt, "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") finally: shutil.rmtree(clone, ignore_errors=True) + shutil.rmtree(reports, ignore_errors=True) def match(findings: tuple[str, ...], replay_report: str, root: str, rung: Rung, effects: Effects) -> set[int] | Failure | Limited: diff --git a/bin/stability_replay/test_stability_replay.py b/bin/stability_replay/test_stability_replay.py index f854167f..a9a10ef2 100644 --- a/bin/stability_replay/test_stability_replay.py +++ b/bin/stability_replay/test_stability_replay.py @@ -232,6 +232,28 @@ class Main(unittest.TestCase): self.assertIn(f" {self.checkout} 2026-10-14T10:00:00Z: 🟑 slow", out) self.assertTrue(out.endswith("finds: claude-sonnet-5-5 at high effort\n")) + def test_points_the_prompts_review_folder_at_a_copy_that_it_removes(self): + folder = self.home / ".local" / "state" / "larv-review" / "code" / "proj-x" + folder.mkdir(parents=True) + (folder / "stability-round-1.md").write_text("round 1\n") + self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to ~/.local/state/larv-review/code/proj-x/stability-round-2.md; the last round's is ~/.local/state/larv-review/code/proj-x/stability-round-1.md.") + seen = [] + + def review(rung): + named = pathlib.Path(re.search(r"report to (\S+)/stability-round-2\.md", self.reviews[-1][4]).group(1)) + seen.append((named, (named / "stability-round-1.md").read_text())) + (named / "stability-round-2.md").write_text("replayed\n") + return {"type": "result", "result": f"review on {rung.model} {rung.effort}"} + + code, _, err = self.run_main(["claude-opus-5-5"], lambda rung: {"found": [0, 1]}, review) + self.assertEqual(code, 0, err) + named, earlier = seen[0] + self.assertEqual(named.parent, folder.parents[1], "the copy sits in the reports folder, where rule-hook lets the reviewer write") + self.assertNotEqual(named, folder) + self.assertEqual(earlier, "round 1\n") + self.assertFalse(named.exists()) + self.assertEqual(sorted(path.name for path in folder.iterdir()), ["stability-round-1.md"]) + def test_replays_the_rounds_of_every_chunk(self): self.write_chunk("proj", "c2", "2026-10-14T10:30:00Z") code, out, err = self.run_main(["claude-opus-5-5"], lambda rung: {"found": [0, 1]}) diff --git a/bin/test_review_folder.py b/bin/test_review_folder.py new file mode 100644 index 00000000..8f9676dc --- /dev/null +++ b/bin/test_review_folder.py @@ -0,0 +1,16 @@ +import pathlib +import sys +import unittest + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) + +from review_folder import review_folder + + +class ReviewFolder(unittest.TestCase): + def test_keys_a_worktree_under_home_by_its_path_relative_to_home(self): + self.assertEqual(review_folder("/h", "/h/code/proj-item-3"), "/h/.local/state/larv-review/code/proj-item-3") + + def test_keys_a_worktree_outside_home_by_its_path_relative_to_the_root(self): + self.assertEqual(review_folder("/h", "/srv/proj-item-3"), "/h/.local/state/larv-review/srv/proj-item-3") + self.assertEqual(review_folder("/h", "/hx/proj"), "/h/.local/state/larv-review/hx/proj", "a sibling of home that shares its prefix is outside it") diff --git a/docs/decisions.md b/docs/decisions.md index ae3830ad..59bab47c 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -222,11 +222,11 @@ Valid while the worker writes the tests that larv-review's reviewers hold to the 2026-10-18, the agent, shipping lilleman's plan item. Serves goal 1.4: a report the worker does not need line by line no longer fills its context. Goal 1.1 holds because the worker reads a finding's full entry before it answers a πŸ”΄ or 🟑. -The worker names each report's file in the reviewer's prompt, per `skills/larv-review/SKILL.md` β†’ "Reports", and `skills/larv-review/review-findings.md` β†’ "Report" sets what the reviewer returns. Each reviewer holds Write for that. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`, so `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit, MultiEdit, and Write outside the folder; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. The folder is fixed, since loop-claude's headless sessions have no scratchpad. It sits outside every checkout, so no project sees a report. It survives a reboot, unlike `/tmp`, so a resumed chunk still reads its earlier rounds. And it is in the user's home, so no other local user reads a report, which may quote a secret, or plants a symlink that widens the folder. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. +The worker names each report's file in the reviewer's prompt, per `skills/larv-review/SKILL.md` β†’ "Reports", and `skills/larv-review/review-findings.md` β†’ "Report" sets what the reviewer returns. Each reviewer holds Write for that. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`, so `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit, MultiEdit, and Write outside the folder; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. The folder is fixed, since loop-claude's headless sessions have no scratchpad. It sits outside every checkout, so no project sees a report. It survives a reboot, unlike `/tmp`, so a resumed chunk still reads its earlier rounds. It is in the user's home, so no other local user plants a symlink that widens the folder, and the worker makes `~/.local/state/larv-review` readable by the user alone, since a report may quote a secret. A chunk keeps its folder after the merge: `stability-replay` hands a replayed reviewer a copy of it, so the replay reads the earlier rounds its prompt names and leaves the chunk's reports as they were. Claude Code's own subagent prompt tells a subagent to return findings rather than write report files; `review-findings.md` β†’ "Report" overrides that, since the file is the worker's input, and a prose-reviewer probed on 2026-10-18 wrote its file. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. -Before this change, reports took a median 19k tokens per chunk, 8% of the worker's peak context, and lines carrying a severity mark were 9–24% of a report (2026-10-08, over 68 archived transcripts). `stability-replay` still counts each πŸ”΄ and 🟑 by its line in the reviewer's reply. +Before this change, reports took a median 19k tokens per chunk, 8% of the worker's peak context, and lines carrying a severity mark were 9–24% of a report (2026-10-08, over 68 archived transcripts). `stability-replay` still counts each πŸ”΄ and 🟑 by its line in the reviewer's reply, now a one-line summary. todo.md item 186 measures what the worker reads of the reports instead. -Valid while Claude Code passes `agent_type` to hooks inside a subagent. +Valid while Claude Code passes `agent_type` to hooks inside a subagent. Without it, the rule refuses nothing, and a reviewer may write anywhere. ## review: stability and product-owner report only a defect, a broken requirement of the plan or the goals, a breach of a technical principle, or for stability a hard place the change touches; each architect finding names a later change the PR makes harder; prose runs only on a chunk that changes prose diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 29047a76..878b7bb2 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -45,7 +45,7 @@ A comment is prose, not code. Passes run in this order: line-level polish on cod Give a reviewer without Bash the branch diff and `git ls-files`'s output in its prompt: some harnesses grant it Read alone. -**Reports.** The chunk's review folder is `~/.local/state/larv-review//`. Name in each prompt to an agent under `~/.claude/agents/` the file there that its full report goes to: `-round-.md`, with the yardstick's name after the pass's for a principles-auditor, and `-rerun` before `.md` for a relaunch one rung up. It writes the report there and returns only its verdict and one line per finding. 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 write anywhere else. +**Reports.** The chunk's review folder is `~/.local/state/larv-review//`. Make it, and keep `~/.local/state/larv-review` readable by you alone: `mkdir -p && chmod 700 ~/.local/state/larv-review`. Keep it after the merge: `stability-replay` replays a round from the reports its prompt names. Name in each prompt to an agent under `~/.claude/agents/` the file there that its full report goes to: `-round-.md`, with the yardstick's name after the pass's for a principles-auditor, and `-rerun` before `.md` for a relaunch one rung up. It writes the report there and returns only its verdict and one line per finding. 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 write anywhere else. `~/.claude/bin/larv-review` holds this section's mechanical rules: the round count, the paired ruling's base and vote count, the scoring run's trigger, and the history's format and latest places, and its count of how often seats agree. 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. @@ -80,7 +80,7 @@ Give a reviewer without Bash the branch diff and `git ls-files`'s output in its **Rung up.** A reviewer rules the work below standard when its report holds systems-architect's BLOCK or a finding against `standards/quality.md`. A comprehension seat does when `record-ruling` counts one of its votes as worse. - **Ask.** Such a reviewer or seat may end its report asking for a rerun one rung up. Relaunch it only on the rung loop-claude's prompt names for it; where the prompt names none, the report stands. -- **Relaunch.** Relaunch a reviewer on that rung with the same prompt and the path of the report that asked; its report stands in place of that one, in the same round. Relaunch a seat with the same prompt alone; its line replaces the one that asked in the votes file, before `record-ruling` runs. A relaunch cannot ask again. +- **Relaunch.** Relaunch a reviewer on that rung with the same prompt, its report file renamed per "Reports", and the path of the report that asked; its report stands in place of that one, in the same round. Relaunch a seat with the same prompt alone; its line replaces the one that asked in the votes file, before `record-ruling` runs. A relaunch cannot ask again. - **Escalate.** A below-standard ruling in the report that stands is escalation trigger 4 in `~/.claude/CLAUDE.md` β†’ "Working with the codebase". **Findings.** A reviewer rates each finding πŸ”΄ must fix, 🟑 should fix, 🟒 nit, ❓ question, or πŸ”€ escalation naming the reviewer whose concern it is. @@ -163,7 +163,7 @@ Launch prose-reviewer with what the diff touched and every section this review c 1. Read the finished PR against the README goals: does anything in it work against one? It breaks a maintain goal β†’ do not merge; redesign the change or drop its item. It works against an achieve goal β†’ do not merge; ask the human, stating the conflict. 2. Run the comprehension check (Β§3) where it runs; it runs once. When `origin/` moves after that, return to Β§4, and keep the ruling and scoring run already recorded. 3. Aligned, every pass done and everything green β†’ **merge**. Follow the repo's merge method (`AGENTS.md`; ff-only where that is the convention). A repo withholds this in its `AGENTS.md` β†’ leave the PR ready and unmerged, and say which line withheld it. -4. Merged β†’ remove the chunk's items from `todo.md` per `~/.claude/CLAUDE.md` β†’ "Working loop", and the chunk's review folder. +4. Merged β†’ remove the chunk's items from `todo.md` per `~/.claude/CLAUDE.md` β†’ "Working loop". 5. Stop. The next chunk gets a fresh session. ## 6. Wrap up diff --git a/skills/larv-review/review-findings.md b/skills/larv-review/review-findings.md index f7c4518b..47ab4923 100644 --- a/skills/larv-review/review-findings.md +++ b/skills/larv-review/review-findings.md @@ -2,7 +2,7 @@ Words: `~/.claude/CLAUDE.md` β†’ "Vocabulary". -A reviewer reads and reports; it edits nothing, and writes only its report. Read `docs/decisions.md` and `todo.md` first: a finding declined or disproved in `docs/decisions.md` or in a comment at the code it concerns, or filed in `todo.md`, is not raised again, unless the decline works against a goal or a technical principle and names no `todo.md` item ending it. +A reviewer reads and reports; it edits nothing. It writes no file but its report, apart from the scratch files a reviewer holding Bash makes through it. Read `docs/decisions.md` and `todo.md` first: a finding declined or disproved in `docs/decisions.md` or in a comment at the code it concerns, or filed in `todo.md`, is not raised again, unless the decline works against a goal or a technical principle and names no `todo.md` item ending it. ## Severity @@ -16,7 +16,7 @@ A finding against a technical principle names it and the file under `~/.claude/p ## Report -Write your full report with the Write tool to the file your prompt names: the verdict, then every finding with its place, its evidence and its fix, as your agent file shapes them. Then return only: +Write your full report with the Write tool to the file your prompt names. The file is the worker's input, which it searches for each finding's entry, so write it even where your harness says to return findings directly. It holds the verdict, then every finding with its place, its evidence and its fix, as your agent file shapes them. Then return only: - the verdict line - one line per finding: its severity mark, its place, what is wrong in one sentence, and the file it breaks where that is `standards/quality.md` or a file under `~/.claude/principles/`, or for a πŸ”€ the reviewer it names, such as `🟑 bin/rank_todo.py:311 place: a cycle among blockers recurses forever (technical-principles.md)` -- 2.52.0 From b6a3dc43a861bf9424a94a57989756cc3b76c7a2 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 00:50:54 +0200 Subject: [PATCH 05/13] =?UTF-8?q?Answer=20principles=20round=202:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1;=20copy=20into=20a=20replay=20?= =?UTF-8?q?only=20the=20reports=20written=20before=20its=20round,=20fail?= =?UTF-8?q?=20closed=20on=20a=20review=20folder=20the=20replay=20cannot=20?= =?UTF-8?q?redirect,=20prepare=20the=20replay=20inside=20its=20error=20han?= =?UTF-8?q?dling,=20and=20drop=20a=20test's=20branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/rule_hook/test_rule_hook.py | 2 +- bin/stability_replay/main.py | 60 +++++++++++-------- bin/stability_replay/test_stability_replay.py | 44 ++++++++++++-- docs/decisions.md | 2 +- 4 files changed, 76 insertions(+), 32 deletions(-) diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index f0eee8c2..486e1b07 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -250,7 +250,7 @@ class ReviewerReport(unittest.TestCase): (home / ".local" / "state" / "larv-review").mkdir(parents=True) (home / ".local" / "state" / "larv-review" / "out").symlink_to(home) found = breaches_of(Call("Write", {"file_path": f"{home}/.local/state/larv-review/out/a.md", "content": "x"}, "/r", "prose-reviewer"), str(home), {}) - self.assertEqual(rules(found[2]) if found else [], ["reviewer-report"]) + self.assertEqual(rules(found[2]), ["reviewer-report"]) def test_a_reviewer_writing_anywhere_else_is_refused(self): for path in ["/r/README.md", "/h/.local/state/larv-review", "/h/.local/state/larv-review-x/a.md", "/h/.local/state/larv-review/../a.md", "/tmp/larv-review/a.md"]: diff --git a/bin/stability_replay/main.py b/bin/stability_replay/main.py index 04a269e3..d5995f7e 100644 --- a/bin/stability_replay/main.py +++ b/bin/stability_replay/main.py @@ -10,7 +10,9 @@ authored by the time the round began, on the branch the reviewer started on. The branch stands at the newest commit authored before the round's chunk began, so a diff against it shows the chunk's change. The prompt names the clone in place of the worktree it named, which the chunk has since removed. A round whose code it cannot find in this way is not replayed; stderr -names it and why. +names it and why. The prompt also names a copy of the chunk's review folder in place of that +folder, holding only the reports written before the round began. A replay whose prompt still +names the review folder finds nothing. It first replays every round on the project's rung, the reference reviewer. Findings on record that the reference reviewer does not raise again may rest on code or rules that have changed @@ -162,31 +164,39 @@ def findings_found(found: Round, code: Code, rung: Rung, anchor: Rung, home: pat # 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: - clone = tempfile.mkdtemp(prefix="stability-replay-") - # The reviewer writes its report into a copy of the chunk's review folder, so it leaves the chunk's reports as they were and still reads the earlier rounds its prompt names. - folder = pathlib.Path(review_folder(str(home), code.path)) - (home / REPORTS).mkdir(mode=0o700, parents=True, exist_ok=True) - reports = tempfile.mkdtemp(prefix="stability-replay-", dir=home / REPORTS) - if folder.is_dir(): - shutil.copytree(folder, reports, dirs_exist_ok=True) - prompt = found.prompt.replace(str(folder), reports).replace(f"~/{folder.relative_to(home)}", reports).replace(code.path, clone) try: - for command in ( - ("clone", "--quiet", "--shared", "--no-checkout", found.root, clone), - ("-C", clone, "update-ref", f"refs/remotes/origin/{code.default}", code.base), - ("-C", clone, "update-ref", f"refs/heads/{code.default}", code.base), - ("-C", clone, "checkout", "--quiet", *(("-B", found.branch) if found.branch and found.branch != code.default else ("--detach",)), code.reviewed), - ): - if isinstance(ran := git(effects, found.root, *command), Failure): - return ran - args = ["--agent", REVIEWER, *rung.flags()] - reply = claude_reply(effects.claude, args, clone, prompt, "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") - finally: - shutil.rmtree(clone, ignore_errors=True) - shutil.rmtree(reports, ignore_errors=True) + (home / REPORTS).mkdir(mode=0o700, parents=True, exist_ok=True) + with tempfile.TemporaryDirectory(prefix="stability-replay-", ignore_cleanup_errors=True) as clone, tempfile.TemporaryDirectory(prefix="stability-replay-", dir=home / REPORTS, ignore_cleanup_errors=True) as reports: + return reviewed_in(found, code, rung, home, effects, clone, reports) + except OSError as failure: + return Failure(f"could not prepare the replay: {failure}") + + +def reviewed_in(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Effects, clone: str, reports: str) -> str | Failure | Limited: + """The report of found's reviewer on rung, replayed on code cloned into clone, with its review folder copied into reports.""" + # The reviewer writes its report into a copy of the chunk's review folder, so it leaves the chunk's reports as they were and still reads the earlier rounds its prompt names. The copy holds only the reports written before the round began: the round's own report, and later ones, would hand the reviewer the findings it is to find. + folder = pathlib.Path(review_folder(str(home), code.path)) + for written in folder.iterdir() if folder.is_dir() else (): + if written.is_file() and written.stat().st_mtime < found.seconds: + shutil.copy2(written, reports) + # The folder goes first: for a worktree outside home, its path holds the worktree's, which code.path would otherwise turn into the clone's. + prompt = found.prompt.replace(str(folder), reports).replace(f"~/{folder.relative_to(home)}", reports).replace(code.path, clone) + # A spelling the rewrite misses, such as $HOME/, would leave the reviewer the live folder and the findings in it. + if REPORTS in prompt.replace(reports, ""): + return Failure("the prompt names the review folder in a spelling the replay does not redirect") + for command in ( + ("clone", "--quiet", "--shared", "--no-checkout", found.root, clone), + ("-C", clone, "update-ref", f"refs/remotes/origin/{code.default}", code.base), + ("-C", clone, "update-ref", f"refs/heads/{code.default}", code.base), + ("-C", clone, "checkout", "--quiet", *(("-B", found.branch) if found.branch and found.branch != code.default else ("--detach",)), code.reviewed), + ): + if isinstance(ran := git(effects, found.root, *command), Failure): + return ran + args = ["--agent", REVIEWER, *rung.flags()] + reply = claude_reply(effects.claude, args, clone, prompt, "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 match(findings: tuple[str, ...], replay_report: str, root: str, rung: Rung, effects: Effects) -> set[int] | Failure | Limited: diff --git a/bin/stability_replay/test_stability_replay.py b/bin/stability_replay/test_stability_replay.py index a9a10ef2..2d86e469 100644 --- a/bin/stability_replay/test_stability_replay.py +++ b/bin/stability_replay/test_stability_replay.py @@ -10,10 +10,11 @@ import subprocess import sys import tempfile import unittest +import unittest.mock sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from stability_replay.rounds import authored_by, recorded_findings, report, reviewed_path, Round, round_from, sample +from stability_replay.rounds import authored_by, recorded_findings, report, reviewed_path, Round, round_from, sample, stamp_seconds from loop_claude.effects import Effects, system_effects from failure import Failure from stability_replay import main @@ -232,27 +233,60 @@ class Main(unittest.TestCase): self.assertIn(f" {self.checkout} 2026-10-14T10:00:00Z: 🟑 slow", out) self.assertTrue(out.endswith("finds: claude-sonnet-5-5 at high effort\n")) - def test_points_the_prompts_review_folder_at_a_copy_that_it_removes(self): + def review_folder_with_round_1(self): + """The chunk's review folder, holding round 1's report from before the replayed round began at 10:00, and that round's own and a later pass's reports, written after.""" folder = self.home / ".local" / "state" / "larv-review" / "code" / "proj-x" folder.mkdir(parents=True) (folder / "stability-round-1.md").write_text("round 1\n") + before = stamp_seconds("2026-10-14T09:50:00Z") + os.utime(folder / "stability-round-1.md", (before, before)) + (folder / "stability-round-2.md").write_text("πŸ”΄ a.txt:1 wrong\n") + (folder / "prose-round-1.md").write_text("later\n") + return folder + + def test_points_the_prompts_review_folder_at_a_copy_of_the_reports_from_before_the_round_that_it_removes(self): + folder = self.review_folder_with_round_1() self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to ~/.local/state/larv-review/code/proj-x/stability-round-2.md; the last round's is ~/.local/state/larv-review/code/proj-x/stability-round-1.md.") seen = [] def review(rung): named = pathlib.Path(re.search(r"report to (\S+)/stability-round-2\.md", self.reviews[-1][4]).group(1)) - seen.append((named, (named / "stability-round-1.md").read_text())) + seen.append((named, sorted(path.name for path in named.iterdir()), (named / "stability-round-1.md").read_text())) (named / "stability-round-2.md").write_text("replayed\n") return {"type": "result", "result": f"review on {rung.model} {rung.effort}"} code, _, err = self.run_main(["claude-opus-5-5"], lambda rung: {"found": [0, 1]}, review) self.assertEqual(code, 0, err) - named, earlier = seen[0] + named, copied, earlier = seen[0] self.assertEqual(named.parent, folder.parents[1], "the copy sits in the reports folder, where rule-hook lets the reviewer write") self.assertNotEqual(named, folder) + self.assertEqual(copied, ["stability-round-1.md"], "the round's own report and later ones would hand the replayed reviewer its findings") self.assertEqual(earlier, "round 1\n") self.assertFalse(named.exists()) - self.assertEqual(sorted(path.name for path in folder.iterdir()), ["stability-round-1.md"]) + self.assertEqual(sorted(path.name for path in folder.iterdir()), ["prose-round-1.md", "stability-round-1.md", "stability-round-2.md"]) + self.assertEqual((folder / "stability-round-2.md").read_text(), "πŸ”΄ a.txt:1 wrong\n") + + def test_replays_no_round_whose_prompt_still_names_the_review_folder_after_the_rewrite(self): + self.review_folder_with_round_1() + self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to $HOME/.local/state/larv-review/code/proj-x/stability-round-2.md.") + code, out, err = self.run_main(["claude-opus-5-5"], unused) + self.assertEqual(code, 0, err) + self.assertEqual(self.reviews, []) + self.assertIn(f"on {REFERENCE} found nothing: the prompt names the review folder in a spelling the replay does not redirect", err) + self.assertTrue(out.endswith("No rung tried: the reference reviewer found no finding to hold one to.\n")) + + def test_finds_nothing_and_leaves_no_folder_behind_when_it_cannot_copy_the_reports(self): + folder = self.review_folder_with_round_1() + (folder / "stability-round-1.md").chmod(0) + self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to ~/.local/state/larv-review/code/proj-x/stability-round-2.md.") + scratch = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory())) + self.enterContext(unittest.mock.patch.object(tempfile, "tempdir", str(scratch))) + code, _, err = self.run_main(["claude-opus-5-5"], unused) + self.assertEqual(code, 0, err) + self.assertEqual(self.reviews, []) + self.assertIn(f"on {REFERENCE} found nothing: could not prepare the replay: ", err) + self.assertEqual(list(scratch.iterdir()), [], "the clone is removed") + self.assertEqual([path.name for path in folder.parent.parent.iterdir()], ["code"], "the copy is removed") def test_replays_the_rounds_of_every_chunk(self): self.write_chunk("proj", "c2", "2026-10-14T10:30:00Z") diff --git a/docs/decisions.md b/docs/decisions.md index 59bab47c..da4224af 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -222,7 +222,7 @@ Valid while the worker writes the tests that larv-review's reviewers hold to the 2026-10-18, the agent, shipping lilleman's plan item. Serves goal 1.4: a report the worker does not need line by line no longer fills its context. Goal 1.1 holds because the worker reads a finding's full entry before it answers a πŸ”΄ or 🟑. -The worker names each report's file in the reviewer's prompt, per `skills/larv-review/SKILL.md` β†’ "Reports", and `skills/larv-review/review-findings.md` β†’ "Report" sets what the reviewer returns. Each reviewer holds Write for that. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`, so `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit, MultiEdit, and Write outside the folder; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. The folder is fixed, since loop-claude's headless sessions have no scratchpad. It sits outside every checkout, so no project sees a report. It survives a reboot, unlike `/tmp`, so a resumed chunk still reads its earlier rounds. It is in the user's home, so no other local user plants a symlink that widens the folder, and the worker makes `~/.local/state/larv-review` readable by the user alone, since a report may quote a secret. A chunk keeps its folder after the merge: `stability-replay` hands a replayed reviewer a copy of it, so the replay reads the earlier rounds its prompt names and leaves the chunk's reports as they were. Claude Code's own subagent prompt tells a subagent to return findings rather than write report files; `review-findings.md` β†’ "Report" overrides that, since the file is the worker's input, and a prose-reviewer probed on 2026-10-18 wrote its file. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. +The worker names each report's file in the reviewer's prompt, per `skills/larv-review/SKILL.md` β†’ "Reports", and `skills/larv-review/review-findings.md` β†’ "Report" sets what the reviewer returns. Each reviewer holds Write for that. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`, so `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit, MultiEdit, and Write outside the folder; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. The folder is fixed, since loop-claude's headless sessions have no scratchpad. It sits outside every checkout, so no project sees a report. It survives a reboot, unlike `/tmp`, so a resumed chunk still reads its earlier rounds. It is in the user's home, so no other local user plants a symlink that widens the folder, and `larv-review review-folder`, which makes the folder, leaves `~/.local/state/larv-review` readable by the user alone, since a report may quote a secret. A chunk keeps its folder after the merge: `stability-replay` hands a replayed reviewer a copy of the reports written before its round began, so the replay reads the earlier rounds its prompt names, never the findings it is to find, and leaves the chunk's reports as they were. Claude Code's own subagent prompt tells a subagent to return findings rather than write report files; `review-findings.md` β†’ "Report" overrides that, since the file is the worker's input, and a prose-reviewer probed on 2026-10-18 wrote its file. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. Before this change, reports took a median 19k tokens per chunk, 8% of the worker's peak context, and lines carrying a severity mark were 9–24% of a report (2026-10-08, over 68 archived transcripts). `stability-replay` still counts each πŸ”΄ and 🟑 by its line in the reviewer's reply, now a one-line summary. todo.md item 186 measures what the worker reads of the reports instead. -- 2.52.0 From 78843560cf549e84e4b451887623f1a64d6addf5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 00:50:54 +0200 Subject: [PATCH 06/13] =?UTF-8?q?Answer=20architecture=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1;=20give=20the=20review=20folde?= =?UTF-8?q?r=20one=20owner=20in=20larv-review=20review-folder,=20which=20m?= =?UTF-8?q?akes=20it=20private=20and=20prints=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- bin/larv_review/main.py | 46 +++++++++++++++++------ bin/larv_review/test_larv_review.py | 11 ++++++ bin/repo_checks/test_reviewer_launches.py | 5 +-- skills/larv-review/SKILL.md | 2 +- 5 files changed, 50 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bed8b534..7247291a 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a - `chunk-preflight` finds the mechanical facts a chunk starts from and makes its worktree; `loop-claude` runs it before it routes each chunk, and `chunk-preflight --help` lists the facts. - `judge-replay ` replays loop-claude's judge on archived verdicts of the projects run on the model, and prints the lowest rung that, like each rung above it, returns them; `judge-replay --help` states the replay. -- `larv-review ` holds larv-review's mechanical rules: the paired ruling's base and vote count, each pass's round count, the scoring run's trigger, and the comprehension history's format and latest places, and its count of how often seats agree; `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, and the comprehension history's format and latest places, and its count of how often seats agree; `larv-review --help` states them. - `loop-claude ` runs a project's next chunk cycle after cycle; `loop-claude --help` states its contract. - `metric-bench [history]` benches cheap static metrics of a project's Python against the places its comprehension history names as hardest; `metric-bench --help` states the metrics and the scores. - `rank_todo.py [--check] [todo.md]` scores and ranks a project's `todo.md`; `rank_todo.py --help` states the format. diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index e0300743..f51d87f8 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -1,17 +1,21 @@ -"""Hold larv-review's mechanical rules: the paired ruling's base and vote count, each pass's rounds, the scoring run's trigger, and the comprehension history's format and latest places, and its count of how often seats agree. +"""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, and the comprehension history's format and latest places, and its count of how often seats agree. -usage: larv-review ruling-base | round-count | needs-scoring-run [...] | record-ruling | record-scoring [...] | places | agreement +usage: larv-review review-folder | ruling-base | round-count | needs-scoring-run [...] | record-ruling | record-scoring [...] | places | agreement The comprehension check records how hard a project is to read, two ways, and blocks no merge. In a paired ruling, simulated readers, the seats, read the branch's head beside a base and vote better, same or worse, overall and on each dimension. In a scoring run, four seats score the project from 1 to 10. Each seat names the places it found hard. -Run it inside a project checkout or one of its worktrees. Each command but record-ruling, places and agreement -first fetches origin, when the checkout has that remote, and takes origin's default branch, or else the -local main or master, as the default branch. When the fetch fails, round-count reads origin as -last fetched and says so on stderr; the other three exit 1. The history is -docs/comprehension-history.md in the checkout. +Run it inside a project checkout or one of its worktrees. Each command but review-folder, +record-ruling, places and agreement first fetches origin, when the checkout has that remote, and +takes origin's default branch, or else the local main or master, as the default branch. When the +fetch fails, round-count reads origin as last fetched and says so on stderr; the other three exit 1. +The history is docs/comprehension-history.md in the checkout. + +review-folder makes the chunk's review folder, where each reviewer writes its report, and prints its +path: ~/.local/state/larv-review/ followed by the worktree's path relative to ~, or to / outside it. +It leaves ~/.local/state/larv-review readable by you alone. ruling-base prints the commit a paired ruling reads against, then which of these found it. The last measured commit is the default branch's newest merged change that adds a paired ruling or a scoring @@ -87,7 +91,8 @@ when the history already holds an entry on what that line reads. Exit 1, saying why, on unknown arguments, an unknown item ID, a seats file it cannot read or that breaks the shape above, or when git cannot start, finds no checkout or no default branch, cannot -fetch origin for ruling-base, needs-scoring-run or record-scoring, or cannot read or write the history or todo.md. +fetch origin for ruling-base, needs-scoring-run or record-scoring, or cannot read or write the +history, todo.md or the review folder. """ import pathlib import re @@ -95,7 +100,7 @@ import sys import typing from round_titles import CAP, PASSES, round_counts -from git_repo import default_branch, git +from git_repo import default_branch, git, top from failure import Failure from larv_review.scoring import FLOOR from larv_review.git import history_changes @@ -103,8 +108,9 @@ from larv_review.ruling_base import measured_commit from larv_review.agreement import MIN_PAIRS from larv_review.plan import plan_reasons from larv_review.record import record_ruling, record_scoring, show_agreement, show_places +from review_folder import REPORTS, review_folder -USAGE = "usage: larv-review ruling-base | round-count | needs-scoring-run [...] | record-ruling | record-scoring [...] | places | agreement" +USAGE = "usage: larv-review review-folder | ruling-base | round-count | needs-scoring-run [...] | record-ruling | record-scoring [...] | places | agreement" def main(argv: list[str]) -> int: @@ -112,7 +118,9 @@ def main(argv: list[str]) -> int: print(__doc__.strip().format(cap=CAP, floor=FLOOR, pairs=MIN_PAIRS)) return 0 command, *given = argv or [""] - if command == "ruling-base" and not given: + if command == "review-folder" and not given: + done = make_review_folder() + elif command == "ruling-base" and not given: done = with_default_branch(show_ruling_base, stale_ok=False) elif command == "round-count" and not given: done = with_default_branch(round_count, stale_ok=True) @@ -152,6 +160,22 @@ def with_default_branch(command: typing.Callable[[str], Failure | None], stale_o return command(branch) +def make_review_folder() -> Failure | None: + worktree = top() + if isinstance(worktree, Failure): + return worktree + home = pathlib.Path.home() + folder = pathlib.Path(review_folder(str(home), worktree)) + try: + (home / REPORTS).mkdir(parents=True, exist_ok=True) + (home / REPORTS).chmod(0o700) + folder.mkdir(parents=True, exist_ok=True) + except OSError as failure: + return Failure(f"could not make the review folder {folder}: {failure}") + print(folder) + return None + + def show_ruling_base(default: str) -> Failure | None: changes = history_changes(default) if isinstance(changes, Failure): diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index c18b6732..cf9eb45d 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -447,6 +447,17 @@ class LarvReviewTool(unittest.TestCase): self.git("remote", "set-head", "origin", "--delete") self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n") + def test_makes_and_prints_the_worktrees_review_folder_readable_by_the_user_alone(self): + reports = self.checkout.parent / ".local" / "state" / "larv-review" + reports.mkdir(parents=True, mode=0o755) + (self.checkout / "sub").mkdir() + ran = subprocess.run([sys.executable, str(TOOL), "review-folder"], capture_output=True, cwd=self.checkout / "sub", env=self.env, text=True) + self.assertEqual((ran.returncode, ran.stdout), (0, f"{reports}/proj\n"), ran.stderr) + self.assertTrue((reports / "proj").is_dir()) + self.assertEqual(reports.stat().st_mode & 0o777, 0o700) + self.assertEqual(self.run_tool("review-folder").stdout, f"{reports}/proj\n") + self.assertIn("unknown arguments", self.run_tool("review-folder", "x").stderr) + def test_takes_a_local_main_without_origin_and_reads_origin_as_last_fetched_when_the_fetch_fails(self): self.commit("Answer prose round 1: a") self.git("remote", "set-url", "origin", str(self.checkout.parent / "gone.git")) diff --git a/bin/repo_checks/test_reviewer_launches.py b/bin/repo_checks/test_reviewer_launches.py index 7658af39..7351e1c9 100644 --- a/bin/repo_checks/test_reviewer_launches.py +++ b/bin/repo_checks/test_reviewer_launches.py @@ -5,7 +5,6 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from review_folder import REPORTS from rule_hook.reviewer_rung import REVIEWERS, SEAT, SECURITY_OPENER from repo_checks.test_python_floor import ROOT @@ -30,5 +29,5 @@ class ReviewerLaunches(unittest.TestCase): security = LARV_REVIEW.split("### Security", 1)[1].split("### Overrides", 1)[0] self.assertIn(SECURITY_OPENER, security) - def test_larv_review_names_the_reports_folder_rule_hook_lets_a_reviewer_write_into(self): - self.assertIn(f"`~/{REPORTS}//`. Make it, and keep `~/.local/state/larv-review` readable by you alone: `mkdir -p && chmod 700 ~/.local/state/larv-review`. Keep it after the merge: `stability-replay` replays a round from the reports its prompt names. Name in each prompt to an agent under `~/.claude/agents/` the file there that its full report goes to: `-round-.md`, with the yardstick's name after the pass's for a principles-auditor, and `-rerun` before `.md` for a relaunch one rung up. It writes the report there and returns only its verdict and one line per finding. 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 write anywhere else. +**Reports.** Run `~/.claude/bin/larv-review review-folder` in the chunk's worktree: it makes the chunk's review folder and prints its path. Keep the folder after the merge: `stability-replay` replays a round from the reports its prompt names. Name in each prompt to an agent under `~/.claude/agents/` the file there that its full report goes to: `-round-.md`, with the yardstick's name after the pass's for a principles-auditor, and `-rerun` before `.md` for a relaunch one rung up. It writes the report there and returns only its verdict and one line per finding. 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 write anywhere else. `~/.claude/bin/larv-review` holds this section's mechanical rules: the round count, the paired ruling's base and vote count, the scoring run's trigger, and the history's format and latest places, and its count of how often seats agree. 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. -- 2.52.0 From 4fa90ee01ace2c1e0ce1a0c75ad64acec84d4ba9 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 00:53:32 +0200 Subject: [PATCH 07/13] =?UTF-8?q?Answer=20principles=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20both=20auditors=20approved,?= =?UTF-8?q?=20split=20the=20review-folder=20test=20and=20test=20its=20fail?= =?UTF-8?q?ure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/larv_review/test_larv_review.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index cf9eb45d..3f7d755e 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -447,15 +447,27 @@ class LarvReviewTool(unittest.TestCase): self.git("remote", "set-head", "origin", "--delete") self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n") - def test_makes_and_prints_the_worktrees_review_folder_readable_by_the_user_alone(self): + def test_makes_and_prints_the_worktrees_review_folder_from_anywhere_in_it(self): reports = self.checkout.parent / ".local" / "state" / "larv-review" - reports.mkdir(parents=True, mode=0o755) (self.checkout / "sub").mkdir() ran = subprocess.run([sys.executable, str(TOOL), "review-folder"], capture_output=True, cwd=self.checkout / "sub", env=self.env, text=True) self.assertEqual((ran.returncode, ran.stdout), (0, f"{reports}/proj\n"), ran.stderr) self.assertTrue((reports / "proj").is_dir()) + + def test_leaves_the_reports_folder_readable_by_the_user_alone_where_it_was_not(self): + reports = self.checkout.parent / ".local" / "state" / "larv-review" + reports.mkdir(parents=True, mode=0o755) + self.assertEqual(self.run_tool("review-folder").returncode, 0) self.assertEqual(reports.stat().st_mode & 0o777, 0o700) - self.assertEqual(self.run_tool("review-folder").stdout, f"{reports}/proj\n") + + def test_fails_where_it_cannot_make_the_review_folder(self): + (self.checkout.parent / ".local" / "state").mkdir(parents=True) + (self.checkout.parent / ".local" / "state" / "larv-review").write_text("") + ran = self.run_tool("review-folder") + self.assertEqual(ran.returncode, 1) + self.assertIn("could not make the review folder", ran.stderr) + + def test_review_folder_takes_no_arguments(self): self.assertIn("unknown arguments", self.run_tool("review-folder", "x").stderr) def test_takes_a_local_main_without_origin_and_reads_origin_as_last_fetched_when_the_fetch_fails(self): -- 2.52.0 From f8a51728a3003dca8aae090c0c30f5cc0417a149 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 00:53:32 +0200 Subject: [PATCH 08/13] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20/security-review=20found=20?= =?UTF-8?q?no=20vulnerability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From d361312edcadae088f2dbd24a6d990379c234ef5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 01:08:28 +0200 Subject: [PATCH 09/13] =?UTF-8?q?Answer=20stability=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1;=20commit=20bin/review=5Ffolde?= =?UTF-8?q?r.py,=20which=20.gitignore=20hid,=20and=20check=20no=20bin=20mo?= =?UTF-8?q?dule=20is=20ignored,=20anchor=20the=20help=20test,=20and=20test?= =?UTF-8?q?=20the=20absolute=20folder=20spelling=20and=20review-folder=20o?= =?UTF-8?q?utside=20a=20checkout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + bin/larv_review/test_larv_review.py | 5 +++++ bin/repo_checks/test_gitignore.py | 4 ++++ bin/review_folder.py | 11 +++++++++++ bin/rule_hook/test_rule_hook.py | 2 +- bin/stability_replay/test_stability_replay.py | 9 +++++++++ 6 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 bin/review_folder.py diff --git a/.gitignore b/.gitignore index e39d52e3..d33fdeaf 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ !bin/reading_cost/*.py !bin/repo_checks/ !bin/repo_checks/*.py +!bin/review_folder.py !bin/round_titles.py !bin/rule-hook !bin/routing_figures/ diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 3f7d755e..0bb425d2 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -467,6 +467,11 @@ class LarvReviewTool(unittest.TestCase): self.assertEqual(ran.returncode, 1) self.assertIn("could not make the review folder", ran.stderr) + def test_review_folder_fails_outside_a_checkout(self): + ran = subprocess.run([sys.executable, str(TOOL), "review-folder"], capture_output=True, cwd=self.checkout.parent, env=self.env, text=True) + self.assertEqual(ran.returncode, 1) + self.assertNotIn("Traceback", ran.stderr) + def test_review_folder_takes_no_arguments(self): self.assertIn("unknown arguments", self.run_tool("review-folder", "x").stderr) diff --git a/bin/repo_checks/test_gitignore.py b/bin/repo_checks/test_gitignore.py index ce70ee45..7b704a0f 100644 --- a/bin/repo_checks/test_gitignore.py +++ b/bin/repo_checks/test_gitignore.py @@ -41,6 +41,10 @@ class Gitignore(unittest.TestCase): ignored = subprocess.run(["git", "ls-files", "-ci", "--exclude-standard"], capture_output=True, check=True, cwd=ROOT, text=True).stdout self.assertEqual(ignored, "") + def test_ignores_no_python_module_or_test_under_bin(self): + ignored = subprocess.run(["git", "ls-files", "-oi", "--exclude-standard", "--", "bin/*.py", "bin/**/*.py"], capture_output=True, check=True, cwd=ROOT, text=True).stdout + self.assertEqual(ignored, "") + def test_ignores_every_private_file(self): ignored = subprocess.run(["git", "check-ignore", "--no-index", "--stdin"], capture_output=True, cwd=ROOT, input="\n".join(PRIVATE), text=True).stdout self.assertEqual(ignored.splitlines(), PRIVATE) diff --git a/bin/review_folder.py b/bin/review_folder.py new file mode 100644 index 00000000..46089c24 --- /dev/null +++ b/bin/review_folder.py @@ -0,0 +1,11 @@ +"""The chunk's review folder, where each reviewer writes its report: skills/larv-review/SKILL.md β†’ "Reports".""" +import os + +# Under the home folder: outside every checkout, so no project sees a report; kept across a reboot, so a resumed chunk still reads its rounds. A fixed path, since a headless session has no scratchpad. +REPORTS = ".local/state/larv-review" + + +def review_folder(home: str, worktree: str) -> str: + """The review folder of the chunk whose worktree is at worktree: its path relative to home, or to / outside it, under REPORTS.""" + inside = worktree.startswith(home.rstrip("/") + "/") + return os.path.join(home, REPORTS, os.path.relpath(worktree, home) if inside else worktree.lstrip("/")) diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index 486e1b07..1e1067be 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -417,4 +417,4 @@ class Hook(unittest.TestCase): self.assertIn(f" {rule}\n The rule: ", helped) self.assertIn("reviewer-report\n The rule: a reviewer writes nothing but its report", helped) self.assertRegex(helped, r" reviewer-report\n( .*\n){2} Takes no override\.\n") - self.assertRegex(helped, r" image-pin\n( .*\n){2} ", "a rule a marker waives says nothing of overrides") + self.assertRegex(helped, r" image-pin\n( .*\n){2} \S", "a rule a marker waives says nothing of overrides") diff --git a/bin/stability_replay/test_stability_replay.py b/bin/stability_replay/test_stability_replay.py index 2d86e469..f623a09a 100644 --- a/bin/stability_replay/test_stability_replay.py +++ b/bin/stability_replay/test_stability_replay.py @@ -266,6 +266,15 @@ class Main(unittest.TestCase): self.assertEqual(sorted(path.name for path in folder.iterdir()), ["prose-round-1.md", "stability-round-1.md", "stability-round-2.md"]) self.assertEqual((folder / "stability-round-2.md").read_text(), "πŸ”΄ a.txt:1 wrong\n") + def test_points_the_review_folders_absolute_path_at_the_copy(self): + folder = self.review_folder_with_round_1() + self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to {folder}/stability-round-2.md.") + code, _, err = self.run_main(["claude-opus-5-5"], lambda rung: {"found": [0, 1]}) + self.assertEqual(code, 0, err) + prompt = self.reviews[0][4] + self.assertNotIn(str(folder), prompt) + self.assertRegex(prompt, rf"report to {folder.parents[1]}/stability-replay-\w+/stability-round-2\.md\.$") + def test_replays_no_round_whose_prompt_still_names_the_review_folder_after_the_rewrite(self): self.review_folder_with_round_1() self.set_prompt(f"Review branch x in {self.home}/code/proj-x. Write your report to $HOME/.local/state/larv-review/code/proj-x/stability-round-2.md.") -- 2.52.0 From 2b1d3707c8f53cc05480e26478288864bb2bcbb0 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 01:16:26 +0200 Subject: [PATCH 10/13] =?UTF-8?q?Answer=20product-owner=20round=201:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20grant=20interactive=20se?= =?UTF-8?q?ssions=20the=20reports=20folder=20and=20fall=20back=20to=20the?= =?UTF-8?q?=20full=20reply=20when=20the=20Write=20fails,=20mark=20up=20the?= =?UTF-8?q?=20summary=20example,=20and=20copy=20into=20a=20replay=20only?= =?UTF-8?q?=20reports=20written=20since=20its=20chunk=20began?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/stability_replay/main.py | 6 +++--- bin/stability_replay/test_stability_replay.py | 9 ++++++--- docs/decisions.md | 2 +- settings.json | 1 + skills/larv-review/review-findings.md | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/bin/stability_replay/main.py b/bin/stability_replay/main.py index d5995f7e..566bfd1f 100644 --- a/bin/stability_replay/main.py +++ b/bin/stability_replay/main.py @@ -11,7 +11,7 @@ branch stands at the newest commit authored before the round's chunk began, so a shows the chunk's change. The prompt names the clone in place of the worktree it named, which the chunk has since removed. A round whose code it cannot find in this way is not replayed; stderr names it and why. The prompt also names a copy of the chunk's review folder in place of that -folder, holding only the reports written before the round began. A replay whose prompt still +folder, holding only the reports written after the chunk began and before the round did. A replay whose prompt still names the review folder finds nothing. It first replays every round on the project's rung, the reference reviewer. Findings on record @@ -174,10 +174,10 @@ def review(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Ef def reviewed_in(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Effects, clone: str, reports: str) -> str | Failure | Limited: """The report of found's reviewer on rung, replayed on code cloned into clone, with its review folder copied into reports.""" - # The reviewer writes its report into a copy of the chunk's review folder, so it leaves the chunk's reports as they were and still reads the earlier rounds its prompt names. The copy holds only the reports written before the round began: the round's own report, and later ones, would hand the reviewer the findings it is to find. + # The reviewer writes its report into a copy of the chunk's review folder, so it leaves the chunk's reports as they were and still reads the earlier rounds its prompt names. The copy holds only the reports written after the chunk began and before the round began: the round's own report, later ones, and an earlier attempt's at the item in the same worktree, would hand the reviewer the findings it is to find. folder = pathlib.Path(review_folder(str(home), code.path)) for written in folder.iterdir() if folder.is_dir() else (): - if written.is_file() and written.stat().st_mtime < found.seconds: + if written.is_file() and found.began <= written.stat().st_mtime < found.seconds: shutil.copy2(written, reports) # The folder goes first: for a worktree outside home, its path holds the worktree's, which code.path would otherwise turn into the clone's. prompt = found.prompt.replace(str(folder), reports).replace(f"~/{folder.relative_to(home)}", reports).replace(code.path, clone) diff --git a/bin/stability_replay/test_stability_replay.py b/bin/stability_replay/test_stability_replay.py index f623a09a..78f0af0d 100644 --- a/bin/stability_replay/test_stability_replay.py +++ b/bin/stability_replay/test_stability_replay.py @@ -234,7 +234,7 @@ class Main(unittest.TestCase): self.assertTrue(out.endswith("finds: claude-sonnet-5-5 at high effort\n")) def review_folder_with_round_1(self): - """The chunk's review folder, holding round 1's report from before the replayed round began at 10:00, and that round's own and a later pass's reports, written after.""" + """The chunk's review folder, holding round 1's report from before the replayed round began at 10:00, that round's own and a later pass's reports, written after, and an earlier attempt's report, from before the chunk began at 09:15.""" folder = self.home / ".local" / "state" / "larv-review" / "code" / "proj-x" folder.mkdir(parents=True) (folder / "stability-round-1.md").write_text("round 1\n") @@ -242,6 +242,9 @@ class Main(unittest.TestCase): os.utime(folder / "stability-round-1.md", (before, before)) (folder / "stability-round-2.md").write_text("πŸ”΄ a.txt:1 wrong\n") (folder / "prose-round-1.md").write_text("later\n") + (folder / "stability-round-3.md").write_text("πŸ”΄ a.txt:1 wrong\n") + attempt = stamp_seconds("2026-10-14T09:00:00Z") + os.utime(folder / "stability-round-3.md", (attempt, attempt)) return folder def test_points_the_prompts_review_folder_at_a_copy_of_the_reports_from_before_the_round_that_it_removes(self): @@ -260,10 +263,10 @@ class Main(unittest.TestCase): named, copied, earlier = seen[0] self.assertEqual(named.parent, folder.parents[1], "the copy sits in the reports folder, where rule-hook lets the reviewer write") self.assertNotEqual(named, folder) - self.assertEqual(copied, ["stability-round-1.md"], "the round's own report and later ones would hand the replayed reviewer its findings") + self.assertEqual(copied, ["stability-round-1.md"], "the round's own report, later ones and an earlier attempt's would hand the replayed reviewer its findings") self.assertEqual(earlier, "round 1\n") self.assertFalse(named.exists()) - self.assertEqual(sorted(path.name for path in folder.iterdir()), ["prose-round-1.md", "stability-round-1.md", "stability-round-2.md"]) + self.assertEqual(sorted(path.name for path in folder.iterdir()), ["prose-round-1.md", "stability-round-1.md", "stability-round-2.md", "stability-round-3.md"]) self.assertEqual((folder / "stability-round-2.md").read_text(), "πŸ”΄ a.txt:1 wrong\n") def test_points_the_review_folders_absolute_path_at_the_copy(self): diff --git a/docs/decisions.md b/docs/decisions.md index da4224af..93225a96 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -222,7 +222,7 @@ Valid while the worker writes the tests that larv-review's reviewers hold to the 2026-10-18, the agent, shipping lilleman's plan item. Serves goal 1.4: a report the worker does not need line by line no longer fills its context. Goal 1.1 holds because the worker reads a finding's full entry before it answers a πŸ”΄ or 🟑. -The worker names each report's file in the reviewer's prompt, per `skills/larv-review/SKILL.md` β†’ "Reports", and `skills/larv-review/review-findings.md` β†’ "Report" sets what the reviewer returns. Each reviewer holds Write for that. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`, so `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit, MultiEdit, and Write outside the folder; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. The folder is fixed, since loop-claude's headless sessions have no scratchpad. It sits outside every checkout, so no project sees a report. It survives a reboot, unlike `/tmp`, so a resumed chunk still reads its earlier rounds. It is in the user's home, so no other local user plants a symlink that widens the folder, and `larv-review review-folder`, which makes the folder, leaves `~/.local/state/larv-review` readable by the user alone, since a report may quote a secret. A chunk keeps its folder after the merge: `stability-replay` hands a replayed reviewer a copy of the reports written before its round began, so the replay reads the earlier rounds its prompt names, never the findings it is to find, and leaves the chunk's reports as they were. Claude Code's own subagent prompt tells a subagent to return findings rather than write report files; `review-findings.md` β†’ "Report" overrides that, since the file is the worker's input, and a prose-reviewer probed on 2026-10-18 wrote its file. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. +The worker names each report's file in the reviewer's prompt, per `skills/larv-review/SKILL.md` β†’ "Reports", and `skills/larv-review/review-findings.md` β†’ "Report" sets what the reviewer returns. Each reviewer holds Write for that. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`, so `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit, MultiEdit, and Write outside the folder; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. The folder is fixed, since loop-claude's headless sessions have no scratchpad. It sits outside every checkout, so no project sees a report. It survives a reboot, unlike `/tmp`, so a resumed chunk still reads its earlier rounds. It is in the user's home, so no other local user plants a symlink that widens the folder, and `larv-review review-folder`, which makes the folder, leaves `~/.local/state/larv-review` readable by the user alone, since a report may quote a secret. A chunk keeps its folder after the merge: `stability-replay` hands a replayed reviewer a copy of the reports written after its chunk began and before its round did, so the replay reads the earlier rounds its prompt names, never the findings it is to find, and leaves the chunk's reports as they were. Claude Code's own subagent prompt tells a subagent to return findings rather than write report files; `review-findings.md` β†’ "Report" overrides that, since the file is the worker's input, and a prose-reviewer probed on 2026-10-18 wrote its file. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. Before this change, reports took a median 19k tokens per chunk, 8% of the worker's peak context, and lines carrying a severity mark were 9–24% of a report (2026-10-08, over 68 archived transcripts). `stability-replay` still counts each πŸ”΄ and 🟑 by its line in the reviewer's reply, now a one-line summary. todo.md item 186 measures what the worker reads of the reports instead. diff --git a/settings.json b/settings.json index 403e99df..28436f68 100644 --- a/settings.json +++ b/settings.json @@ -9,6 +9,7 @@ "permissions": { "defaultMode": "auto", "additionalDirectories": [ + "~/.local/state/larv-review", "~/code" ] }, diff --git a/skills/larv-review/review-findings.md b/skills/larv-review/review-findings.md index 47ab4923..fdb6a3da 100644 --- a/skills/larv-review/review-findings.md +++ b/skills/larv-review/review-findings.md @@ -19,12 +19,12 @@ A finding against a technical principle names it and the file under `~/.claude/p Write your full report with the Write tool to the file your prompt names. The file is the worker's input, which it searches for each finding's entry, so write it even where your harness says to return findings directly. It holds the verdict, then every finding with its place, its evidence and its fix, as your agent file shapes them. Then return only: - the verdict line -- one line per finding: its severity mark, its place, what is wrong in one sentence, and the file it breaks where that is `standards/quality.md` or a file under `~/.claude/principles/`, or for a πŸ”€ the reviewer it names, such as `🟑 bin/rank_todo.py:311 place: a cycle among blockers recurses forever (technical-principles.md)` +- one line per finding: its severity mark, its place, what is wrong in one sentence, and the file it breaks where that is `standards/quality.md` or a file under `~/.claude/principles/`, or for a πŸ”€ the reviewer it names, such as ``🟑 `bin/rank_todo.py:311` `place`: a cycle among blockers recurses forever (technical-principles.md)`` - for stability-reviewer, whether the tests passed, and at which commit - `Rerun one rung up`, where your report ends with it - the report's path -A prompt that names no file gets the full report as your reply. +A prompt that names no file, or a Write that fails, gets the full report as your reply. ## Verdict -- 2.52.0 From f6f84e534b19ce62f22c701ebbb59bae507bd51a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 01:21:35 +0200 Subject: [PATCH 11/13] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=208=20=F0=9F=9F=A1;=20state=20what=20rule-hook=20?= =?UTF-8?q?refuses,=20split=20the=20decision=20and=20credit=20it=20to=20it?= =?UTF-8?q?em=2073,=20order=20review-findings.md=20by=20first=20use,=20inv?= =?UTF-8?q?ert=20the=20report-naming=20sentence,=20and=20reword=20the=20ch?= =?UTF-8?q?angelog,=20the=20stability=20scratch=20line=20and=20the=20repla?= =?UTF-8?q?y's=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 +- CHANGELOG.md | 2 +- CLAUDE.md | 2 +- agents/stability-reviewer.md | 2 +- bin/review_folder.py | 2 +- bin/rule_hook/main.py | 2 +- bin/stability_replay/main.py | 8 ++++---- docs/decisions.md | 14 ++++++++++---- skills/larv-review/SKILL.md | 6 +++--- skills/larv-review/review-findings.md | 26 +++++++++++++------------- 10 files changed, 36 insertions(+), 30 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a0033b34..9ecdf30b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,7 +36,7 @@ Decisions live in `docs/decisions.md`: - 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 - worker: a chunk's worker writes the simplest change that solves its item, test first wherever a test can check the change, and reads a technical principle only where the item, a finding or its own record names it; larv-review's reviewers hold the change to the principles and to the standards in `skills/larv-review/standards/` - tests: each test earns its keep as the technical principles' test bullet says, and the worker takes a test's expected values from its item, never from the code -- review: each reviewer under `agents/` writes its full report into the chunk's review folder under `~/.local/state/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses any other file call from it +- review: each reviewer under `agents/` writes its full report into the chunk's review folder under `~/.local/state/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses its Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/` - review: stability and product-owner report only a defect, a broken requirement of the plan or the goals, a breach of a technical principle, or for stability a hard place the change touches; each architect finding names a later change the PR makes harder; prose runs only on a chunk that changes prose - review: the stability pass mutation-tests the lines a chunk changes, in place of measuring test coverage - routing: one ladder of (model, effort) rungs, ordered by the Artificial Analysis Intelligence Index with Fable 5.1 at max on top; a task's L picks its worker's rung and its E + I its reviewers', by fixed steps counted from the cheapest rung of the project's model diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b3683e6..692b1e72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Each reviewer under `agents/` writes its full report to a file under `~/.local/state/larv-review/`, which larv-review names in its prompt, and returns only its verdict and one line per finding, so a review takes less of the worker's context. The worker reads a finding's full entry before it fixes or answers a πŸ”΄ or 🟑. Each reviewer now holds Write. `rule-hook` refuses a reviewer's Edit and MultiEdit, and any Write outside that folder, and takes no override. Each chunk's folder stays after the merge, so `stability-replay` can replay a later round, which it does on a copy of the folder. +- Each reviewer under `agents/` now writes its full report to a file that larv-review names in the reviewer's prompt, in a folder per chunk under `~/.local/state/larv-review/`. It returns only its verdict and one line per finding, so a review takes less of the worker's context. The worker reads a finding's full entry before it fixes or answers a πŸ”΄ or 🟑. Each reviewer now holds Write. `rule-hook` refuses a reviewer's Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`; no override waives this rule. Each chunk's folder stays after the merge, so `stability-replay` can replay a round that reads an earlier round's report. It replays on a copy of the folder. - `loop-claude` asks an interrupt's question on its own terminal and resumes the worker headless with your one-line answer, so the loop no longer waits for you to leave a claude session. Type `/talk` instead to open the worker's session in claude, as every interrupt did before, to read the diff or discuss first. A release ready to cut opens that session at once. Pressing Enter on an empty answer stops the loop, exit 2. Keys typed before the question shows are dropped, and a pasted answer keeps only its first line; type `/talk` for a longer one. The judge counts that answer as yours, like one typed in claude: the chunk stays open until the answer is recorded, where a later chunk could need it. - When a worker's run ends with a question and a request for a higher rung, `loop-claude` now steps the worker one rung up as the judge interrupts, or as it answers the question with a quote from `README.md` or another file it may quote. The judge must quote a passage showing that the escalation trigger the run cites fired. Before, the step was lost for an answered question, and the worker carried on from the answer on its old rung. The step has the same limits as the step on an unfinished verdict, and no later ruling of that cycle carries a second escalation. The archive's interrupt and quoted-answer outcomes now name the worker's rung. - A scoring run due because a release's items ran out costs four more seats: it is done twice on one head. `larv-review agreement` compares how often Mid A and the inherited architect vote alike in paired rulings with how often their overall scores move the same way between the two runs. After 10 such pairs it gives a verdict, and on `Assumption fails:` larv-review asks you whether to keep the paired ruling. diff --git a/CLAUDE.md b/CLAUDE.md index ce26affa..13364c25 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -66,7 +66,7 @@ The rules only reviewers apply, for quality, comments, READMEs and prose, live i 4. A review rules the work below standard: systems-architect's BLOCK, a finding against larv-review's `standards/quality.md`, or a vote `record-ruling` counts as worse, in the report that stands after any relaunch one rung up (`larv-review` Β§3 β†’ "Rung up"). When one fires, hand the hard part, edits included, to a subagent on the rung loop-claude's prompt names, one above yours. Open the subagent's prompt with the marker loop-claude's prompt gives, then the trigger's evidence. Each later subagent on that task runs on that rung or higher, and each further escalation trigger moves the task one rung higher, up to the highest rung loop-claude's prompt names. Ask the human before going higher. Where loop-claude's prompt names no escalation, as on the ladder's top rung or off it, keep the task in your own thread. -- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits; a reviewer under `agents/` also writes its report to the file larv-review names, and rule-hook refuses it any other Write, Edit or MultiEdit. One that probes a build tags the image as throwaway and removes it afterwards, writes only to the session scratchpad, and removes no image or file it did not create. +- Give a subagent only the access its job needs, and state the limits in its prompt. One that only reads, such as a prose review, gets no shell and no edits. A reviewer under `~/.claude/agents/` writes only its report, under `~/.local/state/larv-review/`, and rule-hook refuses it every other Write, every Edit and every MultiEdit. One that probes a build tags the image as throwaway and removes it afterwards, writes only to the session scratchpad, and removes no image or file it did not create. - Check `README.md` first for build, test, install, and codegen commands, and fix one that misbehaves in the same change. Refresh `README.md` whenever you change what it describes, keeping it true, not longer. - Where `~/.claude/bin/rule-hook` does not check it, such as an image named in test code, a Kubernetes manifest, a `docker run` line or a file a Bash command writes, pin a container image to its full patch version and a GitHub Action to a semver tag. diff --git a/agents/stability-reviewer.md b/agents/stability-reviewer.md index 7196a0e9..3973783d 100644 --- a/agents/stability-reviewer.md +++ b/agents/stability-reviewer.md @@ -12,7 +12,7 @@ You are an elite stability-focused code reviewer with deep expertise in defensiv 1. **Scope the change.** You review every PR; a fresh invocation has no prior context, so determine the diff yourself. Diff the PR branch against its base (`gh pr diff`, or `git merge-base HEAD` then `git diff`), and review the changed lines **plus enough surrounding code and callers** to judge correctness β€” read the whole changed file when practical; a diff alone hides whether a caller breaks. Read the PR description and, when the project uses an issue tracker (project-specific β€” check its docs) and the change references a ticket, that ticket: the diff is judged against its stated intent, and a scope mismatch in either direction is a finding β€” claimed-but-unimplemented, and implemented-but-unasked (#2). 2. **Read every file under `~/.claude/principles/`**, the shared principles, and `~/.claude/skills/larv-review/standards/quality.md`. These are mandatory org guidelines; all code MUST comply with each that applies. A file's `Applies to` line says what it covers; one without the line covers every change. Re-read each time β€” they change. Flag violations prominently. 3. **Read README.md, AGENTS.md and `docs/decisions.md`** in the current project for project-specific conventions, build instructions, tooling, and the accepted trade-offs a reviewer should honor rather than re-flag. Note the documented test, lint, and static-analysis commands β€” you will run them. -4. **Verify, don't just read.** Run the test suite and static analysis/linters through the project's container tooling, unless a decision puts them on the host; tear down test containers afterwards. A full-suite run catches broken callers that diff-reading misses. When a suspected bug is cheap to confirm, reproduce it β€” a scratch script, a targeted test run β€” before reporting it. Put scratch work in a directory you create for this run, through Bash, since Write is for your report alone, and delete it when done; delete nothing else, since a directory the prompt names may hold other agents' files. Leave the working tree exactly as you found it. Anything you could not run goes in Coverage & Verification, never silently skipped. +4. **Verify, don't just read.** Run the test suite and static analysis/linters through the project's container tooling, unless a decision puts them on the host; tear down test containers afterwards. A full-suite run catches broken callers that diff-reading misses. When a suspected bug is cheap to confirm, reproduce it β€” a scratch script, a targeted test run β€” before reporting it. Make scratch work with Bash, since Write is for your report alone. Put it in a directory you create for this run, and delete it when done; delete nothing else, since a directory the prompt names may hold other agents' files. Leave the working tree exactly as you found it. Anything you could not run goes in Coverage & Verification, never silently skipped. 5. **Mutation-test the changed lines.** Run the project's documented mutation command, or else a widely deployed mutation tool for the language: cargo-mutants for Rust, Infection for PHP, mutmut for Python, Stryker for JavaScript and TypeScript. Limit it to the lines the change adds or modifies, through the tool's own option where it has one (cargo-mutants `--in-diff `, Infection `--git-diff-lines`, Stryker `--mutate :`); otherwise mutate only the changed files and keep only the mutants on changed lines. Run it through the project's tooling, as in step 4, on a scratch copy: the tools write files. Report its wall time and mutant count in Coverage & Verification, or why nothing was mutated. Ignore a surviving mutant that leaves behaviour unchanged, or changes only message or log text no caller or user depends on. Report one 🟑 per test to add or strengthen, naming the surviving mutants it would catch. 6. **Two passes minimum, then hunt absences.** - *Breadth:* every hunk in every changed file, no skimming. Track which files you have covered; batch large diffs, never truncate the review. diff --git a/bin/review_folder.py b/bin/review_folder.py index 46089c24..f88739c6 100644 --- a/bin/review_folder.py +++ b/bin/review_folder.py @@ -1,7 +1,7 @@ """The chunk's review folder, where each reviewer writes its report: skills/larv-review/SKILL.md β†’ "Reports".""" import os -# Under the home folder: outside every checkout, so no project sees a report; kept across a reboot, so a resumed chunk still reads its rounds. A fixed path, since a headless session has no scratchpad. +# Why here: docs/decisions.md β†’ `review: each reviewer under agents/ writes its full report into the chunk's review folder`. REPORTS = ".local/state/larv-review" diff --git a/bin/rule_hook/main.py b/bin/rule_hook/main.py index 5ef23a0a..3d5b1b0f 100644 --- a/bin/rule_hook/main.py +++ b/bin/rule_hook/main.py @@ -24,7 +24,7 @@ default branch lacks, and those logged under the branch's own name. Run with no arguments in a terminal, it prints this help. -Exit 2 with the rule, why it holds and how to override it, when a rule blocks the call, or when an +Exit 2 with the rule, why it holds and, where the rule takes an override, how to write one, when a rule blocks the call, or when an override cannot be logged; 0 otherwise. `rule-hook overrides` exits 1 when git cannot read the checkout or the branch's reflog. Exit 1, a non-blocking error to Claude Code, on input it cannot read. diff --git a/bin/stability_replay/main.py b/bin/stability_replay/main.py index 566bfd1f..df1c4155 100644 --- a/bin/stability_replay/main.py +++ b/bin/stability_replay/main.py @@ -11,8 +11,8 @@ branch stands at the newest commit authored before the round's chunk began, so a shows the chunk's change. The prompt names the clone in place of the worktree it named, which the chunk has since removed. A round whose code it cannot find in this way is not replayed; stderr names it and why. The prompt also names a copy of the chunk's review folder in place of that -folder, holding only the reports written after the chunk began and before the round did. A replay whose prompt still -names the review folder finds nothing. +folder, holding only the reports written after the chunk began and before the round did. A replay +whose prompt still names the review folder finds nothing. It first replays every round on the project's rung, the reference reviewer. Findings on record that the reference reviewer does not raise again may rest on code or rules that have changed @@ -174,12 +174,12 @@ def review(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Ef def reviewed_in(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Effects, clone: str, reports: str) -> str | Failure | Limited: """The report of found's reviewer on rung, replayed on code cloned into clone, with its review folder copied into reports.""" - # The reviewer writes its report into a copy of the chunk's review folder, so it leaves the chunk's reports as they were and still reads the earlier rounds its prompt names. The copy holds only the reports written after the chunk began and before the round began: the round's own report, later ones, and an earlier attempt's at the item in the same worktree, would hand the reviewer the findings it is to find. + # 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. folder = pathlib.Path(review_folder(str(home), code.path)) for written in folder.iterdir() if folder.is_dir() else (): if written.is_file() and found.began <= written.stat().st_mtime < found.seconds: shutil.copy2(written, reports) - # The folder goes first: for a worktree outside home, its path holds the worktree's, which code.path would otherwise turn into the clone's. + # Replace the folder's path first: outside home it contains the worktree's path, which replacing code.path would otherwise turn into the clone's. prompt = found.prompt.replace(str(folder), reports).replace(f"~/{folder.relative_to(home)}", reports).replace(code.path, clone) # A spelling the rewrite misses, such as $HOME/, would leave the reviewer the live folder and the findings in it. if REPORTS in prompt.replace(reports, ""): diff --git a/docs/decisions.md b/docs/decisions.md index 93225a96..ed044745 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -218,13 +218,19 @@ The decision `worker: a chunk's worker writes the simplest change…` has the wo Valid while the worker writes the tests that larv-review's reviewers hold to the principles. -## review: each reviewer under `agents/` writes its full report into the chunk's review folder under `~/.local/state/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses any other file call from it +## review: each reviewer under `agents/` writes its full report into the chunk's review folder under `~/.local/state/larv-review/` and returns the worker its verdict and one line per finding; rule-hook refuses its Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/` -2026-10-18, the agent, shipping lilleman's plan item. Serves goal 1.4: a report the worker does not need line by line no longer fills its context. Goal 1.1 holds because the worker reads a finding's full entry before it answers a πŸ”΄ or 🟑. +2026-10-18, lilleman through todo item 73. Serves goal 1.4: a report the worker does not need line by line no longer fills its context. Goal 1.1 holds because the worker reads a finding's full entry before it answers a πŸ”΄ or 🟑. -The worker names each report's file in the reviewer's prompt, per `skills/larv-review/SKILL.md` β†’ "Reports", and `skills/larv-review/review-findings.md` β†’ "Report" sets what the reviewer returns. Each reviewer holds Write for that. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`, so `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit, MultiEdit, and Write outside the folder; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. The folder is fixed, since loop-claude's headless sessions have no scratchpad. It sits outside every checkout, so no project sees a report. It survives a reboot, unlike `/tmp`, so a resumed chunk still reads its earlier rounds. It is in the user's home, so no other local user plants a symlink that widens the folder, and `larv-review review-folder`, which makes the folder, leaves `~/.local/state/larv-review` readable by the user alone, since a report may quote a secret. A chunk keeps its folder after the merge: `stability-replay` hands a replayed reviewer a copy of the reports written after its chunk began and before its round did, so the replay reads the earlier rounds its prompt names, never the findings it is to find, and leaves the chunk's reports as they were. Claude Code's own subagent prompt tells a subagent to return findings rather than write report files; `review-findings.md` β†’ "Report" overrides that, since the file is the worker's input, and a prose-reviewer probed on 2026-10-18 wrote its file. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. +Each reviewer holds Write for its report. Claude Code passes a subagent's type to a PreToolUse hook as `agent_type`. So `bin/rule_hook/reviewer_report.py` refuses a reviewer's Edit and MultiEdit, and any Write outside `~/.local/state/larv-review/`; no marker overrides it. A reviewer's Bash, as stability-reviewer holds, is not confined. -Before this change, reports took a median 19k tokens per chunk, 8% of the worker's peak context, and lines carrying a severity mark were 9–24% of a report (2026-10-08, over 68 archived transcripts). `stability-replay` still counts each πŸ”΄ and 🟑 by its line in the reviewer's reply, now a one-line summary. todo.md item 186 measures what the worker reads of the reports instead. +The folder is fixed, since loop-claude's headless sessions have no scratchpad. It sits outside every checkout, so no project sees a report. It survives a reboot, unlike `/tmp`, so a resumed chunk still reads its earlier rounds. It is in the user's home, so no other local user plants a symlink that widens it. A report may quote a secret, so `larv-review review-folder`, which makes the chunk's folder, leaves `~/.local/state/larv-review` readable by the user alone. + +A chunk keeps its folder after the merge. `stability-replay` hands a replayed reviewer a copy holding only the reports written after the chunk began and before the round did. So the replay reads the earlier rounds its prompt names, never the findings it is to find. The chunk's own reports stay as they were. + +Claude Code's own subagent prompt tells a subagent to return findings rather than write report files. `review-findings.md` β†’ "Report" overrides that, since the file is the worker's input; a prose-reviewer probed on 2026-10-18 wrote the file its prompt named. A general-purpose wrapper that launches the reviewer was not tried: Claude Code's documentation says a subagent cannot start another. + +Before this change, reports took a median 19k tokens per chunk, 8% of the worker's peak context, and lines carrying a severity mark were 9–24% of a report (2026-10-08, over 68 archived transcripts). `stability-replay` still counts each πŸ”΄ and 🟑 by its line in the reviewer's reply, now a one-line summary. todo.md item 186 is to measure what the worker reads of the reports instead. Valid while Claude Code passes `agent_type` to hooks inside a subagent. Without it, the rule refuses nothing, and a reviewer may write anywhere. diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index cc932607..0e564116 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -45,9 +45,9 @@ A comment is prose, not code. Passes run in this order: line-level polish on cod Give a reviewer without Bash the branch diff and `git ls-files`'s output in its prompt: some harnesses grant it Read alone. -**Reports.** Run `~/.claude/bin/larv-review review-folder` in the chunk's worktree: it makes the chunk's review folder and prints its path. Keep the folder after the merge: `stability-replay` replays a round from the reports its prompt names. Name in each prompt to an agent under `~/.claude/agents/` the file there that its full report goes to: `-round-.md`, with the yardstick's name after the pass's for a principles-auditor, and `-rerun` before `.md` for a relaunch one rung up. It writes the report there and returns only its verdict and one line per finding. 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 write anywhere else. +`~/.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, and the history's format and latest places, and its count of how often seats agree. 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. -`~/.claude/bin/larv-review` holds this section's mechanical rules: the round count, the paired ruling's base and vote count, the scoring run's trigger, and the history's format and latest places, and its count of how often seats agree. 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 review-folder` in the chunk's worktree: it makes the chunk's review folder and prints its path. In each prompt to an agent under `~/.claude/agents/`, name the file in that folder for its full report: `-round-.md`. For a principles-auditor, use `principles--round-.md`. For a relaunch one rung up, add `-rerun` before `.md`. 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: `stability-replay` replays a round from the reports its prompt names. **Precedent, then ask** β€” for the architecture pass and the full scan: @@ -80,7 +80,7 @@ Give a reviewer without Bash the branch diff and `git ls-files`'s output in its **Rung up.** A reviewer rules the work below standard when its report holds systems-architect's BLOCK or a finding against `standards/quality.md`. A comprehension seat does when `record-ruling` counts one of its votes as worse. - **Ask.** Such a reviewer or seat may end its report asking for a rerun one rung up. Relaunch it only on the rung loop-claude's prompt names for it; where the prompt names none, the report stands. -- **Relaunch.** Relaunch a reviewer on that rung with the same prompt, its report file renamed per "Reports", and the path of the report that asked; its report stands in place of that one, in the same round. Relaunch a seat with the same prompt alone; its line replaces the one that asked in the votes file, before `record-ruling` runs. A relaunch cannot ask again. +- **Relaunch.** Relaunch a reviewer on that rung with the same prompt, except that it names the `-rerun` report file per "Reports", plus the path of the report that asked; its report stands in place of that one, in the same round. Relaunch a seat with the same prompt alone; its line replaces the one that asked in the votes file, before `record-ruling` runs. A relaunch cannot ask again. - **Escalate.** A below-standard ruling in the report that stands is escalation trigger 4 in `~/.claude/CLAUDE.md` β†’ "Working with the codebase". **Findings.** A reviewer rates each finding πŸ”΄ must fix, 🟑 should fix, 🟒 nit, ❓ question, or πŸ”€ escalation naming the reviewer whose concern it is. diff --git a/skills/larv-review/review-findings.md b/skills/larv-review/review-findings.md index fdb6a3da..e29a2c38 100644 --- a/skills/larv-review/review-findings.md +++ b/skills/larv-review/review-findings.md @@ -2,7 +2,7 @@ Words: `~/.claude/CLAUDE.md` β†’ "Vocabulary". -A reviewer reads and reports; it edits nothing. It writes no file but its report, apart from the scratch files a reviewer holding Bash makes through it. Read `docs/decisions.md` and `todo.md` first: a finding declined or disproved in `docs/decisions.md` or in a comment at the code it concerns, or filed in `todo.md`, is not raised again, unless the decline works against a goal or a technical principle and names no `todo.md` item ending it. +A reviewer reads and reports; it edits nothing. It writes no file but its report, except the scratch files that a reviewer holding Bash makes with Bash. Read `docs/decisions.md` and `todo.md` first: a finding declined or disproved in `docs/decisions.md` or in a comment at the code it concerns, or filed in `todo.md`, is not raised again, unless the decline works against a goal or a technical principle and names no `todo.md` item ending it. ## Severity @@ -14,18 +14,6 @@ A reviewer reads and reports; it edits nothing. It writes no file but its report A finding against a technical principle names it and the file under `~/.claude/principles/` it lives in. A finding against `~/.claude/skills/larv-review/standards/quality.md` names that file and the rule it breaks. -## Report - -Write your full report with the Write tool to the file your prompt names. The file is the worker's input, which it searches for each finding's entry, so write it even where your harness says to return findings directly. It holds the verdict, then every finding with its place, its evidence and its fix, as your agent file shapes them. Then return only: - -- the verdict line -- one line per finding: its severity mark, its place, what is wrong in one sentence, and the file it breaks where that is `standards/quality.md` or a file under `~/.claude/principles/`, or for a πŸ”€ the reviewer it names, such as ``🟑 `bin/rank_todo.py:311` `place`: a cycle among blockers recurses forever (technical-principles.md)`` -- for stability-reviewer, whether the tests passed, and at which commit -- `Rerun one rung up`, where your report ends with it -- the report's path - -A prompt that names no file, or a Write that fails, gets the full report as your reply. - ## Verdict A review's first line, derived from the findings: @@ -38,6 +26,18 @@ A review's first line, derived from the findings: Where your report holds a finding against `~/.claude/skills/larv-review/standards/quality.md`, or you are systems-architect and return BLOCK, you may end it with the line `Rerun one rung up` when you want a more capable reviewer to check that ruling. +## Report + +Write your full report with the Write tool to the file your prompt names. The file is the worker's input, which it searches for each finding's entry, so write it even where your harness says to return findings directly. It holds the verdict, then every finding with its place, its evidence and its fix, as your agent file shapes them. Then return only: + +- the verdict line +- one line per finding, in this order: its severity mark, its place, and what is wrong, in one sentence. Where the finding breaks `standards/quality.md` or a file under `~/.claude/principles/`, end the line with that file's name. For a πŸ”€, end it with the reviewer it names. Example: ``🟑 `bin/example.py:42` `parse`: an empty line raises IndexError (technical-principles.md)`` +- for stability-reviewer, whether the tests passed, and at which commit +- `Rerun one rung up`, where your report ends with it +- the report's path + +A prompt that names no file, or a Write that fails, gets the full report as your reply. + ## Rounds - Handed neither earlier findings nor another pass's fix: surface everything. -- 2.52.0 From 1d8dd330bb40a7d524144e6efed01619407c9f0b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 09:17:20 +0200 Subject: [PATCH 12/13] =?UTF-8?q?Answer=20architecture=20round=204:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1;=20the=20architect=20approved?= =?UTF-8?q?=20the=20review-folder=20command,=20in=20the=20round=20the=20hu?= =?UTF-8?q?man=20granted=20past=20the=20cap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From ec95acab645389553307b817b4550f1b3ac57b8c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 09:21:03 +0200 Subject: [PATCH 13/13] Record the comprehension check: paired ruling same against fdd48bb --- docs/comprehension-history.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/comprehension-history.md b/docs/comprehension-history.md index abef9f05..14d0fc5d 100644 --- a/docs/comprehension-history.md +++ b/docs/comprehension-history.md @@ -2141,3 +2141,24 @@ Inherited architect, decided by: - Locality: `bin/loop_claude/cycle/prompts.py:138` `TYPED_HERE` / `typed_answer`: the resume prompt doubles as a data channel back to the judge, resting on `typed`'s layout, the blank-line partition and `put_question` returning one line, in three modules linked only by a comment - Shape: `bin/loop_claude/routing.py:80` `stepped_from`: returns the stepped route, while `Cycle.stepped_from` holds the route before the step; `escalated` is likewise a function, a bool parameter and a local string - Shape: `bin/loop_claude/cycle/judge.py:95` `Interrupt`: shares `escalation` and `bundled` with `Unfinished` in the opposite positional order, and both are built positionally + +## 2026-10-18T07:20:58Z, PR #310 at 1d8dd33, against fdd48bb + +Ruling: same + +| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall | +|---|---|---|---|---|---| +| Mid A | better | same | same | same | same | +| Inherited architect | same | same | same | same | same | + +Mid A, decided by: + +- Navigation: `bin/review_folder.py:5` `REPORTS`: the review folder's path is one constant in a module named for it, imported by `make_review_folder`, `report_breaches` and `reviewed_in`, so where reports go and who enforces it is found from one name + +Inherited architect, decided by: + +- Locality: `bin/todo_table.py:216` `renamed`: one function now holds the renamed-never-finished rule that `named_releases` and `plan.py`'s `emptied` both call, where a comment kept two files in step by hand +- Locality: `bin/todo_table.py:205` `named_releases`: now a fold whose answer depends on the texts' order, fixed far away by `--reverse` in `git_repo.py`'s `todos_since` and enforced by nothing +- Locality, Self-sufficiency: `bin/stability_replay/main.py:183` `reviewed_in`: three chained replaces that must run in a fixed order, and the copy placed under REPORTS for a reason that lives only in `reviewer_report.py` +- Shape: `bin/stability_replay/main.py:175` `reviewed_in`: seven positional parameters with `clone` and `reports` adjacent strings, and REPORTS meaning the root, its realpath and one round's copy in three files +- Locality: `bin/review_folder.py:5` `REPORTS`: the path is spelled again in `settings.json`, SKILL.md, CLAUDE.md and larv-review's help, and only the Python reads the constant -- 2.52.0