diff --git a/README.md b/README.md index 46dfe067..d08329dd 100644 --- a/README.md +++ b/README.md @@ -228,7 +228,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a - `settings_filter.py` is git's clean filter for `settings.json`: it drops `"model"` and sorts the keys. `.gitattributes` sets the filter `settings` on `settings.json`, and Install's `git config` line makes this script that filter. - `statusline.py` renders Claude Code's status line; `settings.json` → `statusLine` runs it. - `subagent-rung [--plan] ` prints the Agent tool's model and effort for a subagent's task, picked by its L from the project's model on the project's routing ladder, and with `--plan` never below the project's rung; `subagent-rung --help` states the rule. -- `task-bench --image --test []` plants bugs that the tests catch, in the Go and Python files that hold the places the comprehension seats found hardest, has Haiku fix each at the base and at the head, and prints how often the fix passes and what it took. It needs docker and a token from `claude setup-token`; `task-bench --help` says how it plants, runs and checks. It leaves a digest of why runs failed. With `--tasks features` it has Haiku build each feature in the folder the config names as `bench-tasks` instead, from its spec, and checks the build with acceptance tests Haiku never sees. With `--tasks data-sources` it has Haiku add each data source there: a folder that also holds `generate-register`, the seeded script whose made-up register Haiku imports. With `--tasks shipped-features` it has Haiku rebuild features the project shipped: it takes each one's change out of the code, tells Haiku the tagline of the plan item, and checks the build with the tests that change holds. Where a feature's branch landed by fast-forward, its change runs from the commit after the one that took the previous item out of the plan. With `--record-figures`, a bench that finishes appends its figures over every task to the comprehension history. A scoring run starts the bench that way where the project's README documents its `task-bench` command. `task-bench gather` starts a claude on the project's rung, which files a plan item for each place the digest shows to be hard; then gather removes the bench's folder, digest and streams. +- `task-bench --image --test []` plants bugs that the tests catch, in the Go and Python files that hold the places the comprehension seats found hardest, has Haiku fix each at the base and at the head, and prints how often the fix passes and what it took. It needs docker and a token from `claude setup-token`; `task-bench --help` says how it plants, runs and checks. It leaves a digest of why runs failed. With `--tasks features` it has Haiku build each feature in the folder the config names as `bench-tasks` instead, from its spec, and checks the build with acceptance tests Haiku never sees. With `--tasks data-sources` it has Haiku add each data source there: a folder that also holds `generate-register`, the seeded script whose made-up register Haiku imports. With `--tasks shipped-features` it has Haiku rebuild features the project shipped: it takes each one's change out of the code, tells Haiku the tagline of the plan item, and checks the build with the tests that change holds. With `--record-figures`, a bench that finishes appends its figures over every task to the comprehension history. A scoring run starts the bench that way where the project's README documents its `task-bench` command. `task-bench gather` starts a claude on the project's rung, which files a plan item for each place the digest shows to be hard; then gather removes the bench's folder, digest and streams. - `todo-item` reads and changes a project's plan, whatever holds it: `list` prints the items in the plan's order and `show ` one item's row and detail; `add …` files an item under the next free ID, `edit …` sets an item's cells or detail, and `move --release ` sets an item's release; `finish ` removes a finished item and adds the bullet passed with `--changelog` to `CHANGELOG.md`, except for a plan kept in Jira. Each change ranks a markdown plan. `todo-item --help` states the flags. - `touch-predictions record ...` appends what a chunk's items were predicted to touch, under `Touches:` in their details, beside the files and parts its branch touched, to the record the config names as `touch-predictions`; `touch-predictions --help` shows the spelling and how a part is named. `chunk-preflight` reads the same predictions to name the items that may start chunks at once. - `wait-for [] [--timeout ]` waits until a file a background job writes holds a line matching the pattern, and prints it. diff --git a/bin/task_bench/main.py b/bin/task_bench/main.py index 58e2e1f1..8c7eead8 100644 --- a/bin/task_bench/main.py +++ b/bin/task_bench/main.py @@ -83,19 +83,20 @@ such as QZ, and never XK, which is Kosovo's in practice. The table has a row per --tasks shipped-features benches rebuilding features the project shipped, so nobody writes a task. A shipped feature is a chunk on the base's first-parent history that took an item out of `todo.md`. A chunk is a merge commit with what it merged, or the commits a rebase landed together, which share a commit time. A chunk with a commit whose title opens `Drop item :` took -that item out unbuilt, so it didn't ship it. The bench goes through the shipped features newest first, until --shipped of +that item out unbuilt, so it didn't ship it. Commits fast-forwarded onto the branch keep a commit time each, so each is a chunk +of its own, and the chunk that took the item out holds only the feature's last commit. The feature then starts after the latest +earlier chunk that took an item out or landed by a merge or a rebase, leaving out a merge of the default branch into a feature +branch, titled `Merge ... into `. A commit between two features that belongs to neither joins the later one; it counts +only where its tests fail after the revert and pass with the reference patch, as for any feature. A fast-forwarded feature with +no such chunk before it is passed over. The bench goes through the shipped features newest first, until --shipped of them, 5 by default, count. For each: -- it takes the chunk's change out of a copy of each side's tree, as `git apply -R` does. The plan and the project's records stay +- it takes the feature's change out of a copy of each side's tree, as `git apply -R` does. The plan and the project's records stay as the side holds them, since later chunks added to them. The records are the changelog, the comprehension history, the decisions, the reading cost and the score anchors. So Haiku can read there what the changelog says of the feature; - Haiku is told the tagline of the item, or of each item the chunk shipped; - the acceptance tests are the test files the change touched, and its files under a `testdata` folder, each as the head holds it; - the reference patch is the change itself. -With those, a shipped feature counts, and a build passes, as for a feature. Where its branch landed by fast-forward, its -commits keep a commit time each, so the history doesn't mark the feature's start. Its change then runs from the commit after -the one that took the previous item out of the plan, and a commit between two features that belongs to neither joins the later -one; the acceptance check still holds. The bench also passes over three kinds: -- one whose branch landed by fast-forward, with no feature shipped before it to start from; +With those, a shipped feature counts, and a build passes, as for a feature. The bench also passes over two kinds: - one whose change doesn't come out of both trees cleanly, as where a later chunk rewrote its lines; - one whose change touched no test the head still holds. The report says which and why. The table has a row per shipped feature and side, named by its items, as `item 7`. diff --git a/bin/task_bench/shipped_features.py b/bin/task_bench/shipped_features.py index ac94dcbb..a62f9b4b 100644 --- a/bin/task_bench/shipped_features.py +++ b/bin/task_bench/shipped_features.py @@ -5,6 +5,7 @@ is checked.""" import functools import os import pathlib +import re import shutil import typing @@ -19,10 +20,11 @@ from task_bench.runs import of_tests from project_config.settings import RECORDS from task_bench.figures import Side, SIDES -# Why a feature whose chunk landed by fast-forward and has no earlier feature before it is passed over. Each of its commits is a -# chunk of its own to branch_chunks, so the chunk that took the item out holds the branch's last commit alone, and only the commit -# of the feature shipped before it says where the branch starts. -FAST_FORWARDED = "its branch landed by fast-forward, and no feature shipped before it to say which commits built it" +# Why a feature that landed by fast-forward is passed over where no earlier chunk says where its commits start. +FAST_FORWARDED = "its branch landed by fast-forward, and nothing earlier marks where its commits start" +# What git titles a merge of the default branch into a feature branch. Such a merge sits inside the feature's own commits, so it +# doesn't mark where the feature starts. +SYNC_MERGE = re.compile(r"Merge .* into (?!main$|master$)\S+") # The options that keep the checkout's diff config out of a patch. --no-renames writes a renamed file as one file removed and # one added, so `git apply` doesn't have to detect the rename again. @@ -63,18 +65,17 @@ def read_shipped(home: pathlib.Path, checkout: str, base: str, git: Git) -> Ship return cut branch, shipped = cut found: list[Shipped] = [] - # The oldest chunk first, so each feature knows the commit the one before it shipped at. - shipped_at = None + # The oldest chunk first, so each feature knows the commit that ends the chunk before it. + marked = None for chunk, items in reversed(list(zip(branch.chunks, shipped))): - if not items: - continue - if chunk.before: - # A fast-forwarded branch keeps a commit time per commit, so branch_chunks cuts each commit into a chunk of its own, and - # this chunk holds only the commit that took the item out. The feature is every commit since the last item shipped. - starts = shipped_at if chunk.landing == "push" else chunk.before + if items: + # A fast-forwarded feature's commits are a chunk each, and this chunk holds only the last. The earlier ones follow the + # commit that ends the latest earlier chunk of another feature. + starts = marked if chunk.landing == "push" else chunk.before told = "\n\n".join(tagline_text(item.tagline) for item in items) found.append(Shipped(named(items), told, starts, chunk.tip)) - shipped_at = chunk.tip + if (items or chunk.landing != "push") and not SYNC_MERGE.fullmatch(branch.commits[chunk.tip].title): + marked = chunk.tip found.reverse() if not found: return Failure("No chunk on the base's history took an item out of todo.md, so that history holds no shipped feature to rebuild.") @@ -98,7 +99,7 @@ def shipped_tasks(bench: Bench, shipped: ShippedFeatures, count: int) -> Planned break # A feature passed over leaves no folder, so the next one tried takes the same number. folder = bench.folder / "shipped-features" / str(len(tasks) + 1) - taken_out = FAST_FORWARDED if feature.before is None else on_disk(f"take {feature.name} out of the trees in {folder}", lambda: without(bench, feature, shipped.records, folder)) + taken_out = FAST_FORWARDED if feature.before is None else on_disk(f"take {feature.name} out of the trees in {folder}", functools.partial(without, bench, feature, feature.before, shipped.records, folder)) why = taken_out if not isinstance(taken_out, TakenOut) else why_passed_over(bench, taken_out.trees, taken_out.feature) if isinstance(why, Failure): return why @@ -126,12 +127,12 @@ class TakenOut(typing.NamedTuple): feature: Feature -def without(bench: Bench, shipped: Shipped, records: list[str], folder: pathlib.Path) -> TakenOut | str | Failure: - """shipped taken out of a copy of each side's tree, under folder, where its patch and its acceptance tests go too; or why it +def without(bench: Bench, shipped: Shipped, before: str, records: list[str], folder: pathlib.Path) -> TakenOut | str | Failure: + """shipped, as the commits from before to its tip, taken out of a copy of each side's tree, under folder, where its patch and its acceptance tests go too; or why it cannot be, which ends a sentence that opens with its name. A Failure where git fails. Raises OSError where a file cannot be copied.""" - change = (shipped.before, shipped.tip, "--", ".", *(f":(exclude,literal){path}" for path in records)) + change = (before, shipped.tip, "--", ".", *(f":(exclude,literal){path}" for path in records)) # A name that is not UTF-8 is read with U+FFFD in it. The head's tree holds no file of that name, so the file is left out. names = bench.git("diff", "--name-only", "-z", *change, cwd=bench.checkout, errors="replace") if isinstance(names, Failure): diff --git a/bin/task_bench/test_shipped_features.py b/bin/task_bench/test_shipped_features.py index c09e1102..a0fc4d72 100644 --- a/bin/task_bench/test_shipped_features.py +++ b/bin/task_bench/test_shipped_features.py @@ -94,7 +94,7 @@ class ShippedFeaturesCase(BenchOfTasksCase): def fast_forwarded_item_11(self): """Item 11 lands as a fast-forward leaves a branch: a plan commit, the feature and the commit that takes the item out, each - with the time it was written at, so each is a chunk of its own to branch_chunks. The head leaves the default branch after.""" + with the time it was written at, so each is a chunk of its own to branch_chunks. The head branches off after them.""" self.git("checkout", "--quiet", "main") self.plan(11) self.landed(6, "Plan an item", written_then=True) @@ -108,7 +108,7 @@ class ShippedFeaturesCase(BenchOfTasksCase): self.commit("Head") def fast_forwarded_item_11_alone(self): - """Makes the default branch a history of its own, where item 11 is the one item shipped, by fast-forward.""" + """Makes the default branch a history of its own, where item 11 is the one item shipped, and it landed by fast-forward.""" self.git("checkout", "--quiet", "--orphan", "fresh") self.git("rm", "--quiet", "-r", "-f", ".") self.plan(11) @@ -219,7 +219,7 @@ class ShippedFeatureBenchTest(ShippedFeaturesCase): self.commit("Head") report = self.bench(**{"--shipped": "1"}) self.assertEqual(report.reason, "No shipped feature on the base's history counts; the lines above say why.") - self.assertIn("task-bench: passed over the shipped feature item 11: its branch landed by fast-forward, and no feature shipped before it to say which commits built it.", self.progress.getvalue().splitlines()) + self.assertIn("task-bench: passed over the shipped feature item 11: its branch landed by fast-forward, and nothing earlier marks where its commits start.", self.progress.getvalue().splitlines()) def test_fails_before_docker_runs_where_the_history_shipped_no_item(self): self.git("branch", "--quiet", "--force", "main", "main~8") @@ -258,6 +258,31 @@ class ReadShippedTest(ShippedFeaturesCase): self.fast_forwarded_item_11_alone() self.assertEqual([(feature.name, feature.before) for feature in self.read().found], [("item 11", None)]) + def fast_forwarded_item_11_around_a_merge(self, title): + """Item 11's commits, fast-forwarded, with a merge of a commit from a side branch between them under title. Returns the merge's hash.""" + self.git("checkout", "--quiet", "main") + self.git("branch", "--quiet", "side") + self.git("checkout", "--quiet", "side") + (self.repo / "other.go").write_text("package calc\n") + self.landed(5, "Other work") + self.git("checkout", "--quiet", "main") + self.plan(11) + self.landed(6, "Plan an item", written_then=True) + (self.repo / "third.go").write_text("package calc\n") + self.landed(7, "Add Third", written_then=True) + self.git("merge", "--quiet", "--no-ff", "--message", title, "side") + self.plan() + self.landed(9, "Finish item 11 in the plan", written_then=True) + return self.git("rev-parse", "main~1") + + def test_a_fast_forwarded_feature_starts_before_a_merge_of_the_default_branch_into_its_branch(self): + self.fast_forwarded_item_11_around_a_merge("Merge remote-tracking branch 'origin/main' into item-11") + self.assertEqual(self.read().found[0].before, self.git("rev-parse", "main~4")) + + def test_a_fast_forwarded_feature_starts_after_a_chunk_that_landed_by_a_merge_and_shipped_no_item(self): + merge = self.fast_forwarded_item_11_around_a_merge("Merge pull request 'Release review' (#7) from release-review into main") + self.assertEqual(self.read().found[0].before, merge) + def test_a_chunk_that_shipped_two_items_is_one_feature_told_by_both_taglines(self): self.git("checkout", "--quiet", "main") self.plan(7, 8)