From e4145b8e1d088c0a17c1a0a1bcbcaa14aedcd053 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 14:54:22 +0200 Subject: [PATCH 01/15] Measure chunks in projects that merge by rebase, as runs of commits sharing one commit time --- CHANGELOG.md | 1 + bin/score_outcomes/main.py | 74 ++++++++++++++++++----- bin/score_outcomes/outcomes.py | 19 ++++-- bin/score_outcomes/test_score_outcomes.py | 54 +++++++++++++++-- 4 files changed, 124 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c2ca90c..2831d18a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 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 .` 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. 2. Void code health in each project that opts out of the comprehension check, or `rank_todo.py` refuses its plan. diff --git a/bin/score_outcomes/main.py b/bin/score_outcomes/main.py index 511205ba..39331412 100644 --- a/bin/score_outcomes/main.py +++ b/bin/score_outcomes/main.py @@ -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 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 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 git_repo import default_branch, file_at, full_history, git, top 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 markdown_text import listed -from score_outcomes.outcomes import nearest, Outcome, outcomes_of, render, report, shipped from utc_stamp import utc # The scores score-outcomes takes, in order. 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: @@ -88,10 +104,12 @@ def report_text(outcomes: list[Outcome], anchored: Anchors | Failure, given: dic sections = [] 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."] + 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"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)]) + if any(outcome.landed != "merge" for outcome in outcomes): + sections.append(UNMERGED) 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: + """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(): return partial 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] = [] for line in merges.splitlines(): 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): return measured outcomes += measured return outcomes -def measure(merge: str, short: str, merged: str) -> list[Outcome] | Failure: - """What one merge measured for each item it shipped.""" - before = file_at(f"{merge}^1", "todo.md") - if isinstance(before, Failure): - return before - after = file_at(merge, "todo.md") +def read_replays(default: str) -> list[tuple[str, str, int, Landing]] | Failure: + """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.""" + log = git("log", "--first-parent", "--format=%h %ct %at %p", default) + if isinstance(log, Failure): + return log + 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): return after - items = shipped(before, after) + items = shipped(planned, after) if not items: return [] - numstat = git("diff", "--numstat", f"{merge}^1", merge) + numstat = git("diff", "--numstat", before, tip) if isinstance(numstat, Failure): return numstat - titles = git("log", "--format=%s", f"{merge}^1..{merge}^2") + titles = git("log", "--format=%s", titled) if isinstance(titles, Failure): return titles - return outcomes_of(items, short, merged, numstat, titles.splitlines()) + return outcomes_of(items, label, merged, numstat, titles.splitlines(), landed) diff --git a/bin/score_outcomes/outcomes.py b/bin/score_outcomes/outcomes.py index ce103946..63362161 100644 --- a/bin/score_outcomes/outcomes.py +++ b/bin/score_outcomes/outcomes.py @@ -13,10 +13,13 @@ ENOUGH = 10 # The plan, and the records tools append to: none of their lines are the chunk's work. 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) 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 merge: str merged: str @@ -25,6 +28,7 @@ class Outcome: files: int rounds_past_first: int 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. @@ -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) -def outcomes_of(shipped: list[Item], merge: str, merged: str, numstat: str, titles: list[str]) -> 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.""" +def outcomes_of(shipped: list[Item], merge: str, merged: str, numstat: str, titles: list[str], landed: Landing = "merge") -> list[Outcome]: + """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()] work = [row for row in changed if len(row) == 3 and row[2] not in 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()) past_first = sum(max(0, count - 1) for count in round_counts(titles).values()) 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]: @@ -113,10 +117,13 @@ def ranks(values: list[int]) -> list[float]: def render(outcome: Outcome) -> str: 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 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: diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index 8c0f4eed..9d47b8eb 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -11,7 +11,7 @@ from score_outcomes.anchors import anchor_lines, parse_anchors from failure import Failure from test_env import isolated_env 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 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),), ()) -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: - return Outcome(item(id_, {"R": r, "S": s} | ({"C": c} if c else {}) | (levels or {})), "aaaaaaa", merged, shipped_with, lines, 1, rounds, findings) +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, landed) 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.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" @@ -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. - 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): self.assertTrue(report_text([], [], None).startswith("Anchors in docs/score-anchors.md")) @@ -195,12 +210,17 @@ class ScoreOutcomesTool(unittest.TestCase): 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 - def commit(self, title, files): + def commit(self, title, files, at=None, authored=None): for name, text in files.items(): (self.checkout / name).parent.mkdir(parents=True, exist_ok=True) (self.checkout / name).write_text(text) 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) + for name in dates: + self.env.pop(name, None) + return self.git("rev-parse", "--short", "HEAD").strip() def run_tool(self, *args): 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.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): self.git("switch", "-q", "-c", "chunk") self.commit("Do it", {"a.py": "1\n", "todo.md": todo(SECOND)}) -- 2.52.0 From 13e3a713670f56fa13df193d8d0a8d9bc177d4b5 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 14:56:57 +0200 Subject: [PATCH 02/15] Drop the squash claim from the score-outcomes changelog line, since no test covers it --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2831d18a..70a92505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 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`. +- `score-outcomes` now measures chunks in a project that merges by rebase. 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 .` 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. 2. Void code health in each project that opts out of the comprehension check, or `rank_todo.py` refuses its plan. -- 2.52.0 From 2296cb9119488cdd1bc04b294db4d4307972c229 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 16:36:23 +0200 Subject: [PATCH 03/15] File item 200 for rebase-merged chunks, and leave squash and fast-forward in item 111 --- todo.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/todo.md b/todo.md index df450f1a..42cbd391 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 0.1` -`Next ID = 199` +`Next ID = 201` ## Items @@ -71,6 +71,7 @@ | 101 | 0.4.0 | | principle | **Have `larv_review/record.py`'s `read_seats` take the time, the commit check and the history as inputs, so it parses and decides without effects.** | 2 | 1 | 2 | 3 | 3 | 1.1 by 5 | 5.3 | | 111 | 0.4.0 | | | **Measure the chunks of a project that merges by squash or fast-forward, which `score-outcomes` skips today.** | 3 | 2 | 2 | 5 | 3 | 1.1 by 5 | 5.3 | | 110 | 0.4.0 | | | **Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E.** | 3 | 2 | 2 | 5 | 5 | 1.1 by 6, 1.4 by 6 | 4.9 | +| 200 | 0.4.0 | | | **Make `score-outcomes` measure the chunks of a project that merges by rebase.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 4 | 4.2 | | 149 | 0.4.0 | | decision | **Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 7 | 3.0 | | 123 | 0.5.0 | | | **Have `bin/comprehension_history.py` parse each history entry once into seats, votes and places, so `latest_places`, `worse_places` and `worse_votes` neither depend on table order nor split a label to find a seat.** | 2 | 1 | 2 | 3 | 5 | code health by 5, 1.4 by 5 | 11.0 | | 124 | 0.5.0 | | decision | **Group the shared modules at `bin/`'s root into packages named by purpose, so the root holds only launchers and stand-alone tools.** | 4 | 1 | 3 | 6 | 6 | code health by 9, 1.4 by 9 | 11.0 | @@ -330,12 +331,16 @@ Found by the principles audit of PR #242, against "Functional core, imperative s ### 111. Measure the chunks of a project that merges by squash or fast-forward, which `score-outcomes` skips today. -`score-outcomes` reads a chunk from a merge commit: its branch's round titles, and its change against the first parent. Two of the projects under `~/code` merge without merge commits, so their scorers see no finished item. +`score-outcomes` reads a chunk from a merge commit: its branch's round titles, and its change against the first parent. A project that merges by squash or fast-forward has no merge commit, so its scorer sees no finished item. Rebase merges are item 200. ### 110. Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E. `score-outcomes` measures risk only by the 🔴 findings review caught. A serious bug review missed shows later, as a change that fixes code the chunk wrote: the defect that escaped, which E guesses. +### 200. Make `score-outcomes` measure the chunks of a project that merges by rebase. + +A rebase merge replays a pull request's commits at once, so they share one commit time. `score-outcomes` should read each such run as one chunk, under the same rule that reads a merge commit as one chunk. Squash and fast-forward merges stay with item 111. + ### 149. Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release. A release's capacity is a sum of its items' cost, as the formula counts it. Each project states its own; the human sets the first value per project. Nothing is deleted by score. -- 2.52.0 From 3d51ebc5df419fcb6f1d5bd41fd479abc022ab91 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 16:47:51 +0200 Subject: [PATCH 04/15] Measure each chunk by one rule: a merge commit, or a run of commits sharing one commit time --- CHANGELOG.md | 2 +- bin/score_outcomes/anchors.py | 2 +- bin/score_outcomes/main.py | 72 +++++++++++------------ bin/score_outcomes/test_score_outcomes.py | 53 +++++++++++++++-- todo.md | 7 +-- 5 files changed, 84 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70a92505..bcf50e99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `score-outcomes` now measures chunks in a project that merges by rebase. 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`. +- `score-outcomes` measures each chunk on the default branch's first-parent line: a merge commit is a chunk of its own, and any other commit joins the commit above it when both share a commit time, else starts a chunk. - 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 .` 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. 2. Void code health in each project that opts out of the comprehension check, or `rank_todo.py` refuses its plan. diff --git a/bin/score_outcomes/anchors.py b/bin/score_outcomes/anchors.py index c9443766..92be7cac 100644 --- a/bin/score_outcomes/anchors.py +++ b/bin/score_outcomes/anchors.py @@ -39,5 +39,5 @@ def anchor_lines(found: Anchors | Failure, outcomes: list[Outcome]) -> list[str] lines = [] for level, ids in found: lines.append(f"{level}:") - lines += [render(by_id[id_]) if id_ in by_id else f"- Item {id_}: no merge commit on the default branch shipped it." for id_ in ids] + lines += [render(by_id[id_]) if id_ in by_id else f"- Item {id_}: no chunk shipped it." for id_ in ids] return lines diff --git a/bin/score_outcomes/main.py b/bin/score_outcomes/main.py index 39331412..2407b9f8 100644 --- a/bin/score_outcomes/main.py +++ b/bin/score_outcomes/main.py @@ -6,11 +6,12 @@ Run it inside a project checkout or one of its worktrees. It fetches origin, whe that remote, and reads origin's default branch, or else the local main or master; a failed fetch reads origin as last fetched and says so on stderr. -Git history is the record. A chunk is a merge commit on the default branch's first-parent line -whose change removed items from todo.md, and changed more than todo.md and the records below; it -shipped those items. Each item's guess is the scores it held in the todo.md of the merge's first -parent: L, E, I, R and S. An item scored before L, E and I replaced C holds R and S, and C too where -its table also had A, G and Goals. The chunk measures: +Git history is the record. The default branch's first-parent line is cut into chunks by one rule: a +merge commit is a chunk of its own, and any other commit joins the commit above it when both share a +commit time, else starts a chunk. A chunk whose change removed items from todo.md, and changed more +than todo.md and the records below, shipped those items. Each item's guess is the scores it held in +the todo.md the chunk started from: L, E, I, R and S. An item scored before L, E and I replaced C +holds R and S, and C too where its table also had A, G and Goals. The chunk measures: - lines changed: lines added plus lines deleted against the first parent, leaving out todo.md and the records tools append to, docs/comprehension-history.md and docs/reading-cost.md; @@ -21,14 +22,12 @@ 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 lacks the counts, or the branch has no round. -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. +A chunk is marked `by rebase` where a commit in it has a committer time apart from its author time, +since a rebase replays a pull request's commits at once, and `never replayed` where none does, since +a pushed or fast-forwarded commit may be part of a pull request. A merge's titles are its branch's +commits'; any other chunk's are its own. 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 L, E and I, as rank_todo.py does, and lists the 5 finished items whose guesses sit closest, closest @@ -37,7 +36,7 @@ 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. A +E and I, read from the checkout's working tree, each line as above, or that no chunk shipped it. A file that cannot be read, a row that does not hold a level on its scale and a list of IDs, or a level named twice leaves the anchors out, saying why. @@ -132,47 +131,42 @@ def read_anchors() -> Anchors | 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.""" + """What each chunk on the default branch's first-parent line measured.""" if partial := full_history(): return partial - merges = git("log", "--first-parent", "--merges", "--format=%H %h %ct", default, "--", "todo.md") - if isinstance(merges, Failure): - return merges + chunks = read_chunks(default) + if isinstance(chunks, Failure): + return chunks outcomes: list[Outcome] = [] - for line in merges.splitlines(): - merge, short, time = line.split() - 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) + for first, last, committed, landed in chunks: + label = first if first == last else f"{first}^..{last}" + titled = f"{first}^1..{first}^2" if landed == "merge" else f"{first}^1..{last}" + measured = measure(f"{first}^1", last, label, utc(committed), titled, landed) if isinstance(measured, Failure): return measured outcomes += measured return outcomes -def read_replays(default: str) -> list[tuple[str, str, int, Landing]] | Failure: - """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.""" +def read_chunks(default: str) -> list[tuple[str, str, int, Landing]] | Failure: + """Each chunk on the default branch's first-parent line, newest first: its first and last commit as short hashes, its commit time, and how it reached the branch. A merge commit is a chunk of its own; any other commit joins the commit above it when both share a commit time.""" log = git("log", "--first-parent", "--format=%h %ct %at %p", default) if isinstance(log, Failure): return log - runs: list[tuple[str, str, int, Landing]] = [] + chunks: list[tuple[str, str, int, Landing]] = [] + joinable = False 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") + chunks.append((short, short, int(committed), "merge")) + joinable = False + elif joinable and chunks[-1][2] == int(committed): + _, newest, time, landed = chunks[-1] + chunks[-1] = (short, newest, time, "rebase" if landed == "rebase" or committed != authored else "push") else: - runs.append((short, short, int(committed), "rebase" if replayed else "push")) - return runs + chunks.append((short, short, int(committed), "rebase" if committed != authored else "push")) + joinable = True + return chunks def measure(before: str, tip: str, label: str, merged: str, titled: str, landed: Landing) -> list[Outcome] | Failure: diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index 9d47b8eb..3678cd93 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -152,7 +152,7 @@ class Anchors(unittest.TestCase): def test_lists_each_anchor_with_what_its_chunk_measured_and_says_which_it_cannot_find(self): lines = anchor_lines([("L 1", (4, 9))], [outcome(4, 2, 3, None, findings=(1, 2))]) - self.assertEqual(lines, ["L 1:", "- Item 4, R 2, S 3: 10 lines in 1 file, 1 round past each pass's first, 1 🔴, 2 🟡; merged 2026-10-13T10:00:00Z in aaaaaaa. **Item 4.**", "- Item 9: no merge commit on the default branch shipped it."]) + self.assertEqual(lines, ["L 1:", "- Item 4, R 2, S 3: 10 lines in 1 file, 1 round past each pass's first, 1 🔴, 2 🟡; merged 2026-10-13T10:00:00Z in aaaaaaa. **Item 4.**", "- Item 9: no chunk shipped it."]) def test_points_to_the_rules_where_the_project_names_no_anchors(self): self.assertIn("docs/score-anchors.md", anchor_lines([], [])[0]) @@ -222,6 +222,13 @@ class ScoreOutcomesTool(unittest.TestCase): self.env.pop(name, None) return self.git("rev-parse", "--short", "HEAD").strip() + def merge_branch(self, branch, at): + self.env.update({"GIT_COMMITTER_DATE": at, "GIT_AUTHOR_DATE": at}) + self.git("merge", "-q", "--no-ff", "-m", f"Merge {branch}", branch) + for name in ("GIT_COMMITTER_DATE", "GIT_AUTHOR_DATE"): + self.env.pop(name, None) + return self.git("rev-parse", "--short", "HEAD").strip() + def run_tool(self, *args): return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=self.checkout, env=self.env, text=True) @@ -251,8 +258,8 @@ class ScoreOutcomesTool(unittest.TestCase): 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") + def test_counts_a_direct_commit_behind_the_newest_merge_as_a_push_chunk(self): + drop = self.commit("Drop item 5 on main", {"b.py": "1\n", "todo.md": todo(FIRST)}, at="2026-10-12T09:00:00Z", authored="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") @@ -260,9 +267,45 @@ class ScoreOutcomesTool(unittest.TestCase): 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.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-12T09:00:00Z in {drop}, never replayed, so perhaps part of a pull request. **Then this.**", ran.stdout) self.assertNotIn("by rebase", ran.stdout) + def test_labels_a_merge_merge_even_when_its_author_and_commit_times_are_equal(self): + self.git("switch", "-q", "-c", "chunk") + self.commit("Do it", {"a.py": "1\n", "todo.md": todo(SECOND)}, at="2026-10-13T09:00:00Z", authored="2026-10-13T09:00:00Z") + self.git("switch", "-q", "main") + merged = self.merge_branch("chunk", "2026-10-13T10:00:00Z") + ran = self.run_tool("1", "2", "1", "3") + self.assertEqual(ran.returncode, 0, ran.stderr) + self.assertIn(f"merged 2026-10-13T10:00:00Z in {merged}. **Do it.**", ran.stdout) + self.assertNotIn("by rebase", ran.stdout) + self.assertNotIn("never replayed", ran.stdout) + + def test_counts_each_merge_at_one_commit_time_as_its_own_chunk(self): + self.git("switch", "-q", "-c", "one") + self.commit("Do four", {"a.py": "1\n", "todo.md": todo(SECOND)}, at="2026-10-13T10:00:00Z", authored="2026-10-13T10:00:00Z") + self.git("switch", "-q", "main") + first = self.merge_branch("one", "2026-10-13T10:00:00Z") + self.git("switch", "-q", "-c", "two") + self.commit("Do five", {"b.py": "1\n", "todo.md": todo()}, at="2026-10-13T10:00:00Z", authored="2026-10-13T10:00:00Z") + self.git("switch", "-q", "main") + second = self.merge_branch("two", "2026-10-13T10:00:00Z") + ran = self.run_tool("1", "2", "1", "3") + self.assertEqual(ran.returncode, 0, ran.stderr) + self.assertIn(f"merged 2026-10-13T10:00:00Z in {first}. **Do it.**", ran.stdout) + self.assertIn(f"merged 2026-10-13T10:00:00Z in {second}. **Then this.**", ran.stdout) + + def test_counts_a_rebase_run_behind_a_merge_as_one_chunk_labelled_rebase(self): + self.git("switch", "-q", "-c", "other") + self.commit("Other work", {"z.py": "1\n"}) + self.git("switch", "-q", "main") + first = self.commit("Do it", {"a.py": "1\n2\n3\n", "todo.md": todo(SECOND)}, at="2026-10-13T09:00:00Z", authored="2026-10-13T08:00:00Z") + last = self.commit("Answer stability round 1: 1 🔴, 2 🟡; fix", {"a.py": "1\n2\n4\n"}, at="2026-10-13T09:00:00Z", authored="2026-10-13T08:00:00Z") + self.merge_branch("other", "2026-10-13T10:00:00Z") + ran = self.run_tool("1", "2", "1", "3") + self.assertEqual(ran.returncode, 0, ran.stderr) + self.assertIn(f"- Item 4, R 2, 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) + def test_lists_the_projects_anchors_with_what_their_chunks_measured(self): self.git("switch", "-q", "-c", "chunk") self.commit("Do it", {"a.py": "1\n", "todo.md": todo(SECOND)}) @@ -273,7 +316,7 @@ class ScoreOutcomesTool(unittest.TestCase): ran = self.run_tool("1", "2", "1", "3") self.assertEqual(ran.returncode, 0, ran.stderr) self.assertIn("Anchors in docs/score-anchors.md, each level's shipped items:\n\nL 1:\n- Item 4, R 2, S 3, C 10: 1 line in 1 file", ran.stdout) - self.assertIn("I 3:\n- Item 5: no merge commit on the default branch shipped it.", ran.stdout) + self.assertIn("I 3:\n- Item 5: no chunk shipped it.", ran.stdout) def test_refuses_anchors_it_cannot_read(self): (self.checkout / "docs").mkdir() diff --git a/todo.md b/todo.md index 42cbd391..517f95cc 100644 --- a/todo.md +++ b/todo.md @@ -71,7 +71,6 @@ | 101 | 0.4.0 | | principle | **Have `larv_review/record.py`'s `read_seats` take the time, the commit check and the history as inputs, so it parses and decides without effects.** | 2 | 1 | 2 | 3 | 3 | 1.1 by 5 | 5.3 | | 111 | 0.4.0 | | | **Measure the chunks of a project that merges by squash or fast-forward, which `score-outcomes` skips today.** | 3 | 2 | 2 | 5 | 3 | 1.1 by 5 | 5.3 | | 110 | 0.4.0 | | | **Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E.** | 3 | 2 | 2 | 5 | 5 | 1.1 by 6, 1.4 by 6 | 4.9 | -| 200 | 0.4.0 | | | **Make `score-outcomes` measure the chunks of a project that merges by rebase.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 4 | 4.2 | | 149 | 0.4.0 | | decision | **Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 7 | 3.0 | | 123 | 0.5.0 | | | **Have `bin/comprehension_history.py` parse each history entry once into seats, votes and places, so `latest_places`, `worse_places` and `worse_votes` neither depend on table order nor split a label to find a seat.** | 2 | 1 | 2 | 3 | 5 | code health by 5, 1.4 by 5 | 11.0 | | 124 | 0.5.0 | | decision | **Group the shared modules at `bin/`'s root into packages named by purpose, so the root holds only launchers and stand-alone tools.** | 4 | 1 | 3 | 6 | 6 | code health by 9, 1.4 by 9 | 11.0 | @@ -331,16 +330,12 @@ Found by the principles audit of PR #242, against "Functional core, imperative s ### 111. Measure the chunks of a project that merges by squash or fast-forward, which `score-outcomes` skips today. -`score-outcomes` reads a chunk from a merge commit: its branch's round titles, and its change against the first parent. A project that merges by squash or fast-forward has no merge commit, so its scorer sees no finished item. Rebase merges are item 200. +`score-outcomes` reads a chunk from a merge commit: its branch's round titles, and its change against the first parent. A project that merges by squash or fast-forward has no merge commit, so its scorer sees no finished item. ### 110. Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E. `score-outcomes` measures risk only by the 🔴 findings review caught. A serious bug review missed shows later, as a change that fixes code the chunk wrote: the defect that escaped, which E guesses. -### 200. Make `score-outcomes` measure the chunks of a project that merges by rebase. - -A rebase merge replays a pull request's commits at once, so they share one commit time. `score-outcomes` should read each such run as one chunk, under the same rule that reads a merge commit as one chunk. Squash and fast-forward merges stay with item 111. - ### 149. Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release. A release's capacity is a sum of its items' cost, as the formula counts it. Each project states its own; the human sets the first value per project. Nothing is deleted by score. -- 2.52.0 From 58939766d32022519efa2a4f06085dc209e8d9ec Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 17:02:21 +0200 Subject: [PATCH 05/15] =?UTF-8?q?Answer=20stability=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1;=20read=20chunks=20by=20one=20?= =?UTF-8?q?pure=20function,=20and=20skip=20chunks=20that=20never=20changed?= =?UTF-8?q?=20todo.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- bin/score_outcomes/main.py | 35 +++++++++++++---------- bin/score_outcomes/outcomes.py | 6 ++-- bin/score_outcomes/test_score_outcomes.py | 30 ++++++++++++++++--- 4 files changed, 51 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcf50e99..8106963a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ - The stability reviewer applies `principles/technical-principles.md` as written, in place of its own copies of it. Its test-data check now asks for UUID v7, where it asked for randomised UUIDs. - larv-review's principles audit is a pass of its own, and runs on every chunk that changes code, config or tests, not only on one with an architectural decision. A chunk of prose or planning alone skips it. - `rule-hook` refuses an Agent call that launches a reviewer, a comprehension seat or the security pass on a rung below the one `loop-claude` names for it, and takes no override: pass the model and effort the refusal names. -- `score-outcomes` lists a project's score anchors: the shipped items its `docs/score-anchors.md` names for each level of L, E and I, each with what its chunk measured. `rules/todo-items.md` has a scorer compare a new item with them, and says how to choose two or three per level. Add the file to each project that merges with merge commits; elsewhere, score by the level descriptions in `rules/todo-items.md`. +- `score-outcomes` lists a project's score anchors: the shipped items its `docs/score-anchors.md` names for each level of L, E and I, each with what its chunk measured. `rules/todo-items.md` has a scorer compare a new item with them, and says how to choose two or three per level. Add the file to each project that merges with merge commits or by rebase; elsewhere, score by the level descriptions in `rules/todo-items.md`. - `loop-claude` archives each judge reply it rejects in the chunk's `.outcomes.md`, with the reason and the reply as json. Before, such a reply reached only stderr, so a run that exited 1 overnight could not say what the judge had returned. stderr now prints only the reason; the reply is in outcomes.md. If archiving fails, `loop-claude` exits 1. - `loop-claude` routes each chunk on `todo.md` as the default branch holds it, freshly fetched: merge a `todo.md` edit before the chunk it should route starts. Where `todo.md` holds no item for the next release, the earliest release it has named since the newest tag, no item routes the chunk, and the worker is told that release is finished and ready to cut, or, where no work has landed since the tag, to be planned first. Before routing, `loop-claude` runs the new `bin/chunk-preflight` and quotes what it prints in the worker's first prompt: the chunk's mechanical facts, which `chunk-preflight --help` lists. The preflight also makes the chunk's worktree, `-item-` beside the checkout on the branch `item-`, or continues the one already there, and leaves an uncommitted figure in that worktree's `docs/reading-cost.md` for the chunk to commit. It stops a fetch, forge CLI or tool after 60 seconds, or after the seconds `CHUNK_PREFLIGHT_TIMEOUT` sets. The prompt also asks the worker to count the item's size again once it has read the code, and to have the item re-scored where its L would change. Expect the worker to start editing sooner. diff --git a/bin/score_outcomes/main.py b/bin/score_outcomes/main.py index 2407b9f8..6f55e4dc 100644 --- a/bin/score_outcomes/main.py +++ b/bin/score_outcomes/main.py @@ -7,8 +7,8 @@ that remote, and reads origin's default branch, or else the local main or master reads origin as last fetched and says so on stderr. Git history is the record. The default branch's first-parent line is cut into chunks by one rule: a -merge commit is a chunk of its own, and any other commit joins the commit above it when both share a -commit time, else starts a chunk. A chunk whose change removed items from todo.md, and changed more +merge commit is a chunk of its own, and any other commit joins the run of the newer commit above it when +both share a commit time, else starts a chunk. A chunk whose change removed items from todo.md, and changed more than todo.md and the records below, shipped those items. Each item's guess is the scores it held in the todo.md the chunk started from: L, E, I, R and S. An item scored before L, E and I replaced C holds R and S, and C too where its table also had A, G and Goals. The chunk measures: @@ -26,7 +26,7 @@ A chunk is marked `by rebase` where a commit in it has a committer time apart fr since a rebase replays a pull request's commits at once, and `never replayed` where none does, since a pushed or fast-forwarded commit may be part of a pull request. A merge's titles are its branch's commits'; any other chunk's are its own. 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 +chunk. Rebase drops a round's commit that changed no file, so a rebase or push 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 @@ -58,7 +58,7 @@ import sys 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 score_outcomes.outcomes import Landing, nearest, Outcome, outcomes_of, render, report, shipped +from score_outcomes.outcomes import Chunk, Landing, nearest, Outcome, outcomes_of, render, report, shipped from todo_table import LEVELS, risk, TOP_SCORE from markdown_text import listed from utc_stamp import utc @@ -134,11 +134,19 @@ def read_outcomes(default: str) -> list[Outcome] | Failure: """What each chunk on the default branch's first-parent line measured.""" if partial := full_history(): return partial - chunks = read_chunks(default) - if isinstance(chunks, Failure): - return chunks + log = git("log", "--first-parent", "--format=%x1e%h %ct %at %p", "--name-only", default) + if isinstance(log, Failure): + return log + # Each record is a commit's line, then the files it changed against its first parent. + records = [record.splitlines() for record in log.split("\x1e")[1:]] + headers = [record[0] for record in records] + hashes = [header.split()[0] for header in headers] + plan = {short for short, record in zip(hashes, records) if "todo.md" in record} outcomes: list[Outcome] = [] - for first, last, committed, landed in chunks: + for first, last, committed, landed in chunk_log(headers): + # Only a chunk that changed todo.md can ship an item, so the others skip measure's git calls. + if not any(short in plan for short in hashes[hashes.index(last):hashes.index(first) + 1]): + continue label = first if first == last else f"{first}^..{last}" titled = f"{first}^1..{first}^2" if landed == "merge" else f"{first}^1..{last}" measured = measure(f"{first}^1", last, label, utc(committed), titled, landed) @@ -148,14 +156,11 @@ def read_outcomes(default: str) -> list[Outcome] | Failure: return outcomes -def read_chunks(default: str) -> list[tuple[str, str, int, Landing]] | Failure: - """Each chunk on the default branch's first-parent line, newest first: its first and last commit as short hashes, its commit time, and how it reached the branch. A merge commit is a chunk of its own; any other commit joins the commit above it when both share a commit time.""" - log = git("log", "--first-parent", "--format=%h %ct %at %p", default) - if isinstance(log, Failure): - return log - chunks: list[tuple[str, str, int, Landing]] = [] +def chunk_log(lines: list[str]) -> list[Chunk]: + """The chunks `git log --first-parent --format=%h %ct %at %p` lines cut, newest first: each chunk's first and last commit as short hashes, its commit time, and how it reached the branch. A merge commit is a chunk of its own; any other commit joins the run of the newer commit above it when both share a commit time.""" + chunks: list[Chunk] = [] joinable = False - for line in log.splitlines(): + for line in lines: short, committed, authored, *parents = line.split() if len(parents) > 1: chunks.append((short, short, int(committed), "merge")) diff --git a/bin/score_outcomes/outcomes.py b/bin/score_outcomes/outcomes.py index 63362161..93bb5ecf 100644 --- a/bin/score_outcomes/outcomes.py +++ b/bin/score_outcomes/outcomes.py @@ -15,6 +15,8 @@ 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"] +# A chunk's first and last commit as short hashes, its commit time, and how it reached the default branch. +Chunk = tuple[str, str, int, Landing] @dataclasses.dataclass(frozen=True) @@ -28,7 +30,7 @@ class Outcome: files: int rounds_past_first: int findings: tuple[int, int] | None - landed: Landing = "merge" + landed: Landing # An outcome's name and how to read it from an Outcome, None where the chunk did not record it. @@ -50,7 +52,7 @@ 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) -def outcomes_of(shipped: list[Item], merge: str, merged: str, numstat: str, titles: list[str], landed: Landing = "merge") -> list[Outcome]: +def outcomes_of(shipped: list[Item], merge: str, merged: str, numstat: str, titles: list[str], landed: Landing) -> list[Outcome]: """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()] work = [row for row in changed if len(row) == 3 and row[2] not in NOT_WORK] diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index 3678cd93..eef363a8 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -12,7 +12,7 @@ from failure import Failure from test_env import isolated_env from todo_table import Item 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 chunk_log, report_text TOOL = pathlib.Path(__file__).resolve().parents[1] / "score-outcomes" HEADER = "| ID | Release | Exempt | Item | R | S | C | A | G | Goals | Score |\n|---|---|---|---|---|---|---|---|---|---|---|\n" @@ -50,16 +50,38 @@ class Shipped(unittest.TestCase): self.assertEqual(shipped(todo(FIRST, "| x | 0.1.0 | | **Bad.** | 2 | 3 | 5 | 6 | 7 | 1 | 9.0 |"), todo()), []) +class ChunkLog(unittest.TestCase): + # Lines are `%h %ct %at %p`, newest first: short hash, commit time, author time, parents. + + def test_a_merge_is_a_chunk_of_its_own_and_joins_no_run_below_it(self): + self.assertEqual(chunk_log(["m 100 100 a b", "c 100 100 a"]), [("m", "m", 100, "merge"), ("c", "c", 100, "push")]) + + def test_commits_sharing_a_commit_time_form_one_run_labelled_rebase_when_any_differs(self): + self.assertEqual(chunk_log(["c2 200 150 c1", "c1 200 100 r"]), [("c1", "c2", 200, "rebase")]) + + def test_a_run_of_commits_that_all_kept_their_author_time_is_labelled_push(self): + self.assertEqual(chunk_log(["c2 200 200 c1", "c1 200 200 r"]), [("c1", "c2", 200, "push")]) + + def test_a_run_is_rebase_when_only_its_older_commit_was_replayed(self): + self.assertEqual(chunk_log(["c2 200 200 c1", "c1 200 100 r"]), [("c1", "c2", 200, "rebase")]) + + def test_a_run_is_rebase_when_only_its_newer_commit_was_replayed(self): + self.assertEqual(chunk_log(["c2 200 100 c1", "c1 200 200 r"]), [("c1", "c2", 200, "rebase")]) + + def test_a_commit_at_another_time_starts_a_new_chunk(self): + self.assertEqual(chunk_log(["c2 300 300 c1", "c1 200 200 r"]), [("c2", "c2", 300, "push"), ("c1", "c1", 200, "push")]) + + class OutcomesOf(unittest.TestCase): def test_measures_the_change_less_the_plan_and_the_tool_records_and_counts_binary_files(self): 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 = outcomes_of([item(4, {"R": 2}), item(5, {"R": 3})], "abc1234", "2026-10-13T10:00:00Z", numstat, titles) - self.assertEqual(found[0], Outcome(item(4, {"R": 2}), "abc1234", "2026-10-13T10:00:00Z", (5,), 5, 3, 1, (1, 6))) + found = outcomes_of([item(4, {"R": 2}), item(5, {"R": 3})], "abc1234", "2026-10-13T10:00:00Z", numstat, titles, "merge") + self.assertEqual(found[0], Outcome(item(4, {"R": 2}), "abc1234", "2026-10-13T10:00:00Z", (5,), 5, 3, 1, (1, 6), "merge")) self.assertEqual(found[1].shipped_with, (4,)) def test_measures_no_chunk_that_changed_only_the_plan(self): - self.assertEqual(outcomes_of([item(4, {"R": 2})], "abc1234", "2026-10-13T10:00:00Z", "0\t5\ttodo.md\n", []), []) + self.assertEqual(outcomes_of([item(4, {"R": 2})], "abc1234", "2026-10-13T10:00:00Z", "0\t5\ttodo.md\n", [], "merge"), []) class Nearest(unittest.TestCase): -- 2.52.0 From 6b6b82803df91f8f5e9991ea8279de2fe586db14 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 17:15:53 +0200 Subject: [PATCH 06/15] Sort the score-outcomes imports by their first binding --- bin/score_outcomes/main.py | 2 +- bin/score_outcomes/test_score_outcomes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/score_outcomes/main.py b/bin/score_outcomes/main.py index 6f55e4dc..e583e821 100644 --- a/bin/score_outcomes/main.py +++ b/bin/score_outcomes/main.py @@ -56,9 +56,9 @@ import re import sys from score_outcomes.anchors import anchor_lines, Anchors, ANCHORS_PATH, parse_anchors +from score_outcomes.outcomes import Chunk, Landing, nearest, Outcome, outcomes_of, render, report, shipped from git_repo import default_branch, file_at, full_history, git, top from failure import Failure -from score_outcomes.outcomes import Chunk, Landing, nearest, Outcome, outcomes_of, render, report, shipped from todo_table import LEVELS, risk, TOP_SCORE from markdown_text import listed from utc_stamp import utc diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index eef363a8..0a95840a 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -8,11 +8,11 @@ import unittest 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 failure import Failure from test_env import isolated_env from todo_table import Item from score_outcomes.outcomes import Landing, nearest, Outcome, outcomes_of, rank_correlation, render, report, shipped -from score_outcomes.main import chunk_log, report_text TOOL = pathlib.Path(__file__).resolve().parents[1] / "score-outcomes" HEADER = "| ID | Release | Exempt | Item | R | S | C | A | G | Goals | Score |\n|---|---|---|---|---|---|---|---|---|---|---|\n" -- 2.52.0 From 92f82047025982243bb900ccd534ceca9df0328c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 17:56:38 +0200 Subject: [PATCH 07/15] Leave chunks that were never replayed out of score-outcomes' medians and rank correlations --- CHANGELOG.md | 2 +- bin/score_outcomes/main.py | 10 ++++---- bin/score_outcomes/outcomes.py | 6 ++--- bin/score_outcomes/test_score_outcomes.py | 31 ++++++++++++++++++++--- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8106963a..487cdd03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `score-outcomes` measures each chunk on the default branch's first-parent line: a merge commit is a chunk of its own, and any other commit joins the commit above it when both share a commit time, else starts a chunk. +- `score-outcomes` measures each chunk on the default branch's first-parent line: a merge commit is a chunk of its own, and any other commit joins the commit above it when both share a commit time, else starts a chunk. A chunk whose commits were pushed or fast-forwarded as committed may hold only part of its pull request, so the medians and rank correlations leave it out. - 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 .` 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. 2. Void code health in each project that opts out of the comprehension check, or `rank_todo.py` refuses its plan. diff --git a/bin/score_outcomes/main.py b/bin/score_outcomes/main.py index e583e821..ccb4bffd 100644 --- a/bin/score_outcomes/main.py +++ b/bin/score_outcomes/main.py @@ -43,9 +43,9 @@ level named twice leaves the anchors out, saying why. 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 past each pass's first and by 🔴 findings: Spearman's rank correlation, from -1 to +1, where +1 -orders them exactly; none where every chunk held the same level, or the same outcome. It counts only chunks that shipped one -item, since a chunk measures all its items at once, and reports a score only once 10 such chunks -hold it and its outcomes. +orders them exactly; none where every chunk held the same level, or the same outcome. It counts only chunks that +shipped one item, since a chunk measures all its items at once. It leaves out the chunks never replayed, which may +hold only part of a pull request. It reports a score only once 10 such chunks hold it and its outcomes. Exit 1, saying why, on bad arguments, when git cannot start, finds no checkout or reads a shallow clone, or the default branch cannot be read; or, after the rest of the report, when the anchors are @@ -71,7 +71,7 @@ UNMERGED = [ "", "- 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.", + "- 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, so the medians and the rank correlations leave it out.", "- 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.", ] @@ -106,7 +106,7 @@ def report_text(outcomes: list[Outcome], anchored: Anchors | Failure, given: dic 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"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, never-replayed ones left out:", "", *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) diff --git a/bin/score_outcomes/outcomes.py b/bin/score_outcomes/outcomes.py index 93bb5ecf..42443fec 100644 --- a/bin/score_outcomes/outcomes.py +++ b/bin/score_outcomes/outcomes.py @@ -75,8 +75,8 @@ def nearest(outcomes: list[Outcome], given: dict[str, int], count: int = 5) -> l def report(outcomes: list[Outcome]) -> list[str]: - """Among chunks that shipped one item, since a chunk measures all its items at once: for each score in MEDIANS, the median outcome at each value it was guessed at; for each level in ORDERED, how well it orders chunks by review rounds and by 🔴 findings.""" - single = [outcome for outcome in outcomes if not outcome.shipped_with] + """Among chunks that shipped one item, since a chunk measures all its items at once, and that were merged or replayed, since a never-replayed one may hold only part of a pull request: for each score in MEDIANS, the median outcome at each value it was guessed at; for each level in ORDERED, how well it orders chunks by review rounds and by 🔴 findings.""" + single = [outcome for outcome in outcomes if not outcome.shipped_with and outcome.landed != "push"] lines = [] for name, (what, measure) in MEDIANS.items(): held = [(outcome.item.scores[name], value) for outcome in single if name in outcome.item.scores and (value := measure(outcome)) is not None] @@ -100,7 +100,7 @@ def report(outcomes: list[Outcome]) -> list[str]: def too_few(held: int, name: str, what: str) -> str: - chunks = "chunk that shipped one item records" if held == 1 else "chunks that shipped one item record" + chunks = "such chunk records" if held == 1 else "such chunks record" return f"{held} {chunks} {name} and {what}; the report needs {ENOUGH}." diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index 0a95840a..40b37d1f 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -111,11 +111,11 @@ class Report(unittest.TestCase): self.assertFalse([line for line in lines if line.startswith("- C")]) def test_says_how_many_chunks_it_has_under_ten(self): - self.assertIn("- S, lines changed: 1 chunk that shipped one item records S and its outcome; the report needs 10.", report([outcome(1, 2, 2, 4), outcome(2, 2, 2, None, shipped_with=(1,))])) + self.assertIn("- S, lines changed: 1 such chunk records S and its outcome; the report needs 10.", report([outcome(1, 2, 2, 4), outcome(2, 2, 2, None, shipped_with=(1,))])) too_few = report([outcome(1, 2, 2, None, levels={"L": 2, "E": 1, "I": 1}), outcome(2, 2, 2, None, levels={"L": 2}, findings=None)]) for name in "LEI": with self.subTest(name=name): - self.assertIn(f"- {name}, by review rounds past each pass's first and 🔴 findings: 1 chunk that shipped one item records {name} and both outcomes; the report needs 10.", too_few) + self.assertIn(f"- {name}, by review rounds past each pass's first and 🔴 findings: 1 such chunk records {name} and both outcomes; the report needs 10.", too_few) def test_ranks_ties_by_their_mean_rank(self): self.assertAlmostEqual(rank_correlation([1, 1, 2, 2, 2], [1, 2, 3, 4, 5]), 0.866, places=3) @@ -187,7 +187,7 @@ class Anchors(unittest.TestCase): class ReportText(unittest.TestCase): def test_lists_the_nearest_by_r_then_the_anchors_then_the_medians(self): found = [outcome(1, 5, 3, None, merged="2026-10-13T10:00:00Z"), outcome(2, 1, 3, None, merged="2026-10-12T10:00:00Z")] - too_few = "chunks that shipped one item record" + too_few = "such chunks record" self.assertEqual(report_text(found, [("L 1", (2,))], {"L": 1, "E": 1, "I": 1, "S": 3}), f"""Finished items nearest L 1, E 1, I 1, so R 1, and S 3, closest first: - Item 2, R 1, S 3: 10 lines in 1 file, 1 round past each pass's first, 0 🔴, 0 🟡; merged 2026-10-12T10:00:00Z in aaaaaaa. **Item 2.** @@ -198,7 +198,7 @@ Anchors in docs/score-anchors.md, each level's shipped items: L 1: - Item 2, R 1, S 3: 10 lines in 1 file, 1 round past each pass's first, 0 🔴, 0 🟡; merged 2026-10-12T10:00:00Z in aaaaaaa. **Item 2.** -Median outcome at each guessed score, among chunks that shipped one item: +Median outcome at each guessed score, among chunks that shipped one item, never-replayed ones left out: - R, 🔴 findings: 2 {too_few} R and its outcome; the report needs 10. - S, lines changed: 2 {too_few} S and its outcome; the report needs 10. @@ -214,6 +214,29 @@ Median outcome at each guessed score, among chunks that shipped one item: 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_leaves_a_never_replayed_chunk_out_of_the_s_medians_and_keeps_a_rebased_one(self): + found = [outcome(id_, 2, 2, None, lines=10 * id_, landed="rebase" if id_ == 1 else "merge") for id_ in range(1, 11)] + self.assertIn("- S, lines changed: 2 → 55 (10 chunks)", report_text(found + [outcome(11, 2, 2, None, lines=100000, landed="push")], [], None)) + + def test_leaves_a_never_replayed_chunk_out_of_the_r_medians_and_the_rank_correlations(self): + levels = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4] + found = [outcome(id_, 2, 2, None, rounds=level, findings=(5 - level, 0), levels={"L": level, "E": 2, "I": level}) for id_, level in enumerate(levels, 1)] + pushed = outcome(11, 2, 2, None, rounds=9, findings=(9, 0), levels={"L": 1, "E": 2, "I": 1}, landed="push") + text = report_text(found + [pushed], [], None) + self.assertIn("- R, 🔴 findings: 2 → 2.5 (10 chunks)", text) + self.assertIn("- L, by review rounds past each pass's first and 🔴 findings: rank correlation +1.00 and -1.00 (10 chunks)", text) + self.assertIn("- I, by review rounds past each pass's first and 🔴 findings: rank correlation +1.00 and -1.00 (10 chunks)", text) + self.assertIn("- E, by review rounds past each pass's first and 🔴 findings: rank correlation none and none, since every chunk held one value (10 chunks)", text) + + def test_keeps_a_never_replayed_chunk_in_the_nearest_and_anchors_lists(self): + pushed = outcome(9, 2, 3, None, landed="push") + text = report_text([pushed], [("L 1", (9,))], {"L": 1, "E": 1, "I": 1, "S": 3}) + nearest_section, anchors_section = text.split("Anchors in ") + self.assertIn("- Item 9, R 2, S 3:", nearest_section) + self.assertIn("never replayed", nearest_section) + self.assertIn("- Item 9, R 2, S 3:", anchors_section) + self.assertIn("never replayed", anchors_section.split("Median outcome")[0]) + def test_lists_no_nearest_items_where_no_scores_are_given(self): self.assertTrue(report_text([], [], None).startswith("Anchors in docs/score-anchors.md")) -- 2.52.0 From 70cc5c9a0a5c72e206c1a7ad495ee9c833fdc51c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 18:13:59 +0200 Subject: [PATCH 08/15] =?UTF-8?q?Answer=20stability=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=204=20=F0=9F=9F=A1;=20the=20medians'=20note=20nam?= =?UTF-8?q?es=20the=20rebased=20chunks=20it=20counts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/score_outcomes/main.py | 2 +- bin/score_outcomes/test_score_outcomes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/score_outcomes/main.py b/bin/score_outcomes/main.py index ccb4bffd..d23956f3 100644 --- a/bin/score_outcomes/main.py +++ b/bin/score_outcomes/main.py @@ -72,7 +72,7 @@ UNMERGED = [ "- 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, so the medians and the rank correlations leave it out.", - "- 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.", + "- 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 the rebased ones as shown.", ] diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index 40b37d1f..36e2bb0e 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -210,7 +210,7 @@ Median outcome at each guessed score, among chunks that shipped one item, never- 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("at least what history shows, and the medians count the rebased ones as shown.", 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)) -- 2.52.0 From 21d8cab43fd22ac8f7933189a1dc529c8686f360 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 18:14:30 +0200 Subject: [PATCH 09/15] =?UTF-8?q?Answer=20principles=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=206=20=F0=9F=9F=A1;=20split=20the=20five-behaviou?= =?UTF-8?q?r=20rebase=20test=20into=20five=20on=20one=20fixture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/score_outcomes/test_score_outcomes.py | 27 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index 36e2bb0e..95c48edb 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -289,7 +289,7 @@ 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.assertNotIn("Item 5", ran.stdout) - def test_measures_each_chunk_a_rebase_merge_replayed_at_one_commit_time(self): + def run_on_rebased_history(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") @@ -299,9 +299,28 @@ class ScoreOutcomesTool(unittest.TestCase): 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) + item_4 = [line for line in ran.stdout.splitlines() if line.startswith("- Item 4,")] + return ran.stdout, item_4[0], first, last, pushed + + def test_guesses_a_rebase_chunk_from_the_todo_md_before_its_first_commit(self): + _, item_4, _, _, _ = self.run_on_rebased_history() + self.assertTrue(item_4.startswith("- Item 4, R 1, S 3, C 10: "), item_4) + + def test_leaves_the_reading_cost_record_out_of_a_rebase_chunk_lines(self): + _, item_4, _, _, _ = self.run_on_rebased_history() + self.assertIn(": 3 lines in 1 file, ", item_4) + + def test_labels_a_run_of_commits_that_kept_their_author_time_never_replayed(self): + stdout, _, _, _, pushed = self.run_on_rebased_history() + 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.**", stdout) + + def test_measures_a_rebase_run_at_one_commit_time_as_one_chunk_whose_rounds_read_at_least(self): + _, item_4, first, last, _ = self.run_on_rebased_history() + self.assertIn(f"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.**", item_4) + + def test_explains_the_chunks_that_left_no_merge_commit_after_a_rebase(self): + stdout, _, _, _, _ = self.run_on_rebased_history() + self.assertIn("Chunks that left no merge commit:", stdout) def test_counts_a_direct_commit_behind_the_newest_merge_as_a_push_chunk(self): drop = self.commit("Drop item 5 on main", {"b.py": "1\n", "todo.md": todo(FIRST)}, at="2026-10-12T09:00:00Z", authored="2026-10-12T09:00:00Z") -- 2.52.0 From 646f7a7df5f3127447f539645c27cbbe4b22c4ec Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 18:14:45 +0200 Subject: [PATCH 10/15] Reword item 111 to measure each chunk by its merge time, whatever the merge method --- todo.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/todo.md b/todo.md index 517f95cc..b9bc7807 100644 --- a/todo.md +++ b/todo.md @@ -69,7 +69,7 @@ | 102 | 0.4.0 | | | **Give loop-claude's retry delay an environment override, so the black-box test stops replacing `time.sleep` through `sitecustomize`.** | 1 | 1 | 2 | 2 | 2 | 1.1 by 4 | 5.6 | | 66 | 0.4.0 | | principle | **Hold systems-architect's method thresholds only while the comprehension panel finds the flagged code hard.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5 | 5.3 | | 101 | 0.4.0 | | principle | **Have `larv_review/record.py`'s `read_seats` take the time, the commit check and the history as inputs, so it parses and decides without effects.** | 2 | 1 | 2 | 3 | 3 | 1.1 by 5 | 5.3 | -| 111 | 0.4.0 | | | **Measure the chunks of a project that merges by squash or fast-forward, which `score-outcomes` skips today.** | 3 | 2 | 2 | 5 | 3 | 1.1 by 5 | 5.3 | +| 111 | 0.4.0 | | | **Measure each chunk by its merge time, whatever the project's merge method.** | 3 | 2 | 2 | 5 | 3 | 1.1 by 5 | 5.3 | | 110 | 0.4.0 | | | **Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E.** | 3 | 2 | 2 | 5 | 5 | 1.1 by 6, 1.4 by 6 | 4.9 | | 149 | 0.4.0 | | decision | **Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 7 | 3.0 | | 123 | 0.5.0 | | | **Have `bin/comprehension_history.py` parse each history entry once into seats, votes and places, so `latest_places`, `worse_places` and `worse_votes` neither depend on table order nor split a label to find a seat.** | 2 | 1 | 2 | 3 | 5 | code health by 5, 1.4 by 5 | 11.0 | @@ -328,9 +328,9 @@ KISS, in `principles/technical-principles.md`, which keeps a limit only while re Found by the principles audit of PR #242, against "Functional core, imperative shell" (`principles/technical-principles.md`). `bin/larv_review/record.py:67` reads `time.time()`, then checks git (`:70`, `commit_exists`) and the history file (`:75`) inside the function that parses the seats file and decides. A test cannot fix the heading's time, and every test of `read_seats` touches the real checkout. -### 111. Measure the chunks of a project that merges by squash or fast-forward, which `score-outcomes` skips today. +### 111. Measure each chunk by its merge time, whatever the project's merge method. -`score-outcomes` reads a chunk from a merge commit: its branch's round titles, and its change against the first parent. A project that merges by squash or fast-forward has no merge commit, so its scorer sees no finished item. +Where a merge keeps no review titles, such as a squash merge, the report cannot count its review rounds. A fast-forwarded pull request keeps its commits' own times, so each commit counts as its own chunk. ### 110. Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E. -- 2.52.0 From a81047f5f6cb82d2dc9c6eed2eda45ff37e1880f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 18:14:53 +0200 Subject: [PATCH 11/15] Finish item 111, and state score-outcomes' change in one changelog line --- CHANGELOG.md | 2 +- todo.md | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 487cdd03..2506fdda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `score-outcomes` measures each chunk on the default branch's first-parent line: a merge commit is a chunk of its own, and any other commit joins the commit above it when both share a commit time, else starts a chunk. A chunk whose commits were pushed or fast-forwarded as committed may hold only part of its pull request, so the medians and rank correlations leave it out. +- `score-outcomes` measures each chunk by its merge time, whatever the project's merge method. - 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 .` 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. 2. Void code health in each project that opts out of the comprehension check, or `rank_todo.py` refuses its plan. diff --git a/todo.md b/todo.md index b9bc7807..4b0a474b 100644 --- a/todo.md +++ b/todo.md @@ -69,7 +69,6 @@ | 102 | 0.4.0 | | | **Give loop-claude's retry delay an environment override, so the black-box test stops replacing `time.sleep` through `sitecustomize`.** | 1 | 1 | 2 | 2 | 2 | 1.1 by 4 | 5.6 | | 66 | 0.4.0 | | principle | **Hold systems-architect's method thresholds only while the comprehension panel finds the flagged code hard.** | 2 | 2 | 3 | 5 | 3 | 1.1 by 5 | 5.3 | | 101 | 0.4.0 | | principle | **Have `larv_review/record.py`'s `read_seats` take the time, the commit check and the history as inputs, so it parses and decides without effects.** | 2 | 1 | 2 | 3 | 3 | 1.1 by 5 | 5.3 | -| 111 | 0.4.0 | | | **Measure each chunk by its merge time, whatever the project's merge method.** | 3 | 2 | 2 | 5 | 3 | 1.1 by 5 | 5.3 | | 110 | 0.4.0 | | | **Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E.** | 3 | 2 | 2 | 5 | 5 | 1.1 by 6, 1.4 by 6 | 4.9 | | 149 | 0.4.0 | | decision | **Fill each release by priority up to a capacity it states, in place of the bar, and move what does not fit to a later release.** | 4 | 2 | 3 | 7 | 5 | 1.1 by 7 | 3.0 | | 123 | 0.5.0 | | | **Have `bin/comprehension_history.py` parse each history entry once into seats, votes and places, so `latest_places`, `worse_places` and `worse_votes` neither depend on table order nor split a label to find a seat.** | 2 | 1 | 2 | 3 | 5 | code health by 5, 1.4 by 5 | 11.0 | @@ -328,10 +327,6 @@ KISS, in `principles/technical-principles.md`, which keeps a limit only while re Found by the principles audit of PR #242, against "Functional core, imperative shell" (`principles/technical-principles.md`). `bin/larv_review/record.py:67` reads `time.time()`, then checks git (`:70`, `commit_exists`) and the history file (`:75`) inside the function that parses the seats file and decides. A test cannot fix the heading's time, and every test of `read_seats` touches the real checkout. -### 111. Measure each chunk by its merge time, whatever the project's merge method. - -Where a merge keeps no review titles, such as a squash merge, the report cannot count its review rounds. A fast-forwarded pull request keeps its commits' own times, so each commit counts as its own chunk. - ### 110. Count, for each finished chunk, the later changes that fixed code it wrote, and show them beside its guessed E. `score-outcomes` measures risk only by the 🔴 findings review caught. A serious bug review missed shows later, as a change that fixes code the chunk wrote: the defect that escaped, which E guesses. -- 2.52.0 From dc79ebf8280c7aaba1233335fa539bd4535f167d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 18:15:26 +0200 Subject: [PATCH 12/15] Move the score-outcomes line under a new Unreleased section, since 0.2.0 shipped without it --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 334a6945..1379d4f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # Changelog +## Unreleased + +- `score-outcomes` measures each chunk by its merge time, whatever the project's merge method. + ## 0.2.0 -- `score-outcomes` measures each chunk by its merge time, whatever the project's merge method. - 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 .` 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. 2. Void code health in each project that opts out of the comprehension check, or `rank_todo.py` refuses its plan. @@ -25,7 +28,7 @@ - The stability reviewer applies `principles/technical-principles.md` as written, in place of its own copies of it. Its test-data check now asks for UUID v7, where it asked for randomised UUIDs. - larv-review's principles audit is a pass of its own, and runs on every chunk that changes code, config or tests, not only on one with an architectural decision. A chunk of prose or planning alone skips it. - `rule-hook` refuses an Agent call that launches a reviewer, a comprehension seat or the security pass on a rung below the one `loop-claude` names for it, and takes no override: pass the model and effort the refusal names. -- `score-outcomes` lists a project's score anchors: the shipped items its `docs/score-anchors.md` names for each level of L, E and I, each with what its chunk measured. `rules/todo-items.md` has a scorer compare a new item with them, and says how to choose two or three per level. Add the file to each project that merges with merge commits or by rebase; elsewhere, score by the level descriptions in `rules/todo-items.md`. +- `score-outcomes` lists a project's score anchors: the shipped items its `docs/score-anchors.md` names for each level of L, E and I, each with what its chunk measured. `rules/todo-items.md` has a scorer compare a new item with them, and says how to choose two or three per level. Add the file to each project that merges with merge commits; elsewhere, score by the level descriptions in `rules/todo-items.md`. - `loop-claude` archives each judge reply it rejects in the chunk's `.outcomes.md`, with the reason and the reply as json. Before, such a reply reached only stderr, so a run that exited 1 overnight could not say what the judge had returned. stderr now prints only the reason; the reply is in outcomes.md. If archiving fails, `loop-claude` exits 1. - `loop-claude` routes each chunk on `todo.md` as the default branch holds it, freshly fetched: merge a `todo.md` edit before the chunk it should route starts. Where `todo.md` holds no item for the next release, the earliest release it has named since the newest tag, no item routes the chunk, and the worker is told that release is finished and ready to cut, or, where no work has landed since the tag, to be planned first. Before routing, `loop-claude` runs the new `bin/chunk-preflight` and quotes what it prints in the worker's first prompt: the chunk's mechanical facts, which `chunk-preflight --help` lists. The preflight also makes the chunk's worktree, `-item-` beside the checkout on the branch `item-`, or continues the one already there, and leaves an uncommitted figure in that worktree's `docs/reading-cost.md` for the chunk to commit. It stops a fetch, forge CLI or tool after 60 seconds, or after the seconds `CHUNK_PREFLIGHT_TIMEOUT` sets. The prompt also asks the worker to count the item's size again once it has read the code, and to have the item re-scored where its L would change. Expect the worker to start editing sooner. -- 2.52.0 From 7518bc7f775cb6c755d7f772fc7bdcf46efcf2a3 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 18:15:45 +0200 Subject: [PATCH 13/15] Shorten the score-outcomes changelog line to measuring each chunk by its merge time --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1379d4f6..92c41107 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `score-outcomes` measures each chunk by its merge time, whatever the project's merge method. +- `score-outcomes` measures each chunk by its merge time. ## 0.2.0 -- 2.52.0 From 243cbe83b9c59b689e19f613b14b4312e231df59 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 18:17:40 +0200 Subject: [PATCH 14/15] =?UTF-8?q?Answer=20prose=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1;=20the=20help's=20count=20of?= =?UTF-8?q?=2010=20names=20the=20chunks=20it=20counts,=20and=20the=20rewra?= =?UTF-8?q?pped=20paragraphs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/score_outcomes/main.py | 19 ++++++++++--------- bin/score_outcomes/test_score_outcomes.py | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bin/score_outcomes/main.py b/bin/score_outcomes/main.py index d23956f3..c809599c 100644 --- a/bin/score_outcomes/main.py +++ b/bin/score_outcomes/main.py @@ -26,8 +26,8 @@ A chunk is marked `by rebase` where a commit in it has a committer time apart fr since a rebase replays a pull request's commits at once, and `never replayed` where none does, since a pushed or fast-forwarded commit may be part of a pull request. A merge's titles are its branch's commits'; any other chunk's are its own. Two pull requests merged in the same second read as one -chunk. Rebase drops a round's commit that changed no file, so a rebase or push chunk gives its rounds and -findings as lower bounds, `at least`, and the report ends saying all this. +chunk. Rebase drops a round's commit that changed no file, so a rebase or push 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 L, E and I, as rank_todo.py does, and lists the 5 finished items whose guesses sit closest, closest @@ -40,12 +40,13 @@ E and I, read from the checkout's working tree, each line as above, or that no c file that cannot be read, a row that does not hold a level on its scale and a list of IDs, or a level named twice leaves the anchors out, saying why. -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 -past each pass's first and by 🔴 findings: Spearman's rank correlation, from -1 to +1, where +1 -orders them exactly; none where every chunk held the same level, or the same outcome. It counts only chunks that -shipped one item, since a chunk measures all its items at once. It leaves out the chunks never replayed, which may -hold only part of a pull request. It reports a score only once 10 such chunks hold it and its outcomes. +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 past +each pass's first and by 🔴 findings: Spearman's rank correlation, from -1 to +1, where +1 orders +them exactly; none where every chunk held the same level, or the same outcome. It counts only chunks +that shipped one item, since a chunk measures all its items at once. It leaves out the chunks never +replayed, which may hold only part of a pull request. It reports a score only once 10 of the chunks +it counts hold it and its outcomes. Exit 1, saying why, on bad arguments, when git cannot start, finds no checkout or reads a shallow clone, or the default branch cannot be read; or, after the rest of the report, when the anchors are @@ -71,7 +72,7 @@ UNMERGED = [ "", "- 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, so the medians and the rank correlations leave it out.", + "- A run whose commits all kept their author time was never replayed: it was pushed or fast-forwarded as committed. It may hold only part of its pull request, so the medians and the rank correlations leave it out.", "- 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 the rebased ones as shown.", ] diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index 95c48edb..ad60f4ab 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -306,7 +306,7 @@ class ScoreOutcomesTool(unittest.TestCase): _, item_4, _, _, _ = self.run_on_rebased_history() self.assertTrue(item_4.startswith("- Item 4, R 1, S 3, C 10: "), item_4) - def test_leaves_the_reading_cost_record_out_of_a_rebase_chunk_lines(self): + def test_leaves_the_reading_cost_record_out_of_a_rebase_chunks_lines(self): _, item_4, _, _, _ = self.run_on_rebased_history() self.assertIn(": 3 lines in 1 file, ", item_4) -- 2.52.0 From 10495b885233f525c3c15950f11b4bf01398317d Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 21 Oct 2026 22:25:20 +0200 Subject: [PATCH 15/15] =?UTF-8?q?Answer=20product-owner=20round=204:=200?= =?UTF-8?q?=20=F0=9F=94=B4,=201=20=F0=9F=9F=A1;=20the=20changelog=20says?= =?UTF-8?q?=20what=20changes=20for=20rebase=20and=20pushed=20projects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c41107..8f35bae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `score-outcomes` measures each chunk by its merge time. +- `score-outcomes` now also measures projects that merge by rebase: each run of commits that share one commit time counts as a chunk. Add `docs/score-anchors.md` to those projects too. A chunk that was pushed or fast-forwarded may hold only part of its pull request, so the medians and rank correlations leave it out. ## 0.2.0 -- 2.52.0