Answer architecture round 2: keep the judge's rules beside its verdicts, name record_ruling's steps, file HistoryChange with the history, give read_utf8 its own module, count a mis-cased round title, and repair the tracked_places docstring
This commit is contained in:
+29
-28
@@ -20,7 +20,7 @@ one change against its first parent. With none, the base is the one the history'
|
||||
ruling names; with no ruling either, it is the merge base of HEAD and the default branch.
|
||||
|
||||
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,
|
||||
<n>:`, in any case, 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. It only reports: larv-review asks the human in
|
||||
place of a further round.
|
||||
|
||||
@@ -90,7 +90,7 @@ from comprehension_history import appended, DIMENSIONS, heading, Heading, HISTOR
|
||||
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, split, votes
|
||||
from larv_review.ruling import counted, fallen, overall, ruling, split, votes
|
||||
from failure import Failure
|
||||
from larv_review.scoring import fall_ruling, FLOOR, means, under_floor
|
||||
from todo_table import items, ITEMS_HEADER
|
||||
@@ -107,7 +107,7 @@ def main(argv: list[str]) -> int:
|
||||
return 0
|
||||
command, *given = argv or [""]
|
||||
if command == "ruling-base" and not given:
|
||||
done = with_default_branch(ruling_base, stale_ok=False)
|
||||
done = with_default_branch(show_ruling_base, stale_ok=False)
|
||||
elif command == "round-count" and not given:
|
||||
done = with_default_branch(round_count, stale_ok=True)
|
||||
elif command == "needs-scoring-run" and all(re.fullmatch(r"[0-9]+", id_) for id_ in given):
|
||||
@@ -142,7 +142,7 @@ def with_default_branch(command: typing.Callable[[str], Failure | None], stale_o
|
||||
return command(branch)
|
||||
|
||||
|
||||
def ruling_base(default: str) -> Failure | None:
|
||||
def show_ruling_base(default: str) -> Failure | None:
|
||||
changes = history_changes(default)
|
||||
if isinstance(changes, Failure):
|
||||
return changes
|
||||
@@ -205,34 +205,35 @@ def record_ruling(votes_file: pathlib.Path, scores_file: pathlib.Path | None = N
|
||||
read = read_seats(votes_file, paired=True)
|
||||
if isinstance(read, Failure):
|
||||
return read
|
||||
named, given = read
|
||||
said = votes(given.seats)
|
||||
if isinstance(said, Failure):
|
||||
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)
|
||||
overall = [each[-1] for each in count.values()]
|
||||
if split(overall):
|
||||
heading_read, seats_read = read
|
||||
written = votes(seats_read.seats)
|
||||
if isinstance(written, Failure):
|
||||
return written
|
||||
counts = counted(seats_read.seats, written)
|
||||
tally = ", ".join(f"{seat.name} {vote_text(DIMENSIONS[-1], overall(written[seat.name]), overall(counts[seat.name]))}" for seat in seats_read.seats)
|
||||
overall_votes = [overall(each) for each in counts.values()]
|
||||
if split(overall_votes):
|
||||
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.")
|
||||
ruled = ruling(overall_votes)
|
||||
fell = fallen(counts) if ruled != "worse" else []
|
||||
if not fell:
|
||||
if scores_file:
|
||||
return Failure(f"no dimension fell in this {ruled} ruling, so it takes no scores file")
|
||||
return recorded_ruling(heading_read, seats_read, written, counts, ruled, tally, [], None)
|
||||
if not scores_file:
|
||||
print(f"Fell: {', '.join(fell)}, in a {ruled} ruling. Launch the four scoring seats on {heading_read.label} at {heading_read.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 = []
|
||||
if scores_file:
|
||||
scored = read_fall_scores(scores_file, named)
|
||||
if isinstance(scored, Failure):
|
||||
return scored
|
||||
scoring = scored
|
||||
ruled, why = fall_ruling(ruled, fell, scoring.means)
|
||||
notes = [why]
|
||||
scoring = read_fall_scores(scores_file, heading_read)
|
||||
if isinstance(scoring, Failure):
|
||||
return scoring
|
||||
ruled, why = fall_ruling(ruled, fell, scoring.means)
|
||||
return recorded_ruling(heading_read, seats_read, written, counts, ruled, tally, [why], scoring)
|
||||
|
||||
|
||||
def recorded_ruling(heading_read: Heading, seats_read: SeatsFile, written: dict[str, list[str]], counts: dict[str, list[str]], ruled: str, tally: str, notes: list[str], scoring: ScoringRun | None) -> Failure | None:
|
||||
print(f"Ruling: {ruled}. {' '.join(notes + [f'Overall votes as counted: {tally}.'])}")
|
||||
return append(given.read, ruling_entry(named.title, given.seats, said, count, ruled, notes, scoring))
|
||||
return append(seats_read.read, ruling_entry(heading_read.title, seats_read.seats, written, counts, ruled, notes, scoring))
|
||||
|
||||
|
||||
def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int]) -> Failure | None:
|
||||
|
||||
Reference in New Issue
Block a user