From 75b0e463266edf104736860840006a28a5961c28 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 9 Oct 2026 10:58:59 +0200 Subject: [PATCH] Answer architecture round 1: count a dimension's vote only where a place names it, take a fall on a same ruling too, block a fall-called run only on the fallen dimensions, read the chunk's own entries, and repeat a standing ratchet --- AGENTS.md | 2 +- CHANGELOG.md | 4 +- bin/larv_review/history.py | 11 ++++-- bin/larv_review/main.py | 71 +++++++++++++++++++++-------------- bin/larv_review/rules.py | 38 +++++++++++++------ bin/test_larv_review.py | 47 ++++++++++++++++------- docs/comprehension-history.md | 33 ++++++++++++++++ docs/decisions.md | 4 +- skills/larv-review/SKILL.md | 10 ++--- 9 files changed, 154 insertions(+), 66 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 4072baca..041b9c52 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,7 +12,7 @@ Decisions live in `docs/decisions.md`: - loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes - review: a pass gets at most three rounds per chunk; instead of a fourth, the run asks the human - review: a fix for a ๐Ÿ”ด or ๐ŸŸก reruns the pass that found it and each pass whose trigger names fixes like it; a fix for a ๐ŸŸข, a โ“ or a prose finding reruns none -- review: a paired ruling against the last measured commit decides the ratchet, and counts as worse when a dimension it rules fallen is under the floor; the four-seat scoring run checks the floor when a release's items run out, an item names the floor or a better ruling names a fallen dimension +- review: a paired ruling against the last measured commit decides the ratchet, and counts as worse when a dimension it rules fallen is under the floor; the four-seat scoring run checks the floor when a release's items run out, an item names the floor or a ruling names a fallen dimension - review: a project decision may suspend the comprehension check for the plan items it names - review: a pass skips only on a precedent: a decision, or a plan item crediting the pass, that the repo held before the chunk began - loop-claude: the archive keeps the raw transcript, and a failed archive stops the loop diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ef8f130..39b0d0c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,10 @@ ## Unreleased -- larv-review's paired ruling takes each seat's vote on each dimension too: `Navigation same, Locality worse, Shape same, Self-sufficiency same, Overall better`. A better ruling in which a dimension fell calls a scoring run, and counts as worse, blocking the merge, when that dimension's mean is under the floor. +- larv-review's paired ruling takes each seat's vote on each dimension too: `Navigation same, Locality worse, Shape same, Self-sufficiency same, Overall better`. A better or same ruling in which a dimension fell calls a scoring run, and counts as worse, blocking the merge, when that dimension's mean is under the floor. A dimension's vote counts only where the seat names a place under that dimension. - 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`), the scoring run's trigger (`needs-scoring-run ...`), and the vote count, means and history format (`record-ruling` and `record-scoring`, which read a seats file and append to `docs/comprehension-history.md`). 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. Scores a `comprehension floor:` decision entry still holds move into the history through `record-scoring`, as a `Mean:` line. 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 blocks a merge when simulated readers rule that the PR makes the project read worse than 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. A ruling of same leaves that commit in place, so a worse ruling may name places earlier chunks wrote. In each architecture pass Mid A and the inherited architect vote better, same or worse; when they disagree, the maintainability senior and Junior A vote too. A ruling needs a lead of two or more votes, else it is same, and a vote that names no place counts as same. A worse ruling never ships: after three rounds larv-review asks you for another round, a no leaves the PR unmerged, and so does an unattended run. The four-seat scoring run checks the comprehension floor only when a chunk ships or removes a release's last plan item, or ships an item naming the floor; between those runs the floor blocks nothing. A score under the floor blocks the merge until fixed or until you decide to ship; a decision in `docs/decisions.md` that lets every chunk ship under the floor counts as yours. +- larv-review blocks a merge when simulated readers rule that the PR makes the project read worse than 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. A ruling of same leaves that commit in place, so a worse ruling may name places earlier chunks wrote. In each architecture pass Mid A and the inherited architect vote better, same or worse; when they disagree, the maintainability senior and Junior A vote too. A ruling needs a lead of two or more votes, else it is same, and a vote that names no place counts as same. A worse ruling never ships: after three rounds larv-review asks you for another round, a no leaves the PR unmerged, and so does an unattended run. The four-seat scoring run checks the comprehension floor only when a chunk ships or removes a release's last plan item, or ships an item naming the floor; between those runs the floor blocks only a dimension a paired ruling finds fallen. A score under the floor blocks the merge until fixed or until you decide to ship; a decision in `docs/decisions.md` that lets every chunk ship under the floor counts as yours. - 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. diff --git a/bin/larv_review/history.py b/bin/larv_review/history.py index f5258f77..b3ac3c47 100644 --- a/bin/larv_review/history.py +++ b/bin/larv_review/history.py @@ -9,6 +9,7 @@ from markdown_sections import sections DATED = re.compile(r"^[0-9]{4}-[0-9]{2}-[0-9]{2}(?:T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)?, ") DECIDED_BY = "decided by" FELL = re.compile(r"^Fell: (.+)$", re.M) +RATCHET = re.compile(r"^Ratchet: .+$", re.M) HARDEST_FIRST = "hardest first" HEADING = re.compile(r"^([^,]+), (.+) at ([0-9a-f]{7,40})(?:, against ([0-9a-f]{7,40}))?$") # `path:line` or `:line`, then the unit's name where one follows. @@ -28,13 +29,14 @@ class Place: @dataclasses.dataclass(frozen=True) class Entry: - """One paired ruling, which names the commit it was against, its ruling and the dimensions that fell when it is better, or one scoring run, which names none of them.""" + """One paired ruling, which names the commit it was against, its ruling and the dimensions that fell unless it is worse, or one scoring run, which names none of them and may hold a `Ratchet:` line.""" heading: str time: str commit: str against: str | None ruling: str | None fell: list[str] + ratchet: str | None places: list[Place] @property @@ -65,7 +67,8 @@ def entries(history: str) -> list[Entry]: body = "\n".join(bodies) ruling = RULING.search(body) fell = FELL.search(body) - found.append(Entry(heading, named.group(1), named.group(3), named.group(4), ruling.group(1) if ruling else None, fell.group(1).split(", ") if fell else [], seat_places(body))) + ratchet = RATCHET.search(body) + found.append(Entry(heading, named.group(1), named.group(3), named.group(4), ruling.group(1) if ruling else None, [name.strip() for name in fell.group(1).split(",")] if fell else [], ratchet.group(0) if ratchet else None, seat_places(body))) return found @@ -112,9 +115,9 @@ def appended(history: str, entry: str) -> str: def ruling_entry(title: str, seats: list[Seat], said: dict[str, list[str]], counted: dict[str, list[str]], ruled: str, fell: list[str]) -> str: - """A paired ruling's entry, with a `Fell:` line when it is better and fell names dimensions; a seat's vote that counted as same for naming no place says so.""" + """A paired ruling's entry, with a `Fell:` line when it is better or same and fell names dimensions; a seat's vote that counted as same for naming no place says so.""" votes = [[seat.name, *map(vote_text, said[seat.name], counted[seat.name])] for seat in seats] - lines = [f"Ruling: {ruled}"] + ([f"Fell: {', '.join(fell)}"] if ruled == "better" and fell else []) + lines = [f"Ruling: {ruled}"] + ([f"Fell: {', '.join(fell)}"] if ruled != "worse" and fell else []) return entry_text(title, lines, [["Seat", *DIMENSIONS], *votes], [(f"{seat.name}, {DECIDED_BY}:", seat.places) for seat in seats]) diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index 970832fa..f6822e06 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -2,10 +2,10 @@ usage: larv-review ruling-base | round-count | needs-scoring-run [...] | record-ruling | record-scoring -Run it inside a project checkout or one of its worktrees. ruling-base, round-count and -needs-scoring-run first fetch origin, when the checkout has that remote, and take 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 two exit 1. The history is +Run it inside a project checkout or one of its worktrees. Each command but record-ruling 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 and record-scoring +read origin as last fetched and say so on stderr; the other two 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 @@ -20,8 +20,8 @@ cap of {cap} rounds, and each name in such a title that is not a pass. needs-scoring-run takes the IDs of the todo.md items the chunk ships, none when it ships none, and prints why the chunk is due a scoring run, or `No scoring run due.` It is due when the chunk ships -an item whose tagline names the comprehension floor, when the checkout's history ends on a better -paired ruling with a `Fell:` line, or when it leaves a release with no item in +an item whose tagline names the comprehension floor, when the checkout's history ends on a paired +ruling with a `Fell:` line, or when it leaves a release with no item in the checkout's todo.md, less the shipped items, and work has landed towards that release. Work has landed when the chunk ships one of the release's items, or when the release is the earliest the default branch's todo.md names and the default branch has a commit after its newest v* tag, or has @@ -44,12 +44,13 @@ opens with its label, written exactly: `Junior A:`, `Mid A:`, `Maintainability s - `bin/x.py:12` `run`: ... record-ruling takes Mid A's and the inherited architect's votes on each dimension and overall, -each better, same or worse. Each vote of a seat naming no place in backticks, `path:line`, counts -as same, and the printed votes say so. When the two counted overall votes differ, it appends +each better, same or worse. A dimension's vote counts as same unless one of the seat's places in +backticks, `path:line`, names that dimension; the overall vote counts as same unless the seat names +any place. The printed votes say so. When the two counted overall votes differ, it appends nothing and prints `Split:`, saying to add the maintainability senior's and Junior A's lines. Otherwise the ruling is the overall vote that leads each other vote by two or more, else same; it prints `Ruling:` and appends the ruling. A dimension falls when its worse votes lead each other -vote by two or more. On a better ruling, it prints and records a `Fell:` line naming each. +vote by two or more. Unless the ruling is worse, it prints and records a `Fell:` line naming each. record-scoring takes Junior A's, Mid A's, the maintainability senior's and the inherited architect's lines in that order, or a `Mean:` line alone for a run moved from a decision entry. @@ -57,8 +58,10 @@ Each line is `Navigation , Locality , Shape , Self-sufficiency , Ove score from 1 to 10 and the overall at most 1 above the line's lowest dimension. Its first line names no `, against`. It appends the seats' scores and their means, rounded half up to two decimals, and prints the means and each one under the floor of {floor}. When the history ends on a -better paired ruling with a `Fell:` line, it says whether the ruling stands; when a dimension that -fell is under the floor, the ruling counts as worse, and it prints and records a `Ratchet:` line. +paired ruling with a `Fell:` line, it says whether the ruling stands; when a dimension that fell is +under the floor, the ruling counts as worse, and it prints and records a `Ratchet:` line, which +needs-scoring-run repeats until a paired ruling follows it. Both read only the entries the default +branch's history lacks. 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. A file holding a `Mean:` line alone opens with the date or @@ -75,8 +78,8 @@ import sys import time import typing -from larv_review.history import appended, heading, ruling_entry, scoring_entry, vote_text -from larv_review.rules import base, CAP, counted, fallen, fell_under_floor, FLOOR, means, PASSES, pending_fall, plan_items, round_counts, ruling, scoring_run_due, under_floor, votes +from larv_review.history import appended, Entry, heading, ruling_entry, scoring_entry, vote_text +from larv_review.rules import base, CAP, chunk_entries, counted, fall_outcome, fallen, FLOOR, means, PASSES, pending_fall, plan_items, round_counts, ruling, scoring_run_due, standing_ratchet, under_floor, votes from larv_review.git import commit_exists, default_branch, file_at, git, HISTORY, history_changes, landed_since_release, top from larv_review.seats import DIMENSIONS, MEAN, Report, report, score_line, scores from failure import Failure @@ -100,7 +103,7 @@ def main(argv: list[str]) -> int: elif command == "record-ruling" and len(given) == 1: done = record_ruling(pathlib.Path(given[0])) elif command == "record-scoring" and len(given) == 1: - done = record_scoring(pathlib.Path(given[0])) + done = with_default_branch(lambda default: record_scoring(default, pathlib.Path(given[0])), stale_ok=True) elif command == "needs-scoring-run": print(f"needs-scoring-run takes item IDs, the numbers in todo.md's ID column: {' '.join(given)}", file=sys.stderr) return 1 @@ -173,16 +176,29 @@ def needs_scoring_run(default: str, ids: list[int]) -> Failure | None: landed = landed_since_release(default) if isinstance(landed, Failure): return landed - history = history_text() - if isinstance(history, Failure): - return history - reasons = scoring_run_due(planned, chunk, ids, landed, pending_fall(history[1])) + recorded = chunk_history(default) + if isinstance(recorded, Failure): + return recorded + reasons = scoring_run_due(planned, chunk, ids, landed, pending_fall(recorded)) if isinstance(reasons, Failure): return reasons print(f"Scoring run due: the chunk {' and '.join(reasons)}." if reasons else "No scoring run due.") + if ratchet := standing_ratchet(recorded): + print(f"Still standing: {ratchet} Fix it and rule again.") return None +def chunk_history(default: str) -> list[Entry] | Failure: + """The entries the checkout's history holds and the default branch's lacks.""" + held = file_at(default, HISTORY) + if isinstance(held, Failure): + return held + read = history_text() + if isinstance(read, Failure): + return read + return chunk_entries(held, read[1]) + + def record_ruling(seats_file: pathlib.Path) -> Failure | None: read = read_seats(seats_file, paired=True) if isinstance(read, Failure): @@ -199,12 +215,12 @@ def record_ruling(seats_file: pathlib.Path) -> Failure | None: return None fell = fallen(count) print(f"Ruling: {ruled}. Overall votes as counted: {tally}.") - if ruled == "better" and fell: + if ruled != "worse" and fell: print(f"Fell: {', '.join(fell)}. A scoring run is due; the ruling counts as worse if it puts {' or '.join(fell)} under the floor of {FLOOR}.") return append(ruling_entry(title, given.seats, said, count, ruled, fell)) -def record_scoring(seats_file: pathlib.Path) -> Failure | None: +def record_scoring(default: str, seats_file: pathlib.Path) -> Failure | None: read = read_seats(seats_file, paired=False) if isinstance(read, Failure): return read @@ -218,14 +234,13 @@ def record_scoring(seats_file: pathlib.Path) -> Failure | None: mean = means(list(found.values()) or [moved]) under = under_floor(mean) print(f"Means: {', '.join(f'{name} {value}' for name, value in zip(DIMENSIONS, mean))}. {f'Under the floor of {FLOOR}: ' + ', '.join(under) if under else f'None under the floor of {FLOOR}'}.") - history = history_text() - if isinstance(history, Failure): - return history - fell = [] if given.moved_mean else pending_fall(history[1]) - ratchet = [f"Ratchet: the paired ruling counts as worse, as {', '.join(dropped)} fell under the floor of {FLOOR}."] if (dropped := fell_under_floor(fell, mean)) else [] - if fell: - print(ratchet[0] if ratchet else f"The better paired ruling stands: {', '.join(fell)} fell and stays at or above the floor of {FLOOR}.") - return append(scoring_entry(title, given.seats, found, [str(value) for value in mean], ratchet)) + recorded = chunk_history(default) + if isinstance(recorded, Failure): + return recorded + outcome = fall_outcome([] if given.moved_mean else pending_fall(recorded), mean) + if outcome: + print(outcome[0]) + return append(scoring_entry(title, given.seats, found, [str(value) for value in mean], outcome[1] if outcome else [])) def read_seats(seats_file: pathlib.Path, paired: bool) -> tuple[str, Report] | Failure: diff --git a/bin/larv_review/rules.py b/bin/larv_review/rules.py index d02bf4e7..cefcb28a 100644 --- a/bin/larv_review/rules.py +++ b/bin/larv_review/rules.py @@ -31,12 +31,12 @@ def votes(seats: list[Seat]) -> dict[str, list[str]] | Failure: def counted(seats: list[Seat], said: dict[str, list[str]]) -> dict[str, list[str]]: - """Each seat's votes as they count: a seat naming no `path:line` place counts as same on each.""" - return {seat.name: said[seat.name] if names_a_place(seat) else ["same"] * len(DIMENSIONS) for seat in seats} + """Each seat's votes as they count: a dimension's vote counts as same unless one of the seat's `path:line` places names that dimension, and the overall vote unless the seat names any place.""" + return {seat.name: [vote if names_a_place(seat, name) else "same" for name, vote in zip(DIMENSIONS, said[seat.name])] for seat in seats} -def names_a_place(seat: Seat) -> bool: - return any(PLACE.search(place) for place in seat.places) +def names_a_place(seat: Seat, dimension: str) -> bool: + return any(PLACE.search(place) and (dimension == DIMENSIONS[-1] or dimension.lower() in place.lower()) for place in seat.places) def ruling(counted: list[str]) -> str | None: @@ -54,14 +54,30 @@ def fallen(counted: dict[str, list[str]]) -> list[str]: return [name for name, column in zip(DIMENSIONS[:-1], zip(*counted.values())) if ruling(list(column)) == "worse"] -def pending_fall(history: str) -> list[str]: - """The dimensions that fell in the history's newest entry, when it is a better paired ruling, so no scoring run has followed it. Of entries with one time, the later in the file is newer.""" - newest = max(enumerate(entries(history)), key=lambda indexed: (indexed[1].time, indexed[0]), default=None) - return newest[1].fell if newest and newest[1].ruling == "better" else [] +def chunk_entries(default_history: str, history: str) -> list[Entry]: + """The checkout's entries whose headings the default branch's history lacks, oldest first; of entries with one time, the later in the file is newer.""" + held = {entry.heading for entry in entries(default_history)} + return sorted((entry for entry in entries(history) if entry.heading not in held), key=lambda entry: entry.time) -def fell_under_floor(fell: list[str], found: list[decimal.Decimal]) -> list[str]: - return [f"{name} {value}" for name, value in zip(DIMENSIONS, found) if name in fell and value < FLOOR] +def pending_fall(chunk: list[Entry]) -> list[str]: + """The dimensions that fell in the chunk's newest entry: a paired ruling no scoring run has followed yet.""" + return chunk[-1].fell if chunk else [] + + +def standing_ratchet(chunk: list[Entry]) -> str | None: + """The `Ratchet:` line of the chunk's newest entry, which no paired ruling has followed yet.""" + return chunk[-1].ratchet if chunk else None + + +def fall_outcome(fell: list[str], found: list[decimal.Decimal]) -> tuple[str, list[str]] | None: + """What a scoring run says of a pending fall, and the lines it records: a `Ratchet:` line when a fallen dimension's mean is under the floor.""" + if not fell: + return None + if dropped := [f"{name} is {value}" for name, value in zip(DIMENSIONS, found) if name in fell and value < FLOOR]: + line = f"Ratchet: the paired ruling counts as worse, as {' and '.join(fell)} fell and {', '.join(dropped)}, under the floor of {FLOOR}." + return line, [line] + return f"The paired ruling stands: {' and '.join(fell)} fell and stays at or above the floor of {FLOOR}.", [] def means(lines: list[list[str]]) -> list[decimal.Decimal]: @@ -133,7 +149,7 @@ def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], lan shipped = [plan[id_] for id_ in ships] reasons = [f"ships item {item.id}, which names the comprehension floor" for item in shipped if "comprehension floor" in item.tagline.lower()] if fell: - reasons.append(f"has a better paired ruling in which {' and '.join(fell)} fell") + reasons.append(f"has a paired ruling in which {' and '.join(fell)} fell") next_release = min((item.release for item in before), default=None) for release in emptied(before, after, shipped): if any(item.release == release for item in shipped) or (release == next_release and landed): diff --git a/bin/test_larv_review.py b/bin/test_larv_review.py index 83bad3b2..b62e64b6 100644 --- a/bin/test_larv_review.py +++ b/bin/test_larv_review.py @@ -10,7 +10,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) from larv_review.history import appended, entries, HistoryChange, Place, ruling_entry -from larv_review.rules import base, counted, fallen, fell_under_floor, first_ruling, means, measured_commit, pending_fall, plan_items, round_counts, ruling, scoring_run_due, under_floor, votes +from larv_review.rules import base, chunk_entries, counted, fall_outcome, fallen, first_ruling, means, measured_commit, pending_fall, plan_items, round_counts, ruling, scoring_run_due, standing_ratchet, under_floor, votes from failure import Failure from test_loop_claude_black_box import host_env from rank_todo import Item @@ -53,6 +53,10 @@ class Seats(unittest.TestCase): self.assertEqual(written, {"Mid A": ["same", "worse", "same", "same", "worse"], "Inherited architect": ["same", "same", "same", "same", "better"]}) self.assertEqual(counted(seats, written)["Mid A"], ["same"] * 5) + def test_counts_a_dimensions_vote_only_where_a_place_names_that_dimension(self): + seats = [Seat("Mid A", said("better", "worse"), ["`a.py:3` `f`: shorter"]), Seat("Inherited architect", said("better", "worse"), ["`a.py:3` `f`: locality, held at once"])] + self.assertEqual([votes[1:] for votes in counted(seats, {seat.name: [*said("better", "worse").replace(",", "").split()[1::2]] for seat in seats}).values()], [["same", "same", "same", "better"], ["worse", "same", "same", "better"]]) + def test_refuses_two_more_seats_once_the_first_two_agree_overall(self): seats = [Seat(name, said(vote), ["`f.py:1` `f`: x"]) for name, vote in (("Mid A", "worse"), ("Inherited architect", "worse"), ("Maintainability senior", "better"), ("Junior A", "better"))] self.assertIsInstance(votes(seats), Failure) @@ -69,7 +73,11 @@ class Seats(unittest.TestCase): four = {name: ["same", vote, "same", "same", "better"] for name, vote in (("Mid A", "worse"), ("Inherited architect", "same"), ("Maintainability senior", "worse"), ("Junior A", "worse"))} self.assertEqual(fallen(four), ["Locality"]) self.assertEqual(fallen({**four, "Junior A": ["same", "better", "same", "same", "better"]}), []) - self.assertEqual(fell_under_floor(["Locality", "Shape"], [decimal.Decimal(score) for score in ("6", "6.5", "7", "6", "6")]), ["Locality 6.5"]) + found = [decimal.Decimal(score) for score in ("6", "6.5", "7", "6", "6")] + ratchet = "Ratchet: the paired ruling counts as worse, as Locality and Shape fell and Locality is 6.5, under the floor of 7.0." + self.assertEqual(fall_outcome(["Locality", "Shape"], found), (ratchet, [ratchet])) + self.assertEqual(fall_outcome(["Shape"], found), ("The paired ruling stands: Shape fell and stays at or above the floor of 7.0.", [])) + self.assertIsNone(fall_outcome([], found)) def test_rules_by_a_lead_of_two_and_splits_two_seats_that_differ(self): cases = [ @@ -103,7 +111,7 @@ class Seats(unittest.TestCase): class History(unittest.TestCase): def test_reads_back_what_it_writes(self): - seats = [Seat("Mid A", "worse", ["`bin/a.py:3` `f`: hard, with `:9` `g`"]), Seat("Inherited architect", "worse", [])] + seats = [Seat("Mid A", said("better", "worse"), ["`bin/a.py:3` `f`: hard, with `:9` `g`"]), Seat("Inherited architect", said("worse", "worse"), [])] written = {"Mid A": ["same", "worse", "same", "same", "better"], "Inherited architect": ["same", "worse", "same", "same", "worse"]} ruled = ruling_entry("2026-10-08T18:37:21Z, PR #2 at bbbbbbb, against aaaaaaa", seats, written, {**written, "Inherited architect": ["same"] * 5}, "better", ["Locality"]) history = appended(appended("", SCORING), ruled) @@ -114,15 +122,23 @@ class History(unittest.TestCase): self.assertEqual([(entry.commit, entry.against, entry.ruling, entry.fell) for entry in found], [("aaaaaaa", None, None, []), ("bbbbbbb", "aaaaaaa", "better", ["Locality"])]) self.assertEqual(found[1].places, [Place("bin/a.py", "f"), Place("bin/a.py", "g")]) self.assertEqual([entry.paired for entry in found], [False, True]) + self.assertNotIn("Fell:", ruling_entry("2026-10-08T18:37:21Z, PR #2 at bbbbbbb, against aaaaaaa", seats, written, written, "worse", ["Locality"])) class PendingFall(unittest.TestCase): def test_finds_a_fall_in_the_newest_entry_when_it_is_a_better_ruling(self): - fell = paired("2026-10-08T13:00:00Z", "better\n\nFell: Locality, Shape") - self.assertEqual(pending_fall(SCORING + fell), ["Locality", "Shape"]) - self.assertEqual(pending_fall(fell + SCORING.replace("12:00:00Z", "14:00:00Z")), []) - self.assertEqual(pending_fall(SCORING + paired("2026-10-08T13:00:00Z", "better")), []) - self.assertEqual(pending_fall(""), []) + fell = paired("2026-10-08T13:00:00Z", "better\n\nFell: Locality,Shape") + self.assertEqual(pending_fall(chunk_entries("", SCORING + fell)), ["Locality", "Shape"]) + later = SCORING.replace("12:00:00Z", "14:00:00Z").replace("| Mean | 7.00 |", "Ratchet: worse.\n\n| Mean | 7.00 |") + self.assertEqual(pending_fall(chunk_entries("", fell + later)), []) + self.assertEqual(standing_ratchet(chunk_entries("", fell + later)), "Ratchet: worse.") + self.assertEqual(pending_fall(chunk_entries("", SCORING + paired("2026-10-08T13:00:00Z", "same\n\nFell: Locality"))), ["Locality"]) + self.assertEqual(pending_fall(chunk_entries("", "")), []) + + def test_reads_only_the_entries_the_default_branch_lacks(self): + fell = paired("2026-10-08T13:00:00Z", "better\n\nFell: Locality") + merged = SCORING.replace("12:00:00Z", "14:00:00Z").replace("PR #1", "PR #9") + self.assertEqual(pending_fall(chunk_entries(merged, fell + merged)), ["Locality"]) class Base(unittest.TestCase): @@ -183,7 +199,7 @@ class ScoringRunDue(unittest.TestCase): def test_is_due_when_a_better_ruling_hides_a_fall(self): plan = [item(1, (0, 1, 0)), item(2, (0, 1, 0))] - self.assertEqual(scoring_run_due(plan, plan, [], True, ["Locality"]), ["has a better paired ruling in which Locality fell"]) + self.assertEqual(scoring_run_due(plan, plan, [], True, ["Locality"]), ["has a paired ruling in which Locality fell"]) def test_is_not_due_when_a_later_release_loses_its_last_item_unshipped(self): before = [item(1, (0, 1, 0)), item(3, (0, 2, 0))] @@ -279,17 +295,22 @@ class LarvReviewTool(unittest.TestCase): self.assertIn("| Junior A | same | same | same | same | same (voted worse, naming no place) |", history.read_text()) def test_holds_a_better_ruling_that_hides_a_fall_until_a_scoring_run_decides_it(self): - place = "\n\n- `bin/a.py:3` `f`: shorter\n\n" + place = "\n\n- `bin/a.py:3` `f`: Locality, shorter\n\n" ran = self.run_tool("record-ruling", self.seats_file(f"PR #2 at {self.start}, against {self.start}\n\nMid A: {said('better', 'worse')}{place}Inherited architect: {said('better', 'worse')}{place}")) self.assertEqual(ran.returncode, 0, ran.stderr) self.assertIn("Fell: Locality. A scoring run is due", ran.stdout) - self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "Scoring run due: the chunk has a better paired ruling in which Locality fell.\n") + self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "Scoring run due: the chunk has a paired ruling in which Locality fell.\n") line = "Navigation 7, Locality 6.5, Shape 7, Self-sufficiency 7, Overall 7" seats = "".join(f"\n{seat}: {line}\n" for seat in ("Junior A", "Mid A", "Maintainability senior", "Inherited architect")) scored = self.run_tool("record-scoring", self.seats_file(f"PR #2 at {self.start}\n" + seats)) - self.assertIn("Ratchet: the paired ruling counts as worse, as Locality 6.50 fell under the floor of 7.0.", scored.stdout) + self.assertIn("Ratchet: the paired ruling counts as worse, as Locality fell and Locality is 6.50, under the floor of 7.0.", scored.stdout) + self.assertIn("\n\nRatchet: the paired ruling counts as worse", (self.checkout / "docs" / "comprehension-history.md").read_text()) - self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n") + self.assertTrue(self.run_tool("needs-scoring-run", "2").stdout.startswith("No scoring run due.\nStill standing: Ratchet:")) + same = self.run_tool("record-ruling", self.seats_file(f"PR #3 at {self.start}, against {self.start}\n\nMid A: {said('same', 'worse')}{place}Inherited architect: {said('same', 'worse')}{place}")) + self.assertIn("Fell: Locality.", same.stdout, same.stderr) + stands = self.run_tool("record-scoring", self.seats_file(f"PR #2 at {self.start}\n" + seats.replace("Locality 6.5", "Locality 7"))) + self.assertIn("The paired ruling stands: Locality fell and stays at or above the floor of 7.0.", stands.stdout) def test_records_a_scoring_run_with_its_means(self): line = "Navigation 7, Locality 6.5, Shape 7, Self-sufficiency 6.5, Overall 7" diff --git a/docs/comprehension-history.md b/docs/comprehension-history.md index 16424e25..c74868ce 100644 --- a/docs/comprehension-history.md +++ b/docs/comprehension-history.md @@ -528,3 +528,36 @@ Junior A, decided by: - `bin/larv_review/git.py:5` and `bin/metric_bench/main.py:38`: the git layer depends on the history type, and metric-bench on larv-review's package - `bin/larv_review/main.py:1` the module docstring: one home, but a wall of rules leaning on terms defined elsewhere - `bin/larv_review/rules.py:16` `votes`: a seat protocol reconstructed only from `skills/larv-review/SKILL.md:97` + +## 2026-10-09T08:54:36Z, PR #232 at 2c6e063, against 12d6d75 + +Ruling: better + +| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall | +|---|---|---|---|---|---| +| Mid A | better | same | same | better | better | +| Inherited architect | better | worse | same | better | better | + +Mid A, decided by: + +- `bin/larv_review/main.py:146` `round_count`: Navigation, better: the fourth-round symptom leads to a named unit, where the base had only `skills/larv-review/SKILL.md:58` "Count" +- `bin/larv_review/rules.py:42` `ruling`, `:52` `fallen` and `:128` `scoring_run_due`: Self-sufficiency, better: vote arithmetic and the scoring trigger are pure functions with docstrings, where the base had prose alone +- `README.md:68` "Tools": Navigation, better: the README names larv-review and metric-bench +- `bin/larv_review/main.py:1` the module docstring: Self-sufficiency, better, with a cost: Split, Fell, Ratchet and the moved Mean line arrive in long sentences +- `bin/larv_review/history.py:96` `heading`: Locality, against: two flags with DATED and HEADING, traced through `bin/larv_review/seats.py:38` `report` and `bin/larv_review/main.py:207` `record_scoring` +- `bin/larv_review/history.py:18` `SEAT_PLACES`, `:114` `ruling_entry` and `:125` `scoring_entry`: Locality, against: writers and parser must agree on label strings +- `bin/larv_review/rules.py:1` the module: Shape, against: one vague name over five concerns +- `bin/metric_bench/bench.py:87` `resolved` and `bin/metric_bench/main.py:38`: Shape and Locality, against: metric-bench depends on larv-review's history parser + +Inherited architect, decided by: + +- `bin/larv_review/main.py:146` `round_count`: Navigation: the 3am question lands on a function, where the base had `skills/larv-review/SKILL.md:58` "Count" +- `bin/larv_review/rules.py:89` `measured_commit` and `:105` `base`: Self-sufficiency: the ratchet's base is executable, where the base had `skills/larv-review/SKILL.md:100` +- `bin/larv_review/history.py:60` `entries`, `:114` `ruling_entry` and `:125` `scoring_entry`: Self-sufficiency and Navigation: the history's format is a regex plus writers, where the base had `skills/larv-review/SKILL.md:92` +- `bin/larv_review/main.py:207` `record_scoring`, with `bin/larv_review/seats.py:45` `report` and `bin/larv_review/history.py:96` `heading`: Locality: the moved Mean case threads through three modules +- `bin/larv_review/rules.py:57` `pending_fall`, called from `bin/larv_review/main.py:179` and `:224`: Locality: commands depend on state an earlier command appended to the history; `history[1]` hides it at the call site +- `bin/metric_bench/main.py:38` and `bin/metric_bench/bench.py:7`: Locality: metric-bench parses the history with larv-review's `entries`, and keeps its own `git()` at `bin/metric_bench/main.py:143` +- `bin/larv_review/rules.py:1` the module: Shape: a grab-bag name +- `bin/larv_review/git.py:56` `file_at` and `bin/larv_review/main.py:247` `history_text`: Locality: two histories, the default branch's and the checkout's +- `skills/larv-review/SKILL.md:97` "Seats": Self-sufficiency, against the skill: it needs the tool's help open beside it +- `bin/rank_todo.py:386` `parse_row`: Shape, a small gain diff --git a/docs/decisions.md b/docs/decisions.md index 15d88834..70a6ae1b 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -65,9 +65,9 @@ lilleman decided to ship each of these under the floor on the day listed. Each l 2026-10-08, lilleman, replacing the 2026-09-30 rule that every fix, a nit's included, re-enters review. Serves goal 1.4. An audit of the four costliest archived chunks (2026-10-08) found nearly every finding that mattered in a pass's first round; later rounds mostly re-checked the last fix, reworded what an earlier round wrote, or contradicted another round on the same line. A round 2 caught real bugs only where a fix changed behaviour, so stability still reruns on every fix that does, and security on every fix that opens an untrusted-input boundary or touches authn/authz, secrets or crypto. Valid while round-2 reviews of nit and prose fixes keep changing nothing a user would notice. -## review: a paired ruling against the last measured commit decides the ratchet, and counts as worse when a dimension it rules fallen is under the floor; the four-seat scoring run checks the floor when a release's items run out, an item names the floor or a better ruling names a fallen dimension +## review: a paired ruling against the last measured commit decides the ratchet, and counts as worse when a dimension it rules fallen is under the floor; the four-seat scoring run checks the floor when a release's items run out, an item names the floor or a ruling names a fallen dimension -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. 2026-10-09, lilleman: each seat also rules each dimension, and a dimension falls by the same lead of two. A better ruling naming a fallen dimension calls the scoring run, and counts as worse when that dimension's mean is under the floor, so between releases a project cannot trade one dimension below the floor for gains in the other three. Valid while seats reading both versions agree more often than two absolute runs do. +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. 2026-10-09, lilleman: each seat also rules each dimension, and a dimension falls by the same lead of two. A better or same ruling naming a fallen dimension calls the scoring run, and counts as worse when that dimension's mean is under the floor, so between releases a project cannot trade one dimension below the floor for gains in the other three. Such a run blocks on the fallen dimensions alone: the floor's own block stays with a release's end and an item naming the floor. A dimension's vote counts only where one of the seat's places names that dimension. Valid while seats reading both versions agree more often than two absolute runs do. ## review: a project decision may suspend the comprehension check for the plan items it names diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 8435329a..52e9d721 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -95,14 +95,14 @@ Then the comprehension check: simulated readers, launched per `~/.claude/skills/ - **Base.** The last measured commit, which `~/.claude/bin/larv-review ruling-base` prints. - **Head.** Before each 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. - **Seats.** Mid A and the inherited architect. Write what they read and their replies into a seats 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. -- **Ruling.** The `Ruling:` line `record-ruling` prints and appends to the history. A better ruling may carry a `Fell:` line naming dimensions the seats ruled worse; a scoring run then decides whether it stands. +- **Ruling.** The `Ruling:` line `record-ruling` prints and appends to the history. A better or same ruling may carry a `Fell:` line naming dimensions the seats ruled worse; a scoring run then decides whether it stands. -**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 seats file and run `~/.claude/bin/larv-review record-scoring `, which appends the run to the history and prints the four seats' means. +**Scoring run**, when `~/.claude/bin/larv-review needs-scoring-run ` prints `Scoring run due:`. Run `needs-scoring-run` after the paired ruling and 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 seats file and run `~/.claude/bin/larv-review record-scoring `, which appends the run to the history and prints the four seats' means. The chunk does not merge while either holds: -- **Ratchet.** The paired ruling is worse, or `record-scoring` prints `Ratchet:` because a dimension that fell is under the floor. -- **Floor.** `record-scoring` names a mean under the floor of 7.0. +- **Ratchet.** The paired ruling is worse, or `record-scoring` prints `Ratchet:` because a dimension that fell is under the floor, which `needs-scoring-run` repeats as `Still standing:` until a paired ruling follows it. +- **Floor.** `record-scoring` names a mean under the floor of 7.0, on a run `needs-scoring-run` called for a reason besides a fall. Each is a ๐Ÿ”ด of the comprehension check. It is never filed, and stands until a later run clears it or, for the floor, a decision to ship answers it. @@ -117,7 +117,7 @@ A `comprehension floor:` entry written before the history may still hold a scori Put each ruling with its base and votes, and each run's five scores, in the summary. List in the entry each decision to ship under the floor, and file its places in `todo.md` per `~/.claude/CLAUDE.md` โ†’ "Todo items". A project without the entry gets it at its first scoring run, titled `comprehension floor: every dimension and the overall at 7.0 or above` and applying KISS (`~/.claude/principles/technical-principles.md`). -**Fresh.** Where the chunk ran a comprehension check, the architecture pass is done only once its last paired ruling, and its last scoring run where it ran one, read the commit to merge. They may predate commits that change only `docs/decisions.md`, `docs/comprehension-history.md`, `docs/reading-cost.md`, `todo.md` or `CHANGELOG.md`. Any other commit after them, a prose fix included, because the seats read the docs, calls for a rescore: the comprehension check again, once every other pass is done, the auto-reviewer included. A rescore reporting a ๐Ÿ”ด that no decision to ship answers is an architecture round. Any other rescore is not a round: append only its results to the history, in a commit titled `Rescore: โ€ฆ`. A `Rescore:` commit re-enters no pass: push it and wait for the forge's checks (ยง4 step 3), not for an auto-review. +**Fresh.** Where the chunk ran a comprehension check, the architecture pass is done only once its last paired ruling, and its last scoring run where one is due, read the commit to merge. They may predate commits that change only `docs/decisions.md`, `docs/comprehension-history.md`, `docs/reading-cost.md`, `todo.md` or `CHANGELOG.md`. Any other commit after them, a prose fix included, because the seats read the docs, calls for a rescore: the comprehension check again, once every other pass is done, the auto-reviewer included. A rescore reporting a ๐Ÿ”ด that no decision to ship answers is an architecture round. Any other rescore is not a round: append only its results to the history, in a commit titled `Rescore: โ€ฆ`. A `Rescore:` commit re-enters no pass: push it and wait for the forge's checks (ยง4 step 3), not for an auto-review. **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, so neither the ratchet nor the floor can block it, and its summary cites the decision. A chunk due a scoring run runs it, even when every item it ships is named.