Measure chunks in projects that merge by rebase, as runs of commits sharing one commit time

This commit is contained in:
2026-10-21 14:54:22 +02:00
parent fda48ac44c
commit e4145b8e1d
4 changed files with 124 additions and 24 deletions
+1
View File
@@ -2,6 +2,7 @@
## Unreleased ## Unreleased
- `score-outcomes` now measures chunks in a project that merges by rebase or squash. After the default branch's newest merge commit, a chunk is a run of commits sharing one commit time, which a rebase merge gives the commits it replays. Such a chunk's rounds and findings read `at least`, since rebase drops a round's empty commit; a run never replayed reads `never replayed, so perhaps part of a pull request`; and the report ends saying how it reads these chunks. Such projects can now add `docs/score-anchors.md`.
- Every project now shares one achieve goal, code health: the code is easy to understand and change safely. `CLAUDE.md` → "Shared goal" states it, with its signal and counter-signal. `rank_todo.py` ranks it first among a project's achieve goals. A project's overall is the overall mean of the newest scoring run in `docs/comprehension-history.md`, averaged with every other run on its commit. While that overall is under 7.0, or no run has measured the project, code health weighs four times as much as it does at 7.0 or above. An item's Moves cell names it as in `code health by 6`. A README voids it with `**Void:** code health, since <reason>.` under `## Goals`, and `rank_todo.py` then refuses an item that names it. `larv-review record-scoring` re-ranks `todo.md` after it appends a run, and exits 1 where `rank_todo.py` would, keeping the run. Expect items that make code easier to read to rank higher in every project. On upgrade: - Every project now shares one achieve goal, code health: the code is easy to understand and change safely. `CLAUDE.md` → "Shared goal" states it, with its signal and counter-signal. `rank_todo.py` ranks it first among a project's achieve goals. A project's overall is the overall mean of the newest scoring run in `docs/comprehension-history.md`, averaged with every other run on its commit. While that overall is under 7.0, or no run has measured the project, code health weighs four times as much as it does at 7.0 or above. An item's Moves cell names it as in `code health by 6`. A README voids it with `**Void:** code health, since <reason>.` under `## Goals`, and `rank_todo.py` then refuses an item that names it. `larv-review record-scoring` re-ranks `todo.md` after it appends a run, and exits 1 where `rank_todo.py` would, keeping the run. Expect items that make code easier to read to rank higher in every project. On upgrade:
1. Move every machine to this release before any of them ranks a plan another machine shares: an older `rank_todo.py` scores it without code health and rejects a `code health` cell. 1. Move every machine to this release before any of them ranks a plan another machine shares: an older `rank_todo.py` scores it without code health and rejects a `code health` cell.
2. Void code health in each project that opts out of the comprehension check, or `rank_todo.py` refuses its plan. 2. Void code health in each project that opts out of the comprehension check, or `rank_todo.py` refuses its plan.
+60 -14
View File
@@ -21,7 +21,14 @@ its table also had A, G and Goals. The chunk measures:
such as `Answer stability round 1: 1 🔴, 2 🟡; flag a deleted test`. Unknown where a round title such as `Answer stability round 1: 1 🔴, 2 🟡; flag a deleted test`. Unknown where a round title
lacks the counts, or the branch has no round. lacks the counts, or the branch has no round.
A project that merges without merge commits, by fast-forward or squash, has no chunk to measure. After the first-parent line's newest merge commit, where a project merges by rebase or squash, a
chunk is instead a run of commits on that line sharing one commit time, as a rebase merge replays a
pull request's commits at once; it measures against the commit before its first, whose todo.md
holds the guesses, and its titles are its commits'. It is marked `by rebase` where a commit time
differs from its author time, and `never replayed` where none does, since a pushed or
fast-forwarded commit may be part of a pull request. Two pull requests merged in the same second
read as one chunk. Rebase drops a round's commit that changed no file, so such a chunk gives its
rounds and findings as lower bounds, `at least`, and the report ends saying all this.
Given L, E and I, on the levels ~/.claude/rules/todo-items.md defines, and S, it works out R from Given L, E and I, on the levels ~/.claude/rules/todo-items.md defines, and S, it works out R from
L, E and I, as rank_todo.py does, and lists the 5 finished items whose guesses sit closest, closest L, E and I, as rank_todo.py does, and lists the 5 finished items whose guesses sit closest, closest
@@ -52,13 +59,22 @@ import sys
from score_outcomes.anchors import anchor_lines, Anchors, 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 git_repo import default_branch, file_at, full_history, git, top
from failure import Failure from failure import Failure
from score_outcomes.outcomes import Landing, nearest, Outcome, outcomes_of, render, report, shipped
from todo_table import LEVELS, risk, TOP_SCORE from todo_table import LEVELS, risk, TOP_SCORE
from markdown_text import listed from markdown_text import listed
from score_outcomes.outcomes import nearest, Outcome, outcomes_of, render, report, shipped
from utc_stamp import utc from utc_stamp import utc
# The scores score-outcomes takes, in order. # The scores score-outcomes takes, in order.
GIVEN = ("L", "E", "I", "S") GIVEN = ("L", "E", "I", "S")
# How the report reads the chunks that left no merge commit, which history bounds only by their shared commit time.
UNMERGED = [
"Chunks that left no merge commit:",
"",
"- Each is the run of commits on the default branch that share one commit time, since a rebase merge replays a pull request's commits at once. Its guesses come from the todo.md before its first commit.",
"- Two pull requests merged in the same second read as one chunk, so a pull request that shipped nothing adds its lines, files and rounds to the chunk it shares a time with.",
"- A run whose commits all kept their author time was never replayed: pushed or fast-forwarded as committed, it may hold only part of its pull request.",
"- Rebase drops a round's commit that changed no file, so their rounds and findings are at least what history shows, and the medians count them as shown.",
]
def main(argv: list[str]) -> int: def main(argv: list[str]) -> int:
@@ -88,10 +104,12 @@ def report_text(outcomes: list[Outcome], anchored: Anchors | Failure, given: dic
sections = [] sections = []
if given is not None: if given is not None:
r = risk(given["L"], given["E"], given["I"]) 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."] near = [render(outcome) for outcome in nearest(outcomes, given | {"R": r})] or ["- None: no chunk on the default branch shipped an item from todo.md."]
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]) 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])
sections.append([f"Anchors in {ANCHORS_PATH}, each level's shipped items:", "", *anchor_lines(anchored, outcomes)]) sections.append([f"Anchors in {ANCHORS_PATH}, each level's shipped items:", "", *anchor_lines(anchored, outcomes)])
sections.append(["Median outcome at each guessed score, among chunks that shipped one item:", "", *report(outcomes)]) sections.append(["Median outcome at each guessed score, among chunks that shipped one item:", "", *report(outcomes)])
if any(outcome.landed != "merge" for outcome in outcomes):
sections.append(UNMERGED)
return "\n\n".join("\n".join(section) for section in sections) return "\n\n".join("\n".join(section) for section in sections)
@@ -114,6 +132,7 @@ def read_anchors() -> Anchors | Failure:
def read_outcomes(default: str) -> list[Outcome] | Failure: def read_outcomes(default: str) -> list[Outcome] | Failure:
"""What each chunk measured: each merge commit on the default branch's first-parent line, and each run of commits after the newest that share one commit time."""
if partial := full_history(): if partial := full_history():
return partial return partial
merges = git("log", "--first-parent", "--merges", "--format=%H %h %ct", default, "--", "todo.md") merges = git("log", "--first-parent", "--merges", "--format=%H %h %ct", default, "--", "todo.md")
@@ -122,28 +141,55 @@ def read_outcomes(default: str) -> list[Outcome] | Failure:
outcomes: list[Outcome] = [] outcomes: list[Outcome] = []
for line in merges.splitlines(): for line in merges.splitlines():
merge, short, time = line.split() merge, short, time = line.split()
measured = measure(merge, short, utc(int(time))) measured = measure(f"{merge}^1", merge, short, utc(int(time)), f"{merge}^1..{merge}^2", "merge")
if isinstance(measured, Failure):
return measured
outcomes += measured
replays = read_replays(default)
if isinstance(replays, Failure):
return replays
for first, last, committed, landed in replays:
label = f"{first}^..{last}" if first != last else first
measured = measure(f"{first}^1", last, label, utc(committed), f"{first}^1..{last}", landed)
if isinstance(measured, Failure): if isinstance(measured, Failure):
return measured return measured
outcomes += measured outcomes += measured
return outcomes return outcomes
def measure(merge: str, short: str, merged: str) -> list[Outcome] | Failure: def read_replays(default: str) -> list[tuple[str, str, int, Landing]] | Failure:
"""What one merge measured for each item it shipped.""" """Each run of commits on the default branch's first-parent line after its newest merge commit that share one commit time: its first and last commit, as short hashes, that time, and whether a rebase replayed it, which leaves a commit time apart from its author time."""
before = file_at(f"{merge}^1", "todo.md") log = git("log", "--first-parent", "--format=%h %ct %at %p", default)
if isinstance(before, Failure): if isinstance(log, Failure):
return before return log
after = file_at(merge, "todo.md") runs: list[tuple[str, str, int, Landing]] = []
for line in log.splitlines():
short, committed, authored, *parents = line.split()
if len(parents) > 1:
break
replayed = committed != authored
if runs and runs[-1][2] == int(committed):
runs[-1] = (short, runs[-1][1], int(committed), "rebase" if replayed or runs[-1][3] == "rebase" else "push")
else:
runs.append((short, short, int(committed), "rebase" if replayed else "push"))
return runs
def measure(before: str, tip: str, label: str, merged: str, titled: str, landed: Landing) -> list[Outcome] | Failure:
"""What one chunk measured for each item it shipped: its change from the commit before it to its tip, and the titles of the commits in the range titled."""
planned = file_at(before, "todo.md")
if isinstance(planned, Failure):
return planned
after = file_at(tip, "todo.md")
if isinstance(after, Failure): if isinstance(after, Failure):
return after return after
items = shipped(before, after) items = shipped(planned, after)
if not items: if not items:
return [] return []
numstat = git("diff", "--numstat", f"{merge}^1", merge) numstat = git("diff", "--numstat", before, tip)
if isinstance(numstat, Failure): if isinstance(numstat, Failure):
return numstat return numstat
titles = git("log", "--format=%s", f"{merge}^1..{merge}^2") titles = git("log", "--format=%s", titled)
if isinstance(titles, Failure): if isinstance(titles, Failure):
return titles return titles
return outcomes_of(items, short, merged, numstat, titles.splitlines()) return outcomes_of(items, label, merged, numstat, titles.splitlines(), landed)
+13 -6
View File
@@ -13,10 +13,13 @@ ENOUGH = 10
# The plan, and the records tools append to: none of their lines are the chunk's work. # The plan, and the records tools append to: none of their lines are the chunk's work.
NOT_WORK = ("todo.md", HISTORY, RECORD) NOT_WORK = ("todo.md", HISTORY, RECORD)
# How a chunk reached the default branch; rebase and push leave no merge commit to bound it.
Landing = typing.Literal["merge", "rebase", "push"]
@dataclasses.dataclass(frozen=True) @dataclasses.dataclass(frozen=True)
class Outcome: class Outcome:
"""What the merge that shipped an item measured. findings holds the 🔴 and 🟡 counts, None where a round title lacks them or the branch has no round.""" """What the chunk that shipped an item measured. findings holds the 🔴 and 🟡 counts, None where a round title lacks them or the branch has no round. 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 item: Item
merge: str merge: str
merged: str merged: str
@@ -25,6 +28,7 @@ class Outcome:
files: int files: int
rounds_past_first: int rounds_past_first: int
findings: tuple[int, int] | None findings: tuple[int, int] | None
landed: Landing = "merge"
# An outcome's name and how to read it from an Outcome, None where the chunk did not record it. # An outcome's name and how to read it from an Outcome, None where the chunk did not record it.
@@ -46,8 +50,8 @@ def shipped(before: str, after: str) -> list[Item]:
return sorted((item for item in planned if item.id not in kept), key=lambda item: item.id) return sorted((item for item in planned if item.id not in kept), key=lambda item: item.id)
def outcomes_of(shipped: list[Item], merge: str, merged: str, numstat: str, titles: list[str]) -> list[Outcome]: def outcomes_of(shipped: list[Item], merge: str, merged: str, numstat: str, titles: list[str], landed: Landing = "merge") -> list[Outcome]:
"""What one merge measured for each item it shipped, from `git diff --numstat` against its first parent and its branch's commit titles; none where it changed nothing but the plan and the records.""" """What one chunk measured for each item it shipped, from `git diff --numstat` against the commit before it and its commit titles; none where it changed nothing but the plan and the records."""
changed = [row.split("\t", 2) for row in numstat.splitlines()] changed = [row.split("\t", 2) for row in numstat.splitlines()]
work = [row for row in changed if len(row) == 3 and row[2] not in NOT_WORK] work = [row for row in changed if len(row) == 3 and row[2] not in NOT_WORK]
if not work: if not work:
@@ -56,7 +60,7 @@ def outcomes_of(shipped: list[Item], merge: str, merged: str, numstat: str, titl
lines = sum(int(count) for row in work for count in row[:2] if count.isdigit()) lines = sum(int(count) for row in work for count in row[:2] if count.isdigit())
past_first = sum(max(0, count - 1) for count in round_counts(titles).values()) past_first = sum(max(0, count - 1) for count in round_counts(titles).values())
ids = [item.id for item in shipped] ids = [item.id for item in shipped]
return [Outcome(item, merge, merged, tuple(id_ for id_ in ids if id_ != item.id), lines, len(work), past_first, round_findings(titles)) for item in shipped] return [Outcome(item, merge, merged, tuple(id_ for id_ in ids if id_ != item.id), lines, len(work), past_first, round_findings(titles), landed) for item in shipped]
def nearest(outcomes: list[Outcome], given: dict[str, int], count: int = 5) -> list[Outcome]: def nearest(outcomes: list[Outcome], given: dict[str, int], count: int = 5) -> list[Outcome]:
@@ -113,10 +117,13 @@ def ranks(values: list[int]) -> list[float]:
def render(outcome: Outcome) -> str: def render(outcome: Outcome) -> str:
scores = ", ".join(f"{name} {outcome.item.scores[name]}" for name in SHOWN if name in outcome.item.scores) scores = ", ".join(f"{name} {outcome.item.scores[name]}" for name in SHOWN if name in outcome.item.scores)
findings = f"{outcome.findings[0]} 🔴, {outcome.findings[1]} 🟡" if outcome.findings else "findings unknown" # Rebase drops a round's commit that changed no file, so history shows such a chunk's rounds and findings short.
at_least = "" if outcome.landed == "merge" else "at least "
merged = {"merge": f"merged {outcome.merged} in {outcome.merge}", "rebase": f"merged {outcome.merged} by rebase in {outcome.merge}", "push": f"committed {outcome.merged} in {outcome.merge}, never replayed, so perhaps part of a pull request"}[outcome.landed]
findings = f"{at_least}{outcome.findings[0]} 🔴, {outcome.findings[1]} 🟡" if outcome.findings else "findings unknown"
others = outcome.shipped_with others = outcome.shipped_with
together = f", with item{'s' if len(others) > 1 else ''} {', '.join(map(str, others))}" if others else "" together = f", with item{'s' if len(others) > 1 else ''} {', '.join(map(str, others))}" if others else ""
return f"- Item {outcome.item.id}, {scores}: {plural(outcome.lines, 'line')} in {plural(outcome.files, 'file')}, {plural(outcome.rounds_past_first, 'round')} past each pass's first, {findings}; merged {outcome.merged} in {outcome.merge}{together}. {outcome.item.tagline}" return f"- Item {outcome.item.id}, {scores}: {plural(outcome.lines, 'line')} in {plural(outcome.files, 'file')}, {at_least}{plural(outcome.rounds_past_first, 'round')} past each pass's first, {findings}; {merged}{together}. {outcome.item.tagline}"
def plural(count: int, noun: str) -> str: def plural(count: int, noun: str) -> str:
+50 -4
View File
@@ -11,7 +11,7 @@ from score_outcomes.anchors import anchor_lines, parse_anchors
from failure import Failure from failure import Failure
from test_env import isolated_env from test_env import isolated_env
from todo_table import Item from todo_table import Item
from score_outcomes.outcomes import nearest, Outcome, outcomes_of, rank_correlation, render, report, shipped from score_outcomes.outcomes import Landing, nearest, Outcome, outcomes_of, rank_correlation, render, report, shipped
from score_outcomes.main import report_text from score_outcomes.main import report_text
TOOL = pathlib.Path(__file__).resolve().parents[1] / "score-outcomes" TOOL = pathlib.Path(__file__).resolve().parents[1] / "score-outcomes"
@@ -29,8 +29,8 @@ def item(id_: int, scores: dict[str, int]) -> Item:
return Item(id_, (0, 1, 0), "", f"**Item {id_}.**", scores, (("1", None),), ()) return Item(id_, (0, 1, 0), "", f"**Item {id_}.**", scores, (("1", None),), ())
def outcome(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) -> Outcome: def outcome(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") -> Outcome:
return Outcome(item(id_, {"R": r, "S": s} | ({"C": c} if c else {}) | (levels or {})), "aaaaaaa", merged, shipped_with, lines, 1, rounds, findings) return Outcome(item(id_, {"R": r, "S": s} | ({"C": c} if c else {}) | (levels or {})), "aaaaaaa", merged, shipped_with, lines, 1, rounds, findings, landed)
class Shipped(unittest.TestCase): class Shipped(unittest.TestCase):
@@ -121,6 +121,13 @@ class Render(unittest.TestCase):
self.assertEqual(render(outcome(4, 2, 3, 4, findings=(1, 2))), "- Item 4, R 2, S 3, C 4: 10 lines in 1 file, 1 round past each pass's first, 1 🔴, 2 🟡; merged 2026-10-13T10:00:00Z in aaaaaaa. **Item 4.**") self.assertEqual(render(outcome(4, 2, 3, 4, findings=(1, 2))), "- Item 4, R 2, S 3, C 4: 10 lines in 1 file, 1 round past each pass's first, 1 🔴, 2 🟡; merged 2026-10-13T10:00:00Z in aaaaaaa. **Item 4.**")
self.assertIn("1 round past each pass's first, 0 🔴, 0 🟡; merged 2026-10-13T10:00:00Z in aaaaaaa, with item 5. ", render(outcome(4, 2, 3, 4, rounds=1, shipped_with=(5,)))) self.assertIn("1 round past each pass's first, 0 🔴, 0 🟡; merged 2026-10-13T10:00:00Z in aaaaaaa, with item 5. ", render(outcome(4, 2, 3, 4, rounds=1, shipped_with=(5,))))
def test_gives_a_rebase_merged_chunks_rounds_and_findings_as_lower_bounds(self):
self.assertEqual(render(outcome(4, 2, 3, None, findings=(1, 2), landed="rebase")), "- Item 4, R 2, S 3: 10 lines in 1 file, at least 1 round past each pass's first, at least 1 🔴, 2 🟡; merged 2026-10-13T10:00:00Z by rebase in aaaaaaa. **Item 4.**")
self.assertIn("at least 1 round past each pass's first, findings unknown; merged 2026-10-13T10:00:00Z by rebase in aaaaaaa", render(outcome(4, 2, 3, None, findings=None, landed="rebase")))
def test_says_a_chunk_never_replayed_may_be_part_of_a_pull_request(self):
self.assertEqual(render(outcome(4, 2, 3, None, findings=(1, 2), landed="push")), "- Item 4, R 2, S 3: 10 lines in 1 file, at least 1 round past each pass's first, at least 1 🔴, 2 🟡; committed 2026-10-13T10:00:00Z in aaaaaaa, never replayed, so perhaps part of a pull request. **Item 4.**")
ANCHORS_TEXT = "# Score anchors\n\nWhy these.\n\n| Level | Items |\n|---|---|\n| L 1 | 4, 9 |\n| I 3 | 5 |\n" ANCHORS_TEXT = "# Score anchors\n\nWhy these.\n\n| Level | Items |\n|---|---|\n| L 1 | 4, 9 |\n| I 3 | 5 |\n"
@@ -177,6 +184,14 @@ Median outcome at each guessed score, among chunks that shipped one item:
- E, by review rounds past each pass's first and 🔴 findings: 0 {too_few} E and both outcomes; the report needs 10. - E, by review rounds past each pass's first and 🔴 findings: 0 {too_few} E and both outcomes; the report needs 10.
- I, by review rounds past each pass's first and 🔴 findings: 0 {too_few} I and both outcomes; the report needs 10.""") - I, by review rounds past each pass's first and 🔴 findings: 0 {too_few} I and both outcomes; the report needs 10.""")
def test_ends_with_how_it_reads_chunks_merged_by_rebase_only_where_it_measured_one(self):
text = report_text([outcome(1, 5, 3, None, landed="rebase")], [], None)
self.assertIn("\n\nChunks that left no merge commit:\n\n- Each is the run of commits", text.split("Median outcome")[1])
self.assertIn("a pull request that shipped nothing adds its lines, files and rounds", text)
self.assertIn("at least what history shows", text)
self.assertIn("Chunks that left no merge commit", report_text([outcome(1, 5, 3, None, landed="push")], [], None))
self.assertNotIn("Chunks that left no merge commit", report_text([outcome(1, 5, 3, None)], [], None))
def test_lists_no_nearest_items_where_no_scores_are_given(self): def test_lists_no_nearest_items_where_no_scores_are_given(self):
self.assertTrue(report_text([], [], None).startswith("Anchors in docs/score-anchors.md")) self.assertTrue(report_text([], [], None).startswith("Anchors in docs/score-anchors.md"))
@@ -195,12 +210,17 @@ class ScoreOutcomesTool(unittest.TestCase):
def git(self, *args): def git(self, *args):
return subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@t", *args], cwd=self.checkout, check=True, env=self.env, capture_output=True, text=True).stdout return subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@t", *args], cwd=self.checkout, check=True, env=self.env, capture_output=True, text=True).stdout
def commit(self, title, files): def commit(self, title, files, at=None, authored=None):
for name, text in files.items(): for name, text in files.items():
(self.checkout / name).parent.mkdir(parents=True, exist_ok=True) (self.checkout / name).parent.mkdir(parents=True, exist_ok=True)
(self.checkout / name).write_text(text) (self.checkout / name).write_text(text)
self.git("add", name) self.git("add", name)
dates = {"GIT_COMMITTER_DATE": at, "GIT_AUTHOR_DATE": authored}
self.env.update({name: date for name, date in dates.items() if date})
self.git("commit", "-q", "-m", title) self.git("commit", "-q", "-m", title)
for name in dates:
self.env.pop(name, None)
return self.git("rev-parse", "--short", "HEAD").strip()
def run_tool(self, *args): def run_tool(self, *args):
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=self.checkout, env=self.env, text=True) return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=self.checkout, env=self.env, text=True)
@@ -217,6 +237,32 @@ class ScoreOutcomesTool(unittest.TestCase):
self.assertIn("- Item 4, R 2, S 3, C 10: 3 lines in 1 file, 0 rounds past each pass's first, 1 🔴, 2 🟡; merged ", ran.stdout) self.assertIn("- Item 4, R 2, S 3, C 10: 3 lines in 1 file, 0 rounds past each pass's first, 1 🔴, 2 🟡; merged ", ran.stdout)
self.assertNotIn("Item 5", ran.stdout) self.assertNotIn("Item 5", ran.stdout)
def test_measures_each_chunk_a_rebase_merge_replayed_at_one_commit_time(self):
self.commit("Re-score item 4", {"todo.md": todo(FIRST.replace("| 2 | 3 |", "| 1 | 3 |"), SECOND)}, at="2026-10-13T08:00:00Z")
first = self.commit("Score item 4 higher", {"todo.md": todo(FIRST, SECOND)}, at="2026-10-13T09:00:00Z")
self.commit("Do it", {"a.py": "1\n2\n3\n", "todo.md": todo(SECOND)}, at="2026-10-13T09:00:00Z")
self.commit("Record the reading cost", {"docs/reading-cost.md": "9\n"}, at="2026-10-13T09:00:00Z")
last = self.commit("Answer stability round 1: 1 🔴, 2 🟡; fix", {"a.py": "1\n2\n4\n"}, at="2026-10-13T09:00:00Z")
self.commit("Change more", {"a.py": "1\n2\n4\n5\n6\n"}, at="2026-10-13T10:00:00Z")
pushed = self.commit("Do that", {"b.py": "1\n", "todo.md": todo()}, at="2026-10-13T11:00:00Z", authored="2026-10-13T11:00:00Z")
ran = self.run_tool("1", "2", "1", "3")
self.assertEqual(ran.returncode, 0, ran.stderr)
self.assertIn(f"- Item 4, R 1, S 3, C 10: 3 lines in 1 file, at least 0 rounds past each pass's first, at least 1 🔴, 2 🟡; merged 2026-10-13T09:00:00Z by rebase in {first}^..{last}. **Do it.**", ran.stdout)
self.assertIn(f"- Item 5, R 4, S 6, C 8: 1 line in 1 file, at least 0 rounds past each pass's first, findings unknown; committed 2026-10-13T11:00:00Z in {pushed}, never replayed, so perhaps part of a pull request. **Then this.**", ran.stdout)
self.assertIn("Chunks that left no merge commit:", ran.stdout)
def test_measures_merge_commits_as_before_and_reads_no_rebase_chunk_behind_the_newest(self):
self.commit("Drop item 5 on main", {"b.py": "1\n", "todo.md": todo(FIRST)}, at="2026-10-12T09:00:00Z")
self.git("switch", "-q", "-c", "chunk")
self.commit("Do it", {"a.py": "1\n", "todo.md": todo()})
self.git("switch", "-q", "main")
self.git("merge", "-q", "--no-ff", "-m", "Merge chunk", "chunk")
ran = self.run_tool("1", "2", "1", "3")
self.assertEqual(ran.returncode, 0, ran.stderr)
self.assertRegex(ran.stdout, r"- Item 4, R 2, S 3, C 10: 1 line in 1 file, 0 rounds past each pass's first, findings unknown; merged \S+ in [0-9a-f]{7,}\. ")
self.assertNotIn("Item 5", ran.stdout)
self.assertNotIn("by rebase", ran.stdout)
def test_lists_the_projects_anchors_with_what_their_chunks_measured(self): def test_lists_the_projects_anchors_with_what_their_chunks_measured(self):
self.git("switch", "-q", "-c", "chunk") self.git("switch", "-q", "-c", "chunk")
self.commit("Do it", {"a.py": "1\n", "todo.md": todo(SECOND)}) self.commit("Do it", {"a.py": "1\n", "todo.md": todo(SECOND)})