Answer stability round 1: 2 🔴, 0 🟡 (0 misread); a fast-forwarded feature starts after the latest earlier chunk of another feature, a merge of the default branch into a feature branch marks no start, and the types hold

This commit is contained in:
2026-11-24 02:48:41 +01:00
parent f025bc65cd
commit 4328a13ad8
4 changed files with 55 additions and 28 deletions
+18 -17
View File
@@ -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):