From 79cf337936f8e7512950ce3e2765c6cf24e6bb29 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 13 Oct 2026 12:28:18 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20architecture=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=206=20=F0=9F=9F=A1;=20feed=20later=20rulings'=20w?= =?UTF-8?q?orse=20places=20to=20places,=20base=20each=20ruling=20on=20the?= =?UTF-8?q?=20last=20entry,=20merge=20origin=20before=20the=20gate,=20test?= =?UTF-8?q?=20a=20second=20record,=20and=20drop=20stale=20ratchet=20wordin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 +- CHANGELOG.md | 6 +-- bin/comprehension_history.py | 60 +++++++++++++++++++------ bin/larv_review/main.py | 26 +++++------ bin/larv_review/ruling.py | 8 +--- bin/larv_review/ruling_base.py | 25 ++--------- bin/larv_review/test_larv_review.py | 51 +++++++++------------ bin/test_round_titles.py | 2 +- docs/comprehension-history.md | 26 +++++++++++ docs/decisions.md | 6 +-- skills/larv-review/SKILL.md | 21 ++++----- skills/larv-review/standards/quality.md | 2 +- todo.md | 4 +- 13 files changed, 131 insertions(+), 108 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 6618142e..16101795 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,7 @@ Decisions live in `docs/decisions.md`: -- larv-review: a project under the comprehension floor is fixed at the lowest dimension +- larv-review: a project lifting itself to the comprehension floor starts at the lowest dimension - loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md`, `docs/decisions.md`, `~/.claude/CLAUDE.md`, `~/.claude/rules/` and larv-review's standards, and holds a chunk open while an answer the human typed in it is recorded nowhere; the worker's own account of which goal settles a choice decides nothing - loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it - loop-claude: before an interrupt, it marks the checkout and each of its worktrees trusted in `~/.claude.json` diff --git a/CHANGELOG.md b/CHANGELOG.md index ce47abf7..9cefba01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,14 +18,14 @@ - A project may opt out of larv-review's architect, product-owner pass or comprehension check in every chunk, through a `docs/decisions.md` entry titled `review opt-out: …` that names the goal that skipping them serves. A project without such an entry is reviewed as before. Opting out of the comprehension check also skips the scoring run due at a release's end. The principles audit always runs. - A README goal states the project's aim and intent, and no longer names a step of the work, such as "kill weak candidates early". Such steps go in a method section further down the README and name the goal they serve. - The stability reviewer keeps its scratch work in a directory it creates for the run, deletes that directory afterwards, and deletes nothing else. -- larv-review's mechanical rules run in the new, tested `bin/larv-review`: the paired ruling's base (`ruling-base`), each pass's round count (`round-count`, which ignores case in a round's commit title, counts a repeated round number as a round of its own, and says to ask you before another round once a pass is at or past the cap), the scoring run's trigger (`needs-scoring-run ...`), and the vote count, means and history format (`record-ruling ` and `record-scoring [...]`, which append to `docs/comprehension-history.md` and refuse a second entry on what a seats file's first line reads; `record-scoring` refuses a run the plan does not call, and prints `Floor:` naming each mean under the comprehension floor of 7.0), and the places the newest scoring seats found hard (`places`). The skill says when to run each and what its answer means. A seats file line the tool cannot read fails the run, so a mistyped vote never counts as same. The base search compares the history before and after each merged change, so it no longer depends on how a line is worded, and orders a change's rulings by their headings' times. A release whose last plan item moves to another release is due a scoring run too, once work has landed towards it. A seats file must name commits the checkout holds. When origin cannot be fetched, the tool reads it as last fetched and says so. +- larv-review's mechanical rules run in the new, tested `bin/larv-review`: the paired ruling's base (`ruling-base`), each pass's round count (`round-count`, which ignores case in a round's commit title, counts a repeated round number as a round of its own, and says to ask you before another round once a pass is at or past the cap), the scoring run's trigger (`needs-scoring-run ...`), and the vote count, means and history format (`record-ruling ` and `record-scoring [...]`, which append to `docs/comprehension-history.md` and refuse a second entry on what a seats file's first line reads; `record-scoring` refuses a run the plan does not call, and prints `Floor:` naming each mean under the comprehension floor of 7.0), and the places seats found hard since the newest scoring run (`places`). The skill says when to run each and what its answer means. A seats file line the tool cannot read fails the run, so a mistyped vote never counts as same. The base search compares the history before and after each merged change, so it no longer depends on how a line is worded. A release whose last plan item moves to another release is due a scoring run too, once work has landed towards it. A seats file must name commits the checkout holds. When origin cannot be fetched, the tool reads it as last fetched and says so. - The new `bin/metric-bench` benches cheap static metrics of a project's Python against the places its comprehension history names as hardest: cognitive complexity, length, shared state and change spread, each scored by how well it ranks the named functions above the rest. No metric enters review yet. -- larv-review runs a comprehension check, which records how hard the project is to read and blocks no merge. It runs once per chunk, after every other pass, on the commit to merge. Where the architecture pass ran, Mid A and the inherited architect read that commit beside the last measured commit: the default branch's newest merged change that added a scoring run to `docs/comprehension-history.md`, or whose last ruling there is better. They vote better, same or worse on each dimension and overall: `Navigation same, Locality worse, Shape same, Self-sufficiency same, Overall better`. When their overall votes differ, the maintainability senior and Junior A vote too. A ruling needs a lead of two or more votes, else it is same. Each place a seat names opens with the dimensions it moves, such as `Locality, Shape: `, or the run fails, and a vote that no place opens with counts as same. Four seats score the project from 1 to 10 when a chunk ships or removes a release's last plan item, or ships an item naming the comprehension floor of 7.0. +- larv-review runs a comprehension check, which records how hard the project is to read and blocks no merge. It runs once per chunk, after every other pass, on the commit to merge. Where the architecture pass ran, Mid A and the inherited architect read that commit beside the last measured commit: the default branch's newest merged change that added a ruling or a scoring run to `docs/comprehension-history.md`. They vote better, same or worse on each dimension and overall: `Navigation same, Locality worse, Shape same, Self-sufficiency same, Overall better`. When their overall votes differ, the maintainability senior and Junior A vote too. A ruling needs a lead of two or more votes, else it is same. Each place a seat names opens with the dimensions it moves, such as `Locality, Shape: `, or the run fails, and a vote that no place opens with counts as same. Four seats score the project from 1 to 10 when a chunk ships or removes a release's last plan item, or ships an item naming the comprehension floor of 7.0. - larv-review reruns fewer passes after a fix. A fix reruns the pass whose 🔴 or 🟡 it answers, plus stability when the fix changes behaviour, security when it opens an untrusted-input boundary or touches authn/authz, secrets or crypto, and architecture when it carries an architectural decision. A rerun reviews only what changed since that pass last reviewed. A fix for a 🟢, a ❓ or any prose finding reruns no pass, and prose takes one round. - larv-review runs one security pass on each change: the full scan alone when it runs, else `/security-review`. - larv-review runs the new `bin/reading-cost`, which measures each chunk `loop-claude` finished from its archive: the new input tokens the worker and its subagents took in before the worker's first commit, and the files git tracks that they read most. It appends each figure the project's `docs/reading-cost.md` lacks. Once 10 chunks are measured, and the last 5 chunks' median is above the 5 before them, larv-review files one plan item naming the files read most, or refreshes it. The chunk that ships it runs `reading-cost --reset`, so the trend counts only chunks that finished after it. - larv-review appends every paired ruling and scoring run to the project's `docs/comprehension-history.md`: the commit the seats read, a ruling's base, each seat's vote or scores, and the places each seat named. The PR summary gives each ruling with its base and votes. The seats do not read the history. -- The architect and the stability reviewer get the places the newest scoring seats found hard, from the new `larv-review places`. Each reports, as a 🟡, a place the change touches without making it easier to read; the chunk fixes it or says in the PR summary why not. A session filing a `todo.md` item reads the places too, and an item touching one says to make it easier to read. +- The architect and the stability reviewer get the places seats found hard since the newest scoring run, from the new `larv-review places`: that run's places, and each later ruling's places a seat voted worse. Each reports, as a 🟡, a place the change touches without making it easier to read; the chunk fixes it or says in the PR summary why not. A session filing a `todo.md` item reads the places too, and an item touching one says to make it easier to read. - The README's goals put quality with the fewest interrupts first, as goal 1; sharing the setup, backups and leaking nothing follow as goals 2–4. - larv-review skips the comprehension check for a chunk whose plan items a project decision names. The decision also names the later item whose check ends the suspension. The skipped chunk's summary cites the decision. A chunk that ships or removes a release's last plan item, or ships an item naming the floor, still gets the scoring run. - README → Install and Update give the commands that check the latest tag out into `~/.claude`: on a new machine, whether or not Claude Code has already created the directory, and on one already on an older tag. diff --git a/bin/comprehension_history.py b/bin/comprehension_history.py index 835c0b54..bb641061 100644 --- a/bin/comprehension_history.py +++ b/bin/comprehension_history.py @@ -40,7 +40,7 @@ class Place: @dataclasses.dataclass(frozen=True) class Entry: - """One paired ruling, which names the commit it was against and its ruling, or one scoring run, which names neither. A scoring run's places, or those of the scores a fall called into a ruling, are scored_places.""" + """One paired ruling, which names the commit it was against and its ruling, or one scoring run, which names neither. The places under a scoring seat's label are scored_places; a ruling holds them where the scoring seats' scores are part of it.""" heading: str time: str commit: str @@ -48,6 +48,7 @@ class Entry: ruling: str | None ruled_places: list[Place] scored_places: list[Place] + body: str @property def paired(self) -> bool: @@ -98,19 +99,42 @@ def entries(history: str) -> list[Entry]: if named := HEADING.match(heading): body = "\n".join(bodies) ruling = RULING.search(body) - found.append(Entry(heading, named.group(1), named.group(3), named.group(4), ruling.group(1) if ruling else None, seat_places(body, RULED_PLACES), seat_places(body, SCORED_PLACES))) + found.append(Entry(heading, named.group(1), named.group(3), named.group(4), ruling.group(1) if ruling else None, seat_places(body, RULED_PLACES), seat_places(body, SCORED_PLACES), body)) return found def latest_places(history: str) -> str | None: - """The heading and the seats' places of the newest entry, by its time, whose seats scored the project: a scoring run, or a ruling whose fall called the scoring seats. None when no entry did.""" - scored = [(named.group(1), heading, "\n".join(bodies)) for heading, bodies in sections(history).items() if (named := HEADING.match(heading)) and seat_places("\n".join(bodies), SCORED_PLACES)] - if not scored: - return None - _, heading, body = max(scored) - lines = body.splitlines() - start = next(index for index, line in enumerate(lines) if SCORED_PLACES.match(line)) - return f"## {heading}\n" + "".join(f"\n{line}\n\n" if SCORED_PLACES.match(line) else f"{line}\n" for line in lines[start:]) + """The places seats found hard since the newest entry, by time, that holds scoring seats' places: all of that entry's scoring places, then, in each later paired ruling, each place opening with a dimension its seat's vote counted as worse. Each entry's places come under its heading, oldest first; with no such entry, every ruling's count. None when no place counts.""" + found = sorted(entries(history), key=lambda entry: entry.time) + start = max((index for index, entry in enumerate(found) if entry.scored_places), default=0) + parts = [entry_places(entry, scored=index == start and bool(entry.scored_places)) for index, entry in enumerate(found) if index >= start] + return "\n".join(part for part in parts if part) or None + + +def entry_places(entry: Entry, scored: bool) -> str: + """An entry's heading and the places latest_places counts in it, each under its seat's label; empty when none counts.""" + worse = {} if scored else worse_votes(entry.body) + labelled = labelled_bullets(entry.body, SCORED_PLACES if scored else RULED_PLACES) + kept = [(label, bullets if scored else [bullet for bullet in bullets if moves_worse(bullet, worse.get(label.split(",")[0], set()))]) for label, bullets in labelled] + text = "".join(f"\n{label}\n\n" + "".join(f"{bullet}\n" for bullet in bullets) for label, bullets in kept if bullets) + return f"## {entry.heading}\n{text}" if text else "" + + +def worse_votes(body: str) -> dict[str, set[str]]: + """Each seat's dimensions, Overall included, whose vote in the ruling's table counted as worse; `same (voted worse, …)` counted as same.""" + rows = [[cell.strip() for cell in line.strip("|").split("|")] for line in body.splitlines() if line.startswith("| ")] + return {name: {dimension for dimension, vote in zip(DIMENSIONS, votes) if vote == "worse"} for name, *votes in rows if len(votes) == len(DIMENSIONS)} + + +def moves_worse(bullet: str, worse: set[str]) -> bool: + """Whether a ruled place opens with a dimension its seat counted worse; Overall counts as one.""" + return bool(worse & set(place_dimensions(bullet.removeprefix("- ")))) + + +def place_dimensions(place: str) -> list[str]: + """The dimensions a place opens with, as in `Locality, Shape: `path:line` ...`; empty when any name before the first `: ` is no dimension.""" + named = place.partition(": ")[0].split(", ") + return named if all(name in DIMENSIONS for name in named) else [] def recorded(history: str, read: str) -> bool: @@ -119,17 +143,25 @@ def recorded(history: str, read: str) -> bool: def seat_places(body: str, labels: re.Pattern[str]) -> list[Place]: - """The places under each seat label labels matches.""" - places = [] + """The places on the first line of each bullet under a seat label labels matches.""" + return [place for _, bullets in labelled_bullets(body, labels) for bullet in bullets for place in bullet_places(bullet.splitlines()[0])] + + +def labelled_bullets(body: str, labels: re.Pattern[str]) -> list[tuple[str, list[str]]]: + """Each seat label labels matches, with its bullets, each with its indented continuation lines.""" + found: list[tuple[str, list[str]]] = [] listing = False for line in body.splitlines(): if labels.match(line): + found.append((line, [])) listing = True elif listing and line.startswith("- "): - places += bullet_places(line) + found[-1][1].append(line) + elif listing and line.startswith(" ") and found[-1][1]: + found[-1][1][-1] += f"\n{line}" elif not line.startswith(" "): listing = False - return places + return found def bullet_places(bullet: str) -> list[Place]: diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index 43dc3d42..db1b8308 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -14,10 +14,9 @@ last fetched and says so on stderr; the other three exit 1. The history is docs/comprehension-history.md in the checkout. 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 scoring run to the -history, or whose last added paired ruling, by heading time, is better; a merge commit counts as -one change against its first parent. With none, the base is the one the history's first paired -ruling names; with no ruling either, it is the merge base of HEAD and the default branch. +measured commit is the default branch's newest merged change that adds a paired ruling or a scoring +run to the history; a merge commit counts as one change against its first parent. With none, it is +the merge base of HEAD and the default branch. round-count prints each pass's round count among the commits not yet on the default branch whose titles open `Answer round :`, ignoring case. The count is the highest , or the number of @@ -68,9 +67,10 @@ paired ruling's base. It appends the seats' scores and their means, rounded half decimals, prints the means and, when a mean is under the floor of {floor}, a line opening `Floor:` naming each one. -places prints the places the seats named in the history's newest entry, by its time, that scored -the project: a scoring run, or a ruling recorded before this tool stopped calling the scoring seats -on a fallen dimension. +places prints the places seats found hard since the history's newest entry, by time, that holds +scoring seats' places: all of that entry's, then, from each later paired ruling, each place that +opens with a dimension, or Overall, its seat's vote counted as worse. Each entry's places come under +its heading, oldest first. With no such entry, it reads every ruling. Each record is appended to the history, created when missing, under a heading of the current UTC time and the seats file's first line. Each commit that line names must be in the checkout. It exits 1 @@ -85,13 +85,12 @@ import re import sys import typing -from larv_review.ruling_base import base from round_titles import CAP, PASSES, round_counts -from git_repo import default_branch, file_at, git +from git_repo import default_branch, git from failure import Failure from larv_review.scoring import FLOOR -from comprehension_history import HISTORY from larv_review.git import history_changes +from larv_review.ruling_base import measured_commit from larv_review.plan import plan_reasons from larv_review.record import record_ruling, record_scoring, show_places @@ -145,11 +144,8 @@ def show_ruling_base(default: str) -> Failure | None: changes = history_changes(default) if isinstance(changes, Failure): return changes - history = file_at(default, HISTORY) - if isinstance(history, Failure): - return history - if found := base(changes, history): - print("\n".join(found)) + if found := measured_commit(changes): + print(f"{found}\nthe last measured commit") return None merge_base = git("merge-base", "HEAD", default) if isinstance(merge_base, Failure): diff --git a/bin/larv_review/ruling.py b/bin/larv_review/ruling.py index c5f1ba05..a21a4249 100644 --- a/bin/larv_review/ruling.py +++ b/bin/larv_review/ruling.py @@ -1,4 +1,4 @@ -from comprehension_history import DIMENSIONS, PLACE, Seat +from comprehension_history import DIMENSIONS, PLACE, place_dimensions, Seat from failure import Failure from larv_review.seats import FIRST_SEATS, SPLIT_SEATS, vote_line @@ -38,12 +38,6 @@ def names_a_place(seat: Seat, dimension: str) -> bool: return any(PLACE.search(place) and (dimension == DIMENSIONS[-1] or dimension in place_dimensions(place)) for place in seat.places) -def place_dimensions(place: str) -> list[str]: - """The dimensions a place opens with, as in `Locality, Shape: `path:line` ...`; empty when any name before the first `: ` is no dimension.""" - named = place.partition(": ")[0].split(", ") - return named if all(name in DIMENSIONS for name in named) else [] - - def split(overall: list[str]) -> bool: """Whether only the first two seats voted overall and they differ, so two more must vote: two votes that differ cannot reach a lead of two.""" return len(overall) == 2 and overall[0] != overall[1] diff --git a/bin/larv_review/ruling_base.py b/bin/larv_review/ruling_base.py index 5bf5e30e..3b7211ec 100644 --- a/bin/larv_review/ruling_base.py +++ b/bin/larv_review/ruling_base.py @@ -1,30 +1,11 @@ -from comprehension_history import entries, Entry, HistoryChange +from comprehension_history import entries, HistoryChange def measured_commit(changes: list[HistoryChange]) -> str | None: - """The newest change, of changes given newest first, that adds a scoring run to the history, or whose last added paired ruling is better. - - It is the ratchet's base. A ruling of same leaves the base where it was, so a run of small falls each ruled same still adds up against one commit. Entry times are UTC stamps in ISO order, so they sort as text. - """ + """The newest change, of changes given newest first, that adds a paired ruling or a scoring run to the history: the paired ruling's base, so each ruling measures the changes merged since the last one measured.""" for change in changes: held = {entry.heading for entry in entries(change.before)} - added = [entry for entry in entries(change.after) if entry.heading not in held] - rulings = sorted((entry for entry in added if entry.paired), key=lambda entry: entry.time) - ruled_better = bool(rulings) and rulings[-1].ruling == "better" - if ruled_better or any(not entry.paired for entry in added): + if any(entry.heading not in held for entry in entries(change.after)): return change.commit return None - -def first_ruling(history: str) -> Entry | None: - rulings = sorted((entry for entry in entries(history) if entry.paired), key=lambda entry: entry.time) - return rulings[0] if rulings else None - - -def base(changes: list[HistoryChange], history: str) -> tuple[str, str] | None: - """The commit a paired ruling reads against, and which fallback found it; None leaves the merge base of HEAD and the default branch. history is the default branch's.""" - if found := measured_commit(changes): - return found, "the last measured commit" - if (first := first_ruling(history)) and first.against: - return first.against, "the base the history's first paired ruling names" - return None diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 650c00b0..d82a9200 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -11,13 +11,13 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from comprehension_history import appended, entries, HistoryChange, latest_places, Place, recorded, ruling_entry, scoring_entry, ScoringRun, Seat -from larv_review.ruling_base import base, first_ruling, measured_commit import comprehension_history from larv_review.ruling import counted, ruling, split, votes from failure import Failure from test_env import isolated_env from todo_table import Item, items from larv_review.scoring import means, under_floor +from larv_review.ruling_base import measured_commit from larv_review.seats import score_line, scores, seats_file from larv_review.plan import scoring_run_due @@ -133,40 +133,28 @@ class History(unittest.TestCase): self.assertIn("| Mean | 7.00 | 6.50 | 7.00 | 7.00 | 7.00 |\n\nJunior A, hardest first:", history) self.assertEqual([entry.paired for entry in found], [False, True]) - def test_names_the_places_of_the_newest_entry_that_scored_the_project(self): + def test_names_the_places_found_hard_since_the_newest_entry_that_scored_the_project(self): scored = "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\n| Seat | Overall |\n|---|---|\n| Mean | 7.00 |\n\nJunior A, hardest first:\n\n- `bin/b.py:4` `h`: long\n and wrapped\n\nInherited architect, would restructure first:\n\n- `bin/c.py:1` `k`: tangled\n" - fell = "## 2026-10-09T12:00:00Z, PR #2 at bbbbbbb, against aaaaaaa\n\nRuling: same\n\nMid A, decided by:\n\n- Locality: `bin/a.py:3` `f`: hard\n\nMid A, hardest first:\n\n- `bin/d.py:2` `m`: deep\n" - ruled = paired("2026-10-10T12:00:00Z", "worse") + "\nMid A, decided by:\n\n- Locality: `bin/a.py:3` `f`: hard\n" + seats = [Seat("Mid A", "", ["Locality, Shape: `bin/a.py:3` `f`: held at once", "Navigation: `README.md:4` \"Tools\": easier to find"]), Seat("Inherited architect", "", ["Locality: `bin/d.py:2` `m`: deep"])] + said = {"Mid A": ["better", "same", "worse", "same", "worse"], "Inherited architect": ["same", "worse", "same", "same", "worse"]} + ruled = ruling_entry("2026-10-10T12:00:00Z, PR #2 at bbbbbbb, against aaaaaaa", seats, said, {**said, "Inherited architect": ["same"] * 5}, "same") + older = paired("2026-10-07T12:00:00Z", "worse") + "\n| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |\n|---|---|---|---|---|---|\n| Mid A | same | worse | same | same | worse |\n\nMid A, decided by:\n\n- Locality: `bin/e.py:1` `n`: old\n" self.assertIsNone(latest_places("")) - self.assertIsNone(latest_places(appended("", ruled))) - self.assertEqual(latest_places(appended(appended("", scored), ruled)), "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\nJunior A, hardest first:\n\n- `bin/b.py:4` `h`: long\n and wrapped\n\nInherited architect, would restructure first:\n\n- `bin/c.py:1` `k`: tangled\n") - self.assertEqual(latest_places(appended(appended(appended("", ruled), fell), scored)), "## 2026-10-09T12:00:00Z, PR #2 at bbbbbbb, against aaaaaaa\n\nMid A, hardest first:\n\n- `bin/d.py:2` `m`: deep\n") + self.assertIsNone(latest_places(appended("", paired("2026-10-07T12:00:00Z", "same")))) + hard_since = "## 2026-10-10T12:00:00Z, PR #2 at bbbbbbb, against aaaaaaa\n\nMid A, decided by:\n\n- Locality, Shape: `bin/a.py:3` `f`: held at once\n" + self.assertEqual(latest_places(appended(appended(appended("", older), ruled), scored)), "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\nJunior A, hardest first:\n\n- `bin/b.py:4` `h`: long\n and wrapped\n\nInherited architect, would restructure first:\n\n- `bin/c.py:1` `k`: tangled\n\n" + hard_since) + self.assertEqual(latest_places(appended(appended("", ruled), older)), "## 2026-10-07T12:00:00Z, PR #2 at bbbbbbb, against aaaaaaa\n\nMid A, decided by:\n\n- Locality: `bin/e.py:1` `n`: old\n\n" + hard_since) class Base(unittest.TestCase): - def test_takes_the_newest_change_adding_a_scoring_run_or_ending_on_a_better_ruling(self): + def test_takes_the_newest_change_adding_an_entry(self): older = HistoryChange("old", "", SCORING) same = HistoryChange("same", SCORING, SCORING + paired("2026-10-08T13:00:00Z", "same")) - self.assertEqual(measured_commit([same, older]), "old") - # The file holds the later ruling first, as a merge conflict resolved the other way would. - better = HistoryChange("better", SCORING, SCORING + paired("2026-10-08T14:00:00Z", "better") + paired("2026-10-08T13:00:00Z", "worse")) - self.assertEqual(measured_commit([better, older]), "better") - worse_last = HistoryChange("worse", SCORING, SCORING + paired("2026-10-08T13:00:00Z", "better") + paired("2026-10-08T14:00:00Z", "worse")) - self.assertEqual(measured_commit([worse_last, older]), "old") - self.assertIsNone(measured_commit([same])) - scored_fall = HistoryChange("same fell", SCORING, SCORING + paired("2026-10-08T13:00:00Z", "same\n\nFell: Locality, each at or above the floor.\n\n| Seat | Overall |\n|---|---|\n| Mean | 7.00 |")) - self.assertEqual(measured_commit([scored_fall, older]), "old") - - def test_falls_back_to_the_first_rulings_base_then_to_none(self): - ruled = paired("2026-10-08T13:00:00Z", "worse") - self.assertEqual(base([HistoryChange("c", "", ruled)], ruled), ("aaaaaaa", "the base the history's first paired ruling names")) - self.assertIsNone(base([], "")) - self.assertEqual(base([HistoryChange("c", "", SCORING)], SCORING), ("c", "the last measured commit")) - - def test_finds_the_earliest_ruling_by_its_time(self): - ruled = first_ruling(paired("2026-10-08T14:00:00Z", "same", "ccccccc") + paired("2026-10-08T13:00:00Z", "worse")) - self.assertEqual(ruled and ruled.commit, "bbbbbbb") - self.assertIsNone(first_ruling(SCORING)) + self.assertEqual(measured_commit([same, older]), "same") + worse = HistoryChange("worse", SCORING, SCORING + paired("2026-10-08T14:00:00Z", "worse")) + self.assertEqual(measured_commit([worse, older]), "worse") + self.assertEqual(measured_commit([HistoryChange("none", SCORING, SCORING + "\nAn edit outside any entry.\n"), older]), "old") + self.assertIsNone(measured_commit([HistoryChange("none", SCORING, SCORING)])) class ScoringRunDue(unittest.TestCase): @@ -233,7 +221,7 @@ class LarvReviewTool(unittest.TestCase): path.write_text(textwrap.dedent(text)) return str(path) - def test_takes_the_merge_base_until_a_merged_change_records_a_scoring_run(self): + def test_takes_the_merge_base_until_a_merged_change_records_an_entry(self): start = self.git("rev-parse", "HEAD").strip() self.commit("work") ran = self.run_tool("ruling-base") @@ -310,6 +298,9 @@ class LarvReviewTool(unittest.TestCase): ran = self.run_tool("record-ruling", votes_file) self.assertEqual(ran.returncode, 0, ran.stderr) self.assertTrue(ran.stdout.startswith("Ruling: better. Overall votes as counted:")) + again = self.run_tool("record-ruling", votes_file) + self.assertEqual((again.returncode, again.stdout), (1, "")) + self.assertIn("already holds an entry on", again.stderr) self.assertEqual([entry.ruling for entry in entries((self.checkout / "docs" / "comprehension-history.md").read_text())], ["better"]) def test_records_a_scoring_run_with_its_means(self): @@ -333,6 +324,8 @@ class LarvReviewTool(unittest.TestCase): ran = self.run_tool("places") self.assertEqual((ran.returncode, ran.stdout), (0, "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\nJunior A, hardest first:\n\n- `bin/b.py:4` `h`: long\n"), ran.stderr) self.assertIn("unknown arguments", self.run_tool("places", "x").stderr) + outside = subprocess.run([sys.executable, str(TOOL), "places"], capture_output=True, cwd=self.checkout.parent, env=self.env, text=True) + self.assertEqual((outside.returncode, outside.stdout), (1, "")) def test_refuses_a_ruling_file_that_names_no_base_or_a_commit_the_checkout_lacks(self): ran = self.run_tool("record-ruling", self.seats_file(f"PR #2 at {self.start}\n\nMid A: {said('same')}\n\nInherited architect: {said('same')}\n")) diff --git a/bin/test_round_titles.py b/bin/test_round_titles.py index 1cb56861..0911ee33 100644 --- a/bin/test_round_titles.py +++ b/bin/test_round_titles.py @@ -9,7 +9,7 @@ from round_titles import lacks_counts, round_counts, round_findings class Rounds(unittest.TestCase): def test_counts_each_passs_highest_round(self): - counts = round_counts(["Answer prose round 1: x", "Answer full scan round 2: y", "Answer full scan round 1: z", "Answer stability: no round", "Answer stabilty round 1: typo", "Answer security round 1: rename round 2: x", "Rescore: w"]) + counts = round_counts(["Answer prose round 1: x", "Answer full scan round 2: y", "Answer full scan round 1: z", "Answer stability: no round", "Answer stabilty round 1: typo", "Answer security round 1: rename round 2: x", "Record the comprehension check: w"]) self.assertEqual((counts["prose"], counts["full scan"], counts["stability"], counts["architecture"], counts["stabilty"], counts["security"]), (1, 2, 0, 0, 1, 1)) def test_counts_a_mis_cased_title_under_its_pass(self): diff --git a/docs/comprehension-history.md b/docs/comprehension-history.md index ea51b828..ed372f1c 100644 --- a/docs/comprehension-history.md +++ b/docs/comprehension-history.md @@ -1510,3 +1510,29 @@ Inherited architect, decided by: - Locality: `bin/loop_claude/project/records.py:10` `HUMAN_RULE_DIRS`: the judge reads every file in two folders, shrinking the transcript it sees - Locality: `bin/loop_claude/cycle/judge.py:41` `JUDGE_RULES`: the judge's rule text is built across three files - Locality: `bin/rule_hook/override_log.py:36` `this_chunks`: which overrides list depends on reflog, branch name and default-branch state + +## 2026-10-13T10:23:39Z, PR #255 at 459df0a, against 4cc9953 + +Ruling: better + +| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall | +|---|---|---|---|---|---| +| Mid A | same | better | same | same | better | +| Inherited architect | same | better | same | worse | better | + +Mid A, decided by: + +- Locality, Overall: `skills/larv-review/SKILL.md:99` "Comprehension check": the check is one self-contained subsection that runs once in §5 and blocks nothing; at 4cc9953 Ratchet, Floor, Fell, Fresh, Rescore and the round cap referred to each other +- Locality: `bin/larv_review/record.py:14` `record_ruling`: one straight path now; at 4cc9953 it branched four ways on a fall and a scores file, with `read_fall_scores`, `refuse_recorded` and `fall_ruling` to follow +- Locality: `bin/reading_cost/measure.py:43` `commit_time`: finds the worker's first commit through the shared `git_command.commits` parser rule-hook uses, in place of its own regex and tokenizer + +Inherited architect, decided by: + +- Locality, Overall: `skills/larv-review/SKILL.md:99` "Comprehension check": runs once, blocks nothing, under its own heading; at 4cc9953 it forced cross-references into Round cap, Later rounds and No rerun +- Locality: `bin/larv_review/record.py:14` `record_ruling`: reads one votes file and appends one ruling; at 4cc9953 a two-call state machine with `Fell:` and a second file +- Locality: `bin/reading_cost/measure.py:43` `commit_time`: one parse of a command shared with rule-hook, in place of a regex and a separate lexer +- Self-sufficiency: `bin/larv_review/ruling_base.py:7` `measured_commit`: the docstring still calls the base the ratchet's base and speaks of falls nothing in the code defines +- Self-sufficiency: `bin/comprehension_history.py:43` `Entry`: docstrings and the `places` help describe the scores a fall called into a ruling, which needs the project's history open to parse +- Self-sufficiency: `AGENTS.md:5` decision titles: one says a project under the floor is fixed at the lowest dimension, others that the check blocks nothing, so a reader cannot tell whether `Floor:` means stop +- Self-sufficiency: `skills/larv-review/standards/quality.md:6` quality bar: points at §3 "Architecture" for the comprehension check, which now has its own subsection +- Locality: `bin/rule_hook/override_log.py:118` `local_default_branch`: a second default-branch resolver beside `bin/git_repo.py:21` `default_branch`, neither naming the other diff --git a/docs/decisions.md b/docs/decisions.md index 642be9c4..eab0d2f7 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -1,6 +1,6 @@ # Decisions -## larv-review: a project under the comprehension floor is fixed at the lowest dimension +## larv-review: a project lifting itself to the comprehension floor starts at the lowest dimension 2026-09-20, lilleman. Serves goal 1. Across six projects scored with the four seats, Locality or Self-sufficiency was the lowest dimension at every seat and Navigation at none, so a layout fix would not lift a project under the floor. Valid while the scoring run keeps those four seats. @@ -58,7 +58,7 @@ 2026-10-08, lilleman. Serves goals 1.1 and 1.4. Two independent four-seat runs moved up to 0.4 on near-identical code, so a fall within that noise forced rounds that changed nothing (PR #224). A seat reading both versions judges the difference on the same material, so the noise the versions share cancels. No conventional significance level lets a sign test settle with four votes, so the human chose a lead of two votes over every other ruling, same included. Two seats that agree settle it, so a PR that leaves the reading as it was costs two seats. A third seat alone can never settle it, so the third and fourth launch together. The base is the default branch's newest merged change that adds a scoring run to the history, or whose last added paired ruling is better. The human chose the last measured commit on the architect's finding that with a merge base as the base, chunks without an architecture pass, and a suspended restructure's steps, could each lower comprehension unseen. A ruling of same leaves the base where it was, or a run of small falls each ruled same would add up unseen. A scoring run moves it too: otherwise a project never ruled better would compare against its first ruling forever, and a release's floor check is where the human sees the absolute level. Reading the default branch one merged change at a time keeps the rule working for merge commits and squash merges alike: a branch's own early ruling of better never counts, only the merged change's last ruling. The scoring run also runs on a chunk shipping an item that names the floor, so the chunk that lifts a project to the floor can prove it. A chunk that removes a release's last item without shipping it runs it too, so no release ends unmeasured. Valid while seats reading both versions agree more often than two absolute runs do. -2026-10-13, lilleman. No published study validates simulated reader panels as a measure of how easy code is to understand, and item 84's test of whether the panel's signal beats its noise has not run. So no ruling, score or floor blocks a merge, and the ratchet is gone. The runs go on, so the history keeps the scores and the places the seats found hard, for later measurement. The architect, the stability reviewer and a session filing an item read the newest places, since those places are what a chunk can improve. With nothing to block, the check runs once per chunk, on the commit to merge, in place of a run in each architecture round and a rescore after later commits. A fallen dimension no longer calls the four scoring seats either: their scores only decided the block. This replaces the 2026-10-09 rule that made a fall under the floor count as worse. +2026-10-13, lilleman. No published study validates simulated reader panels as a measure of how easy code is to understand, and item 84's test of whether the panel's signal beats its noise has not run. So no ruling, score or floor blocks a merge, and the ratchet is gone. The runs go on, so the history keeps the scores and the places the seats found hard, for later measurement. The architect, the stability reviewer and a session filing an item read the newest places, since those places are what a chunk can improve. With nothing to block, the check runs once per chunk, on the commit to merge, in place of a run in each architecture round and a rescore after later commits. A fallen dimension no longer calls the four scoring seats either: their scores only decided the block. This replaces the 2026-10-09 rule that made a fall under the floor count as worse. The base is now the newest merged change that adds any ruling or scoring run: with worse rulings merging, a base left behind them would charge one chunk's ruling with earlier chunks' falls. The newest places are the newest scoring run's and each later ruling's places a seat voted worse, so they change with each ruling. A chunk that leaves a touched place as hard says why in its PR summary, as item 99 asked, not in a decline's record, which would outlive the place. ## review: a project decision may suspend the comprehension check for the plan items it names @@ -82,7 +82,7 @@ ## review: an ask no user answers leaves the PR unmerged -2026-09-30, claude. Serves goal 1: the round cap, a BLOCK's restructure, Stage 0's questions and a goal conflict are the human's call, and an unmerged PR is what brings it to them; merging would make the call for them. Where an option reviews more — run the pass, fix under the floor, fix a finding no goal lets the run decline — the run takes it; a ❓, or a fix changing a goal or a decision, is filed in `todo.md`, which reaches the human without holding the chunk. Valid while a human reads every unmerged PR an unattended run leaves. +2026-09-30, claude. Serves goal 1: the round cap, a BLOCK's restructure, Stage 0's questions and a goal conflict are the human's call, and an unmerged PR is what brings it to them; merging would make the call for them. Where an option reviews more — run the pass, fix a finding no goal lets the run decline — the run takes it; a ❓, or a fix changing a goal or a decision, is filed in `todo.md`, which reaches the human without holding the chunk. Valid while a human reads every unmerged PR an unattended run leaves. ## loop-claude: every claude it starts bypasses permissions inside its sandbox diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 7f397a2f..bcee551a 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -98,19 +98,19 @@ Then the principles audit: one principles-auditor for the README's goals, and on ### Comprehension check -The comprehension check records how hard the project is to read, and blocks no merge. Simulated readers, the seats, launched per `~/.claude/skills/comprehension-panel/SKILL.md`, each read the whole project, not the diff. It reports no findings and is no pass: it runs once, in §5, after every pass is done, the auto-reviewer included, so it reads the commit to merge. It runs a paired ruling where the architecture pass ran, and a scoring run where one is due. +The comprehension check records how hard the project is to read, and blocks no merge. Simulated readers, the seats, launched per `~/.claude/skills/comprehension-panel/SKILL.md`, each read the whole project, not the diff. It reports no findings and is no pass: it runs once, in §5, after every pass is done, the auto-reviewer included, so it reads the commit to merge. It runs a paired ruling where the architecture pass ran, the principles audit alone included, and a scoring run where one is due. **Paired ruling.** Each seat votes whether the project reads better, the same or worse at this branch's head than at the base. - **Base.** The last measured commit, which `~/.claude/bin/larv-review ruling-base` prints. -- **Head.** Before the ruling, merge `origin/` into this branch unless the head already holds it, so the seats see only this branch's change on top of the base. +- **Head.** The head holds `origin/`, merged in at §4 step 1, so the seats see only this branch's change on top of the base. - **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. **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`. Junior A, Mid A, the maintainability senior and the inherited architect each score the project at the head from 1 to 10 overall and on four dimensions: Navigation, Locality, Shape and Self-sufficiency. Write their lines into a scores file and run `~/.claude/bin/larv-review record-scoring `, which appends the run to the history and prints the four seats' means. -**Record.** `docs/comprehension-history.md` keeps every paired ruling and scoring run, which `larv-review` appends; never edit one. Commit what it appends in one commit titled `Record the comprehension check: …`, push it, and wait for the forge's checks (§4 step 3), not for an auto-review; it re-enters no pass. Resolve a merge conflict in the file by putting the default branch's entries first. Put each ruling with its base and votes, and each run's five scores, in the summary. +**Record.** `docs/comprehension-history.md` keeps every paired ruling and scoring run, which `larv-review` appends; never edit one. Commit what it appends in one commit titled `Record the comprehension check: …`, push it, and wait for the forge's checks (§4 step 4), not for an auto-review; it re-enters no pass. Resolve a merge conflict in the file by putting the default branch's entries first. Put each ruling with its base and votes, and each run's five scores, in the summary. -**Places.** Give systems-architect and stability-reviewer what `~/.claude/bin/larv-review places` prints: the places the newest scoring seats found hard. Ask each to report, as a 🟡, each of those places the change touches without making it easier to read. Fix such a 🟡, or say in the PR summary why not; that reason settles it in place of a decline's record. +**Places.** Give systems-architect and stability-reviewer what `~/.claude/bin/larv-review places` prints: the places seats found hard since the newest scoring run. Ask each to report, as a 🟡, each of those places the change touches without making it easier to read, matching a place by its path and unit, since its line may have moved. Fix such a 🟡, or say in the PR summary why not; that reason settles it in place of a decline's record. **Suspended.** A decision in the project's `docs/decisions.md`, held before the chunk began, may name plan items to ship without a comprehension check. A named item counts as `todo.md` worded it before the chunk began. The decision must name the later plan item whose chunk ends the suspension with a comprehension check. A chunk may ship named items only with each other. Such a chunk skips the comprehension check, and its summary cites the decision. A chunk due a scoring run runs it, even when every item it ships is named. @@ -138,12 +138,13 @@ Launch prose-reviewer with what the diff touched and every section this review c ## 4. Gate -1. Run `~/.claude/bin/rank_todo.py --check todo.md`; a failure is a finding. -2. Run the project's test suite locally unless the last stability round already left it verified green. -3. Watch the forge's checks until every one passes. A red check is a finding. -4. No CI configured → the gate is local tests only; note it in the summary. -5. Everything green → mark the PR ready, dropping any `WIP:`/`Draft:` title prefix. -6. **External auto-reviewer**, when the repo has one — its config file (`.coderabbit.yaml` and the like), or its comments on earlier PRs; none → skip it, say so. Marking the PR ready is what summons it. Wait up to **10 minutes** for its first review, checking about once a minute; nothing by then → note it in the summary and carry on, never waiting twice. Its rounds, §3 → "Round cap". Once it has reviewed, each later return here, after a fix re-entered per §3, waits up to **5 minutes** for its re-review of the new commit. +1. Merge `origin/` into this branch unless the head already holds it. +2. Run `~/.claude/bin/rank_todo.py --check todo.md`; a failure is a finding. +3. Run the project's test suite locally unless the last stability round, or a later run, left the head verified green. +4. Watch the forge's checks until every one passes. A red check is a finding. +5. No CI configured → the gate is local tests only; note it in the summary. +6. Everything green → mark the PR ready, dropping any `WIP:`/`Draft:` title prefix. +7. **External auto-reviewer**, when the repo has one — its config file (`.coderabbit.yaml` and the like), or its comments on earlier PRs; none → skip it, say so. Marking the PR ready is what summons it. Wait up to **10 minutes** for its first review, checking about once a minute; nothing by then → note it in the summary and carry on, never waiting twice. Its rounds, §3 → "Round cap". Once it has reviewed, each later return here, after a fix re-entered per §3, waits up to **5 minutes** for its re-review of the new commit. ## 5. Goal alignment, then merge diff --git a/skills/larv-review/standards/quality.md b/skills/larv-review/standards/quality.md index fc2141c0..481b7f44 100644 --- a/skills/larv-review/standards/quality.md +++ b/skills/larv-review/standards/quality.md @@ -3,7 +3,7 @@ Quality is proven by review. Every change is reviewed as a diff. The whole project is measured when a change carries an architectural decision, and before each release, because a project can drift from the principles one clean diff at a time. `SKILL.md` §3 says which review runs when. Quality has three parts. When two pull against each other, the earlier one wins. 1. **Correct.** The work does what the goals and the plan say, and tests prove it. -2. **True to the technical principles** (`~/.claude/principles/technical-principles.md`). The comprehension check (`SKILL.md` §3 → "Architecture") measures KISS. +2. **True to the technical principles** (`~/.claude/principles/technical-principles.md`). The comprehension check (`SKILL.md` §3 → "Comprehension check") measures KISS. 3. **Plainly written**, per `prose.md`. ## A false claim is a bug diff --git a/todo.md b/todo.md index 0ca99280..7f8ac57f 100644 --- a/todo.md +++ b/todo.md @@ -187,7 +187,7 @@ Raised by the principles audit of PR #224. The `settings.json` decision is valid Raised by the principles audit of PR #215 against KISS, in `principles/technical-principles.md`, and goal 1.1. 2026-10-13: the floor blocks nothing now, so the item is scored by its value instead of kept as a defect. -PR #234's last scoring run, at b2a277b, put Locality and Self-sufficiency at 6.50 and the overall at 6.75. Every seat named larv-review's rules, which cannot be followed without `skills/larv-review/SKILL.md` §3 open beside the code: "Round cap", "Re-entry", "Fresh" and "Suspended" point at each other; `bin/larv_review/record.py` `record_ruling` branches on split, worse, fell and a scores file, with its terms defined only in `larv-review --help` and the skill; the pass list lives in both `bin/round_titles.py` `PASSES` and the skill's table, which also counts the auto-reviewer; `bin/comprehension_history.py` is reader, writer and seat registry in one, and parses the history by regex for two tools. Also named: the judge's prompt assembled from `cycle/judge.py`, `cycle/prompts.py` and `project/records.py`; git run four ways, in `bin/larv_review/git.py`, `bin/metric_bench/main.py`, `bin/reading_cost/main.py` and `bin/loop_claude/effects.py`; `SeatsFile.read`, a field named like a method. +PR #234's last scoring run, at b2a277b, put Locality and Self-sufficiency at 6.50 and the overall at 6.75. Every seat named larv-review's rules, which cannot be followed without `skills/larv-review/SKILL.md` §3 open beside the code: "Round cap", "Re-entry", "Fresh" and "Suspended" pointed at each other until PR #255; `bin/larv_review/record.py` `record_ruling` branched on split, worse, fell and a scores file, with its terms defined only in `larv-review --help` and the skill; the pass list lives in both `bin/round_titles.py` `PASSES` and the skill's table, which also counts the auto-reviewer; `bin/comprehension_history.py` is reader, writer and seat registry in one, and parses the history by regex for two tools. Also named: the judge's prompt assembled from `cycle/judge.py`, `cycle/prompts.py` and `project/records.py`; git run four ways, in `bin/larv_review/git.py`, `bin/metric_bench/main.py`, `bin/reading_cost/main.py` and `bin/loop_claude/effects.py`; `SeatsFile.read`, a field named like a method. ### 5. Key a project on its checkout's full path, and refuse to start while another session uses that key. @@ -213,7 +213,7 @@ KISS, in `principles/technical-principles.md`, which keeps a limit only while re ### 101. Have `larv_review/record.py`'s `read_seats` take the time, the commit check and the history as inputs, so it parses and decides without effects. -Found by the principles audit of PR #242, against "Functional core, imperative shell" (`principles/technical-principles.md`). `bin/larv_review/record.py:94` reads `time.time()`, then checks git (`:97`, `commit_exists`) and the history file (`:100`) inside the function that parses the seats file and decides. A test cannot fix the heading's time, and every test of `read_seats` touches the real checkout. +Found by the principles audit of PR #242, against "Functional core, imperative shell" (`principles/technical-principles.md`). `bin/larv_review/record.py:67` reads `time.time()`, then checks git (`:70`, `commit_exists`) and the history file (`:75`) inside the function that parses the seats file and decides. A test cannot fix the heading's time, and every test of `read_seats` touches the real checkout. ### 29. Make the contributor a standing member of every project's audience, unless its `## Audience` says maintainability does not matter.