Answer principles round 1: 0 🔴, 3 🟡 (0 misread); refuse a misread count above the findings, share the lower-bound rule, name score-outcomes' new list in the README
This commit is contained in:
+10
-9
@@ -1,4 +1,4 @@
|
||||
"""The titles of larv-review's round commits, `Answer <pass> round <n>: <k> 🔴, <m> 🟡 (<j> misread); <summary>`: each pass's round count, and the findings the rounds reported. <j> counts the 🔴 and 🟡 findings a reviewer marked `[misread]`, because the implementer misread code that had already shipped."""
|
||||
"""The titles of larv-review's round commits, `Answer <pass> round <n>: <k> 🔴, <m> 🟡 (<j> misread); <summary>`: each pass's round count, and the findings the rounds reported. <j> counts the 🔴 and 🟡 findings a reviewer marked `[misread]`."""
|
||||
import dataclasses
|
||||
import re
|
||||
|
||||
@@ -7,13 +7,13 @@ from review_passes import PASSES
|
||||
# The most rounds a pass takes before the run asks the human, per `docs/decisions.md` → `review: a pass gets at most three rounds per chunk; …`. rule-hook's `round-cap` refuses a round title past it, and `larv-review round-count` marks a pass at or past it.
|
||||
CAP = 3
|
||||
ROUND = re.compile(r"^Answer (.+?) round ([0-9]+):", re.IGNORECASE)
|
||||
# What follows a round title's colon: the round's 🔴 and 🟡 counts, then how many of them were misread, which titles from before the count lack, then `;` and its summary, if any.
|
||||
# What follows a round title's colon: the round's 🔴 and 🟡 counts, then how many of them a reviewer marked `[misread]`, a count that titles from before it lack, then `;` and its summary, if any.
|
||||
FINDINGS = re.compile(r" ([0-9]+) 🔴, ([0-9]+) 🟡(?: \(([0-9]+) misread\))?(?:;|$)")
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Counts:
|
||||
"""A round title's findings: its 🔴 and 🟡 counts, and how many of them were misread, None for a title from before that count."""
|
||||
class Findings:
|
||||
"""A round title's findings: its 🔴 and 🟡 counts, and how many of them a reviewer marked `[misread]`, None for a title from before that count."""
|
||||
red: int
|
||||
yellow: int
|
||||
misread: int | None
|
||||
@@ -42,16 +42,17 @@ def past_cap(title: str) -> bool:
|
||||
return named is not None and int(named.group(2)) > CAP
|
||||
|
||||
|
||||
def title_counts(title: str) -> Counts | None:
|
||||
"""The counts after a round title's colon; None where title is no round title, or lacks the 🔴 and 🟡 counts."""
|
||||
def title_counts(title: str) -> Findings | None:
|
||||
"""The counts after a round title's colon; None where title is no round title, lacks the 🔴 and 🟡 counts, or counts more misread findings than both."""
|
||||
named = ROUND.match(title)
|
||||
found = FINDINGS.match(title, named.end()) if named else None
|
||||
if not found:
|
||||
return None
|
||||
return Counts(int(found.group(1)), int(found.group(2)), None if found.group(3) is None else int(found.group(3)))
|
||||
counts = Findings(int(found.group(1)), int(found.group(2)), None if found.group(3) is None else int(found.group(3)))
|
||||
return None if counts.misread is not None and counts.misread > counts.red + counts.yellow else counts
|
||||
|
||||
|
||||
def round_findings(titles: list[str]) -> Counts | None:
|
||||
def round_findings(titles: list[str]) -> Findings | None:
|
||||
"""The counts summed over the round titles among titles; None where a round title lacks the 🔴 and 🟡 counts, or no title is a round. Its misread is None where a round title lacks that count."""
|
||||
counts = []
|
||||
for title in titles:
|
||||
@@ -62,4 +63,4 @@ def round_findings(titles: list[str]) -> Counts | None:
|
||||
if not counts:
|
||||
return None
|
||||
misreads = [found.misread for found in counts if found.misread is not None]
|
||||
return Counts(sum(found.red for found in counts), sum(found.yellow for found in counts), sum(misreads) if len(misreads) == len(counts) else None)
|
||||
return Findings(sum(found.red for found in counts), sum(found.yellow for found in counts), sum(misreads) if len(misreads) == len(counts) else None)
|
||||
|
||||
@@ -2,7 +2,7 @@ import dataclasses
|
||||
import statistics
|
||||
import typing
|
||||
|
||||
from round_titles import Counts, round_counts, round_findings
|
||||
from round_titles import Findings, round_counts, round_findings
|
||||
from comprehension_history import HISTORY
|
||||
from todo_table import Item, items
|
||||
from markdown_text import listed
|
||||
@@ -22,7 +22,7 @@ Chunk = tuple[str, str, int, Landing]
|
||||
# The tool's name and report call a Result an outcome, a word the code keeps for an entry of a `.outcomes.md` file: docs/decisions.md → `bin/: an outcome is an entry`.
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Result:
|
||||
"""What the chunk that shipped an item measured. findings holds the 🔴 and 🟡 counts, and how many of them arose from misreading code that had already shipped, None where a round title lacks the 🔴 and 🟡 counts or the branch has no round; its misread is None where a round title lacks that count. landed says how the chunk reached the default branch: by a merge commit, by a rebase that replayed its commits, or by commits never replayed."""
|
||||
"""What the chunk that shipped an item measured. findings holds the 🔴 and 🟡 counts, and how many of them a reviewer marked `[misread]`, None where a round title lacks the 🔴 and 🟡 counts or the branch has no round; its misread is None where a round title lacks that count. landed says how the chunk reached the default branch: by a merge commit, by a rebase that replayed its commits, or by commits never replayed."""
|
||||
item: Item
|
||||
merge: str
|
||||
merged: str
|
||||
@@ -30,7 +30,7 @@ class Result:
|
||||
lines: int
|
||||
files: int
|
||||
rounds_past_first: int
|
||||
findings: Counts | None
|
||||
findings: Findings | None
|
||||
landed: Landing
|
||||
|
||||
|
||||
@@ -101,15 +101,11 @@ def report(results: list[Result]) -> list[str]:
|
||||
|
||||
|
||||
def misreads(results: list[Result]) -> list[str]:
|
||||
"""For each chunk whose round titles count them, newest first: its 🔴 and 🟡 findings from misread shipped code, among all its 🔴 and 🟡 findings."""
|
||||
# A chunk that shipped several items gives each the same Result fields but item, so one line per chunk.
|
||||
"""Newest first, each chunk's 🔴 and 🟡 findings with how many of them a reviewer marked `[misread]`, for each chunk whose round titles count those."""
|
||||
# A chunk that shipped several items has a Result for each, so one line per chunk.
|
||||
chunks = {result.merge: result for result in results}
|
||||
lines = []
|
||||
for result in sorted(chunks.values(), key=lambda result: result.merged, reverse=True):
|
||||
if result.findings is None or result.findings.misread is None:
|
||||
continue
|
||||
at_least = "" if result.landed == "merge" else "at least "
|
||||
lines.append(f"- {result.merged} in {result.merge}: {at_least}{result.findings.misread} of {result.findings.red} 🔴, {result.findings.yellow} 🟡")
|
||||
newest_first = sorted(chunks.values(), key=lambda result: result.merged, reverse=True)
|
||||
lines = [f"- {result.merged} in {result.merge}: {counted(result)}" for result in newest_first if result.findings is not None and result.findings.misread is not None]
|
||||
return lines or ["- None: no chunk's round titles count them."]
|
||||
|
||||
|
||||
@@ -133,14 +129,23 @@ def ranks(values: list[int]) -> list[float]:
|
||||
|
||||
def render(result: Result) -> str:
|
||||
scores = ", ".join(f"{name} {result.item.scores[name]}" for name in SHOWN if name in result.item.scores)
|
||||
# Rebase drops a round's commit that changed no file, so history shows such a chunk's rounds and findings short.
|
||||
at_least = "" if result.landed == "merge" else "at least "
|
||||
merged = {"merge": f"merged {result.merged} in {result.merge}", "rebase": f"merged {result.merged} by rebase in {result.merge}", "push": f"committed {result.merged} in {result.merge}, never replayed, so perhaps part of a pull request"}[result.landed]
|
||||
misread = "" if result.findings is None or result.findings.misread is None else f" ({result.findings.misread} misread)"
|
||||
findings = f"{at_least}{result.findings.red} 🔴, {result.findings.yellow} 🟡{misread}" if result.findings else "findings unknown"
|
||||
others = result.shipped_with
|
||||
together = f", with item{'s' if len(others) > 1 else ''} {', '.join(map(str, others))}" if others else ""
|
||||
return f"- Item {result.item.id}, {scores}: {plural(result.lines, 'line')} in {plural(result.files, 'file')}, {at_least}{plural(result.rounds_past_first, 'round')} past each pass's first, {findings}; {merged}{together}. {result.item.tagline}"
|
||||
return f"- Item {result.item.id}, {scores}: {plural(result.lines, 'line')} in {plural(result.files, 'file')}, {at_least(result)}{plural(result.rounds_past_first, 'round')} past each pass's first, {counted(result)}; {merged}{together}. {result.item.tagline}"
|
||||
|
||||
|
||||
def at_least(result: Result) -> str:
|
||||
"""The words that mark a chunk's rounds and findings as lower bounds: rebase drops a round's commit that changed no file, so history shows a chunk that left no merge commit short."""
|
||||
return "" if result.landed == "merge" else "at least "
|
||||
|
||||
|
||||
def counted(result: Result) -> str:
|
||||
"""A chunk's findings as its round titles spell them: `1 🔴, 2 🟡 (1 misread)`, the misread count left out where they lack it."""
|
||||
if result.findings is None:
|
||||
return "findings unknown"
|
||||
misread = "" if result.findings.misread is None else f" ({result.findings.misread} misread)"
|
||||
return f"{at_least(result)}{result.findings.red} 🔴, {result.findings.yellow} 🟡{misread}"
|
||||
|
||||
|
||||
def plural(count: int, noun: str) -> str:
|
||||
|
||||
@@ -9,8 +9,8 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from score_outcomes.anchors import anchor_lines, parse_anchors
|
||||
from score_outcomes.main import chunk_log, report_text
|
||||
from round_titles import Counts
|
||||
from failure import Failure
|
||||
from round_titles import Findings
|
||||
from test_env import isolated_env
|
||||
from todo_table import Item
|
||||
from score_outcomes.results import Landing, nearest, rank_correlation, render, report, Result, results_of, shipped
|
||||
@@ -31,7 +31,7 @@ def item(id_: int, scores: dict[str, int]) -> Item:
|
||||
|
||||
|
||||
def result(id_: int, r: int, s: int, c: int | None, lines: int = 10, rounds: int = 1, findings: tuple[int, int] | None = (0, 0), merged: str = "2026-10-13T10:00:00Z", shipped_with: tuple[int, ...] = (), levels: dict[str, int] | None = None, landed: Landing = "merge", misread: int | None = None, merge: str = "aaaaaaa") -> Result:
|
||||
return Result(item(id_, {"R": r, "S": s} | ({"C": c} if c else {}) | (levels or {})), merge, merged, shipped_with, lines, 1, rounds, None if findings is None else Counts(*findings, misread), landed)
|
||||
return Result(item(id_, {"R": r, "S": s} | ({"C": c} if c else {}) | (levels or {})), merge, merged, shipped_with, lines, 1, rounds, None if findings is None else Findings(*findings, misread), landed)
|
||||
|
||||
|
||||
class Shipped(unittest.TestCase):
|
||||
@@ -78,13 +78,9 @@ class ResultsOf(unittest.TestCase):
|
||||
numstat = "3\t1\ta.py\n-\t-\tlogo.png\n0\t1\t2026\n5\t0\ttodo.md\n9\t0\tdocs/reading-cost.md\n4\t0\tdocs/comprehension-history.md\n"
|
||||
titles = ["Answer stability round 1: 1 🔴, 2 🟡; fix", "Answer stability round 2: 0 🔴, 1 🟡; fix", "Answer prose round 1: 0 🔴, 3 🟡", "Do it"]
|
||||
found = results_of([item(4, {"R": 2}), item(5, {"R": 3})], "abc1234", "2026-10-13T10:00:00Z", numstat, titles, "merge")
|
||||
self.assertEqual(found[0], Result(item(4, {"R": 2}), "abc1234", "2026-10-13T10:00:00Z", (5,), 5, 3, 1, Counts(1, 6, None), "merge"))
|
||||
self.assertEqual(found[0], Result(item(4, {"R": 2}), "abc1234", "2026-10-13T10:00:00Z", (5,), 5, 3, 1, Findings(1, 6, None), "merge"))
|
||||
self.assertEqual(found[1].shipped_with, (4,))
|
||||
|
||||
def test_counts_the_findings_from_misread_shipped_code_where_every_round_title_counts_them(self):
|
||||
titles = ["Answer stability round 1: 1 🔴, 2 🟡 (2 misread); fix", "Answer prose round 1: 0 🔴, 3 🟡 (1 misread)"]
|
||||
self.assertEqual(results_of([item(4, {"R": 2})], "abc1234", "2026-10-13T10:00:00Z", "3\t1\ta.py\n", titles, "merge")[0].findings, Counts(1, 5, 3))
|
||||
|
||||
def test_measures_no_chunk_that_changed_only_the_plan(self):
|
||||
self.assertEqual(results_of([item(4, {"R": 2})], "abc1234", "2026-10-13T10:00:00Z", "0\t5\ttodo.md\n", [], "merge"), [])
|
||||
|
||||
@@ -223,11 +219,8 @@ Median outcome at each guessed score, among chunks that shipped one item, never-
|
||||
found = [result(1, 5, 3, None, findings=(1, 2), misread=1, merge="bbbbbbb", merged="2026-10-12T10:00:00Z", shipped_with=(2,)), result(2, 5, 3, None, findings=(1, 2), misread=1, merge="bbbbbbb", merged="2026-10-12T10:00:00Z", shipped_with=(1,)), result(3, 5, 3, None, findings=(0, 4), misread=0, merge="ccccccc", merged="2026-10-14T10:00:00Z", landed="rebase"), result(4, 5, 3, None)]
|
||||
self.assertIn("""🔴 and 🟡 findings from misread shipped code, per finished chunk whose round titles count them, newest first:
|
||||
|
||||
- 2026-10-14T10:00:00Z in ccccccc: at least 0 of 0 🔴, 4 🟡
|
||||
- 2026-10-12T10:00:00Z in bbbbbbb: 1 of 1 🔴, 2 🟡""", report_text(found, [], None))
|
||||
self.assertIn("""🔴 and 🟡 findings from misread shipped code, per finished chunk whose round titles count them, newest first:
|
||||
|
||||
- None: no chunk's round titles count them.""", report_text([result(4, 5, 3, None)], [], None))
|
||||
- 2026-10-14T10:00:00Z in ccccccc: at least 0 🔴, 4 🟡 (0 misread)
|
||||
- 2026-10-12T10:00:00Z in bbbbbbb: 1 🔴, 2 🟡 (1 misread)""", report_text(found, [], None))
|
||||
|
||||
def test_ends_with_how_it_reads_chunks_merged_by_rebase_only_where_it_measured_one(self):
|
||||
text = report_text([result(1, 5, 3, None, landed="rebase")], [], None)
|
||||
|
||||
@@ -4,7 +4,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from round_titles import Counts, lacks_counts, past_cap, round_counts, round_findings
|
||||
from round_titles import Findings, lacks_counts, past_cap, round_counts, round_findings
|
||||
|
||||
|
||||
class Rounds(unittest.TestCase):
|
||||
@@ -32,22 +32,19 @@ class Cap(unittest.TestCase):
|
||||
|
||||
class RoundFindings(unittest.TestCase):
|
||||
def test_sums_the_counts_each_round_title_opens_with(self):
|
||||
self.assertEqual(round_findings(["Answer stability round 1: 1 🔴, 2 🟡; flag a deleted test", "Answer prose round 1: 0 🔴, 3 🟡", "Merge origin/main"]), Counts(1, 5, None))
|
||||
self.assertEqual(round_findings(["Answer stability round 1: 1 🔴, 2 🟡; flag a deleted test", "Answer prose round 1: 0 🔴, 3 🟡", "Merge origin/main"]), Findings(1, 5, None))
|
||||
|
||||
def test_knows_no_count_when_a_round_title_or_every_round_lacks_one(self):
|
||||
self.assertIsNone(round_findings(["Answer stability round 1: 1 🔴, 2 🟡; fix", "Answer prose round 1: fix the README"]))
|
||||
self.assertIsNone(round_findings(["Answer stability round 1: 1 🔴, 2 🟡 fix"]))
|
||||
self.assertIsNone(round_findings(["Do the work"]))
|
||||
|
||||
def test_reads_the_counts_of_a_title_that_also_counts_misread_findings(self):
|
||||
self.assertEqual(round_findings(["Answer stability round 1: 1 🔴, 2 🟡 (1 misread); fix", "Answer prose round 1: 0 🔴, 3 🟡 (0 misread)"]), Counts(1, 5, 1))
|
||||
|
||||
def test_sums_the_misread_findings_each_round_title_counts(self):
|
||||
self.assertEqual(round_findings(["Answer stability round 1: 1 🔴, 2 🟡 (1 misread); fix", "Answer prose round 1: 0 🔴, 3 🟡 (2 misread)", "Merge origin/main"]), Counts(1, 5, 3))
|
||||
self.assertEqual(round_findings(["Answer stability round 1: 0 🔴, 0 🟡 (0 misread)"]), Counts(0, 0, 0))
|
||||
self.assertEqual(round_findings(["Answer stability round 1: 1 🔴, 2 🟡 (1 misread); fix", "Answer prose round 1: 0 🔴, 3 🟡 (2 misread)", "Merge origin/main"]), Findings(1, 5, 3))
|
||||
self.assertEqual(round_findings(["Answer stability round 1: 0 🔴, 0 🟡 (0 misread)"]), Findings(0, 0, 0))
|
||||
|
||||
def test_knows_no_misread_count_when_a_round_title_lacks_one(self):
|
||||
self.assertEqual(round_findings(["Answer stability round 1: 1 🔴, 2 🟡 (1 misread); fix", "Answer prose round 1: 0 🔴, 3 🟡; fix"]), Counts(1, 5, None))
|
||||
self.assertEqual(round_findings(["Answer stability round 1: 1 🔴, 2 🟡 (1 misread); fix", "Answer prose round 1: 0 🔴, 3 🟡; fix"]), Findings(1, 5, None))
|
||||
|
||||
|
||||
def test_finds_a_round_title_without_counts(self):
|
||||
@@ -55,6 +52,11 @@ class RoundFindings(unittest.TestCase):
|
||||
self.assertTrue(lacks_counts("Answer stability round 1: 0 🔴, 1 🟡; fix"))
|
||||
self.assertFalse(lacks_counts("Answer stability round 1: 0 🔴, 1 🟡 (0 misread); fix"))
|
||||
self.assertFalse(lacks_counts("Answer prose round 2: 0 🔴, 0 🟡 (0 misread)"))
|
||||
|
||||
def test_takes_a_title_counting_more_misread_findings_than_findings_as_lacking_its_counts(self):
|
||||
self.assertTrue(lacks_counts("Answer stability round 1: 1 🔴, 2 🟡 (4 misread); fix"))
|
||||
self.assertFalse(lacks_counts("Answer stability round 1: 1 🔴, 2 🟡 (3 misread); fix"))
|
||||
self.assertIsNone(round_findings(["Answer stability round 1: 1 🔴, 2 🟡 (4 misread); fix"]))
|
||||
self.assertFalse(lacks_counts("Answer the question"))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user