diff --git a/README.md b/README.md index 15d6349d..a5410a0f 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a - `settings_filter.py` is git's clean filter for `settings.json`: it drops `"model"` and sorts the keys. `.gitattributes` sets the filter `settings` on `settings.json`, and Install's `git config` line makes this script that filter. - `statusline.py` renders Claude Code's status line; `settings.json` → `statusLine` runs it. - `subagent-rung [--plan] ` prints the Agent tool's model and effort for a subagent's task, picked by its L from the project's model on the project's routing ladder, and with `--plan` never below the project's rung; `subagent-rung --help` states the rule. -- `task-bench --image --test []` plants bugs that the tests catch, at the places the comprehension seats found hardest, has Haiku fix each at the base and at the head, and prints how often the fix passes and what it took. It needs docker and a token from `claude setup-token`; `task-bench --help` says how it plants, runs and checks. It leaves a digest of why runs failed. `task-bench gather` starts a claude on the project's rung, which files a plan item for each place the digest shows to be hard; then gather removes the bench's folder, digest and streams. +- `task-bench --image --test []` plants bugs that the tests catch, at the places the comprehension seats found hardest, has Haiku fix each at the base and at the head, and prints how often the fix passes and what it took. It needs docker and a token from `claude setup-token`; `task-bench --help` says how it plants, runs and checks. It leaves a digest of why runs failed. `larv-review record-bench` appends the bench's figures over every bug to the comprehension history, which a scoring run does where the project's README documents its `task-bench` command. `task-bench gather` starts a claude on the project's rung, which files a plan item for each place the digest shows to be hard; then gather removes the bench's folder, digest and streams. - `todo-item` reads and changes a project's plan, whatever holds it: `list` prints the items in the plan's order and `show ` one item's row and detail; `add …` files an item under the next free ID, `edit …` sets an item's cells or detail, and `move --release ` sets an item's release; `finish ` removes a finished item and adds the bullet passed with `--changelog` to `CHANGELOG.md`, except for a plan kept in Jira. Each change ranks a markdown plan. `todo-item --help` states the flags. - `touch-predictions record ...` appends what a chunk's items were predicted to touch, under `Touches:` in their details, beside the files and parts its branch touched, to the record the config names as `touch-predictions`; `touch-predictions --help` shows the spelling and how a part is named. `chunk-preflight` reads the same predictions to name the items that may start chunks at once. - `wait-for [] [--timeout ]` waits until a file a background job writes holds a line matching the pattern, and prints it. diff --git a/bin/larv_review/bench_record.py b/bin/larv_review/bench_record.py new file mode 100644 index 00000000..c8eebf69 --- /dev/null +++ b/bin/larv_review/bench_record.py @@ -0,0 +1,64 @@ +"""`larv-review record-bench`: a task-bench's figures over every bug, appended to the comprehension history from the bench's digest. The entry is a report beside the panel's: its heading names no ` at `, so nothing that reads the history's rulings and scoring runs takes it for one.""" +import pathlib +import re + +from failure import Failure +from git_cli.git_repo import git, top +from larv_review.history_commands import held_history +from review_rules.comprehension_history import appended +from review_rules.review_folder import made_review_folder +from task_bench.bench_folder import held +from task_bench.gather import DIGEST +from text_files.utc_stamp import utc + +# The digest's line that names the commits, as task_bench.digest.digest writes it. +SIDES = re.compile(r"^Base ([0-9a-f]{7,40}), head ([0-9a-f]{7,40})\.", re.M) +# How the table's three rows over every bug open: the base, the head and the head's change. +OVER_ALL = "| All |" +COMMIT_LENGTH = 8 + + +def record_bench(home: pathlib.Path, now: float) -> str | Failure: + """Appends the entry of the bench whose digest the chunk's review folder holds, and returns the line the tool prints. It waits for a bench that still runs there.""" + checkout = top() + if isinstance(checkout, Failure): + return checkout + branch = git("rev-parse", "--abbrev-ref", "HEAD") + if isinstance(branch, Failure): + return branch + review = made_review_folder(checkout, home) + if isinstance(review, Failure): + return review + with held(review) as folder: + if isinstance(folder, Failure): + return folder + try: + digest = (folder / DIGEST).read_text(encoding="utf-8") + except FileNotFoundError: + return Failure(f"{folder} holds no digest: run task-bench in this checkout first, and record it before `task-bench gather`") + except (OSError, UnicodeDecodeError) as failure: + return Failure(f"could not read {folder / DIGEST}: {failure}") + entry = bench_entry(digest, branch.strip(), now) + if entry is None: + return Failure(f"{folder / DIGEST} is no task-bench digest: it lacks the line that names its base and head, or the table's three All rows") + name, text = entry + read = held_history(home) + if isinstance(read, Failure): + return read + history, found = read + if f", {name}\n" in found.text: + return Failure(f"{history.label} already holds {name}; record each bench once") + written = history.write(appended(found.text, text), found.version) + return written if isinstance(written, Failure) else f"Appended to {history.label}." + + +def bench_entry(digest: str, branch: str, now: float) -> tuple[str, str] | None: + """What the history calls the bench of branch that digest tells of, and its entry, stamped with now: the table's header and its rows over every bug. None where digest is no task-bench digest.""" + sides = SIDES.search(digest) + table = [line for line in digest.splitlines() if line.startswith("|")] + rows = [line for line in table if line.startswith(OVER_ALL)] + if not sides or len(rows) != 3: + return None + base, head = (commit[:COMMIT_LENGTH] for commit in sides.groups()) + name = f"task-bench of {branch}: head {head} against base {base}" + return name, "\n".join([f"## {utc(now)}, {name}", "", *table[:2], *rows]) + "\n" diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index b745e92a..34cbf41a 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -114,6 +114,13 @@ record-ruling and record-scoring append each entry to the history, created when heading of the current UTC time and the seats file's first line. Each commit that line names must be in the checkout. Each exits 1 when the history already holds an entry on what that line reads. +record-bench appends the figures of the task-bench last run in this checkout, a report beside the +panel's entries that no command here reads: the bench's table, cut to its three rows over every bug, +under a heading of the current UTC time and `task-bench of : head against base +`. It reads the digest in the bench's folder, `task-bench` in the chunk's review folder, so +run it before `task-bench gather`, which removes that folder; it waits for a bench that still runs. +It exits 1 where the folder holds no digest, or the history already holds that bench. + places prints the places seats found hard since the newest scored commit: the places of each scoring run on it, and, in each later ruling, each place opening with a dimension, or Overall, that its seat voted worse. @@ -185,6 +192,7 @@ from larv_review.owed import owed_scoring_run from review_rules.review_passes import PASSES, REVIEWERS from larv_review.scoring_due import plan_reasons from larv_review.scoring_setup import prepare_scoring +from larv_review.bench_record import record_bench from larv_review.history_commands import read_agreement, read_places, record_ruling, record_scoring from larv_review.round_title import round_title @@ -234,6 +242,7 @@ COMMANDS = { "record-ruling": Command("record-ruling ", lambda given: len(given) == 1, lambda given: printed(record_ruling(pathlib.Path(given[0]), pathlib.Path.home(), time.time()))), "prepare-scoring": Command("prepare-scoring", no_arguments, lambda given: prepared_scoring()), "record-scoring": Command("record-scoring [...]", lambda given: bool(given) and are_ids(given[1:]), run_record_scoring, ids_from=1), + "record-bench": Command("record-bench", no_arguments, lambda given: printed(record_bench(pathlib.Path.home(), time.time()))), "places": Command("places", no_arguments, lambda given: printed(read_places(pathlib.Path.home()))), "agreement": Command("agreement", no_arguments, lambda given: printed(read_agreement(pathlib.Path.home()))), "reviewer-header": Command("reviewer-header [--rerun]", fits_reviewer_header, run_reviewer_header), diff --git a/bin/larv_review/test_larv_review.py b/bin/larv_review/test_larv_review.py index 177e0189..0603c96c 100644 --- a/bin/larv_review/test_larv_review.py +++ b/bin/larv_review/test_larv_review.py @@ -4,6 +4,7 @@ import itertools import json import os import pathlib +import re import subprocess import sys import tempfile @@ -1063,6 +1064,37 @@ class LarvReviewTool(unittest.TestCase): self.assertEqual(ran.returncode, 1) self.assertIn("could not make the review folder", ran.stderr) + def bench_digest(self, text): + folder = pathlib.Path(self.run_tool("review-folder").stdout.strip()) / "task-bench" + folder.mkdir() + (folder / "digest.md").write_text(text) + + def test_record_bench_appends_the_rows_over_every_bug_under_a_heading_that_is_no_ruling_or_scoring_run(self): + table = "| Bug | Side | Passed | Output |\n|---|---|---|---|\n" + rows_over_all = "| All | base | 3/4 | 900 |\n| All | head | 4/4 | 700 |\n| All | change | +1 | -22% |\n" + self.bench_digest(f"# task-bench digest\n\nBase {'a' * 40}, head {'b' * 40}. A bug's name gives its line at the base.\n\n{table}| 1: pick.go:12 | base | 3/4 | 900 |\n| 1: pick.go:12 | head | 4/4 | 700 |\n{rows_over_all}\n## 1: pick.go:12\n\n| not | the | table |\n") + self.commit("history", {"docs/comprehension-history.md": "# Comprehension history\n\n" + SCORING}) + ran = self.run_tool("record-bench") + self.assertEqual((ran.returncode, ran.stdout), (0, f"Appended to {self.checkout / 'docs/comprehension-history.md'}.\n"), ran.stderr) + history = (self.checkout / "docs/comprehension-history.md").read_text() + self.assertRegex(history, rf"\n\n## \d{{4}}-\d\d-\d\dT\d\d:\d\d:\d\dZ, task-bench of chunk: head bbbbbbbb against base aaaaaaaa\n\n{re.escape(table + rows_over_all)}$") + self.assertEqual([entry.heading for entry in entries(history)], ["2026-10-08T12:00:00Z, PR #1 at aaaaaaa"]) + again = self.run_tool("record-bench") + self.assertEqual(again.returncode, 1) + self.assertIn("already holds task-bench of chunk: head bbbbbbbb against base aaaaaaaa", again.stderr) + self.assertEqual((self.checkout / "docs/comprehension-history.md").read_text(), history) + + def test_record_bench_fails_without_a_digest_and_on_one_without_its_commits_or_its_rows_over_every_bug(self): + ran = self.run_tool("record-bench") + self.assertEqual(ran.returncode, 1) + self.assertIn("holds no digest: run task-bench in this checkout first", ran.stderr) + self.bench_digest("# task-bench digest\n\n| Bug | Side |\n|---|---|\n| All | base |\n") + ran = self.run_tool("record-bench") + self.assertEqual(ran.returncode, 1) + self.assertIn("digest.md is no task-bench digest", ran.stderr) + self.assertFalse((self.checkout / "docs/comprehension-history.md").exists()) + self.assertIn("unknown arguments", self.run_tool("record-bench", "x").stderr) + def test_review_folder_fails_outside_a_checkout(self): ran = subprocess.run([sys.executable, str(TOOL), "review-folder"], capture_output=True, cwd=self.checkout.parent, env=self.env, text=True) self.assertEqual(ran.returncode, 1) @@ -1085,7 +1117,7 @@ class LarvReviewTool(unittest.TestCase): def test_help_and_the_usage_line_list_the_same_commands(self): usage = next(line for line in self.run_tool("--help").stdout.splitlines() if line.startswith("usage: larv-review ")) listed = usage.removeprefix("usage: larv-review ").split(" | ") - self.assertEqual([shape.split()[0] for shape in listed], ["review-folder", "ruling-base", "round-count", "needs-scoring-run", "scoring-run-owed", "record-ruling", "prepare-scoring", "record-scoring", "places", "agreement", "reviewer-header", "round-title", "reviewer-context"]) + self.assertEqual([shape.split()[0] for shape in listed], ["review-folder", "ruling-base", "round-count", "needs-scoring-run", "scoring-run-owed", "record-ruling", "prepare-scoring", "record-scoring", "record-bench", "places", "agreement", "reviewer-header", "round-title", "reviewer-context"]) self.assertIn(f"usage: larv-review {' | '.join(listed)}", self.run_tool().stderr) def test_takes_a_local_main_without_origin_and_reads_origin_as_last_fetched_when_the_fetch_fails(self): diff --git a/docs/decisions.md b/docs/decisions.md index a2d0f46c..406548e6 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -45,6 +45,7 @@ Each project principle states one rule that the decisions below apply; their ent - routing: loop-claude reads the items a chunk takes from the worker's latest `Chunk items:` line and scores them by `todo.md` as the default branch held it when the cycle started; the judge reports the escalation and whether a release is ready to cut - routing: the worker changes rung only as a chunk starts, after every second unfinished verdict, when it names a chunk item that picks a higher rung, or when it cites an escalation trigger the judge finds - task-bench: a bench takes 5 bugs and 5 runs per side, after a 2 × 2 pilot on a new setup, and at no affordable count does a chunk-sized change rise above the noise +- task-bench: where a project's README documents a bench command, a scoring run runs it beside the seats and `larv-review record-bench` records its figures in the comprehension history, as a report that doesn't block a merge or file an item until the human rules on about 10 recorded benches - tests: each test earns its keep as the technical principles' test bullet says, and the worker takes a test's expected values from its item, never from the code - the repo may name bender, bender-infra and ai-sandbox - todo.md: an item of the next release predicts the files and parts it will touch under `Touches:` in its detail; chunk-preflight takes, in the plan's order, the items that overlap none taken before them as the chunks that may run at once, and the optional `touch-predictions` record keeps each chunk's prediction beside what it touched @@ -861,6 +862,18 @@ Measured on `fejkdata` (Go, 5 bugs planted in the files `larv-review places` nam - **One finished chunk**: `fejkdata`'s PR #490, base `33b7fa80`, head `5b9c2a14`, which the comprehension panel ruled better on Navigation, Locality and Shape and the same on Self-sufficiency. The bench planted 5 bugs and ran 38 of 50 runs before the machine restarted. The first 3 runs per bug and side, 30 runs, are the ones counted, and all passed. The mean of the bugs' changes was +4.6% in output tokens, +8.9% in cache-read tokens and +3.8% in turns, with the bugs' own changes in cache-read tokens from -41% to +47%. The two token figures sit inside the spread at 5 × 3, 17% and 22%. The turns' +3.8% sits inside their spread at 5 × 5, 14%, and the spread at 5 × 3 can only be wider. The mean of the wall times' changes, +105%, lies above the 86% of that row, from one bug whose head runs took 6.8 times as long at the median. Nobody read its streams to find out why. The head cost slightly more tokens where the panel finds it easier to read, and the wall time can't be judged, so the bench neither confirmed nor contradicted the panel. - **Cost**: 5 bugs × 6 runs took 3.9 hours and 34M cache-read, 1.2M cache-write and 0.3M output tokens; a run takes about 3.5 minutes, and planting 16 to 25 minutes. A 5 × 5 bench is about 3.3 hours and 28M cache-read tokens. Gremlins ran out of 8 GB at the base of PR #490, so the help's example takes 16 GB. +## task-bench: where a project's README documents a bench command, a scoring run runs it beside the seats and `larv-review record-bench` records its figures in the comprehension history, as a report that doesn't block a merge or file an item until the human rules on about 10 recorded benches + +2026-11-23, lilleman, through todo item 509. Serves code health, whose signal is the panel's overall score, since a signal only simulated readers give stays unchecked until a measurement stands beside it; and goal 1.4, since the bench runs only where a scoring run already does. + +**A report, not a gate.** The bench's entry sits in the history beside the scoring run's, under a heading no command reads as a ruling or a run. A bench that fails, or a project whose README documents no bench command, doesn't hold up the merge. Once about 10 chunks have recorded both, the human rules whether the bench's figures agree with the panel's scores, and whether the bench then replaces the scoring run or gates a merge. + +**The README names the command**, as it names the project's mutation command: a bench needs the project's image, test command and Gremlins prefix, and a README already says how the project's tools run. + +**The entry keeps the three rows over every bug.** The rows per bug stay in the bench's digest, which `task-bench gather` reads: a bug is planted anew each bench, so its row doesn't compare with a later entry's. + +Valid while task-bench's figures are unproven against the panel's scores. + ## tests: CI runs the suite through `ci.sh` on every pull request, in a pinned Python container, and `main`'s branch protection holds a merge until it passes 2026-11-09, larv-review, through todo item 12. Serves goal 1.1: a merge no longer rests on the worker's word. larv-review's gate was the local run alone, which it skips when the last stability round left the suite green, so an unattended chunk could merge on the worker's own report. gitea.larvit.se's runners labelled `docker-host` run `.gitea/workflows/ci.yml`, which runs `ci.sh` on the committed HEAD in a pinned Python container; the script's header says how. A run takes about 3 minutes. diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 2209859d..98ba4b58 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -3456,3 +3456,7 @@ Read most (opens and searches): - `bin/task_bench/runs.py` 2 - `docs/decisions.md` 2 - `CHANGELOG.md` 1 + +## Reading cost, chunk 5c33cc8bf84f, finished 2026-11-23T13:17:23Z + +41140 new input tokens before the first commit. diff --git a/skills/larv-review/SKILL.md b/skills/larv-review/SKILL.md index 91e5c62d..77c80e2d 100644 --- a/skills/larv-review/SKILL.md +++ b/skills/larv-review/SKILL.md @@ -172,9 +172,10 @@ The comprehension check records how hard the project is for its contributor to r - **Seats.** 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. Run `~/.claude/bin/larv-review prepare-scoring`. It makes the worktree the seats read and prints each seat's prompt file; launch each seat with its file's text as its prompt. 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. - **Floor item.** Where `record-scoring` prints `Floor:`, a `Next:` line follows: file one floor item, or refresh the open one. A floor item is a plan item meant to bring every mean to the project's readability floor, which `record-scoring`'s `Floor:` line names. File it as one ambitious refactor, not touch-ups. It restructures the area behind the places `larv-review places` prints for this run, chosen where they bear on the lowest dimension, sized to bring every mean to that floor, and quotes those places. Its tagline opens with `Reach the comprehension floor:`, so its own chunk runs a scoring run; while a mean stays under the floor, that run's `Next:` line asks for the next floor item. Mark it `owner`, since the human asked that such a project always hold one, so no score deletes it. Put it in the earliest release the plan names after the one the chunk ships into, or else in the next version after that one that `~/.claude/rules/todo-items.md` allows, so the floor doesn't hold up any release. While one is open, refresh its places and aim from the newest run instead of filing another; the item the chunk ships doesn't count as open. Commit it with the run, as "Record" says. - **Second run.** Where `needs-scoring-run` printed that the chunk `leaves release … with no plan item`, run `prepare-scoring` again and launch the same four seats afresh on the same head. Their scores file's first line is ` rerun at `. Record it with the same `record-scoring` command. +- **Bench.** Where the project's README documents a `task-bench` command, start it when the seats launch, on the same head, in the background under `~/.claude/bin/run-heavy`. Once it ends, run `~/.claude/bin/larv-review record-bench`, which appends the bench's figures to the history, and put its `All` `change` row in the summary. A second run takes no second bench. The bench is a report beside the panel's scores: none of its figures blocks a merge or files an item. Where it fails, say why in the summary and merge without it. A project whose README documents no such command skips it. - **Agreement.** After the second run, run `~/.claude/bin/larv-review agreement` and put its counts in the summary. On `Assumption fails:`, ask the user whether to keep the paired ruling or change the decision `review: the comprehension check records …`. Record the answer as a decision in the repo whose history was counted, with the counts that led to the ask. A later run asks again only when the rulings' rate falls, or the runs' rate rises, against the recorded counts. -**Record.** `docs/comprehension-history.md` keeps every paired ruling and scoring run, which `larv-review` appends; never edit one. Commit what it appends, with the `todo.md` that `record-scoring` re-ranks in one commit titled `Record the comprehension check: …`, and push it; it re-enters no pass, and `chunk-pr merge` waits for the forge's checks it starts. 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, scoring run and bench, which `larv-review` appends; never edit one. Commit what it appends, with the `todo.md` that `record-scoring` re-ranks in one commit titled `Record the comprehension check: …`, and push it; it re-enters no pass, and `chunk-pr merge` waits for the forge's checks it starts. 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.** The header of systems-architect and stability-reviewer names `places.md`, which holds what `~/.claude/bin/larv-review places` prints: the places seats found hard since the newest scored commit. 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 the function or section it names, 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.