Answer stability round 1: 1 🔴, 12 🟡 (0 misread); wait-for waits out a half-written line, prepare-scoring honours claudeMdExcludes, and a merge by another method waits for the checks
CI / tests (pull_request) Successful in 2m38s

This commit is contained in:
2026-11-12 09:13:37 +01:00
parent 37f19d1677
commit 58133e69fe
8 changed files with 90 additions and 23 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ skills/comprehension-panel/seat-prompts.md builds them. It prints the worktree's
prompt's. It takes {{language}}, {{kind}}, {{domain}}, {{domain docs}} and {{3am question}} from the
checkout's AGENTS.md → "Scoring run". claude-config keeps no AGENTS.md, so there it takes them from
seat-prompts.md → "claude-config's values". It fills the other placeholders from the worktree and
the panel's SKILL.md. --preloaded replaces {{preloaded}}, which by default names each CLAUDE.md, its
the panel's SKILL.md. --preloaded replaces {{preloaded}}, which by default names each CLAUDE.md the main checkout's claudeMdExcludes doesn't exclude, its
imports and each rule file without `paths:` that Claude Code loads into a seat. Where any one of
the five values is missing, it exits 1 and doesn't write anything. Where a setup that
record-scoring never removed is still there, it removes it first and says so.
+17 -2
View File
@@ -1,4 +1,5 @@
"""Set up a scoring run: the worktree its seats read and each seat's prompt, filled from skills/comprehension-panel/seat-prompts.md."""
import json
import pathlib
import re
import shutil
@@ -96,16 +97,30 @@ def file_globs(paths: list[str]) -> str:
def preloaded_files(main: pathlib.Path, home: pathlib.Path) -> str:
"""The files Claude Code loads into a seat started in main before its first tool call: each CLAUDE.md, the files it imports, and each rule file without `paths:`."""
"""The files Claude Code loads into a seat started in main before its first tool call: each CLAUDE.md that main's settings don't exclude, the files it imports, and each rule file without `paths:`."""
excludes = claude_md_excludes(main)
found = []
for shown, claude_md, rules in (("~/.claude/", home / ".claude" / CLAUDE_MD, home / ".claude" / "rules"), ("", main / CLAUDE_MD, main / ".claude" / "rules")):
if claude_md.is_file():
if claude_md.is_file() and not any(claude_md.full_match(pattern) for pattern in excludes):
found.append(f"`{shown}{CLAUDE_MD}`")
found += [f"`{shown}{name}`, which it imports" for name in re.findall(r"^@(\S+)", claude_md.read_text(), re.M)]
found += [f"`{shown}{rule.relative_to(claude_md.parent)}`" for rule in sorted(rules.glob("*.md")) if not re.search(r"^paths:", rule.read_text(), re.M)]
return listed(found, "and") if found else "none"
def claude_md_excludes(main: pathlib.Path) -> list[str]:
"""The `claudeMdExcludes` globs of main's .claude/settings.json and settings.local.json, which keep a matching CLAUDE.md out of a session."""
globs = []
for name in ("settings.json", "settings.local.json"):
try:
settings = json.loads((main / ".claude" / name).read_text())
except (OSError, ValueError):
continue
excludes = settings.get("claudeMdExcludes") if isinstance(settings, dict) else None
globs += [glob for glob in excludes if isinstance(glob, str)] if isinstance(excludes, list) else []
return globs
def prompt_parts() -> dict[str, str] | Failure:
"""seat-prompts.md's opening, shared brief and each report as their fenced text, and each seat's background, keyed by heading or label."""
path = PANEL / "seat-prompts.md"
+14 -1
View File
@@ -9,7 +9,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from larv_review.scoring_setup import bullets, file_globs, prepare_scoring, project_values, score_bullets, section
from larv_review.scoring_setup import bullets, file_globs, preloaded_files, prepare_scoring, project_values, score_bullets, section
from failure import Failure
from test_env import isolated_env
@@ -141,6 +141,19 @@ class PrepareScoring(unittest.TestCase):
junior = (self.root / ".local" / "state" / "larv-review" / "proj" / "scoring" / "junior-a.md").read_text()
self.assertIn("from a DIFFERENT version (main): `CLAUDE.md` and `AGENTS.md`, which it imports.", junior)
def test_leaves_out_a_claude_md_the_project_settings_exclude(self):
(self.root / ".claude").mkdir()
(self.root / ".claude" / "CLAUDE.md").write_text("# Home\n")
(self.root / ".claude" / "rules").mkdir()
rule = "always"
(self.root / ".claude" / "rules" / f"{rule}.md").write_text("# Always\n")
(self.checkout / ".claude").mkdir()
(self.checkout / ".claude" / "settings.json").write_text('{"claudeMdExcludes": ["**/.claude/CLAUDE.md"]}\n')
(self.checkout / ".claude" / "settings.local.json").write_text("not json")
self.assertEqual(preloaded_files(self.checkout, self.root), f"`~/.claude/rules/{rule}.md`")
(self.checkout / ".claude" / "settings.json").write_text('{"claudeMdExcludes": [3]}\n')
self.assertEqual(preloaded_files(self.checkout, self.root), f"`~/.claude/CLAUDE.md` and `~/.claude/rules/{rule}.md`")
if __name__ == "__main__":
unittest.main()
+15
View File
@@ -1,6 +1,7 @@
import contextlib
import importlib.util
import io
from unittest import mock
import os
import pathlib
import re
@@ -59,6 +60,20 @@ class Report(unittest.TestCase):
self.assertEqual(main.report("usage: pytest\nerror: unrecognized arguments\n"), [])
class Main(unittest.TestCase):
def test_prints_the_help_for_h_or_help_first_and_runs_anything_else(self):
for argv in (["-h"], ["--help"], ["--help", "bin/x"]):
with self.subTest(argv=argv):
out = io.StringIO()
with contextlib.redirect_stdout(out), mock.patch.object(main, "run") as run:
self.assertEqual(main.main(argv), 0)
self.assertEqual(out.getvalue(), main.__doc__.strip() + "\n")
run.assert_not_called()
with mock.patch.object(main, "run", return_value=1) as run:
self.assertEqual(main.main(["bin/x", "-h"]), 1)
run.assert_called_once_with(["bin/x", "-h"])
class RunWithAStandIn(unittest.TestCase):
"""run with a stand-in for pytest: a Python script given the arguments run passes on."""
+22 -9
View File
@@ -27,14 +27,19 @@ class Clock(typing.Protocol):
def sleep(self, seconds: float) -> None: ...
def line_in(path: pathlib.Path, pattern: re.Pattern[str] | None) -> str | None | Failure:
"""The first line matching pattern, or without one the last line, where the file holds anything; else None."""
def text_of(path: pathlib.Path) -> str | None | Failure:
"""What the file holds; None where it doesn't exist."""
try:
lines = path.read_text(errors="replace").splitlines()
return path.read_text(errors="replace")
except FileNotFoundError:
return None
except OSError as error:
return Failure(f"cannot read {path}: {error.strerror}")
def line_in(text: str, pattern: re.Pattern[str] | None) -> str | None:
"""The first line of text matching pattern, or without one its last line; None where there is none."""
lines = text.splitlines()
if pattern is None:
return lines[-1] if lines else None
return next((line for line in lines if pattern.search(line)), None)
@@ -44,18 +49,26 @@ def waited(file: str, pattern: str | None, timeout: float, clock: Clock = time)
path = pathlib.Path(file)
compiled = re.compile(pattern) if pattern is not None else None
deadline = clock.monotonic() + timeout
while (found := line_in(path, compiled)) is None:
before = None
while True:
text = text_of(path)
if isinstance(text, Failure):
return text
# A last line without its newline may still be being written: it counts once a poll finds it unchanged.
settled = text is None or text.endswith("\n") or text == before
whole = text if settled or text is None else text[:text.rfind("\n") + 1]
# Without a pattern the last line is wanted, so an unsettled one waits.
if whole is not None and (settled or compiled is not None) and (found := line_in(whole, compiled)) is not None:
return found
before = text
left = deadline - clock.monotonic()
if left <= 0:
if not path.exists():
if text is None:
return Failure(f"{file} did not appear in {timeout:g} s")
last = line_in(path, None)
if isinstance(last, Failure):
return last
last = line_in(text, None)
wanted = f"no line matching `{pattern}`" if pattern is not None else "nothing"
return Failure(f"{file} held {wanted} after {timeout:g} s" + (f"; its last line: {last}" if last is not None else ""))
clock.sleep(min(POLL_SECONDS, left))
return found
def arguments(argv: list[str]) -> tuple[str, str | None, float] | Failure:
+17 -6
View File
@@ -4,7 +4,6 @@ import pathlib
import subprocess
import sys
import tempfile
import threading
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
@@ -59,6 +58,17 @@ class WaitFor(unittest.TestCase):
def test_gives_up_on_a_file_that_never_appears(self):
self.assertEqual(main.waited(str(self.file), None, 5, Clock()), Failure(f"{self.file} did not appear in 5 s"))
def test_waits_for_a_half_written_last_line_to_end(self):
self.file.write_text("running\n== 3 passed in")
clock = Clock(lambda: self.file.write_text("running\n== 3 passed in 1s ==\n"))
self.assertEqual(main.waited(str(self.file), "passed", 60, clock), "== 3 passed in 1s ==")
def test_takes_a_last_line_without_a_newline_once_a_poll_finds_it_unchanged(self):
self.file.write_text("# Report\nNo findings.")
clock = Clock()
self.assertEqual(main.waited(str(self.file), None, 60, clock), "No findings.")
self.assertEqual(clock.now, main.POLL_SECONDS)
def test_reads_a_line_that_is_not_utf_8(self):
self.file.write_bytes(b"caf\xe9 passed\n")
self.assertEqual(main.waited(str(self.file), "passed", 60, Clock()), "caf\ufffd passed")
@@ -85,6 +95,8 @@ class WaitFor(unittest.TestCase):
for argv, expected in (
([str(self.file), "passed", "--timeout", "5"], (0, "== 1 passed ==\n", "")),
(["--help"], (0, main.__doc__.strip() + "\n", "")),
(["-h"], (0, main.__doc__.strip() + "\n", "")),
(["--help", str(self.file)], (0, main.__doc__.strip() + "\n", "")),
([str(self.file), "("], (1, "", "wait-for: cannot read the pattern `(`: missing ), unterminated subpattern at position 0\n")),
):
with self.subTest(argv=argv):
@@ -96,6 +108,7 @@ class WaitFor(unittest.TestCase):
def test_arguments_take_the_timeout_anywhere_and_refuse_a_bad_one(self):
self.assertEqual(main.arguments(["--timeout", "1.5", "f", "p"]), ("f", "p", 1.5))
self.assertEqual(main.arguments(["f"]), ("f", None, 540.0))
self.assertEqual(main.arguments(["f", "--timeout", "0.5"]), ("f", None, 0.5))
for timeout in ("0", "-1", "x", "1.", None):
with self.subTest(timeout=timeout):
argv = ["f", "--timeout"] + ([timeout] if timeout else [])
@@ -104,11 +117,9 @@ class WaitFor(unittest.TestCase):
with self.subTest(argv=argv):
self.assertEqual(main.arguments(argv), Failure(main.USAGE))
def test_the_command_waits_for_a_file_another_process_writes(self):
writer = threading.Timer(0.5, lambda: self.file.write_text("== 1 passed in 0.1s ==\n"))
writer.start()
self.addCleanup(writer.cancel)
result = subprocess.run([sys.executable, str(TOOL), str(self.file), "passed", "--timeout", "20"], capture_output=True, text=True)
def test_the_command_prints_the_line_a_file_holds(self):
self.file.write_text("== 1 passed in 0.1s ==\n")
result = subprocess.run([sys.executable, str(TOOL), str(self.file), "passed", "--timeout", "20"], capture_output=True, text=True, timeout=10)
self.assertEqual((result.returncode, result.stdout, result.stderr), (0, "== 1 passed in 0.1s ==\n", ""))
def test_refuses_a_bad_pattern_timeout_or_argument_count_waiting_for_nothing(self):
+1 -1
View File
@@ -198,7 +198,7 @@ Launch prose-reviewer with what the diff touched and every section this review c
1. Read the finished PR against the README goals and code health, unless the README voids it: does anything in it work against one? It breaks a maintain goal → do not merge; redesign the change or drop its item. It works against an achieve goal → do not merge; ask the human, stating the conflict.
2. Run the comprehension check (§3) where it runs; it runs once. When `origin/<default branch>` moves after that, return to §4, and keep the ruling and scoring run already recorded.
3. Remove the chunk's items from `todo.md` per `~/.claude/CLAUDE.md` → "Working loop" in the branch, commit and push that; the commit re-enters no pass.
4. Aligned and every pass done → **merge** with `~/.claude/bin/chunk-pr merge`, run in the background, since its wait can outlast the Bash tool's timeout. It waits for the pull request's checks to pass, then takes the first merge method the repository allows on its forge. A repo whose `AGENTS.md` names another method merges that way with the forge's CLI instead, after `~/.claude/bin/larv-review scoring-run-owed` exits 0. A repo withholds this in its `AGENTS.md` → leave the PR ready and unmerged, and say which line withheld it.
4. Aligned and every pass done → **merge** with `~/.claude/bin/chunk-pr merge`, run in the background, since its wait can outlast the Bash tool's timeout. It waits for the pull request's checks to pass, then takes the first merge method the repository allows on its forge. A repo whose `AGENTS.md` names another method merges that way with the forge's CLI instead, once the pull request's checks pass and `~/.claude/bin/larv-review scoring-run-owed` exits 0. A repo withholds this in its `AGENTS.md` → leave the PR ready and unmerged, and say which line withheld it.
5. Merged → run `~/.claude/bin/chunk-pr clean` in the chunk's worktree, and put a failure it prints in the summary.
6. Stop. The next chunk gets a fresh session.
+3 -3
View File
@@ -37,7 +37,7 @@
| 304 | 0.10.0 | 303 | defect | **Archive each review-replay and judge-replay run's transcript beside its result, so a replay that decided a rung can be checked and re-priced later.** | 2 | 2 | 2 | 4 | 3 | 1.4 by 2, 3 by 2 | 4.4 |
| 306 | 0.10.0 | | | **Set a strategy that keeps loop-claude's archive and larv-review's review folders backed up and small over the years, compressing older entries without losing any.** | 3 | 2 | 4 | 7 | 5 | 3 by 5 | 3.9 |
| 302 | 0.10.0 | | | **Call a scoring run for an item whose tagline makes the comprehension floor its target, and not for one that only names the floor, such as in a quoted decision title.** | 2 | 2 | 3 | 5 | 3 | code health by 2 | 3.6 |
| 287 | 0.10.0 | | | **Move the forge helpers `Forge`, `forge_of`, `runner`, `open_pull`, `merged_pull`, `pull_at` and `gitea` into one module that `chunk_preflight`, `chunk_pr`, `deploy_release` and `larv_review` all import from, so no tool imports another tool's internals for them.** | 3 | 1 | 3 | 5 | 5 | code health by 3 | 3.4 |
| 287 | 0.10.0 | | | **Move the forge helpers `Forge`, `forge_of`, `runner`, `open_pull`, `merged_pull`, `pull_at`, `gitea`, `checks_passed` and `required_checks` into one module that `chunk_preflight`, `chunk_pr`, `deploy_release` and `larv_review` all import from, so no tool imports another tool's internals for them.** | 3 | 1 | 3 | 5 | 5 | code health by 3 | 3.4 |
| 338 | 0.10.0 | | owner | **Script each step that 0.9.0's chunks repeated by hand and a program can compute, filing one item per step, and file this audit again for the next release.** | 1 | 2 | 1 | 2 | 2 | 1.4 by 3, 1.5 by 3 | 2.6 |
| 288 | 0.10.0 | | | **Point the two reading-cost decisions at code health and goal 1.4's counter-signal, in place of the goal 1.1 they cite.** | 1 | 2 | 1 | 2 | 1 | code health by 1, 1.4 by 1 | 2.6 |
| 77 | 0.10.0 | | | **Teach `bin/metric-bench` Go and TypeScript, rerun it once two projects' comprehension histories name places, and bring into review only a metric that tracks the panel.** | 4 | 2 | 1 | 5 | 6 | 1.1 by 7, 1.4 by 7 | 2.4 |
@@ -254,7 +254,7 @@ Recommendation: a floor item's tagline opens with one fixed phrase, `Reach the c
The same chunk names the phrase where a floor item is filed: `skills/larv-review/SKILL.md` → "Floor item", the `Next:` lines `floor_step` prints, and `larv-review --help` (`bin/larv_review/main.py`, lines 35 and 89). It rewords open floor item 300's tagline to open with the phrase, and updates the tests in `bin/larv_review/test_larv_review.py` that use floor taglines (lines 120, 361, 435, 537), adding one where a tagline quotes the floor mid-sentence and is due no run.
### 287. Move the forge helpers `Forge`, `forge_of`, `runner`, `open_pull`, `merged_pull`, `pull_at` and `gitea` into one module that `chunk_preflight`, `chunk_pr`, `deploy_release` and `larv_review` all import from, so no tool imports another tool's internals for them.
### 287. Move the forge helpers `Forge`, `forge_of`, `runner`, `open_pull`, `merged_pull`, `pull_at`, `gitea`, `checks_passed` and `required_checks` into one module that `chunk_preflight`, `chunk_pr`, `deploy_release` and `larv_review` all import from, so no tool imports another tool's internals for them.
Today the helpers live in two tools. `Forge` is defined in `bin/chunk_preflight/gathered.py` and imported by `bin/chunk_preflight/choices.py`, `bin/chunk_preflight/facts.py`, `bin/chunk_preflight/main.py` and `bin/chunk_pr/main.py`, and again through `choices` by `bin/deploy_release/forge.py`. `forge_of` lives in `choices.py`, which `bin/chunk_pr/main.py`, `bin/deploy_release/cut.py` and `bin/larv_review/reviewer_header.py` import. `open_pull`, `runner` and `gitea` live in `bin/deploy_release/forge.py`, which `bin/chunk_pr/main.py` and `bin/larv_review/reviewer_header.py` import. So `deploy_release` imports `chunk_preflight`, and `chunk_pr` and `larv_review` import both.
@@ -346,7 +346,7 @@ Places the seats named, hardest first (`larv-review places`):
- Shape: `bin/review_rules/comprehension_history.py:127` `entries`: a line-by-line parser that tolerates two legacy formats.
- Shape: `bin/records/__init__.py:1` `records`: one name for three concepts, as `cut` and `Plan` also name several.
- Shape: `bin/rule_hook/rules.py:25` `RULES`: rules sit inline in one module while five others have a module each.
- Navigation, Shape: `README.md:116` `bin/`: about 55 entries in one flat list, some 31 of them packages, the worst fan-out level.
- Navigation, Shape: `README.md:116` `bin/`: about 64 entries in one flat list, some 35 of them packages, the worst fan-out level.
- Self-sufficiency: `skills/larv-review/SKILL.md:147` "Scoring run": dense rule prose with many cross-references; three sections rebuild one rule.
Scored L 4 because the refactor touches several components that hold known defects, E 2 because review and a manual check see a regression, I 3 because every session runs these tools. The chunk runs a scoring run, since its tagline names the comprehension floor.