Answer principles round 1: 0 🔴, 1 🟡; print the rest of the report when the anchors cannot be read, and still exit 1

This commit is contained in:
2026-10-16 20:00:40 +02:00
parent 0f3434f2c5
commit 717f56d319
3 changed files with 68 additions and 24 deletions
+10 -12
View File
@@ -30,9 +30,9 @@ scored before L, E and I, the newest first among equals. Each line gives what th
measured, which items shipped with it, and its tagline.
Then the project's anchors, the shipped items its docs/score-anchors.md names for each level of L,
E and I, read from the checkout's working tree, each line as above, or that no merge shipped it. Exit 1
on a row that names no level on its scale, a level named twice, or an Items cell that is not a list
of IDs.
E and I, read from the checkout's working tree, each line as above, or that no merge shipped it. A
row that names no level on its scale, a level named twice, or an Items cell that is not a list of
IDs leaves the anchors out, saying why, and exits 1 after the rest of the report.
Then the median of the outcome R and S each predict at each value they were guessed at: R against
🔴 findings, S against lines changed. And how well L, E and I each order chunks by review rounds
@@ -48,7 +48,7 @@ import pathlib
import re
import sys
from score_outcomes.anchors import anchor_lines, ANCHORS_PATH, parse_anchors
from score_outcomes.anchors import anchor_lines, Anchors, ANCHORS_PATH, parse_anchors
from git_repo import default_branch, file_at, full_history, git, top
from failure import Failure
from todo_table import LEVELS, risk, TOP_SCORE
@@ -78,17 +78,15 @@ def main(argv: list[str]) -> int:
if isinstance(outcomes, Failure):
return failed(outcomes)
anchored = read_anchors()
if isinstance(anchored, Failure):
return failed(anchored)
given = dict(zip(GIVEN, map(int, argv)))
print(report_text(outcomes, anchored, given))
return 0
print(report_text(outcomes, anchored, dict(zip(GIVEN, map(int, argv))) if argv else None))
# Anchors the tool cannot read leave the rest of the report standing, and still fail the run.
return failed(anchored) if isinstance(anchored, Failure) else 0
def report_text(outcomes: list[Outcome], anchored: list[tuple[str, tuple[int, ...]]], given: dict[str, int]) -> str:
def report_text(outcomes: list[Outcome], anchored: Anchors | Failure, given: dict[str, int] | None) -> str:
"""The report: the finished items nearest the given scores, where any are given, then the anchors, then the medians."""
sections = []
if given:
if given is not None:
r = risk(given["L"], given["E"], given["I"])
near = [render(outcome) for outcome in nearest(outcomes, given | {"R": r})] or ["- None: no merge commit on the default branch shipped an item from todo.md. A project that merges by squash or fast-forward has none."]
sections.append([f"Finished items nearest L {given['L']}, E {given['E']}, I {given['I']}, so R {r}, and S {given['S']}, closest first:", "", *near])
@@ -102,7 +100,7 @@ def failed(failure: Failure) -> int:
return 1
def read_anchors() -> list[tuple[str, tuple[int, ...]]] | Failure:
def read_anchors() -> Anchors | Failure:
"""The checkout's anchors as its working tree holds them, so a branch that edits them shows its edit; none where it has no such file."""
root = top()
if isinstance(root, Failure):