Answer architecture round 1: give loop-claude's prompt text one home, split larv-review's plan trigger and ruling base out, share todo.md's table and the project key, and name the scoring run, the checkout roots and the test env for what they are

This commit is contained in:
2026-10-09 14:43:19 +02:00
parent b1913ed65d
commit dde06fc465
38 changed files with 406 additions and 259 deletions
+27 -20
View File
@@ -2,6 +2,11 @@
usage: larv-review ruling-base | round-count | needs-scoring-run [<item ID>...] | record-ruling <votes file> [<scores file>] | record-scoring <scores file> [<item ID>...]
The comprehension check keeps a project from reading worse, two ways. In a paired ruling, seats read
the branch's head beside a base and vote better, same or worse, overall and on each dimension; a
worse ruling blocks the merge, which is the ratchet. In a scoring run, four seats score the project
from 1 to 10; a mean under the floor of {floor} blocks the merge.
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 reads origin as
@@ -16,7 +21,8 @@ ruling names; with no ruling either, it is the merge base of HEAD and the defaul
round-count prints each pass's count: the highest <n> among the titles opening `Answer <pass> round
<n>:` of commits the default branch does not hold. It marks each pass at the cap of {cap} rounds,
and each name in such a title that is not a pass.
and each name in such a title that is not a pass. It only reports: larv-review asks the human in
place of a further round.
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
@@ -80,16 +86,17 @@ import sys
import time
import typing
from comprehension_history import appended, DIMENSIONS, heading, Heading, HISTORY, recorded, ruling_entry, Scoring, scoring_entry, vote_text
from larv_review.base import base
from comprehension_history import appended, DIMENSIONS, heading, Heading, HISTORY, recorded, ruling_entry, scoring_entry, ScoringRun, vote_text
from larv_review.ruling_base import base
from larv_review.rounds import CAP, PASSES, round_counts
from larv_review.git import commit_exists, default_branch, file_at, git, history_changes, landed_since_release, top
from larv_review.ruling import counted, fallen, ruling, votes
from larv_review.ruling import counted, fallen, ruling, split, votes
from failure import Failure
from larv_review.scoring import fall_ruling, fall_step, FLOOR, means, plan_items, scoring_run_due, under_floor
from rank_todo import ITEMS_HEADER
from larv_review.scoring import fall_ruling, FLOOR, means, under_floor
from todo_table import items, ITEMS_HEADER
from file_writes import replace_file
from larv_review.seats import scores, seats_file, SeatsFile
from larv_review.plan import scoring_run_due
USAGE = "usage: larv-review ruling-base | round-count | needs-scoring-run [<item ID>...] | record-ruling <votes file> [<scores file>] | record-scoring <scores file> [<item ID>...]"
@@ -182,10 +189,10 @@ def plan_reasons(default: str, ids: list[int]) -> list[str] | Failure:
except (OSError, UnicodeDecodeError) as failure:
return Failure(f"could not read todo.md: {failure}")
# While a chunk reshapes todo.md into one table, the default branch's todo.md has no items table.
planned = plan_items(before) if ITEMS_HEADER in before.splitlines() else []
planned = items(before) if ITEMS_HEADER in before.splitlines() else []
if isinstance(planned, Failure):
return Failure(f"{default}'s todo.md: {planned.reason}")
chunk = plan_items(after)
chunk = items(after)
if isinstance(chunk, Failure):
return Failure(f"the checkout's todo.md: {chunk.reason}")
landed = landed_since_release(default)
@@ -204,21 +211,21 @@ def record_ruling(votes_file: pathlib.Path, scores_file: pathlib.Path | None = N
return said
count = counted(given.seats, said)
tally = ", ".join(f"{seat.name} {vote_text(DIMENSIONS[-1], said[seat.name][-1], count[seat.name][-1])}" for seat in given.seats)
ruled = ruling([each[-1] for each in count.values()])
if ruled is None:
overall = [each[-1] for each in count.values()]
if split(overall):
print(f"Split: {tally}. Launch the maintainability senior and Junior A together, add their lines to the votes file, and run this again.")
return None
ruled = ruling(overall)
fell = fallen(count) if ruled != "worse" else []
if fell and not scores_file:
print(f"Fell: {', '.join(fell)}, in a {ruled} ruling. Launch the four scoring seats on {named.label} at {named.commit}, write their lines to a scores file, and run this again with both files.")
return None
if scores_file and not fell:
return Failure(f"no dimension fell in this {ruled} ruling, so it takes no scores file")
scoring = None
notes = []
match fall_step(fell, scores_file is not None):
case "ask":
print(f"Fell: {', '.join(fell)}, in a {ruled} ruling. Launch the four scoring seats on {named.label} at {named.commit}, write their lines to a scores file, and run this again with both files.")
return None
case "refuse":
return Failure(f"no dimension fell in this {ruled} ruling, so it takes no scores file")
if scores_file:
scored = read_scoring(scores_file, named)
scored = read_fall_scores(scores_file, named)
if isinstance(scored, Failure):
return scored
scoring = scored
@@ -247,7 +254,7 @@ def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int]) -> F
return append(given.read, scoring_entry(named.title, scoring))
def read_scoring(scores_file: pathlib.Path, votes: Heading) -> Scoring | Failure:
def read_fall_scores(scores_file: pathlib.Path, votes: Heading) -> ScoringRun | Failure:
"""The scores a fall called, once their file names what the votes file read."""
read = read_seats(scores_file, paired=False, fresh=False)
if isinstance(read, Failure):
@@ -258,11 +265,11 @@ def read_scoring(scores_file: pathlib.Path, votes: Heading) -> Scoring | Failure
return scored_seats(given)
def scored_seats(given: SeatsFile) -> Scoring | Failure:
def scored_seats(given: SeatsFile) -> ScoringRun | Failure:
found = scores(given.seats)
if isinstance(found, Failure):
return found
return Scoring(given.seats, found, means(list(found.values())))
return ScoringRun(given.seats, found, means(list(found.values())))
def read_seats(path: pathlib.Path, paired: bool, fresh: bool = True) -> tuple[Heading, SeatsFile] | Failure: