From 4ebe36edef90fb5863f2fdf770de7e71acffe4b7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 13 Oct 2026 01:27:05 +0200 Subject: [PATCH] Answer architecture round 1: the worker writes the test first and reads a principle a finding or its record names; findings name their principle; one regex for citable rule files --- CHANGELOG.md | 4 ++-- CLAUDE.md | 7 ++++--- README.md | 2 +- agents/prose-reviewer.md | 2 +- agents/stability-reviewer.md | 2 +- bin/loop_claude/loop/main.py | 5 +++-- bin/loop_claude/paths.py | 4 ++-- bin/loop_claude/test_loop_claude.py | 4 ++-- bin/repo_checks/test_citations.py | 11 ++++++++--- docs/decisions.md | 2 +- rules/todo-items.md | 1 + skills/larv-review/review-findings.md | 2 ++ skills/larv-review/standards/prose.md | 4 ++-- todo.md | 7 ++++++- 14 files changed, 36 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e34dcc4d..6f09379b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -- A session implements the simplest change that solves its item and reads no technical principle; larv-review's reviewers hold the change to the principles, and each finding names the principle it applies. `CLAUDE.md` keeps a short core of "Prose". "Quality", the rules for comments and READMEs, and the examples behind "Prose" moved to `skills/larv-review/standards/`, which the prose and stability reviewers and `loop-claude`'s judge read. `CLAUDE.md` no longer has "Maintaining this file". The rules for a README's Goals and Audience load from `rules/goals-and-audience.md`. -- `CLAUDE.md` keeps only the rules no file path can scope. The rules for `todo.md` items, comments, decisions and READMEs moved to files under `rules/`. Claude Code loads each one when a session reads or writes a matching file. `loop-claude`'s judge reads them beside `CLAUDE.md`, and the prose and stability reviewers read them where they once read `CLAUDE.md`. +- A session implements the simplest change that solves its item and reads no technical principle; larv-review's reviewers hold the change to the principles, and each finding names the principle it applies. `CLAUDE.md` keeps a short core of "Prose". "Quality", the rules for comments and READMEs, and the examples behind "Prose" moved to `skills/larv-review/standards/`, which the prose and stability reviewers and `loop-claude`'s judge read. `CLAUDE.md` no longer has "Maintaining this file". A `todo.md` item names a release whose bump semver allows. +- `CLAUDE.md` keeps only the rules no file path can scope. The rules for `todo.md` items, decisions and a README's Goals and Audience moved to files under `rules/`. Claude Code loads each one when a session reads or writes a matching file. `loop-claude`'s judge reads them beside `CLAUDE.md`. - A README no longer holds cross-cutting decisions; `docs/decisions.md` does. - A technical principle, "Prefer deep modules": a module puts a small, intuitive interface in front of a lot of hidden work, and hides how it works but never what it depends on. It wins over "Explicit over implicit" unless hiding the work makes it harder for someone new to the project to tell what a call does. "Functional core, imperative shell" moves up to second place, a core rule beside "Compose, do not entangle" that no other principle overrides. The systems architect holds every module to it. - A hook blocks each Bash, Edit, MultiEdit and Write call that breaks a rule a program can check: a commit message that is not one line passed with `-m`, a Claude or Anthropic attribution, a container image short of a full patch version, an Action pinned to anything but a semver tag, an unsorted block in an ignore file, and a commit of a `todo.md` that `rank_todo.py --check` rejects. `CLAUDE.md` states those rules only where the hook cannot check them; `~/.claude/bin/rule-hook --help` states what it checks. A call overrides a rule with `# rule-override : `. larv-review's new overrides pass, run before stability, accepts or rejects each override the chunk logged, and the PR body lists each with its ruling; a rejected override means the chunk keeps the rule. An override that touches a credential, a security rule or a production system, or cannot be undone, is asked of you. diff --git a/CLAUDE.md b/CLAUDE.md index ea9bf05f..e1449db2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,7 +12,7 @@ How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The - **Work one chunk at a time, and make it as large as one purpose allows.** Every review has a fixed cost, so a chunk takes the next plan item plus every other item for which three things hold: one PR title states what they achieve together, without listing them; they name one release; and they fire the same review passes (`larv-review` §3). Tiny items, a few lines of change each, need neither a shared purpose nor the same passes: bundle up to ten that name one release into one chunk. Split a milestone into items in `todo.md` before starting it. Fix a finding in the chunk's own change within the chunk. File a finding about anything else in `todo.md`. An item marked `question` waits for the human; take the next item. - **Ask, don't guess.** First check whether the goals already answer the question. If they nearly do, propose a change to the goals and show how it answers this case: an answer settles one question, a goal settles every question like it. Write every answer once, where it belongs, never only in chat: a goal in `README.md`, a working rule in `AGENTS.md`, a standing choice in a comment at the one place it governs, or in `docs/decisions.md` once made in more than one place. When an answer holds a goal and a choice, write the goal in the README, and record as a choice only what the goal leaves open. - **Bench a syntax with the people who write it.** Before a new or changed spelling of something users read or write ships — markdown, HTML, a config key, a CLI flag — a panel of fresh-context readers, seated as those users from the README's `## Audience`, picks it. -- **Implement the simplest change that solves the item, and ship it with `/larv-review`.** Its reviewers hold the change to the technical principles, each finding naming the principle it applies, and you fix what they find. Read no file under `~/.claude/principles/` unless the item changes it. +- **Write a failing test for the item, implement the simplest change that passes it, and ship it with `/larv-review`.** Its reviewers hold the change to the technical principles, each finding naming the principle it applies, and you fix what they find. Read a file under `~/.claude/principles/` only when the item changes it, a finding or a record you write names it, or you decline a finding. - **Remove a finished item's row and detail from `todo.md`, and revise any decision that cites it.** If the repo publishes something others consume — a package, an image, an API — reword the item for them and move it to `CHANGELOG.md` under `## Unreleased`. A changelog is for the public, never for the next agent. Otherwise delete it; git history is the record. - **Releases are the human's.** The version bump and the publishing credentials are theirs, whatever another rule says. Prepare everything else, so cutting a release is one decision. - **Open each `todo.md` item or ticket with a bold one-sentence tagline**, so the taglines alone say what a release holds. The tagline states the target state, checkable when done: an imperative verb plus what holds afterwards. A present-tense fact reads as the current state and says nothing about what to do. Add "today X" only where the direction is otherwise ambiguous. GOOD: `**Accept undefined in MetadataValue and drop such keys on output.**` BANNED: `MetadataValue accepts undefined; such keys are dropped on output`. @@ -27,7 +27,7 @@ Everything written — chat, commit messages, comments, docs, code — is in **E 3. **Default to delete.** Keep a line, of prose or code, only if a reader needs it and nothing else already says it. 4. **Short.** Cut whatever does not clearly help 1–3. -Write the thing, not an introduction to it. State what holds and stop, without the alternative you rejected. +Write the thing, not an introduction to it. State what holds and stop; name a rejected alternative only where that stops a reader choosing it. ## Public API specs - Text in public API specs (OpenAPI `description`/`title` fields, in a spec file or in code, and the generated api-docs) is read by external consumers. Never leak internal references: no ticket IDs, internal URLs, repo/system code-names, "see ticket X". Describe behaviour in consumer terms. GOOD: `Deprecated alias for paymentAccountId`. BANNED: `…will be removed (ABC-123)`. @@ -57,6 +57,7 @@ Claude Code loads a rule file when a session reads or writes a file its `paths:` ## Git, commits, and PRs - Mark no commit, PR, issue comment or file as the work of Claude, Anthropic or an agent. - Commit message and PR title: **one line**, prefixed with the ticket ID when the work has one. Example: `ABC-123 - Regression tests for GET /v4/clients`. Never include the repo/project name (like "twu-4") — we're already in that context. +- When the work has a ticket, read it before starting: verify the change matches it and pull useful context from it. - PR summary: short and concise. No test plan (it lives in the ticket), no link to the ticket (it's in the title). - Branch for a ticket: exactly the ticket ID, nothing more. `ABC-123`, never `ABC-123-some-description`. - Use `gh` on GitHub remotes and `tea` on Gitea remotes (e.g. `gitea.larvit.se`) — same command shape: `tea pr list|create`, `tea issue`, `tea release`, `tea api`. Everything in this section applies to both. @@ -72,7 +73,7 @@ Claude Code loads a rule file when a session reads or writes a file its `paths:` ## Vocabulary - **chunk** — the unit of work, shipped as one PR; "Working loop" says what it holds. -- **cycle** — in `loop-claude`, worker runs and the judge's verdict on each, until the chunk closes or is left for the next cycle. In between, the human answers any interrupt, or the worker resumes with an answer the judge quoted from `README.md`, `AGENTS.md`, `docs/decisions.md`, `~/.claude/CLAUDE.md` or `~/.claude/rules/`. +- **cycle** — in `loop-claude`, worker runs and the judge's verdict on each, until the chunk closes or is left for the next cycle. In between, the human answers any interrupt, or the worker resumes with an answer the judge quoted from `README.md`, `AGENTS.md`, `docs/decisions.md`, `~/.claude/CLAUDE.md`, `~/.claude/rules/` or `~/.claude/skills/larv-review/standards/`. - **gate** — the merge gate: the checks a PR passes before it merges. - **interrupt** — `loop-claude` handing the terminal to the human, `claude --resume`, for a decision that is theirs. - **judge** — the headless claude that reads a worker's transcript each cycle and decides whether to interrupt and whether the chunk is finished. diff --git a/README.md b/README.md index c047e3c0..f61f0359 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Claude Code configuration -My personal `~/.claude`, version controlled: `CLAUDE.md`, `AGENTS.md` and `rules/` for instructions, the words under `CLAUDE.md` → "Vocabulary"; `agents/` and `skills/`; `principles/` for what the reviewer agents hold projects to; `docs/` for decisions and the comprehension history; `settings.json` for the harness and `.claude/settings.json` for the harness inside this repo; `CHANGELOG.md` and `todo.md`; the tools in `bin/`; and `workflow-bench/`, the scripts and prompts of the 2026-09-30 bench of larv-review. +My personal `~/.claude`, version controlled: `CLAUDE.md`, `AGENTS.md` and `rules/` for instructions, the words under `CLAUDE.md` → "Vocabulary"; `agents/` and `skills/`; `principles/` and `skills/larv-review/standards/` for what the reviewer agents hold projects to; `docs/` for decisions and the comprehension history; `settings.json` for the harness and `.claude/settings.json` for the harness inside this repo; `CHANGELOG.md` and `todo.md`; the tools in `bin/`; and `workflow-bench/`, the scripts and prompts of the 2026-09-30 bench of larv-review. ## Goals diff --git a/agents/prose-reviewer.md b/agents/prose-reviewer.md index 837dab03..64527585 100644 --- a/agents/prose-reviewer.md +++ b/agents/prose-reviewer.md @@ -17,7 +17,7 @@ Run them in this order. A fix for a later check never breaks an earlier one. 3. **Default to delete.** A line the reader does not need fails. Fix: **Delete** what the code, a type, a test name, the README or another rule already says. Fix: **Move** a choice made in one place to a comment there, one made in more places to `docs/decisions.md` with its title in `AGENTS.md`, and a goal to the README. A pointer standing where a definition belongs (`~/.claude/skills/larv-review/standards/comments.md` → "Links and pointers", "A pointer is not a definition") gets the fix **Move back**: inline the definition, and leave the reasoning where it is. 4. **Short.** Words that do not clearly help 1–3 fail. Fix: **Cut**. -Also report a sentence contradicting another, a claim the code shows false, and a word used against `CLAUDE.md` → "Vocabulary". +Also report a list whose order carries no meaning and is not sorted (`~/.claude/principles/technical-principles.md` → "Deterministic order"), a sentence contradicting another, a claim the code shows false, and a word used against `CLAUDE.md` → "Vocabulary". ## Growth diff --git a/agents/stability-reviewer.md b/agents/stability-reviewer.md index 30c244f5..b38f513f 100644 --- a/agents/stability-reviewer.md +++ b/agents/stability-reviewer.md @@ -10,7 +10,7 @@ You are an elite stability-focused code reviewer with deep expertise in defensiv ## First Steps 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 in the shared principles**, and `~/.claude/skills/larv-review/standards/quality.md`, at `~/.claude/principles/`. 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. +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. 5. **Two passes minimum, then hunt absences.** diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 49b8b2e2..7bbf45dd 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -6,8 +6,9 @@ Run it anywhere inside a project checkout whose README.md has ## Goals and ## Au premises; the task runs at the checkout root. Each cycle a worker runs the task. A judge then reads the transcript's end, the premises, and the records: the project's AGENTS.md and docs/decisions.md, and the human's ~/.claude/CLAUDE.md, ~/.claude/rules/*.md and -~/.claude/skills/larv-review/standards/*.md, where they exist. It rules whether the chunk, the work of one PR, is finished. A chunk stays unfinished until each answer the human typed in it that a later chunk -could need is recorded: the premises or the records hold it, or the transcript shows the worker +~/.claude/skills/larv-review/standards/*.md, where they exist. It rules whether the chunk, the work +of one PR, is finished. A chunk stays unfinished until each answer the human typed in it that a +later chunk could need is recorded: the premises or the records hold it, or the transcript shows the worker writing it into the premises, AGENTS.md, docs/decisions.md, todo.md or a code comment. A choice the worker made that the premises or the records settle is not asked about. When the worker asks a question they answer, the judge quotes the answer, loop-claude prints it, and the worker resumes diff --git a/bin/loop_claude/paths.py b/bin/loop_claude/paths.py index 5182fbd7..fcca1544 100644 --- a/bin/loop_claude/paths.py +++ b/bin/loop_claude/paths.py @@ -5,8 +5,8 @@ import pathlib @dataclasses.dataclass(frozen=True) class Paths: claude_code_transcripts: pathlib.Path - claude_json: pathlib.Path claude_dir: pathlib.Path + claude_json: pathlib.Path home: pathlib.Path model_catalog: pathlib.Path models_file: pathlib.Path @@ -16,8 +16,8 @@ def paths_from(home: pathlib.Path) -> Paths: claude = home / ".claude" return Paths( claude_code_transcripts=claude / "projects", - claude_json=home / ".claude.json", claude_dir=claude, + claude_json=home / ".claude.json", home=home, model_catalog=claude / "cache" / "model-catalog", models_file=claude / "loop-claude-models.json", diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index e0518f20..3f56ce31 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -407,11 +407,11 @@ class Records(unittest.TestCase): self.assertEqual(records.read_records(root, claude_md.parent), "From AGENTS.md:\n# Rules\n\nFrom docs/decisions.md:\n# Decisions\n\nFrom ~/.claude/CLAUDE.md:\n# Global") pathlib.Path(claude_md.parent, "rules").mkdir() pathlib.Path(claude_md.parent, "rules", "todo-items.md").write_text("# Todo\n") - pathlib.Path(claude_md.parent, "rules", "readme.md").write_text("# Readme\n") + pathlib.Path(claude_md.parent, "rules", "goals-and-audience.md").write_text("# Goals\n") pathlib.Path(claude_md.parent, "rules", "notes.txt").write_text("not a rule\n") pathlib.Path(claude_md.parent, "skills", "larv-review", "standards").mkdir(parents=True) pathlib.Path(claude_md.parent, "skills", "larv-review", "standards", "comments.md").write_text("# Comments\n") - self.assertTrue(records.read_records(root, claude_md.parent).endswith("From ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/readme.md:\n# Readme\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/.claude/skills/larv-review/standards/comments.md:\n# Comments")) + self.assertTrue(records.read_records(root, claude_md.parent).endswith("From ~/.claude/CLAUDE.md:\n# Global\n\nFrom ~/.claude/rules/goals-and-audience.md:\n# Goals\n\nFrom ~/.claude/rules/todo-items.md:\n# Todo\n\nFrom ~/.claude/skills/larv-review/standards/comments.md:\n# Comments")) def test_stops_on_a_record_it_cannot_read(self): with tempfile.TemporaryDirectory() as root: diff --git a/bin/repo_checks/test_citations.py b/bin/repo_checks/test_citations.py index 0df2cd41..7bc89787 100644 --- a/bin/repo_checks/test_citations.py +++ b/bin/repo_checks/test_citations.py @@ -6,14 +6,16 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) +from loop_claude.project.records import HUMAN_RULE_DIRS from repo_checks.test_python_floor import ROOT -CITATION = re.compile(r'`?(?:~/\.claude/)?(CLAUDE\.md|rules/[\w-]+\.md|skills/larv-review/standards/[\w-]+\.md)`? → ("[^"]+"(?:,? (?:and )?"[^"]+")*)') +RULE_PATH = rf"(?:{'|'.join(map(re.escape, HUMAN_RULE_DIRS))})/[\w-]+\.md" +CITATION = re.compile(rf'`?(?:~/\.claude/)?(CLAUDE\.md|{RULE_PATH})`? → ("[^"]+"(?:,? (?:and )?"[^"]+")*)') HEADING = re.compile(r"^#+ (.+?)(?: \(.*\))?$", re.MULTILINE) LEAD = re.compile(r"^(?:- )?\*\*(.+?)(?:\*\*|[:.](?=\*\*| )| —)", re.MULTILINE) NAME = re.compile(r'"([^"]+)"') -RULE_FILE = re.compile(r"(?