Answer prose round 1: 0 🔴, 3 🟡 (0 misread); name which round commits count, and plainer docstrings and README bullets

This commit is contained in:
2026-10-28 22:38:37 +01:00
parent 4c552e0e58
commit 2866b828bc
6 changed files with 29 additions and 16 deletions
+6 -6
View File
@@ -10,7 +10,7 @@ from utc_stamp import utc
# The plan, and the records tools append to: none of their lines are the chunk's work.
NOT_WORK = ("todo.md", HISTORY, RECORD)
# Each commit as its hash, commit and author times and parents, its short hash and title, then the files it changed; a merge's are those it changed against its first parent. git refuses a NUL byte in a commit message, so a title can't split a record.
# Each commit as its hash, commit and author times and parents, its short hash and title, then the files it changed; a merge's files are those it changed against its first parent. git refuses a NUL byte in a commit message, so a title can't split a record.
LOG = ("log", "--format=%x00%H %ct %at %P%x1f%h%x1f%s", "--name-only", "--diff-merges=first-parent")
# One commit's record in LOG's output, without the NUL that opens it.
LOG_RECORD = re.compile(r"([0-9a-f]+) ([0-9]+) ([0-9]+) ([0-9a-f ]*)\x1f([0-9a-f]+)\x1f(.*)", re.DOTALL)
@@ -32,7 +32,7 @@ class Commit:
@dataclasses.dataclass(frozen=True)
class Span:
"""A chunk on a default branch, as cut_branch cuts it. Its change runs from before, None for the branch's first chunk, to tip, its newest commit on the first-parent line. label names it as the reports do, landed says how it reached the branch, and merged is tip's commit time. titles are those of every commit it brought."""
"""A chunk on a default branch, as cut_branch cuts it. before is the commit its change starts from, None for the branch's oldest chunk; tip is its newest commit on the first-parent line. label names it as the reports do, landed says how it reached the branch, and merged is tip's commit time. titles are those of every commit it brought."""
before: str | None
tip: str
label: str
@@ -43,7 +43,7 @@ class Span:
@dataclasses.dataclass(frozen=True)
class BranchChunk(Span):
"""A chunk with shipped, each todo.md item its change removed, as scored before it, and fixed_by, the later chunks that fixed code it shipped, newest first."""
"""A Span with two more fields: shipped holds each todo.md item its change removed, as scored before the change; fixed_by names the later chunks that fixed code it shipped, newest first."""
shipped: tuple[Item, ...]
fixed_by: tuple[str, ...]
@@ -110,7 +110,7 @@ def chunk_log(line: list[Commit]) -> list[list[Commit]]:
def landing(run: list[Commit]) -> Landing:
"""How a chunk chunk_log cut reached the branch: by a merge commit, by a rebase that gave a commit a commit time other than its author time, or by commits never replayed."""
"""How a run that chunk_log cut reached the branch: by a merge commit, by a rebase that gave a commit a commit time other than its author time, or by commits never replayed."""
if len(run[0].parents) > 1:
return "merge"
return "rebase" if any(commit.committed != commit.authored for commit in run) else "push"
@@ -145,7 +145,7 @@ def shipped(before: str, after: str) -> list[Item]:
def plan_revisions(branch: Branch) -> list[str]:
"""The revisions whose todo.md shipped_by needs: the commit before and the tip of each chunk, but the branch's first, that brought a commit changing todo.md."""
"""The revisions whose todo.md shipped_by needs: for each chunk that brought a commit changing todo.md, other than the branch's oldest chunk, the commit before it and its tip."""
changed = sorted({branch.owner[commit.hash] for commit in branch.commits.values() if "todo.md" in commit.files})
revisions: dict[str, None] = {}
for index in changed:
@@ -156,7 +156,7 @@ def plan_revisions(branch: Branch) -> list[str]:
def shipped_by(branch: Branch, plans: dict[str, str]) -> list[tuple[Item, ...]]:
"""The items each of the branch's chunks shipped, in the order of its chunks, read from todo.md's text at each revision plan_revisions named, as plans holds it; none for a chunk with a revision plans lacks, which changed no plan."""
"""The items each of the branch's chunks shipped, in the order of its chunks. plans holds todo.md's text at each revision plan_revisions names. A chunk with a revision plans lacks changed no plan, so it shipped none."""
found: list[tuple[Item, ...]] = []
for chunk in branch.chunks:
if chunk.before is not None and chunk.before in plans and chunk.tip in plans:
+4 -4
View File
@@ -1,6 +1,6 @@
"""The later chunks that fixed code each chunk on a default branch shipped: its escaped defects.
A later chunk fixed code an earlier chunk shipped where one of its changes removes or rewrites lines that `git blame` traces to a commit the earlier chunk brought. Two kinds of change count: the chunk's whole change, where it ships a todo.md item marked `defect` or `security`; and a round commit of the chunk answering a 🔴 that a reviewer marked `[misread]`. Each later chunk counts at most once against each earlier chunk."""
A later chunk fixed code an earlier chunk shipped where one of its changes removes or rewrites lines that `git blame` traces to a commit the earlier chunk brought. Two kinds of change count: the chunk's whole change, where it ships a todo.md item marked `defect` or `security`; and a round commit of the chunk whose title counts both a 🔴 and a misread finding. Each later chunk counts at most once against each earlier chunk."""
import re
import typing
@@ -28,7 +28,7 @@ class Traced(typing.NamedTuple):
def fixing_changes(branch: Branch, shipped: list[tuple[Item, ...]]) -> list[FixingChange]:
"""Each change that fixes a defect: the whole change of each chunk that ships a FIXES item, as shipped_by lists them, and each round commit answering a 🔴 a reviewer marked `[misread]`."""
"""Each change that fixes a defect: the whole change of each chunk that ships a FIXES item, as shipped_by lists them, and each round commit whose title counts both a 🔴 and a misread finding."""
changes = []
for index, (chunk, items) in enumerate(zip(branch.chunks, shipped)):
if chunk.before is not None and any(item.exempt in FIXES for item in items):
@@ -46,7 +46,7 @@ def with_fixes(branch: Branch, shipped: list[tuple[Item, ...]], traced: list[Tra
fixed: dict[int, set[int]] = {}
for change in traced:
for commit in change.commits:
# Blame at a commit names only commits the branch's log holds; one it lacks counts against no chunk.
# Blame at a commit on the branch should name only commits its log holds; any other counts against no chunk.
if commit in branch.owner and branch.owner[commit] > change.chunk:
fixed.setdefault(branch.owner[commit], set()).add(change.chunk)
chunks = []
@@ -57,7 +57,7 @@ def with_fixes(branch: Branch, shipped: list[tuple[Item, ...]], traced: list[Tra
def removed_work(diff: str) -> dict[str, list[tuple[int, int]]]:
"""The old lines of a chunk's work each hunk of a `git diff -U0` removes or rewrites, as removed reads them: outside the plan and the records."""
"""What removed reads from a `git diff -U0`, less the paths in NOT_WORK: the plan and the records."""
return {path: spans for path, spans in removed(diff).items() if path not in NOT_WORK}
+1 -1
View File
@@ -91,7 +91,7 @@ def misreads(results: list[Result]) -> list[str]:
def fixed_later(results: list[Result]) -> list[str]:
"""Newest first, each finished chunk that later chunks fixed code of, naming them, then how many finished chunks none fixed."""
"""Newest first, each finished chunk whose code later chunks fixed, naming them, then how many finished chunks none fixed."""
chunks = one_per_chunk(results)
lines = [f"- {result.merged} in {result.merge}: {later(result)}, by {listed(result.fixed_by, 'and')}" for result in chunks if result.fixed_by]
if not lines: