Merge remote-tracking branch 'origin/main' into item-532
CI / tests (pull_request) Has been cancelled
CI / tests (pull_request) Has been cancelled
# Conflicts: # todo.md
This commit is contained in:
+14
-4
@@ -7,7 +7,7 @@ from transcript_archive.write import archive
|
||||
from agent_cycle.worker import AUTO_COMPACT_WINDOW, COMPACT_WINDOW, run_worker, worker_args
|
||||
from claude_code.output_limits import BASH_CEILING, BASH_CEILING_CHARACTERS
|
||||
from agent_cycle.judge import Brief, judge, Rejected
|
||||
from claude_code.session import delete_session, Session, session_open, transcript_file
|
||||
from claude_code.session import delete_session, discard_empty_transcript, Session, session_open, transcript_file
|
||||
from loop_effects.effects import Effects, say
|
||||
from claude_code.entries import Entry
|
||||
from failure import Failure
|
||||
@@ -15,6 +15,7 @@ from agent_cycle.verdicts import Finished, Interrupt, Judged, QuotedAnswer, Take
|
||||
from agent_cycle.interrupt import interrupt, Talked, WorkerSession
|
||||
from transcript_archive.judge_run import JudgeRun
|
||||
from transcript_archive.read import last_spent
|
||||
from claude_code.reply import Limited
|
||||
from agent_cycle.routing import next_route, step_up, StepUp
|
||||
from transcript_archive import outcomes
|
||||
from model_routing.ladder import ProjectRung, Rung
|
||||
@@ -121,8 +122,7 @@ def step(cycle: Cycle, state: Active) -> Event | Stop:
|
||||
def work(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, stepped: bool) -> WorkerRan | Stop:
|
||||
if isinstance(answered, QuotedAnswer):
|
||||
say(f"\n=== {cycle.prompts.quote_sources} answered: {answered.question} ===\n{answered.answer}", cycle.effects, stdout=True)
|
||||
# worker_start runs inside the lambda: a failed attempt may have opened the session.
|
||||
if stop := retried("worker", lambda: run_worker(cycle.root, worker_start(cycle, answered, stepped), worker_environment(cycle), cycle.project_archive, cycle.project.rung if cycle.project else cycle.route.rung, cycle.effects), cycle.effects):
|
||||
if stop := retried("worker", lambda: started_worker(cycle, answered, stepped), cycle.effects):
|
||||
return stop
|
||||
path = transcript_file(cycle.session)
|
||||
return WorkerRan(path) if path is not None else Stop(1, f"claude left no transcript for session {cycle.session.id}")
|
||||
@@ -137,13 +137,23 @@ def worker_session(cycle: Cycle, transcript_path: str, stepped_from: Rung | None
|
||||
return WorkerSession(cycle.root, cycle.session.id, cycle.route.rung, stepped_from or cycle.route.rung, transcript_path, worker_environment(cycle))
|
||||
|
||||
|
||||
def worker_start(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, stepped: bool) -> list[str]:
|
||||
def started_worker(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, stepped: bool) -> Failure | Limited | None:
|
||||
"""One run of the worker. worker_start runs on each attempt: a failed one may have opened the session, or left it empty."""
|
||||
args = worker_start(cycle, answered, stepped)
|
||||
if isinstance(args, Failure):
|
||||
return args
|
||||
return run_worker(cycle.root, args, worker_environment(cycle), cycle.project_archive, cycle.project.rung if cycle.project else cycle.route.rung, cycle.effects)
|
||||
|
||||
|
||||
def worker_start(cycle: Cycle, answered: QuotedAnswer | TypedAnswer | None, stepped: bool) -> list[str] | Failure:
|
||||
if isinstance(answered, QuotedAnswer):
|
||||
return worker_args(cycle.session, cycle.route.rung, cycle.prompts.answered(answered.question, answered.answer, cycle.route, cycle.project, stepped), resume=True)
|
||||
if isinstance(answered, TypedAnswer):
|
||||
return worker_args(cycle.session, cycle.route.rung, cycle.prompts.typed(answered.question, answered.answer, cycle.route, cycle.project, stepped), resume=True)
|
||||
if session_open(cycle.session):
|
||||
return worker_args(cycle.session, cycle.route.rung, cycle.prompts.resumed(cycle.unfinished_evidence, cycle.route, cycle.project), resume=True)
|
||||
if failure := discard_empty_transcript(cycle.session):
|
||||
return failure
|
||||
return worker_args(cycle.session, cycle.route.rung, cycle.prompts.fresh(cycle.task, cycle.premises, cycle.route, cycle.project, cycle.facts), resume=False)
|
||||
|
||||
|
||||
|
||||
@@ -172,6 +172,43 @@ Worker: {OFF_LADDER}
|
||||
self.assertEqual(workers[1][workers[1].index("-p") + 1], "Resumed: working")
|
||||
self.assertEqual(self.archived_outcomes(), [f"Task: Do it.\n\n2026-09-21T14:13:20Z Verdict: unfinished\n\nEvidence:\n> working\n\nConfig: {CONFIG}\nJudge: judge-model\nWorker: {OFF_LADDER}\n"] * 2)
|
||||
|
||||
def test_a_session_whose_transcript_is_empty_starts_fresh_with_its_session_id(self):
|
||||
path = self.paths.claude_code_transcripts / "-fake" / f"{self.session.id}.jsonl"
|
||||
path.parent.mkdir(parents=True)
|
||||
path.touch()
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("finished")])
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake)).verdict, Finished("working"))
|
||||
worker, = fake.made("stream_claude")
|
||||
self.assertIn("--session-id", worker)
|
||||
self.assertNotIn("--resume", worker)
|
||||
|
||||
def test_a_worker_that_fails_leaving_an_empty_transcript_is_retried_with_a_fresh_session(self):
|
||||
path = self.paths.claude_code_transcripts / "-fake" / f"{self.session.id}.jsonl"
|
||||
|
||||
def fails_leaving_it_empty(args):
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.touch()
|
||||
return Streamed(1)
|
||||
|
||||
fake = FakeEffects(streams=[fails_leaving_it_empty, Worker(self.paths.claude_code_transcripts.parent)], claude=[judged("finished")])
|
||||
with contextlib.redirect_stderr(io.StringIO()) as said:
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake)).verdict, Finished("working"))
|
||||
self.assertIn("retrying the worker in a minute", said.getvalue())
|
||||
self.assertEqual(["--session-id" in worker and "--resume" not in worker for worker in fake.made("stream_claude")], [True, True])
|
||||
|
||||
def test_a_worker_stops_where_it_cannot_remove_the_empty_transcript_of_its_session(self):
|
||||
assert_not_root(self)
|
||||
path = self.paths.claude_code_transcripts / "-fake" / f"{self.session.id}.jsonl"
|
||||
path.parent.mkdir(parents=True)
|
||||
path.touch()
|
||||
path.parent.chmod(0o500)
|
||||
self.addCleanup(path.parent.chmod, 0o700)
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)])
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
stop = run.run_cycle(self.cycle(fake))
|
||||
self.assertEqual(stop, Stop(1, f"the worker failed three times running: could not remove the empty transcript {path}: Permission denied; claude refuses to start the session while that file stands"))
|
||||
self.assertEqual(fake.made("stream_claude"), [])
|
||||
|
||||
def test_a_cycle_stopped_by_a_failure_or_ctrl_c_archives_what_its_session_holds(self):
|
||||
fake = FakeEffects(streams=[Worker(self.paths.claude_code_transcripts.parent)], claude=[ran(code=1)] * 3)
|
||||
self.assertEqual(run.run_cycle(self.cycle(fake)).code, 1)
|
||||
|
||||
@@ -12,7 +12,7 @@ NAMESPACE = uuid.UUID("64fb586b-d926-4bb3-a44c-c903e86d3eec")
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Session:
|
||||
"""Exists while its transcript does."""
|
||||
"""Open while its transcript holds something: claude cannot resume an empty one."""
|
||||
id: uuid.UUID
|
||||
claude_code_transcripts: pathlib.Path
|
||||
name: str
|
||||
@@ -29,7 +29,20 @@ def transcript_file(session: Session) -> str | None:
|
||||
|
||||
|
||||
def session_open(session: Session) -> bool:
|
||||
return transcript_file(session) is not None
|
||||
path = transcript_file(session)
|
||||
return path is not None and os.path.getsize(path) > 0
|
||||
|
||||
|
||||
def discard_empty_transcript(session: Session) -> Failure | None:
|
||||
"""Removes the 0-byte transcript a failed run can leave: claude refuses `--session-id` for an id whose file stands, and cannot `--resume` it."""
|
||||
path = transcript_file(session)
|
||||
if path is None or os.path.getsize(path) > 0:
|
||||
return None
|
||||
try:
|
||||
os.remove(path)
|
||||
except OSError as failure:
|
||||
return Failure(f"could not remove the empty transcript {path}: {failure.strerror or failure}; claude refuses to start the session while that file stands")
|
||||
return None
|
||||
|
||||
|
||||
# <session id>.jsonl, <session id>/subagents/, and from older Claude Code versions <session id>.superseded-*/ and <session id>.orphaned-*.jsonl
|
||||
|
||||
@@ -2,11 +2,13 @@ import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from claude_code import entries, reply, transcript
|
||||
from test_env import assert_not_root
|
||||
from claude_code import entries, reply, session, transcript
|
||||
from failure import Failure
|
||||
|
||||
|
||||
@@ -224,5 +226,38 @@ class ClaudeReply(unittest.TestCase):
|
||||
self.assertEqual(reply.claude_reply(self.claude(FileNotFoundError(2, "No such file or directory")), [], "/r", "p", "claude"), Failure("could not start claude: No such file or directory"))
|
||||
|
||||
|
||||
class EmptyTranscript(unittest.TestCase):
|
||||
def setUp(self):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
self.session = session.session_named("A proj a-driver", pathlib.Path(temp.name))
|
||||
self.path = pathlib.Path(temp.name) / "-home-me-code-log" / f"{self.session.id}.jsonl"
|
||||
self.path.parent.mkdir()
|
||||
|
||||
def test_a_session_is_open_only_where_its_transcript_holds_something(self):
|
||||
self.assertFalse(session.session_open(self.session))
|
||||
self.path.touch()
|
||||
self.assertFalse(session.session_open(self.session))
|
||||
self.path.write_text("{")
|
||||
self.assertTrue(session.session_open(self.session))
|
||||
|
||||
def test_discarding_removes_an_empty_transcript_and_keeps_one_that_holds_something(self):
|
||||
self.path.touch()
|
||||
self.assertIsNone(session.discard_empty_transcript(self.session))
|
||||
self.assertFalse(self.path.exists())
|
||||
self.path.write_text("{")
|
||||
self.assertIsNone(session.discard_empty_transcript(self.session))
|
||||
self.assertEqual(self.path.read_text(), "{")
|
||||
|
||||
def test_discarding_fails_naming_the_file_it_could_not_remove(self):
|
||||
assert_not_root(self)
|
||||
self.path.touch()
|
||||
self.path.parent.chmod(0o500)
|
||||
self.addCleanup(self.path.parent.chmod, 0o700)
|
||||
failure = session.discard_empty_transcript(self.session)
|
||||
self.assertIsInstance(failure, Failure)
|
||||
self.assertEqual(failure.reason, f"could not remove the empty transcript {self.path}: Permission denied; claude refuses to start the session while that file stands")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -46,7 +46,7 @@ class RouteSources(unittest.TestCase):
|
||||
opened = session.session_named("A proj loop-claude", pathlib.Path(root, "projects"))
|
||||
transcript = pathlib.Path(root, "projects", "-fake", f"{opened.id}.jsonl")
|
||||
transcript.parent.mkdir(parents=True)
|
||||
transcript.write_text("")
|
||||
transcript.write_text("{}\n")
|
||||
unread = Failure("no git")
|
||||
fake = FakeEffects(git=[*ON_MAIN, unread, unread, unread, unread])
|
||||
with contextlib.redirect_stderr(io.StringIO()) as stderr:
|
||||
@@ -176,7 +176,7 @@ class ChunkFacts(unittest.TestCase):
|
||||
self.assertEqual((fresh.made("python"), "- A fact." in facts), ([(["/b/chunk-preflight", "--worktree", "--item", "7"], "/r")], True))
|
||||
transcript = pathlib.Path(home, "projects", "-fake", f"{opened.id}.jsonl")
|
||||
transcript.parent.mkdir(parents=True)
|
||||
transcript.write_text("")
|
||||
transcript.write_text("{}\n")
|
||||
resumed = FakeEffects()
|
||||
facts, _ = chunk_start.chunk_start(a_loop(resumed.effects(), session=opened, launcher=self.LAUNCHER))
|
||||
self.assertEqual((resumed.made("python"), facts), ([], ""))
|
||||
|
||||
+10
-6
@@ -95,17 +95,21 @@ 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 <ID>:` took
|
||||
that item out unbuilt, so it didn't ship it. 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
|
||||
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. 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 is passed over where no such chunk comes before it, and where its branch merged the default branch into
|
||||
itself, since its commits then hold the changes of the features that merge brought in. A merge titled
|
||||
`Merge remote-tracking branch '...' into <branch>` is read as that, whatever the branch. The bench goes through the shipped
|
||||
features newest first, until --shipped of them, 5 by default, count. For each:
|
||||
- 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. The bench also passes over three kinds:
|
||||
- one whose branch landed by fast-forward. Its commits keep a commit time each, so the history doesn't say which of them
|
||||
built it;
|
||||
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`.
|
||||
|
||||
@@ -5,6 +5,7 @@ is checked."""
|
||||
import functools
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import typing
|
||||
|
||||
@@ -14,15 +15,18 @@ from branch_chunks.read import cut_with_shipped, unsupported
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import Git
|
||||
from plan.todo_table import Item, tagline_text
|
||||
from branch_chunks.cut import Landing
|
||||
from project_config.main import located
|
||||
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 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.
|
||||
FAST_FORWARDED = "its branch landed by fast-forward, so the history doesn't say which commits built it"
|
||||
# Why a feature that landed by fast-forward is passed over: no earlier chunk says where its commits start, or its branch merged
|
||||
# the default branch into itself, so its commits hold what other features built.
|
||||
NO_START = "its branch landed by fast-forward, and nothing earlier marks where its commits start"
|
||||
MERGED_IN = "its branch landed by fast-forward after merging the default branch into itself, so its commits hold other features' changes"
|
||||
# What git titles a merge of the default branch into a feature branch, other than into main or master, which git leaves out of
|
||||
# the title. A person's merge of a branch into another default branch has the same title; its feature is then passed over.
|
||||
SYNC_MERGE = re.compile(r"Merge (?:remote-tracking )?branch '[^']+' 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.
|
||||
@@ -31,13 +35,14 @@ PLAIN_DIFF = ("--no-color", "--no-ext-diff", "--no-textconv", "--no-renames", "-
|
||||
|
||||
class Shipped(typing.NamedTuple):
|
||||
"""A feature the project shipped: the name the report gives it, such as `item 7`, the tagline of each item its chunk took out
|
||||
of the plan, a paragraph each, the commits its chunk's change runs between, and how the chunk landed."""
|
||||
of the plan, a paragraph each, and the commits its change runs between. before is None where the history doesn't say where
|
||||
the change starts, and passed_over then says why."""
|
||||
|
||||
name: str
|
||||
told: str
|
||||
before: str
|
||||
before: str | None
|
||||
tip: str
|
||||
landing: Landing
|
||||
passed_over: str = ""
|
||||
|
||||
|
||||
class ShippedFeatures(typing.NamedTuple):
|
||||
@@ -62,11 +67,24 @@ def read_shipped(home: pathlib.Path, checkout: str, base: str, git: Git) -> Ship
|
||||
if isinstance(cut, Failure):
|
||||
return cut
|
||||
branch, shipped = cut
|
||||
found = [
|
||||
Shipped(named(items), "\n\n".join(tagline_text(item.tagline) for item in items), chunk.before, chunk.tip, chunk.landing)
|
||||
for chunk, items in zip(branch.chunks, shipped)
|
||||
if items and chunk.before
|
||||
]
|
||||
found: list[Shipped] = []
|
||||
# The oldest chunk first, so each feature knows the commit that ends the chunk before it.
|
||||
marked = None
|
||||
merged_in = False
|
||||
for chunk, items in reversed(list(zip(branch.chunks, shipped))):
|
||||
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, why = chunk.before, ""
|
||||
if chunk.landing == "push":
|
||||
starts, why = (None, NO_START) if marked is None else (None, MERGED_IN) if merged_in else (marked, "")
|
||||
told = "\n\n".join(tagline_text(item.tagline) for item in items)
|
||||
found.append(Shipped(named(items), told, starts, chunk.tip, why))
|
||||
if SYNC_MERGE.fullmatch(branch.commits[chunk.tip].title):
|
||||
merged_in = True
|
||||
elif items or chunk.landing != "push":
|
||||
marked, merged_in = chunk.tip, False
|
||||
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.")
|
||||
return ShippedFeatures(found, [path for path in map(config.tracked, ("plan", *RECORDS)) if path])
|
||||
@@ -89,7 +107,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.landing == "push" else on_disk(f"take {feature.name} out of the trees in {folder}", lambda: without(bench, feature, shipped.records, folder))
|
||||
taken_out = feature.passed_over 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
|
||||
@@ -117,12 +135,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):
|
||||
|
||||
@@ -17,8 +17,8 @@ from task_bench.test_task_bench import BASE_CODE, HEAD_CODE
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import git
|
||||
from task_bench import main
|
||||
from task_bench.shipped_features import MERGED_IN, read_shipped
|
||||
from branch_chunks.read import READ_AT
|
||||
from task_bench.shipped_features import read_shipped
|
||||
|
||||
HEADER = "| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves |\n|---|---|---|---|---|---|---|---|---|---|---|\n"
|
||||
ROWS = {
|
||||
@@ -92,6 +92,35 @@ class ShippedFeaturesCase(BenchOfTasksCase):
|
||||
self.env.pop(name, None)
|
||||
|
||||
|
||||
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 branches off after them."""
|
||||
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.repo / "third_test.go").write_text("test -e third.go\n")
|
||||
self.landed(7, "Add Third", written_then=True)
|
||||
self.plan()
|
||||
self.landed(8, "Finish item 11 in the plan", written_then=True)
|
||||
self.git("checkout", "--quiet", "-B", "item-1")
|
||||
(self.repo / "calc.go").write_text(HEAD_CODE)
|
||||
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, and it landed by fast-forward."""
|
||||
self.git("checkout", "--quiet", "--orphan", "fresh")
|
||||
self.git("rm", "--quiet", "-r", "-f", ".")
|
||||
self.plan(11)
|
||||
(self.repo / "calc_test.go").write_text("exit 0\n")
|
||||
self.landed(1, "Plan an item", written_then=True)
|
||||
(self.repo / "third.go").write_text("package calc\n")
|
||||
self.landed(2, "Add Third", written_then=True)
|
||||
self.plan()
|
||||
self.landed(3, "Finish item 11 in the plan", written_then=True)
|
||||
self.git("branch", "--quiet", "--force", "main", "fresh")
|
||||
|
||||
|
||||
class ShippedFeatureBenchTest(ShippedFeaturesCase):
|
||||
def test_has_haiku_rebuild_each_shipped_feature_from_its_tagline_and_checks_it_with_the_tests_its_change_added(self):
|
||||
report = self.bench()
|
||||
@@ -175,23 +204,22 @@ class ShippedFeatureBenchTest(ShippedFeaturesCase):
|
||||
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 8: its revert doesn't apply at the head.", self.progress.getvalue().splitlines())
|
||||
|
||||
def test_passes_over_a_feature_whose_branch_landed_by_fast_forward(self):
|
||||
# Each commit keeps the time it was written at, so the commit that takes the item out is a chunk of its own.
|
||||
self.git("checkout", "--quiet", "main")
|
||||
self.plan(11)
|
||||
self.landed(6, "Plan an item")
|
||||
(self.repo / "third.go").write_text("package calc\n")
|
||||
(self.repo / "third_test.go").write_text("test -e third.go\n")
|
||||
self.landed(7, "Add Third", written_then=True)
|
||||
self.plan()
|
||||
self.landed(8, "Finish item 11 in the plan", written_then=True)
|
||||
# The bench's base is where the head left the default branch, so the head leaves it after item 11.
|
||||
def test_rebuilds_a_feature_whose_branch_landed_by_fast_forward_from_the_commits_after_the_item_shipped_before_it(self):
|
||||
self.fast_forwarded_item_11()
|
||||
report = self.bench(**{"--shipped": "1"})
|
||||
self.assertNotIsInstance(report, Failure, report)
|
||||
# Nothing is passed over, and the feature has a row at each side.
|
||||
self.assertEqual(report[1], "")
|
||||
self.assertEqual([line[:23] for line in report if line.startswith("| 1: item 11")], ["| 1: item 11 | base | 0", "| 1: item 11 | head | 0"])
|
||||
|
||||
def test_passes_over_a_fast_forwarded_feature_where_no_item_shipped_before_it(self):
|
||||
self.fast_forwarded_item_11_alone()
|
||||
self.git("checkout", "--quiet", "-B", "item-1")
|
||||
(self.repo / "calc.go").write_text(HEAD_CODE)
|
||||
self.commit("Head")
|
||||
report = self.bench(**{"--shipped": "1"})
|
||||
self.assertNotIsInstance(report, Failure, report)
|
||||
self.assertEqual(report[1], "Passed over the shipped feature item 11: its branch landed by fast-forward, so the history doesn't say which commits built it.")
|
||||
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 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")
|
||||
@@ -221,6 +249,41 @@ class ReadShippedTest(ShippedFeaturesCase):
|
||||
])
|
||||
self.assertEqual(shipped.records, ["todo.md", "decisions.md", "score-anchors.md", "docs/comprehension-history.md", "docs/reading-cost.md", "changelog.md"])
|
||||
|
||||
def test_a_fast_forwarded_feature_starts_after_the_chunk_that_shipped_the_item_before_it(self):
|
||||
self.fast_forwarded_item_11()
|
||||
newest = self.read().found[0]
|
||||
self.assertEqual((newest.name, newest.before, newest.tip), ("item 11", self.git("rev-parse", "main~3"), self.git("rev-parse", "main")))
|
||||
|
||||
def test_a_fast_forwarded_feature_with_no_item_shipped_before_it_has_no_start(self):
|
||||
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_passes_over_a_fast_forwarded_feature_whose_branch_merged_the_default_branch_into_itself(self):
|
||||
self.fast_forwarded_item_11_around_a_merge("Merge remote-tracking branch 'origin/main' into item-11")
|
||||
newest = self.read().found[0]
|
||||
self.assertEqual((newest.name, newest.before, newest.passed_over), ("item 11", None, MERGED_IN))
|
||||
|
||||
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)
|
||||
@@ -231,6 +294,14 @@ class ReadShippedTest(ShippedFeaturesCase):
|
||||
self.assertEqual((newest.name, newest.told), ("items 7, 8", "Add `Halve`, which halves a whole number.\n\nMultiply in `Twice`."))
|
||||
self.assertEqual((newest.before, newest.tip), (self.git("rev-parse", "main~3"), self.git("rev-parse", "main")))
|
||||
|
||||
def test_a_feature_that_landed_by_a_rebase_starts_at_its_own_chunk_whatever_was_fast_forwarded_before_it(self):
|
||||
self.git("checkout", "--quiet", "main")
|
||||
self.plan(11)
|
||||
self.landed(6, "Plan an item", written_then=True)
|
||||
self.plan()
|
||||
self.landed(7, "Build it", "Finish item 11 in the plan")
|
||||
self.assertEqual(self.read().found[0].before, self.git("rev-parse", "main~2"))
|
||||
|
||||
def test_an_item_a_commit_title_drops_is_not_shipped(self):
|
||||
self.git("checkout", "--quiet", "main")
|
||||
self.plan(8)
|
||||
|
||||
Reference in New Issue
Block a user