Rule each dimension in the paired ruling, and count a better ruling as worse when a dimension it rules fallen is under the floor

This commit is contained in:
2026-10-09 10:51:09 +02:00
parent a984e98e0a
commit 2c6e0633cf
10 changed files with 197 additions and 88 deletions
+52 -22
View File
@@ -20,7 +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, 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 better
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
@@ -34,26 +35,30 @@ opens with its label, written exactly: `Junior A:`, `Mid A:`, `Maintainability s
PR #231 at abc1234, against def5678
Mid A: worse
Mid A: Navigation same, Locality worse, Shape same, Self-sufficiency same, Overall worse
- `bin/x.py:12` `run`: three branches to hold at once
Inherited architect: worse
Inherited architect: Navigation same, Locality worse, Shape same, Self-sufficiency same, Overall worse
- `bin/x.py:12` `run`: ...
record-ruling takes Mid A's and the inherited architect's votes, better, same or worse; a better or
worse vote naming no place in backticks, `path:line`, counts as same, and the printed votes say so.
When the two counted 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 vote that leads each
other vote by two or more, else same; it prints `Ruling:` and appends the ruling.
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
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.
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.
Each line is `Navigation <n>, Locality <n>, Shape <n>, Self-sufficiency <n>, Overall <n>`, each
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}.
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.
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
@@ -71,7 +76,7 @@ import time
import typing
from larv_review.history import appended, heading, ruling_entry, scoring_entry, vote_text
from larv_review.rules import base, CAP, FLOOR, means, PASSES, plan_items, round_counts, ruling, scoring_run_due, under_floor, votes
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.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
@@ -168,7 +173,10 @@ def needs_scoring_run(default: str, ids: list[int]) -> Failure | None:
landed = landed_since_release(default)
if isinstance(landed, Failure):
return landed
reasons = scoring_run_due(planned, chunk, ids, landed)
history = history_text()
if isinstance(history, Failure):
return history
reasons = scoring_run_due(planned, chunk, ids, landed, pending_fall(history[1]))
if isinstance(reasons, Failure):
return reasons
print(f"Scoring run due: the chunk {' and '.join(reasons)}." if reasons else "No scoring run due.")
@@ -180,16 +188,20 @@ def record_ruling(seats_file: pathlib.Path) -> Failure | None:
if isinstance(read, Failure):
return read
title, given = read
counted = votes(given.seats)
if isinstance(counted, Failure):
return counted
tally = ", ".join(f"{seat.name} {vote_text(seat, counted[seat.name])}" for seat in given.seats)
ruled = ruling(list(counted.values()))
said = votes(given.seats)
if isinstance(said, Failure):
return said
count = counted(given.seats, said)
tally = ", ".join(f"{seat.name} {vote_text(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:
print(f"Split: {tally}. Launch the maintainability senior and Junior A together, add their lines to the seats file, and run this again.")
return None
print(f"Ruling: {ruled}. Votes as counted: {tally}.")
return append(ruling_entry(title, given.seats, counted, ruled))
fell = fallen(count)
print(f"Ruling: {ruled}. Overall votes as counted: {tally}.")
if ruled == "better" 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:
@@ -206,7 +218,14 @@ 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}'}.")
return append(scoring_entry(title, given.seats, found, [str(value) for value in mean]))
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))
def read_seats(seats_file: pathlib.Path, paired: bool) -> tuple[str, Report] | Failure:
@@ -225,16 +244,27 @@ def read_seats(seats_file: pathlib.Path, paired: bool) -> tuple[str, Report] | F
return named.title, given
def append(entry: str) -> Failure | None:
def history_text() -> tuple[pathlib.Path, str] | Failure:
"""The checkout's history and its text, empty when the file is missing."""
checkout = top()
if isinstance(checkout, Failure):
return checkout
history = pathlib.Path(checkout, HISTORY)
try:
text = history.read_text(encoding="utf-8") if history.exists() else ""
history.parent.mkdir(parents=True, exist_ok=True)
return history, history.read_text(encoding="utf-8") if history.exists() else ""
except (OSError, UnicodeDecodeError) as failure:
return Failure(f"could not read {history}: {failure}")
def append(entry: str) -> Failure | None:
read = history_text()
if isinstance(read, Failure):
return read
history, text = read
try:
history.parent.mkdir(parents=True, exist_ok=True)
except OSError as failure:
return Failure(f"could not create {history.parent}: {failure}")
if unwritten := replace_file(history, appended(text, entry).encode()):
return Failure(f"could not write {history}: {unwritten.reason}")
print(f"Appended to {history}.")