diff --git a/CHANGELOG.md b/CHANGELOG.md index c1520fb4..795237b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `score-outcomes` now gives, beside each finished item's S, the size of the code the item names: the files and folders its tagline or detail names in backticks, counted in files and lines as they stood before its chunk. +- `score-outcomes` now shows, after each finished item's scores, 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/release_plan/named_code.py b/bin/release_plan/named_code.py index 18252ea8..43db6aa8 100644 --- a/bin/release_plan/named_code.py +++ b/bin/release_plan/named_code.py @@ -9,7 +9,7 @@ def named_paths(text: str, tracked: list[str]) -> list[tuple[str, int]]: def named_files(text: str, tracked: list[str]) -> list[str]: - """Each tracked file that a backticked span in text names, itself or by a folder holding it, once, in tracked's order.""" + """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)] diff --git a/bin/score_outcomes/main.py b/bin/score_outcomes/main.py index 56d7347a..56a2369b 100644 --- a/bin/score_outcomes/main.py +++ b/bin/score_outcomes/main.py @@ -46,9 +46,12 @@ L, E and I, as rank_todo.py does, and lists the 5 finished items whose guesses s 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. Where the item's tagline or detail names -tracked files or folders, each in backticks such as `bin/rank_todo.py`, the line gives their size -before the chunk beside the item's S: how many files and their lines, which bound what the change -could touch. +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 item's scores: how many files they +held before the chunk, and how many lines. 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 @@ -184,13 +187,15 @@ def read_results(default: str) -> list[Result] | Failure: 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 - # Only the files the items name, since counting every file's lines for every chunk doubles the run. + # 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", empty_tree.strip(), chunk.before, "--", *named) if named else "" + 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)) diff --git a/bin/score_outcomes/results.py b/bin/score_outcomes/results.py index 16a1c626..9db23146 100644 --- a/bin/score_outcomes/results.py +++ b/bin/score_outcomes/results.py @@ -12,10 +12,10 @@ from release_plan.named_code import named_files ENOUGH = 10 -# An item's size in lines, not an S: no published scale maps lines to S, and the report's S medians already set the S guessed beside the lines changed. +# 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: - """The tracked files an item's tagline and detail name, folders by the files they hold, as the chunk that shipped it found them: how many, and their lines, a binary file holding none. They bound what the chunk's change could touch.""" + """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 @@ -37,8 +37,6 @@ class Result: named: NamedCode | None - - # A measure's name and how to read it from a Result, None where the chunk did not record it. Measure = tuple[str, typing.Callable[[Result], int | None]] # The scores whose median result the report gives at each guessed value. @@ -63,13 +61,13 @@ def results_of(chunk: BranchChunk, numstat: str, details: dict[int, str], tree: def item_text(item: Item, details: dict[int, str]) -> str: - """The tagline and detail, where the item names the files it changes.""" + """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` against the empty tree, which counts every line as added; git counts a binary file's lines as "-", so it holds none.""" - rows = [row.split("\t", 2) for row in numstat.splitlines()] + """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} diff --git a/bin/score_outcomes/test_score_outcomes.py b/bin/score_outcomes/test_score_outcomes.py index 7a8e0ecb..c5f1e975 100644 --- a/bin/score_outcomes/test_score_outcomes.py +++ b/bin/score_outcomes/test_score_outcomes.py @@ -54,7 +54,7 @@ class ResultsOf(unittest.TestCase): 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\n-\t-\tlogo.png\n0\t0\tempty.txt\n"), {"a.py": 3, "logo.png": 0, "empty.txt": 0}) + 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): @@ -326,14 +326,25 @@ class ScoreOutcomesTool(unittest.TestCase): 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", "todo.md": todo(FIRST, SECOND) + "\n## Details\n\n### 4. Do it.\n\nChange `a.py`.\n"}) + 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, naming code of 2 lines in 1 file: 1 line in 1 file, ", ran.stdout) + self.assertIn("- Item 4, R 2, S 3, C 10, naming code of 5 lines in 2 files: 1 line in 1 file, ", 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()