Answer architecture round 5: give record_scoring's moved Mean its own path, and take pending_fall from a paired entry alone
This commit is contained in:
+46
-27
@@ -10,8 +10,8 @@ docs/comprehension-history.md in the checkout.
|
||||
|
||||
ruling-base prints the commit a paired ruling reads against, then which of these found it. The last
|
||||
measured commit is the default branch's newest merged change whose last added paired ruling, by
|
||||
heading time, is better, or that adds a scoring run to the history while that ruling names no fall; a merge commit counts as
|
||||
one change against its first parent. With none, the base is the one the history's first paired
|
||||
heading time, is better, or that adds a scoring run to the history while that ruling names no
|
||||
fall; a merge commit counts as one change against its first parent. With none, the base is the one the history's first paired
|
||||
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
|
||||
@@ -23,8 +23,8 @@ prints why the chunk is due a scoring run, or `No scoring run due.` The chunk's
|
||||
the checkout's history holds and the default branch's lacks. It is due when the chunk ships an
|
||||
item whose tagline names the comprehension floor, when the chunk's newest entry is a 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
|
||||
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
|
||||
no v* tag.
|
||||
|
||||
@@ -36,12 +36,14 @@ opens with its label, written exactly: `Junior A:`, `Mid A:`, `Maintainability s
|
||||
|
||||
PR #231 at abc1234, against def5678
|
||||
|
||||
Mid A: Navigation same, Locality worse, Shape same, Self-sufficiency same, Overall worse
|
||||
Mid A: Navigation better, Locality worse, Shape same, Self-sufficiency same, Overall better
|
||||
|
||||
- Navigation, Overall: `README.md:40` "Tools": names the tool a symptom leads to
|
||||
- Locality: `bin/x.py:12` `run`: three branches to hold at once
|
||||
|
||||
Inherited architect: Navigation same, Locality worse, Shape same, Self-sufficiency same, Overall worse
|
||||
Inherited architect: Navigation better, Locality worse, Shape same, Self-sufficiency same, Overall better
|
||||
|
||||
- Navigation: `README.md:40` "Tools": ...
|
||||
- Locality: `bin/x.py:12` `run`: ...
|
||||
|
||||
record-ruling takes Mid A's and the inherited architect's votes on each dimension and overall,
|
||||
@@ -50,8 +52,7 @@ joined by `, ` and followed by `: `. A dimension's vote counts as same unless on
|
||||
places opens with that dimension and holds a `path:line` in backticks; the overall vote counts as
|
||||
same unless any place holds one. 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
|
||||
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. Unless the ruling is worse, it prints and records a `Fell:` line naming each.
|
||||
|
||||
@@ -61,13 +62,14 @@ architect's lines in that order, or a `Mean:` line alone for a run moved from a
|
||||
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}. It exits 1 on a run with
|
||||
seats that no plan item, release or fall calls. A `Floor:` line says the means under the floor
|
||||
block the merge, as they do when needs-scoring-run would give a reason besides a fall. It reads the
|
||||
chunk's entries as needs-scoring-run does. When a fall is pending, it says whether the paired
|
||||
ruling stands. When a fallen dimension's mean is under the floor, the ruling counts as worse, and
|
||||
it prints and records a `Ratchet:` line. needs-scoring-run repeats that line as `Still standing:`
|
||||
until a paired ruling follows it.
|
||||
decimals, and prints the means, the item IDs it read, and each mean under the floor of {floor}. It
|
||||
exits 1 on a run with seats that no plan item, release or fall calls. A line opening `Floor:` says
|
||||
the means under the floor block the merge, as they do when needs-scoring-run would give a reason
|
||||
besides a fall. It reads the chunk's entries as needs-scoring-run does. When a fall is pending, it
|
||||
says whether the paired ruling stands. When a fallen dimension's mean is under the floor, the
|
||||
ruling counts as worse, and it prints and records a `Ratchet:` line. needs-scoring-run repeats that
|
||||
line, prefixed with `Still standing:`, until a paired ruling follows it. Once a scoring run follows
|
||||
a fall, the fall calls no other.
|
||||
|
||||
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
|
||||
@@ -78,6 +80,7 @@ Exit 1, saying why, on unknown arguments, an unknown item ID, a seats file it ca
|
||||
breaks the shape above, or when git cannot start, finds no checkout or no default branch, cannot
|
||||
fetch origin for ruling-base or needs-scoring-run, or cannot read or write the history or todo.md.
|
||||
"""
|
||||
import decimal
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
@@ -85,7 +88,7 @@ import time
|
||||
import typing
|
||||
|
||||
from larv_review.history import appended, Entry, heading, ruling_entry, scoring_entry, vote_text
|
||||
from larv_review.rules import base, CAP, chunk_entries, counted, fall_outcome, fallen, FLOOR, floor_verdict, means, PASSES, pending_fall, plan_items, round_counts, ruling, scoring_run_due, standing_ratchet, under_floor, votes
|
||||
from larv_review.rules import base, CAP, chunk_entries, counted, fall_outcome, fallen, FLOOR, floor_verdict, means, PASSES, pending_fall, plan_items, round_counts, ruling, scoring_run_due, standing_ratchet, uncalled, 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
|
||||
@@ -111,7 +114,8 @@ def main(argv: list[str]) -> int:
|
||||
elif command == "record-scoring" and given and all(re.fullmatch(r"[0-9]+", id_) for id_ in given[1:]):
|
||||
done = with_default_branch(lambda default: record_scoring(default, pathlib.Path(given[0]), [int(id_) for id_ in given[1:]]), stale_ok=True)
|
||||
elif command in ("needs-scoring-run", "record-scoring") and given:
|
||||
print(f"{command} takes item IDs, the numbers in todo.md's ID column: {' '.join(given)}", file=sys.stderr)
|
||||
named = given[1:] if command == "record-scoring" else given
|
||||
print(f"{command} takes item IDs, the numbers in todo.md's ID column, not {' '.join(id_ for id_ in named if not re.fullmatch(r'[0-9]+', id_))}; {USAGE}", file=sys.stderr)
|
||||
return 1
|
||||
elif not argv:
|
||||
print(USAGE, file=sys.stderr)
|
||||
@@ -236,28 +240,43 @@ def record_scoring(default: str, seats_file: pathlib.Path, ids: list[int]) -> Fa
|
||||
if isinstance(read, Failure):
|
||||
return read
|
||||
title, given = read
|
||||
found = scores(given.seats) if given.moved_mean is None else {}
|
||||
if given.moved_mean is not None:
|
||||
return record_moved_mean(title, given.moved_mean)
|
||||
found = scores(given.seats)
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
moved = [] if given.moved_mean is None else score_line(MEAN, given.moved_mean)
|
||||
if isinstance(moved, Failure):
|
||||
return moved
|
||||
mean = means(list(found.values()) or [moved])
|
||||
mean = means(list(found.values()))
|
||||
recorded = chunk_history(default)
|
||||
if isinstance(recorded, Failure):
|
||||
return recorded
|
||||
blocking = [] if given.moved_mean else due_reasons(default, ids, [])
|
||||
blocking = due_reasons(default, ids, [])
|
||||
if isinstance(blocking, Failure):
|
||||
return blocking
|
||||
if not (blocking or given.moved_mean or pending_fall(recorded)):
|
||||
return Failure("no plan item, release or fall calls this scoring run; name the item IDs the chunk ships, as needs-scoring-run took them")
|
||||
print(f"Means: {', '.join(f'{name} {value}' for name, value in zip(DIMENSIONS, mean))}. {floor_verdict(under_floor(mean), blocking)}")
|
||||
outcome = fall_outcome([] if given.moved_mean else pending_fall(recorded), mean)
|
||||
fell = pending_fall(recorded)
|
||||
if not (blocking or fell):
|
||||
return Failure(uncalled(recorded))
|
||||
print(f"Means: {means_text(mean)}.")
|
||||
print(f"Item IDs read: {', '.join(map(str, ids)) or 'none'}.")
|
||||
print(floor_verdict(under_floor(mean), blocking))
|
||||
outcome = fall_outcome(fell, mean)
|
||||
if outcome:
|
||||
print(outcome[0])
|
||||
return append(scoring_entry(title, given.seats, found, [str(value) for value in mean], outcome[1] if outcome else []))
|
||||
|
||||
|
||||
def record_moved_mean(title: str, line: str) -> Failure | None:
|
||||
moved = score_line(MEAN, line)
|
||||
if isinstance(moved, Failure):
|
||||
return moved
|
||||
mean = means([moved])
|
||||
print(f"Means: {means_text(mean)}.")
|
||||
return append(scoring_entry(title, [], {}, [str(value) for value in mean], []))
|
||||
|
||||
|
||||
def means_text(mean: list[decimal.Decimal]) -> str:
|
||||
return ", ".join(f"{name} {value}" for name, value in zip(DIMENSIONS, mean))
|
||||
|
||||
|
||||
def read_seats(seats_file: pathlib.Path, paired: bool) -> tuple[str, Report] | Failure:
|
||||
"""The seats file, and the heading its record goes under, once each commit it names is in the checkout."""
|
||||
try:
|
||||
|
||||
@@ -70,7 +70,14 @@ def chunk_entries(default_history: str, history: str) -> list[Entry]:
|
||||
|
||||
def pending_fall(chunk: list[Entry]) -> list[str]:
|
||||
"""The dimensions that fell in the chunk's newest entry, empty unless that entry is a paired ruling."""
|
||||
return chunk[-1].fell if chunk else []
|
||||
return chunk[-1].fell if chunk and chunk[-1].paired else []
|
||||
|
||||
|
||||
def uncalled(chunk: list[Entry]) -> str:
|
||||
"""Why a scoring run nothing calls fails, and what to do instead."""
|
||||
if chunk and not chunk[-1].paired:
|
||||
return "the chunk's newest entry is already a scoring run; record a paired ruling first, or name the item IDs the chunk ships"
|
||||
return "no plan item, release or fall calls this scoring run; name the item IDs the chunk ships, as needs-scoring-run took them"
|
||||
|
||||
|
||||
def standing_ratchet(chunk: list[Entry]) -> str | None:
|
||||
|
||||
@@ -319,6 +319,8 @@ class LarvReviewTool(unittest.TestCase):
|
||||
|
||||
self.assertIn("\n\nRatchet: the paired ruling counts as worse", (self.checkout / "docs" / "comprehension-history.md").read_text())
|
||||
self.assertTrue(self.run_tool("needs-scoring-run", "2").stdout.startswith("No scoring run due.\nStill standing: Ratchet:"))
|
||||
again = self.run_tool("record-scoring", self.seats_file(f"PR #2 at {self.start}\n" + seats))
|
||||
self.assertIn("already a scoring run; record a paired ruling first", again.stderr)
|
||||
same = self.run_tool("record-ruling", self.seats_file(f"PR #3 at {self.start}, against {self.start}\n\nMid A: {said('same', 'worse')}{place}Inherited architect: {said('same', 'worse')}{place}"))
|
||||
self.assertIn("Fell: Locality.", same.stdout, same.stderr)
|
||||
stands = self.run_tool("record-scoring", self.seats_file(f"PR #2 at {self.start}\n" + seats.replace("Locality 6.5", "Locality 7")))
|
||||
@@ -338,7 +340,10 @@ class LarvReviewTool(unittest.TestCase):
|
||||
self.assertIn("name the item IDs the chunk ships", uncalled.stderr)
|
||||
due = self.run_tool("record-scoring", self.seats_file(f"PR #3 at {self.start}\n" + seats), "1")
|
||||
self.assertEqual(due.returncode, 0, due.stderr)
|
||||
self.assertIn("Floor: Locality 6.50, Self-sufficiency 6.50 under the floor of 7.0 block the merge, as the chunk leaves release 0.1.0 with no plan item.", due.stdout)
|
||||
self.assertIn("\nItem IDs read: 1.\nFloor: Locality 6.50, Self-sufficiency 6.50 under the floor of 7.0 block the merge, as the chunk leaves release 0.1.0 with no plan item.\n", due.stdout)
|
||||
swapped = self.run_tool("record-scoring", "1", self.seats_file(f"PR #3 at {self.start}\n" + seats))
|
||||
self.assertEqual(swapped.returncode, 1)
|
||||
self.assertIn("not /", swapped.stderr)
|
||||
text = (self.checkout / "docs" / "comprehension-history.md").read_text()
|
||||
self.assertIn("| Mean | 7.00 | 6.50 | 7.00 | 6.50 | 7.00 |", text)
|
||||
self.assertIn("Inherited architect, would restructure first:", text)
|
||||
|
||||
Reference in New Issue
Block a user