diff --git a/CHANGELOG.md b/CHANGELOG.md index 77f7b346..1dbd4adf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- `score-outcomes` now shows, beside what each finished item's chunk measured, the size of the files and folders its tagline or detail names in backticks: how many files, and how many lines, as they stood before its chunk. - `workflow-bench/bench.py` now prints a failed run, such as a failed clone, as a `: FAILED: …` line beside the other runs' results, in place of stopping at the first failure. - A scoring run under the comprehension floor of 7.0 now leaves a plan item meant to reach it. `larv-review record-scoring` follows its `Floor:` line with a `Next:` line. It says to file one ambitious refactor aimed at the lowest dimension, or to refresh the one `todo.md` already holds. The item's tagline holds `comprehension floor`, so its own chunk runs a scoring run. It goes into the release after the chunk's, so the floor doesn't hold up any release (larv-review §3 → "Floor item"). An item already in `todo.md` whose tagline holds those words counts as the open one: drop or reword it if it isn't such a refactor. - `loop-claude` now interrupts you less. A worker takes its own recommendation on a choice no rule reserves for you, and records it, and the judge answers an ask that carries a recommendation by quoting the rule that says so. You are still asked about a goal, a release's planned items and its cut, a change to the routing ladder, and whatever another rule asks your approval for; `CLAUDE.md` → "Working loop", "Ask, don't guess" lists them. diff --git a/bin/chunk_preflight/choices.py b/bin/chunk_preflight/choices.py index 34d5e4bf..9cd5e1b5 100644 --- a/bin/chunk_preflight/choices.py +++ b/bin/chunk_preflight/choices.py @@ -1,6 +1,5 @@ """The pure choices the preflight's steps act on.""" import pathlib -import re from release_plan.release_standing import chunk_item, Cut, dated_cut, LastCut, ReadyToCut, ReviewDue, Unknown, Unplanned from failure import Failure @@ -82,10 +81,3 @@ def pulls_command(forge: Forge, branch: str) -> list[str]: if forge == "gh": return [*PULLS_LIST["gh"], "--head", branch, "--json", "number,url", "--template", "{{range .}}{{.number}}\t{{.url}}\n{{end}}"] return [*PULLS_LIST["tea"], "--fields", "index,head,url", "--output", "tsv"] - - -def named_paths(text: str, tracked: list[str]) -> list[tuple[str, int]]: - """Each backticked span in text, in order and once, that names a tracked file or folder, with how many of the tracked files it holds: 1 for a file.""" - spans = dict.fromkeys(span.removesuffix("/") for span in re.findall(r"`([^`\s]+)`", text)) - held = ((span, sum(path == span or path.startswith(f"{span}/") for path in tracked)) for span in spans) - return [(span, count) for span, count in held if count] diff --git a/bin/chunk_preflight/main.py b/bin/chunk_preflight/main.py index d6c6fe56..1509084a 100644 --- a/bin/chunk_preflight/main.py +++ b/bin/chunk_preflight/main.py @@ -61,7 +61,8 @@ from git_cli.git_repo import commit_exists, default_branch, file_at, git, top from release_plan.release_standing import default_plan from failure import Failure from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, NoItem, Plan, Ran, Worktree -from chunk_preflight.choices import forge_of, named_paths, planned, pulls_command, worktree_add, worktree_on +from chunk_preflight.choices import forge_of, planned, pulls_command, worktree_add, worktree_on +from release_plan.named_code import named_paths from chunk_preflight.facts import render BIN = pathlib.Path(__file__).resolve().parents[1] diff --git a/bin/chunk_preflight/test_chunk_preflight.py b/bin/chunk_preflight/test_chunk_preflight.py index 1011bdb0..f5790919 100644 --- a/bin/chunk_preflight/test_chunk_preflight.py +++ b/bin/chunk_preflight/test_chunk_preflight.py @@ -9,7 +9,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from failure import Failure -from chunk_preflight.choices import forge_of, named_paths, planned, worktree_add +from chunk_preflight.choices import forge_of, planned, worktree_add from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, NoItem, Ran, Worktree from test_env import isolated_env from release_plan.release_standing import LastCut @@ -501,16 +501,6 @@ class Plans(unittest.TestCase): class Gathering(unittest.TestCase): - def test_names_each_tracked_file_or_folder_a_backticked_span_names_once_with_its_files(self): - cases = ( - ("`src/` and `src`", ["src/app.py", "srcfoo/x.py"], [("src", 1)]), - ("`src/`", ["src/app.py", "src/b.py"], [("src", 2)]), - ("`src/app.py`, `gone.py` and `run`", ["src/app.py"], [("src/app.py", 1)]), - ) - for text, tracked, named in cases: - with self.subTest(text=text): - self.assertEqual(named_paths(text, tracked), named) - def test_adds_the_worktree_on_the_local_branch_else_on_a_new_one_tracking_origins_else_on_a_new_one_off_the_default_branch(self): path = pathlib.Path("/c/proj-item-3") self.assertEqual(worktree_add("item-3", path, "origin/main", True, True)[0], ["worktree", "add", "--quiet", "/c/proj-item-3", "item-3"]) diff --git a/bin/release_plan/named_code.py b/bin/release_plan/named_code.py new file mode 100644 index 00000000..43db6aa8 --- /dev/null +++ b/bin/release_plan/named_code.py @@ -0,0 +1,22 @@ +"""The tracked files and folders an item's text names, each as a backticked span such as `bin/rank_todo.py` or `bin/`.""" +import re + + +def named_paths(text: str, tracked: list[str]) -> list[tuple[str, int]]: + """Each backticked span in text, in order and once, that names a tracked file or folder, with how many of the tracked files it holds: 1 for a file.""" + held = ((span, sum(holds(span, path) for path in tracked)) for span in spans(text)) + return [(span, count) for span, count in held if count] + + +def named_files(text: str, tracked: list[str]) -> list[str]: + """Each tracked file that a backticked span in text names, either the file itself or a folder holding it, once, in tracked's order.""" + named = spans(text) + return [path for path in tracked if any(holds(span, path) for span in named)] + + +def spans(text: str) -> list[str]: + return list(dict.fromkeys(span.removesuffix("/") for span in re.findall(r"`([^`\s]+)`", text))) + + +def holds(span: str, path: str) -> bool: + return path == span or path.startswith(f"{span}/") diff --git a/bin/release_plan/test_named_code.py b/bin/release_plan/test_named_code.py new file mode 100644 index 00000000..26fdea0e --- /dev/null +++ b/bin/release_plan/test_named_code.py @@ -0,0 +1,35 @@ +import pathlib +import sys +import unittest + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) + +from release_plan.named_code import named_files, named_paths + + +class NamedPaths(unittest.TestCase): + def test_names_each_tracked_file_or_folder_a_backticked_span_names_once_with_its_files(self): + cases = ( + ("`src/` and `src`", ["src/app.py", "srcfoo/x.py"], [("src", 1)]), + ("`src/`", ["src/app.py", "src/b.py"], [("src", 2)]), + ("`src/app.py`, `gone.py` and `run`", ["src/app.py"], [("src/app.py", 1)]), + ) + for text, tracked, named in cases: + with self.subTest(text=text): + self.assertEqual(named_paths(text, tracked), named) + + +class NamedFiles(unittest.TestCase): + def test_lists_each_tracked_file_a_span_names_by_itself_or_its_folder_once(self): + cases = ( + ("`src` and `src/a.py`", ["b.py", "src/a.py", "src/b.py", "srcfoo/x.py"], ["src/a.py", "src/b.py"]), + ("`b.py`, `gone.py` and `run`", ["b.py", "c.py"], ["b.py"]), + ("no span", ["b.py"], []), + ) + for text, tracked, named in cases: + with self.subTest(text=text): + self.assertEqual(named_files(text, tracked), named) + + +if __name__ == "__main__": + unittest.main() diff --git a/bin/score_outcomes/main.py b/bin/score_outcomes/main.py index c0bcc5cb..36dd14df 100644 --- a/bin/score_outcomes/main.py +++ b/bin/score_outcomes/main.py @@ -45,7 +45,13 @@ Given L, E and I, on the levels ~/.claude/rules/todo-items.md defines, and S, it L, E and I, as rank_todo.py does, and lists the 5 finished items whose guesses sit closest, closest first: the least mean squared difference over the scores both hold, so R and S alone for an item scored before L, E and I, the newest first among equals. Each line gives what the item's chunk -measured, which items shipped with it, and its tagline. +measured, which items shipped with it, and its tagline. Where the item's tagline or detail names +tracked files or folders in backticks, each by its path from the repository root such as +`bin/rank_todo.py`, the line also gives their size, after the later fixes: how many files they +are, and how many lines they held before the chunk. A named folder counts the files it holds. This is the +size of the code the item said it would change; the chunk's change may reach beyond it. Where the +todo.md a chunk started from holds a ## Details section that cannot be read, it says so on stderr +and sizes that chunk's items by their taglines alone. 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 chunk shipped it. A @@ -73,6 +79,7 @@ clone, or the default branch cannot be read; or, after the rest of the report, w left out. """ import functools +import os import pathlib import re import sys @@ -81,9 +88,10 @@ from score_outcomes.anchors import anchor_lines, Anchors, ANCHORS_PATH, parse_an from branch_chunks.read import branch_chunks from git_cli.git_repo import default_branch, full_history, git, top from failure import Failure -from score_outcomes.results import fixed_later, misreads, nearest, render, report, Result, results_of -from release_plan.todo_table import LEVELS, risk, TOP_SCORE +from score_outcomes.results import file_lines, fixed_later, item_text, misreads, nearest, render, report, Result, results_of +from release_plan.todo_table import item_details, LEVELS, risk, TOP_SCORE from records.markdown_text import listed +from release_plan.named_code import named_files # The scores score-outcomes takes, in order. GIVEN = ("L", "E", "I", "S") @@ -165,6 +173,9 @@ def read_results(default: str) -> list[Result] | Failure: chunks = branch_chunks(default, run) if isinstance(chunks, Failure): return chunks + empty_tree = run("hash-object", "-t", "tree", os.devnull) + if isinstance(empty_tree, Failure): + return empty_tree results: list[Result] = [] for chunk in chunks: if chunk.before is None or not chunk.shipped: @@ -172,5 +183,20 @@ def read_results(default: str) -> list[Result] | Failure: numstat = run("diff", "--numstat", chunk.before, chunk.tip) if isinstance(numstat, Failure): return numstat - results += results_of(chunk, numstat) + plan = run("show", f"{chunk.before}:todo.md") + if isinstance(plan, Failure): + return plan + found = item_details(plan) + if isinstance(found, Failure): + print(f"score-outcomes: the todo.md before {chunk.label} cannot be read for its details, so its items are sized by their taglines alone: {found.reason}", file=sys.stderr) + details = {} if isinstance(found, Failure) else found + tracked = run("ls-tree", "-r", "-z", "--name-only", chunk.before) + if isinstance(tracked, Failure): + return tracked + # Count only the files the items name, since counting every file's lines for every chunk doubles the run. + named = list(dict.fromkeys(path for item in chunk.shipped for path in named_files(item_text(item, details), tracked.split("\0")[:-1]))) + tree = run("--literal-pathspecs", "diff", "--numstat", "-z", empty_tree.strip(), chunk.before, "--", *named) if named else "" + if isinstance(tree, Failure): + return tree + results += results_of(chunk, numstat, details, file_lines(tree)) return results diff --git a/bin/score_outcomes/results.py b/bin/score_outcomes/results.py index dec2362c..6d3dde9b 100644 --- a/bin/score_outcomes/results.py +++ b/bin/score_outcomes/results.py @@ -6,15 +6,24 @@ from branch_chunks.cut import BranchChunk, Landing, NOT_WORK from review_rules.round_titles import Findings, round_findings, rounds_past_first from release_plan.todo_table import Item from records.markdown_text import listed +from release_plan.named_code import named_files # Fewest single-item chunks a score needs before its medians print: the 10 figures the reading-cost trend waits for; no published standard sets either. ENOUGH = 10 +# A size in files and lines, not an S, since no published scale maps lines to S. The report's S medians show which S was guessed for how many lines changed. +@dataclasses.dataclass(frozen=True) +class NamedCode: + """How many tracked files an item's tagline and detail name, and their lines, as they stood before the chunk that shipped it. A named folder counts the files it holds. A binary file counts no lines.""" + files: int + lines: int + + # The tool's name and report call a Result an outcome, a word the code keeps for an entry of a `.outcomes.md` file: docs/decisions.md → `bin/: an outcome is an entry`. @dataclasses.dataclass(frozen=True) class Result: - """What the chunk that shipped an item measured. findings holds the 🔴 and 🟡 counts, and how many of them a reviewer marked `[misread]`, None where a round title lacks the 🔴 and 🟡 counts or the branch has no round; its misread is None where a round title lacks that count. landing says how the chunk reached the default branch: by a merge commit, by a rebase that replayed its commits, or by commits never replayed. fixed_by names the later chunks that fixed code it shipped, newest first, as branch_chunks counts them.""" + """What the chunk that shipped an item measured. findings holds the 🔴 and 🟡 counts, and how many of them a reviewer marked `[misread]`, None where a round title lacks the 🔴 and 🟡 counts or the branch has no round; its misread is None where a round title lacks that count. landing says how the chunk reached the default branch: by a merge commit, by a rebase that replayed its commits, or by commits never replayed. fixed_by names the later chunks that fixed code it shipped, newest first, as branch_chunks counts them. named is None where the item names no tracked file.""" item: Item merge: str merged: str @@ -25,6 +34,7 @@ class Result: findings: Findings | None landing: Landing fixed_by: tuple[str, ...] + named: NamedCode | None # A measure's name and how to read it from a Result, None where the chunk did not record it. @@ -37,8 +47,8 @@ ORDERED = ("L", "E", "I") SHOWN = ("L", "E", "I", "R", "S", "C") -def results_of(chunk: BranchChunk, numstat: str) -> list[Result]: - """What one chunk measured for each item it shipped, from `git diff --numstat` of its change; none where it changed nothing but the plan and the records.""" +def results_of(chunk: BranchChunk, numstat: str, details: dict[int, str], tree: dict[str, int]) -> list[Result]: + """What one chunk measured for each item it shipped, from `git diff --numstat` of its change; none where it changed nothing but the plan and the records. details holds each item's detail in the todo.md the chunk started from, and tree each file's lines before the chunk, as file_lines reads them.""" 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: @@ -47,7 +57,23 @@ def results_of(chunk: BranchChunk, numstat: str) -> list[Result]: lines = sum(int(count) for row in work for count in row[:2] if count.isdigit()) titles = list(chunk.titles) ids = [item.id for item in chunk.shipped] - return [Result(item, chunk.label, chunk.merged, tuple(id_ for id_ in ids if id_ != item.id), lines, len(work), rounds_past_first(titles), round_findings(titles), chunk.landing, chunk.fixed_by) for item in chunk.shipped] + return [Result(item, chunk.label, chunk.merged, tuple(id_ for id_ in ids if id_ != item.id), lines, len(work), rounds_past_first(titles), round_findings(titles), chunk.landing, chunk.fixed_by, named_code(item_text(item, details), tree)) for item in chunk.shipped] + + +def item_text(item: Item, details: dict[int, str]) -> str: + """The text that may name files: the item's tagline and its detail.""" + return f"{item.tagline}\n{details.get(item.id, '')}" + + +def file_lines(numstat: str) -> dict[str, int]: + """Each file's lines from `git diff --numstat -z` against the empty tree, which counts every line as added. Git prints "-" for a binary file's lines, so that file counts 0 lines.""" + rows = [row.split("\t", 2) for row in numstat.split("\0")] + return {row[2]: int(row[0]) if row[0].isdigit() else 0 for row in rows if len(row) == 3} + + +def named_code(text: str, tree: dict[str, int]) -> NamedCode | None: + files = named_files(text, list(tree)) + return NamedCode(len(files), sum(tree[path] for path in files)) if files else None def nearest(results: list[Result], given: dict[str, int], count: int = 5) -> list[Result]: @@ -129,7 +155,14 @@ def render(result: Result) -> str: merged = {"merge": f"merged {result.merged} in {result.merge}", "rebase": f"merged {result.merged} by rebase in {result.merge}", "push": f"committed {result.merged} in {result.merge}, never replayed, so perhaps part of a pull request"}[result.landing] others = result.shipped_with together = f", with item{'s' if len(others) > 1 else ''} {', '.join(map(str, others))}" if others else "" - return f"- Item {result.item.id}, {scores}: {plural(result.lines, 'line')} in {plural(result.files, 'file')}, {at_least(result)}{plural(result.rounds_past_first, 'round')} past each pass's first, {counted(result)}, {later(result)}; {merged}{together}. {result.item.tagline}" + return f"- Item {result.item.id}, {scores}: {plural(result.lines, 'line')} in {plural(result.files, 'file')}, {at_least(result)}{plural(result.rounds_past_first, 'round')} past each pass's first, {counted(result)}, {later(result)}{named(result)}; {merged}{together}. {result.item.tagline}" + + +def named(result: Result) -> str: + """The size of the code the item names, labelled apart from the lines its chunk changed, which S is checked against.""" + if result.named is None: + return "" + return f", and the {plural(result.named.files, 'file')} it names held {plural(result.named.lines, 'line')} before" def at_least(result: Result) -> str: diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index 3793ff7b..6c6ffac9 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -10,10 +10,10 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from score_outcomes.anchors import anchor_lines, parse_anchors from branch_chunks.cut import BranchChunk, Landing from failure import Failure +from score_outcomes.results import file_lines, NamedCode, nearest, rank_correlation, render, report, Result, results_of from review_rules.round_titles import Findings from test_env import isolated_env from release_plan.todo_table import Item -from score_outcomes.results import nearest, rank_correlation, render, report, Result, results_of from score_outcomes.main import report_text TOOL = pathlib.Path(__file__).resolve().parents[1] / "score-outcomes" @@ -31,20 +31,30 @@ def item(id_: int, scores: dict[str, int]) -> Item: return Item(id_, (0, 1, 0), "", f"**Item {id_}.**", scores, (("1", None),), ()) -def result(id_: int, r: int, s: int, c: int | None, lines: int = 10, rounds: int = 1, findings: tuple[int, int] | None = (0, 0), merged: str = "2026-10-13T10:00:00Z", shipped_with: tuple[int, ...] = (), levels: dict[str, int] | None = None, landing: Landing = "merge", misread: int | None = None, merge: str = "aaaaaaa", fixed_by: tuple[str, ...] = ()) -> Result: - return Result(item(id_, {"R": r, "S": s} | ({"C": c} if c else {}) | (levels or {})), merge, merged, shipped_with, lines, 1, rounds, None if findings is None else Findings(*findings, misread), landing, fixed_by) +def result(id_: int, r: int, s: int, c: int | None, lines: int = 10, rounds: int = 1, findings: tuple[int, int] | None = (0, 0), merged: str = "2026-10-13T10:00:00Z", shipped_with: tuple[int, ...] = (), levels: dict[str, int] | None = None, landing: Landing = "merge", misread: int | None = None, merge: str = "aaaaaaa", fixed_by: tuple[str, ...] = (), named: NamedCode | None = None) -> Result: + return Result(item(id_, {"R": r, "S": s} | ({"C": c} if c else {}) | (levels or {})), merge, merged, shipped_with, lines, 1, rounds, None if findings is None else Findings(*findings, misread), landing, fixed_by, named) class ResultsOf(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 = results_of(BranchChunk("before", "tip", "abc1234", "merge", "2026-10-13T10:00:00Z", tuple(titles), (item(4, {"R": 2}), item(5, {"R": 3})), ("def5678",)), numstat) - self.assertEqual(found[0], Result(item(4, {"R": 2}), "abc1234", "2026-10-13T10:00:00Z", (5,), 5, 3, 1, Findings(1, 6, None), "merge", ("def5678",))) + found = results_of(BranchChunk("before", "tip", "abc1234", "merge", "2026-10-13T10:00:00Z", tuple(titles), (item(4, {"R": 2}), item(5, {"R": 3})), ("def5678",)), numstat, {}, {}) + self.assertEqual(found[0], Result(item(4, {"R": 2}), "abc1234", "2026-10-13T10:00:00Z", (5,), 5, 3, 1, Findings(1, 6, None), "merge", ("def5678",), None)) self.assertEqual(found[1].shipped_with, (4,)) def test_measures_no_chunk_that_changed_only_the_plan(self): - self.assertEqual(results_of(BranchChunk("before", "tip", "abc1234", "merge", "2026-10-13T10:00:00Z", (), (item(4, {"R": 2}),), ()), "0\t5\ttodo.md\n"), []) + self.assertEqual(results_of(BranchChunk("before", "tip", "abc1234", "merge", "2026-10-13T10:00:00Z", (), (item(4, {"R": 2}),), ()), "0\t5\ttodo.md\n", {}, {}), []) + + def test_counts_the_files_an_item_names_in_its_tagline_or_detail_and_their_lines_before_the_chunk(self): + named_in_tagline = Item(6, (0, 1, 0), "", "**Change `c.py`.**", {"R": 1}, (("1", None),), ()) + chunk = BranchChunk("before", "tip", "abc1234", "merge", "2026-10-13T10:00:00Z", (), (item(4, {"R": 2}), item(5, {"R": 3}), named_in_tagline), ()) + tree = {"src/x.py": 3, "src/y.py": 2, "b.py": 4, "c.py": 9, "logo.png": 0} + found = results_of(chunk, "1\t0\ta.py\n", {4: "Change `src`, `src/x.py`, `b.py` and `gone.py`.", 5: "Nothing named."}, tree) + self.assertEqual([result.named for result in found], [NamedCode(3, 9), None, NamedCode(1, 9)]) + + def test_reads_each_files_lines_from_a_numstat_against_the_empty_tree_a_binary_file_holding_none(self): + self.assertEqual(file_lines("3\t0\ta.py\0-\t-\tlogo.png\x000\t0\tempty.txt\x002\t0\tsrc/åäö.py\0"), {"a.py": 3, "logo.png": 0, "empty.txt": 0, "src/åäö.py": 2}) class Nearest(unittest.TestCase): @@ -106,6 +116,10 @@ class Render(unittest.TestCase): self.assertEqual(render(result(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 🟡, 0 later fixes; merged 2026-10-13T10:00:00Z in aaaaaaa. **Item 4.**") self.assertIn("1 round past each pass's first, 0 🔴, 0 🟡, 0 later fixes; merged 2026-10-13T10:00:00Z in aaaaaaa, with item 5. ", render(result(4, 2, 3, 4, rounds=1, shipped_with=(5,)))) + def test_gives_the_size_of_the_code_the_item_names_after_what_its_chunk_measured(self): + self.assertIn("- Item 4, R 2, S 3, C 4: 10 lines in 1 file, 1 round past each pass's first, 0 🔴, 0 🟡, 0 later fixes, and the 2 files it names held 40 lines before; merged ", render(result(4, 2, 3, 4, named=NamedCode(2, 40)))) + self.assertIn("0 later fixes, and the 1 file it names held 1 line before; merged ", render(result(4, 2, 3, None, named=NamedCode(1, 1)))) + def test_counts_the_later_fixes_of_the_chunk_that_shipped_it(self): self.assertIn("0 🔴, 0 🟡, 1 later fix; merged", render(result(4, 2, 3, None, fixed_by=("bbbbbbb",)))) self.assertIn("0 🔴, 0 🟡, 2 later fixes; merged", render(result(4, 2, 3, None, fixed_by=("bbbbbbb", "ccccccc")))) @@ -311,6 +325,27 @@ class ScoreOutcomesTool(unittest.TestCase): 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_gives_the_lines_of_the_files_an_items_detail_names_as_its_chunk_found_them(self): + self.commit("Detail it", {"a.py": "1\n2\n", "src/åäö.py": "1\n2\n3\n", "todo.md": todo(FIRST, SECOND) + "\n## Details\n\n### 4. Do it.\n\nChange `a.py` and `src`.\n"}) + self.git("switch", "-q", "-c", "chunk") + self.commit("Do it", {"a.py": "1\n2\n3\n", "todo.md": todo(SECOND)}) + 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.assertIn("- Item 4, R 2, S 3, C 10: 1 line in 1 file, 0 rounds past each pass's first, findings unknown, 0 later fixes, and the 2 files it names held 5 lines before; merged ", ran.stdout) + + def test_says_on_stderr_when_a_chunks_details_cannot_be_read_and_sizes_its_items_by_their_taglines(self): + self.commit("Break the details", {"todo.md": todo(FIRST, SECOND) + "\n## Details\n\nloose text\n\n### 4. Do it.\n\nChange `a.py`.\n", "a.py": "1\n"}) + self.git("switch", "-q", "-c", "chunk") + self.commit("Do it", {"a.py": "1\n2\n", "todo.md": todo(SECOND)}) + 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.assertIn("cannot be read for its details, so its items are sized by their taglines alone: ## Details holds text before its first ### . heading", ran.stderr) + self.assertIn("- Item 4, R 2, S 3, C 10: 1 line in 1 file, ", ran.stdout) + 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) diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 02888ae5..b0891cf0 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -1220,3 +1220,20 @@ Read most (opens and searches): - `README.md` 3 - `bin/larv_review/history_commands.py` 3 - `bin/loop_claude/cycle/run.py` 3 + +## Reading cost, chunk b4cd6ca6988d, finished 2026-11-08T22:04:45Z + +84028 new input tokens before the first commit. + +Read most (opens and searches): + +- `todo.md` 8 +- `bin/rule_hook/test_rule_hook.py` 6 +- `bin/judge_replay/test_judge_replay.py` 5 +- `bin/loop_claude/test_loop_claude.py` 5 +- `bin/machine_load/test_machine_load.py` 3 +- `bin/subagent_rung/test_subagent_rung.py` 2 +- `bin/test_settings_filter.py` 2 +- `bin/test_statusline.py` 2 +- `AGENTS.md` 1 +- `CHANGELOG.md` 1 diff --git a/todo.md b/todo.md index d2c8b361..de28839f 100644 --- a/todo.md +++ b/todo.md @@ -6,14 +6,14 @@ `Bar = 0.1` -`Next ID = 277` +`Next ID = 278` ## Items | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| +| 277 | 0.7.0 | | question | **Map the size of the code an item names onto S, on a scale the human picks, and have `score-outcomes` print that S for the item being scored and for each finished item it lists.** | 3 | 2 | 2 | 5 | 4 | 1.1 by 4, 1.4 by 3 | 2.4 | | 1 | 0.7.0 | | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 | -| 113 | 0.7.0 | | | **Compute an item's S from the code it names, where it names any, and show it beside the finished items `score-outcomes` lists.** | 3 | 2 | 2 | 5 | 4 | 1.1 by 5, 1.4 by 5 | 3.4 | | 263 | 0.7.0 | | | **Have the judge reject an interrupt that re-asks what the human answered earlier in the chunk, unless the ask quotes what that answer left open.** | 2 | 2 | 3 | 5 | 3 | 1.2 by 6, 1.5 by 2 | 3.2 | | 162 | 0.7.0 | | owner | **Script each step that 0.2.0's chunks repeated by hand and a program can compute, filing one item per step, and file this audit again for the next release.** | 2 | 2 | 1 | 3 | 3 | 1.4 by 4, 1.5 by 4 | 3.1 | | 221 | 0.7.0 | | | **Parse each transcript entry once, where `bin/claude_code/transcript.py` reads it, into a typed value naming its kind, so no consumer works out an entry's kind from a raw `dict`.** | 4 | 1 | 3 | 6 | 6 | code health by 4 | 3.0 | @@ -63,6 +63,14 @@ ## Details +### 277. Map the size of the code an item names onto S, on a scale the human picks, and have `score-outcomes` print that S for the item being scored and for each finished item it lists. + +Item 113 shipped the figure: beside each finished item it lists, `score-outcomes` prints how many tracked files the item's tagline or detail names in backticks, as full paths from the repo root with a folder counting the files it holds, and how many lines they held before its chunk. It maps nothing onto S's 1 to 10 scale, prints nothing for the item being scored, and counts a unit named without its file, such as a function, as nothing. + +Question for the human: which scale maps named lines to S? No published scale maps lines to S, so the threshold is yours (`CLAUDE.md` → "Web research"). One option, from this repo's data: give the S whose finished items' median lines changed sits nearest the named lines. On 2026-11-08 those medians were S 1 → 11, 2 → 36, 3 → 83, 4 → 219, 5 → 370, 6 → 848. A named file's size bounds a change only loosely: item 84 named files holding 2422 lines and changed 227, and item 132 named 385 and changed 2. + +Find units named without their file too, such as a function in backticks, and count the lines of the file that defines each. Once `score-outcomes` prints the S, point `~/.claude/rules/todo-items.md`'s S rule (→ "Score L, E and I against the project's anchors") at it, so a scorer sets S from the figure. + ### 1. Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume. It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost disk loses every unattended run's record. Back it up only to a destination private to me and encrypted at rest: the worker runs with permissions bypassed, so the archived tool results can hold credentials it read. @@ -71,10 +79,6 @@ It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost The README line covers the bench's transcripts in `workflow-bench/logs/` too (goal 3). -### 113. Compute an item's S from the code it names, where it names any, and show it beside the finished items `score-outcomes` lists. - -`score-outcomes` grounds L, E, I and S in finished chunks only. Where an item names files or units, their size bounds what the change can touch. - ### 263. Have the judge reject an interrupt that re-asks what the human answered earlier in the chunk, unless the ask quotes what that answer left open. 43 of the 175 chunks with an interrupt asked two or more times, and hold 123 of the archive's 255 interrupts (2026-11-08). Examples: adf-codec asked 4 times between 19:04 and 20:54 on 2026-11-04, 3 of them on item 167; bender-infra asked 3 times on 2026-10-21 whether to grant principles and stability one more round; fejkdata asked twice in 4 minutes on 2026-10-12 to cut 0.1.0. The judge already reads the transcript (`docs/decisions.md:45`), so it sees the earlier answer. The change touches `bin/loop_claude/cycle/judge.py` `quotes_checked` and `grounded`; make them easier to read, as the seats named them.