From 95fb0d03cfee3da5fdd9f244765163b7a41fc7b9 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 12 Nov 2026 20:10:55 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20architecture=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20score=5Fbul?= =?UTF-8?q?lets=20reads=20the=20shared=20dimension=20names,=20every=20ladd?= =?UTF-8?q?er=20model=20has=20a=20price?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/larv_review/main.py | 11 +++++------ bin/larv_review/scoring_setup.py | 19 +++++++++++-------- bin/larv_review/test_scoring_setup.py | 4 ++++ bin/model_routing/test_prices.py | 17 +++++++++++++++++ bin/review_replay/replay.py | 2 +- 5 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 bin/model_routing/test_prices.py diff --git a/bin/larv_review/main.py b/bin/larv_review/main.py index b933c08e..3a136718 100644 --- a/bin/larv_review/main.py +++ b/bin/larv_review/main.py @@ -169,10 +169,11 @@ from larv_review.reviewer_header import reviewer_header class Command(typing.NamedTuple): - """One subcommand: how the usage line spells it, whether the arguments after its name fit, and what it does with them.""" + """One subcommand: how the usage line spells it, whether the arguments after its name fit, and what it does with them. Where it ends in item IDs, ids_from is the number of arguments before them, so main can name the ones that aren't.""" shape: str fits: typing.Callable[[list[str]], bool] run: typing.Callable[[list[str]], Failure | None] + ids_from: int | None = None def no_arguments(given: list[str]) -> bool: @@ -188,18 +189,16 @@ COMMANDS = { "review-folder": Command("review-folder", no_arguments, lambda given: make_review_folder()), "ruling-base": Command("ruling-base", no_arguments, lambda given: with_default_branch(show_ruling_base, stale_ok=False)), "round-count": Command("round-count", no_arguments, lambda given: with_default_branch(round_count, stale_ok=True)), - "needs-scoring-run": Command("needs-scoring-run [...]", are_ids, lambda given: with_default_branch(lambda default: needs_scoring_run(default, [int(id_) for id_ in given]), stale_ok=False)), + "needs-scoring-run": Command("needs-scoring-run [...]", are_ids, lambda given: with_default_branch(lambda default: needs_scoring_run(default, [int(id_) for id_ in given]), stale_ok=False), ids_from=0), "scoring-run-owed": Command("scoring-run-owed", no_arguments, lambda given: with_default_branch(owed, stale_ok=False)), "record-ruling": Command("record-ruling ", lambda given: len(given) == 1, lambda given: record_ruling(pathlib.Path(given[0]))), "prepare-scoring": Command("prepare-scoring [--preloaded ]", lambda given: not given or len(given) == 2 and given[0] == "--preloaded", lambda given: prepared_scoring(given[1] if given else None)), - "record-scoring": Command("record-scoring [...]", lambda given: bool(given) and are_ids(given[1:]), lambda given: with_default_branch(lambda default: record_scoring(default, pathlib.Path(given[0]), [int(id_) for id_ in given[1:]]), stale_ok=False)), + "record-scoring": Command("record-scoring [...]", lambda given: bool(given) and are_ids(given[1:]), lambda given: with_default_branch(lambda default: record_scoring(default, pathlib.Path(given[0]), [int(id_) for id_ in given[1:]]), stale_ok=False), ids_from=1), "places": Command("places", no_arguments, lambda given: show_places()), "agreement": Command("agreement", no_arguments, lambda given: show_agreement()), "reviewer-header": Command("reviewer-header [--rerun]", lambda given: given[:1] != [] and given[0] in REVIEWERS and given[1:] in ([], ["--rerun"]), lambda given: with_default_branch(lambda default: reviewer_header(default, given[0], given[1:] == ["--rerun"]), stale_ok=True)), "reviewer-context": Command("reviewer-context", no_arguments, lambda given: printed(hook_reply(sys.stdin.read(), pathlib.Path.home()))), } -# The commands that take item IDs, each with the number of arguments before the IDs. -ID_COMMANDS = {"needs-scoring-run": 0, "record-scoring": 1} SHAPES = " | ".join(command.shape for command in COMMANDS.values()) USAGE = f"usage: larv-review {SHAPES}" @@ -215,7 +214,7 @@ def main(argv: list[str]) -> int: command = COMMANDS.get(name) if command and command.fits(given): done = command.run(given) - elif command and name in ID_COMMANDS and (named := [id_ for id_ in given[ID_COMMANDS[name]:] if not re.fullmatch(r"[0-9]+", id_)]): + elif command and command.ids_from is not None and (named := [id_ for id_ in given[command.ids_from:] if not re.fullmatch(r"[0-9]+", id_)]): print(f"{name} takes item IDs, the numbers in todo.md's ID column, not {' '.join(named)}; {USAGE}", file=sys.stderr) return 1 else: diff --git a/bin/larv_review/scoring_setup.py b/bin/larv_review/scoring_setup.py index 130cddca..32d7af49 100644 --- a/bin/larv_review/scoring_setup.py +++ b/bin/larv_review/scoring_setup.py @@ -4,6 +4,7 @@ import pathlib import re import shutil +from review_rules.comprehension_history import DIMENSIONS from failure import Failure from records.markdown_text import FENCE, listed, section from git_cli.git_repo import git @@ -18,6 +19,8 @@ SEATS = ( ("maintainability-senior", "Senior, maintainability", "Report: Junior A, Mid A and the maintainability senior"), ("inherited-architect", "Architect, inherited", "Report: the inherited architect"), ) +# The dimensions a seat scores beside the overall, which comes last in DIMENSIONS. +PANEL_DIMENSIONS = DIMENSIONS[:-1] VALUE_NAMES = ("language", "kind", "domain", "domain docs", "3am question") FORBIDDEN_FILES = ("todo.md", "docs/decisions.md", "docs/comprehension-history.md", "docs/reading-cost.md") FORBIDDEN = "todo.md, docs/decisions.md, docs/comprehension-history.md or docs/reading-cost.md (the plan, the decision log, past panels' records and past chunks' reading cost)" @@ -43,17 +46,17 @@ def bullets(lines: list[str]) -> list[list[str]]: ANCHOR = re.compile(r"- \*\*\d+ — ") -DIMENSIONS = ("Navigation", "Locality", "Shape", "Self-sufficiency") +DIMENSION = re.compile(r"- \*\*([^*]+)\*\* — ") def score_bullets(skill: str) -> tuple[list[str], list[str]] | Failure: - """The six anchor bullets and the four dimension bullets of SKILL.md → "The score", without bold, each on one line. A bullet is one by how it opens, `- ** — ` or `- ****`, so other bullets and their order in the section change nothing.""" - lines = [line.replace("**", "") for group in bullets(section(skill, "The score") or []) for line in group if ANCHOR.match(line) or line.startswith(tuple(f"- **{name}**" for name in DIMENSIONS))] - anchors = [line for line in lines if line[2].isdigit()] - dimensions = [line for line in lines if not line[2].isdigit()] - if len(anchors) != 6 or [line.split(" — ")[0] for line in dimensions] != [f"- {name}" for name in DIMENSIONS]: - return Failure(f"{PANEL / 'SKILL.md'} → \"The score\" no longer holds six bullets opening `- ** — ` and four opening `- ****` for Navigation, Locality, Shape and Self-sufficiency, in that order") - return anchors, dimensions + """The six anchor bullets and the four dimension bullets of SKILL.md → "The score", without bold, each on one line. A bullet is one by how it opens, `- ** — ` or `- **** — `, so other bullets and their order in the section change nothing.""" + lines = [line for group in bullets(section(skill, "The score") or []) for line in group] + anchors = [line.replace("**", "") for line in lines if ANCHOR.match(line)] + dimensions = [(match[1], line) for line in lines if (match := DIMENSION.match(line))] + if len(anchors) != 6 or tuple(name for name, _ in dimensions) != PANEL_DIMENSIONS: + return Failure(f"{PANEL / 'SKILL.md'} → \"The score\" no longer holds six bullets opening `- ** — ` and one opening `- **** — ` for each of {listed(list(PANEL_DIMENSIONS), 'and')}, in that order") + return anchors, [line.replace("**", "") for _, line in dimensions] def project_values(text: str, source: str) -> dict[str, str] | Failure: diff --git a/bin/larv_review/test_scoring_setup.py b/bin/larv_review/test_scoring_setup.py index eaace866..313c52ad 100644 --- a/bin/larv_review/test_scoring_setup.py +++ b/bin/larv_review/test_scoring_setup.py @@ -38,6 +38,10 @@ class ScoreBullets(unittest.TestCase): with self.subTest(dropped=dropped): self.assertIsInstance(score_bullets(skill.replace(dropped, "- Dropped:", 1)), Failure) + def test_fails_where_a_fifth_dimension_is_added(self): + skill = SKILL.read_text() + self.assertIsInstance(score_bullets(skill.replace("- **Shape** —", "- **Extra** — a new one.\n- **Shape** —", 1)), Failure) + class ProjectValues(unittest.TestCase): def test_reads_each_spelling_the_projects_use(self): diff --git a/bin/model_routing/test_prices.py b/bin/model_routing/test_prices.py new file mode 100644 index 00000000..5999e34b --- /dev/null +++ b/bin/model_routing/test_prices.py @@ -0,0 +1,17 @@ +import pathlib +import sys +import unittest + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) + +from model_routing.ladder import LADDER +from model_routing.prices import PRICES + + +class Prices(unittest.TestCase): + def test_every_model_on_the_ladder_has_a_price_since_a_model_without_one_costs_nothing_in_a_figure(self): + self.assertEqual(sorted({rung.model for rung in LADDER} - set(PRICES)), []) + + +if __name__ == "__main__": + unittest.main() diff --git a/bin/review_replay/replay.py b/bin/review_replay/replay.py index 5fc68bc6..3e1707ae 100644 --- a/bin/review_replay/replay.py +++ b/bin/review_replay/replay.py @@ -88,7 +88,7 @@ class Copies: reports: str -# The shell makes and removes the clone itself, and is tested on a temporary home as judge-replay's is; rounds.py's core takes the filesystem as an argument. +# The shell makes and removes the clone itself, and is tested on a temporary home as judge-replay's is. def review(found: Round, code: Code, rung: Rung, home: pathlib.Path, effects: Effects, bare: bool) -> str | Failure | Limited: try: (home / REPORTS).mkdir(mode=0o700, parents=True, exist_ok=True)