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:
2026-10-23 11:40:38 +02:00
parent 1d3b928bdb
commit 1e225c4397
5 changed files with 47 additions and 46 deletions
+21 -16
View File
@@ -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: