Answer architecture round 2: 0 🔴, 2 🟡 (0 misread); score_bullets reads the shared dimension names, every ladder model has a price
This commit is contained in:
@@ -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 [<item ID>...]", 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 [<item ID>...]", 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 <votes file>", lambda given: len(given) == 1, lambda given: record_ruling(pathlib.Path(given[0]))),
|
||||
"prepare-scoring": Command("prepare-scoring [--preloaded <text>]", 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 <scores file> [<item ID>...]", 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 <scores file> [<item ID>...]", 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 <pass> [--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:
|
||||
|
||||
@@ -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, `- **<n> — ` or `- **<dimension>**`, 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 `- **<n> — ` and four opening `- **<dimension>**` 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, `- **<n> — ` or `- **<name>** — `, 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 `- **<n> — ` and one opening `- **<name>** — ` 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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user