From d256c687be5920a4b6d442963a8751549e3abb50 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 00:23:59 +0200 Subject: [PATCH] Resolve every cited CLAUDE.md heading in a test --- CHANGELOG.md | 2 +- README.md | 2 +- agents/review-protocol.md | 2 +- bin/test_citations.py | 17 +++++++++++++++++ todo.md | 3 +-- 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 bin/test_citations.py diff --git a/CHANGELOG.md b/CHANGELOG.md index c355a4a0..76300535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ - `loop-claude --help` names the Claude Code version its transcript, session and trust handling were observed on; check it first when an upgrade breaks a cycle. - `loop-claude` runs the model each project's settings pick; `LOOP_CLAUDE_WORKER_MODEL` and `LOOP_CLAUDE_JUDGE_MODEL` override it. This repo runs on Fable 5.1. - Reviewers share one protocol for verdicts, severities, rounds and declines: `agents/review-protocol.md`. -- Skills and agents cite `CLAUDE.md` by heading; the comment and documentation bar lives there alone. +- Skills and agents cite `CLAUDE.md` by heading, and a test resolves each citation; the comment and documentation bar lives there alone. - Update a main checkout with `git pull --ff-only`, never `--autostash`. - One word per concept across `CLAUDE.md`, the agents, the skills and `loop-claude`, each defined once under `CLAUDE.md` → "Vocabulary" and cited from where it is used. - `settings.json`, the agents and the status line name no machine-specific path; the status line shows reset times in the host's time zone. diff --git a/README.md b/README.md index feff3bdb..455c5150 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Rename `## Unreleased` in `CHANGELOG.md` to the version, commit, and tag that co - `loop-claude ` runs a project's next chunk cycle after cycle; `loop-claude --help` states its contract. -Test: `python3 -m unittest bin/test_loop_claude.py` +Test: `python3 -m unittest discover -s bin -p 'test_*.py'` ## Tracking a new file diff --git a/agents/review-protocol.md b/agents/review-protocol.md index 9021b299..644606dc 100644 --- a/agents/review-protocol.md +++ b/agents/review-protocol.md @@ -34,6 +34,6 @@ A reviewer honours an accepted risk in `docs/decisions.md` and a finding decline ## Documenting decisions -Knowledge that outlives one review goes in the repo, never in a memory file: `docs/decisions.md` for every standing decision — accepted risks, declined findings, deliberate deviations, rejected alternatives — and otherwise where `~/.claude/CLAUDE.md` → "Ask, don't guess" and "Comments and documentation" put its kind. +Knowledge that outlives one review goes in the repo, never in a memory file: `docs/decisions.md` for every standing decision — accepted risks, declined findings, deliberate deviations, rejected alternatives — and otherwise where `~/.claude/CLAUDE.md` → "Working loop", "Ask, don't guess", and "Comments and documentation" put its kind. Create the file if it is missing; fix it if it is wrong. Record only decisions the human made and declines made under Declining, plus answers the human gives to ❓ — an unrecorded answer gets asked again next review. Default to recording nothing: never what a change did, never a narration of one symbol, file or test. diff --git a/bin/test_citations.py b/bin/test_citations.py new file mode 100644 index 00000000..fafb6d8b --- /dev/null +++ b/bin/test_citations.py @@ -0,0 +1,17 @@ +import pathlib +import re +import subprocess +import unittest + +ROOT = pathlib.Path(__file__).resolve().parents[1] +CITATION = re.compile(r'CLAUDE\.md`?[ ,→]+"([^"]+)"') +HEADING = re.compile(r"^#+ (.+?)(?: \(.*\))?$", re.MULTILINE) + + +class Citations(unittest.TestCase): + def test_every_cited_heading_is_in_claude_md(self): + headings = set(HEADING.findall((ROOT / "CLAUDE.md").read_text())) + tracked = subprocess.run(["git", "ls-files", "-z"], capture_output=True, check=True, cwd=ROOT, text=True).stdout.split("\0") + cited = [(path, heading) for path in filter(None, tracked) for heading in CITATION.findall((ROOT / path).read_text())] + self.assertTrue(cited) + self.assertEqual([f"{path}: {heading}" for path, heading in cited if heading not in headings], []) diff --git a/todo.md b/todo.md index 1e83dcb2..00cbc047 100644 --- a/todo.md +++ b/todo.md @@ -4,11 +4,10 @@ Ordered by how many seats of the 2026-09-24 scoring panel (`docs/decisions.md`) named the place; each is one chunk. -- Pin every `CLAUDE.md` heading the agents and skills cite with a test that resolves each citation. - Define chunk, plan and release inside `JUDGE_RULES`; the judge reads nothing else. - Name the `set -u` empty-array idiom and the `@sh` eval in `statusline.sh`, one line each. - Make `CLAUDE.md`'s comment rules say an invariant earns a line only where the code cannot show it, state the one-line rule once, and scope the docstring exemption to what a tool consumes; today a reviewer finds two sentences saying keep and one saying delete. -- Open `CLAUDE.md` → "Negation and history" with its scope, comments and docs beside code, and cut its two restatements of the section bar; today a reviewer cites it against a `CHANGELOG.md` line, which the next paragraph governs. +- Open `CLAUDE.md` → "Comments and documentation", "Negation and history", with its scope, comments and docs beside code, and cut its two restatements of the section bar; today a reviewer cites it against a `CHANGELOG.md` line, which the next paragraph governs. - Give the comprehension floor in `larv-review` its own heading and move its six-project calibration sentence to `docs/decisions.md`; today it sits under §2 "Trigger". - Cut what `review-protocol.md` → "Documenting decisions" restates from `CLAUDE.md`: the decision kinds, the create-or-fix line and the record-nothing default. - Make the missing-premises exit name what is missing: `README.md` itself, a `## Goals` or `## Audience` heading, or a body under one; today all three print the same line.