Answer stability round 1: 1 🔴, 1 🟡 (0 misread); stamp deploy-release's trace in UTC, end a stopped run's trace, drop redundant assertions, and the product-owner and prose fixes

This commit is contained in:
2026-11-27 14:14:28 +01:00
parent 3eb57d44c6
commit 74066a3134
13 changed files with 107 additions and 77 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
- loop-claude starts a chunk on a fresh session where its session's transcript is empty, in place of resuming a session claude cannot find, which failed three times and waited for the human.
- larv-review's prose pass takes a second round after a fix that rewrites a claim a command or a source file can check, such as generated output, a number or a licence term.
- `deploy-release --cut-patch <commits>` cuts the newest tag's next patch release, such as 0.15.2 after v0.15.1, holding only the commits named, for a fix that must ship before main's other unreleased work. It runs `ci.sh` on the patch, tags and pushes it, merges the tag back into main through a pull request, and moves `~/.claude` to it. Plain `--cut` now refuses a patch release, and a release review counts only for the release its title names: `Release review of 0.16.0` reviews 0.16.0 and no other.
- `deploy-release` keeps each run's steps, with their times, in a file under `~/.local/state/deploy-release/`, and stops a patch cut's `ci.sh` after 30 minutes, naming the log that holds its output.
- `deploy-release --cut` and `--cut-patch` keep each step, with its time in UTC, in a file under `~/.local/state/deploy-release/`, and `--cut-patch` stops `ci.sh` after 30 minutes, naming the log that holds its output.
- `task-bench` plants bugs in Rust files too, from the mutants cargo-mutants catches, and tells Haiku the panic message `cargo test` prints.
- `task-bench --tasks shipped-features` benches rebuilding features the project shipped: it takes each one's change out of the code, tells Haiku the tagline of its plan item, and checks the build with the tests that change holds. `--shipped <n>` sets how many it takes, and a feature whose branch landed by fast-forward starts after the latest earlier chunk that shipped an item or landed by a merge or a rebase, and is passed over where none comes before it or its branch merged the default branch into itself.
- `task-bench` plants a Python mutant in a file whose lines end in CRLF, which it could not re-apply before, and a Go mutant there keeps applying.
+2 -2
View File
@@ -196,7 +196,7 @@ Once the next release holds no item in `todo.md` and its release review has land
bin/deploy-release --cut
```
It renames `## Unreleased` in `CHANGELOG.md` to the version and merges that through a pull request, since nobody can push to `main`. Then it tags the merged commit `v<version>`, pushes the tag, and moves this machine's `~/.claude` to it. Where a step fails it stops with the reason, and a rerun continues where it stopped. A cut keeps each step it finished, with its time, in a file of its own under `~/.local/state/deploy-release/`. `deploy-release --help` lists the steps. Each other machine takes the release with Update.
It renames `## Unreleased` in `CHANGELOG.md` to the version and merges that through a pull request, since nobody can push to `main`. Then it tags the merged commit `v<version>`, pushes the tag, and moves this machine's `~/.claude` to it. Where a step fails it stops with the reason, and a rerun continues where it stopped. A cut keeps each step it finished, with its time in UTC, in a file of its own under `~/.local/state/deploy-release/`. `deploy-release --help` lists the steps. Each other machine takes the release with Update.
A fix that must ship before `main`'s other unreleased work goes out as a patch release, such as 0.15.2 after v0.15.1. File its item under that release, merge its chunk, then cut it at once with the commits the chunk merged, as a range or one commit. A range leaves out its first commit, as git's `..` does, so start it at the commit before the chunk's first:
@@ -243,7 +243,7 @@ Install puts only `loop-claude` on `PATH`; call the others by their path, such a
### Packages under `bin/`
`bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests. Beside the packages, `bin/`'s root holds only the launchers, the tools of one file with their tests, `test_env.py`, `failure.py` and `setup.cfg`. `failure.py`'s `Failure`, which modules across `bin/` return for a failed step, belongs to no single package. `agent_cycle/`, `atlassian/`, `branch_chunks/`, `chunk_driver/`, `claude_code/`, `command_lines/`, `forge/`, `git_cli/`, `loop_effects/`, `loop_state/`, `machine_load/`, `model_routing/`, `notifier/`, `plan/`, `plan_store/`, `record_store/`, `release_plan/`, `review_rules/`, `rung_replay/`, `text_files/` and `transcript_archive/` serve more than one tool. No package imports one that imports it back, and a package's `doubles.py` holds the test doubles that other packages' tests use, so no module imports a `test_*` module of another package; `repo_checks/test_package_cycles.py` checks both. No Python file of the repo, `workflow-bench/`'s included, uses `mock.patch`, which `repo_checks/test_no_patched_globals.py` checks. The packages below are grouped by what they are for, in alphabetical order within a group.
`bin/` is the import root: each launcher puts it on `sys.path`, so a module imports another by its path under `bin/`, such as `from claude_code.entries import parse_entry`. Each tool's package holds its tests. Beside the packages, `bin/`'s root holds only the launchers, the tools of one file with their tests, `test_env.py`, `failure.py` and `setup.cfg`. `failure.py`'s `Failure`, which modules across `bin/` return for a failed step, belongs to no single package. `agent_cycle/`, `atlassian/`, `branch_chunks/`, `chunk_driver/`, `claude_code/`, `command_lines/`, `forge/`, `git_cli/`, `loop_effects/`, `loop_state/`, `machine_load/`, `model_routing/`, `notifier/`, `plan/`, `plan_store/`, `record_store/`, `release_plan/`, `review_rules/`, `rung_replay/`, `text_files/` and `transcript_archive/` serve more than one tool. No package imports one that imports it back, and a package's `doubles.py` holds the test doubles that other packages' tests use, so no module imports a `test_*` module of another package; `repo_checks/test_package_cycles.py` checks both. No Python file of the repo, `workflow-bench/`'s included, uses `mock.patch`, which `repo_checks/test_no_patched_globals.py` checks. Within each group below, the entries are in alphabetical order.
#### Driving chunks
+8 -7
View File
@@ -28,13 +28,14 @@ and prints that the release reviews and the cuts are the human's to call. It pri
that todo.md has named at that cut or since, less a release its ## Renamed section marks renamed.
Where nothing is cut, it is the earliest release todo.md has ever named, less those renamed, so a
release whose items are all done still reads as next.
Where the next release holds no item, it says so, naming it where todo.md named it since the cut:
to be planned first where no change is unreleased (the ## Unreleased entries, or else the
commits since the cut), else its release review due, and finished and ready to cut once that
review has landed. The review has landed once a commit titled `Release review of <release>`,
naming exactly the next release, is on the default branch after the newest v* tag, or anywhere
on a branch with no tag. A review of any other release doesn't count. Where todo.md named no
next release, a review of any release after the last cut counts.
Where the next release holds no item, it says so, and names the release where todo.md named it
since the cut. Where no change is unreleased (the ## Unreleased entries, or else the commits
since the cut), that release is to be planned first. Otherwise its release review is due, and
once the review has landed the release is finished and ready to cut. The review has landed
once a commit titled `Release review of <release>`, where <release> is exactly the next
release, is on the default branch after the newest v* tag, or anywhere on a branch with no
tag. The one exception: where todo.md named no next release since the cut, such a commit
counts whichever release it names.
Where todo.md files items under x.y.z or earlier, someone cut a release that still held them:
they count as the next release, the earliest after x.y.z that todo.md names or has named
since the cut, and a line says to move them there. Where there is no such release, it says todo.md files items under a release
+1 -1
View File
@@ -25,7 +25,7 @@ Remove = typing.Callable[[str], Failure | None]
def ci_runner(log: pathlib.Path, seconds: float, say: Say, container: str, remove: Remove, grace: float = GRACE_SECONDS) -> Ci:
"""Runs ci.sh in a worktree with its output in log, as it comes, and its test container named container. A Failure where it can't start, where log can't be written, or where it still runs after seconds, which stops it, each process it started and that container."""
"""Runs ci.sh in a worktree with its output in log, as it comes, and its test container named container. A Failure where it can't start, where log can't be written, or where it still runs after seconds. In that last case the runner stops ci.sh, each process ci.sh started, and that container."""
def run(worktree: pathlib.Path) -> CiRan | Failure:
say(f"ci.sh's output goes to {log}; it is stopped where it still runs after {lasting(seconds)}")
try:
+6 -6
View File
@@ -17,7 +17,7 @@ from failure import Failure
from plan_store.todo_md import FilePlan
from record_store.stores import FileStore
from forge.commands import forge_of, runner
from plan.release import newest_tag, Release, tagged, UNRELEASED_HEADING, version
from plan.release import newest_tag, Release, REVIEW_TITLE, tagged, UNRELEASED_HEADING, version
from forge import pulls
from deploy_release import release_pull
from deploy_release.trace import Say
@@ -54,7 +54,7 @@ def cut(clone: str, checkout: str, sleep: typing.Callable[[float], None], say: S
if isinstance(patched := patch_refusal(clone, ref, ready.release), Failure):
return patched
if not ready.reviewed:
return Failure(f"the release review of {named} hasn't landed")
return Failure(f"the release review of {named} hasn't landed: {ref} holds no commit titled `{REVIEW_TITLE}{named}` after the newest tag. `chunk-preflight --help` says which commit counts.")
title, tag, branch = f"Cut release {named}", f"v{named}", f"release-{named}"
merged = commit_titled(title, ref, clone)
if merged is None:
@@ -242,22 +242,22 @@ def push_cut_commit(clone: str, ref: str, branch: str, named: str, title: str, r
def renamed(changelog: str | None) -> str | Failure:
text, count = UNRELEASED_HEADING.subn(f"## {named}", changelog or "", count=1)
return text if count else Failure(f"CHANGELOG.md on {ref} has no ## Unreleased section to rename")
if isinstance(written := rewritten(worktree / "CHANGELOG.md", f"rename ## Unreleased to ## {named} in the cut's worktree, so nothing is pushed", renamed), Failure):
if isinstance(written := rewritten(worktree / "CHANGELOG.md", f"rename ## Unreleased to ## {named} in the cut's worktree", "Nothing is pushed.", renamed), Failure):
return written
if isinstance(committed := git("commit", "--quiet", "-am", title, cwd=str(worktree)), Failure):
return committed
return push_branch(worktree, branch, replacing)
def rewritten(file: pathlib.Path, doing: str, rewrite: typing.Callable[[str | None], str | Failure]) -> Failure | None:
"""Replace file's text with what rewrite makes of it, or of None where there is no such file. A Failure where rewrite gives one, which leaves the file, or where the file can't be read or written: that one says doing, the step that stopped, and names the file."""
def rewritten(file: pathlib.Path, doing: str, outcome: str, rewrite: typing.Callable[[str | None], str | Failure]) -> Failure | None:
"""Replace file's text with what rewrite makes of it, or of None where there is no such file. Where rewrite gives a Failure, return it and leave the file. Where the file can't be read or written, the Failure names doing, the step that stopped, then the file, and ends with outcome, a sentence on where that leaves the run."""
try:
text = rewrite(file.read_text(encoding="utf-8") if file.exists() else None)
if isinstance(text, Failure):
return text
file.write_text(text, encoding="utf-8")
except (OSError, UnicodeError) as failure:
return Failure(f"could not {doing}: {failure}" + ("" if str(file) in str(failure) else f" ({file})"))
return Failure(f"could not {doing}: {failure}" + ("" if str(file) in str(failure) else f" ({file})") + f". {outcome}")
return None
+15 -10
View File
@@ -33,8 +33,9 @@ with --cut-patch.
deletes the branch on origin, then moves <checkout> to the tag as above. A failed delete only warns.
It says on stderr as each step finishes, and ends stdout, after the changelog, with the line
`Done: v<version> is cut and pushed, and <checkout> is on it.`
It keeps each of those lines, with its time, in a file of the run's own under $XDG_STATE_HOME/deploy-release
(default ~/.local/state/deploy-release), and so does --cut-patch.
It keeps each of those lines, with its time in UTC, in the run's trace: a file of its own under
$XDG_STATE_HOME/deploy-release (default ~/.local/state/deploy-release), named by when the run began. --cut-patch does too.
Where Ctrl-C or an unexpected fault ends the run, the trace ends with a line that starts `stopped:`.
Where a step fails it stops, exit 1, with git's or the forge's reason, and leaves the pull request
and the branch as they are. A rerun continues: it takes the branch's open pull request and a cut
commit already merged, and drops a cut tag an earlier run made but never pushed. Once the tag is pushed, the release is cut: where only the
@@ -53,8 +54,8 @@ doesn't hold, and on a GitHub origin, whose rebase merge would drop the tag from
2. In a worktree of its own at the tag, it applies each commit's changes, except to CHANGELOG.md, todo.md,
docs/comprehension-history.md and docs/reading-cost.md, heads CHANGELOG.md with the release's section, and commits that
titled `Cut release <version>`. Where a commit doesn't apply, it stops, names it, and says how to cut the patch by hand.
3. It runs ci.sh on that commit, with its output in a file beside the run's trace, which it names on stderr. It stops
where ci.sh fails or still runs after 30 minutes, before anything is tagged.
3. It runs ci.sh on that commit and names on stderr the file, beside the run's trace, that takes ci.sh's output. It
stops where ci.sh fails or still runs after 30 minutes, before anything is tagged.
4. It tags the commit v<version>, annotated `Cut release <version>`, and pushes only the tag.
5. On a fresh origin/main it merges the tag keeping main's files, moves the release's entries from ## Unreleased to a
## <version> section below it, commits that titled `Merge release <version> into main`, and lands it through the branch
@@ -63,7 +64,6 @@ doesn't hold, and on a GitHub origin, whose rebase merge would drop the tag from
A rerun takes a tag origin holds already, once it checks the tag lists the same changelog entries, and the merge-back's open
pull request. Once the merge-back has merged, the release is cut: where only the move stopped, run a bare deploy-release.
"""
import datetime
import os
import pathlib
import shlex
@@ -96,17 +96,22 @@ def main(argv: list[str]) -> int:
return 1
print(moved)
return 0
clone, now = os.getcwd(), datetime.datetime.now
clone, now = os.getcwd(), time.time
folder, name = trace.trace_folder(os.environ, pathlib.Path.home()), trace.run_name(now(), os.getpid())
begun = trace.started(folder, name, f"deploy-release {shlex.join([*argv[:2 if patching else 1], checkout])} in {clone}", now)
if isinstance(begun, Failure):
print(f"deploy-release: warning: {begun.reason}", file=sys.stderr)
file = None if isinstance(begun, Failure) else begun
say = trace.saying(file, now, sys.stderr)
if commits is not None:
moved = cut_patch(clone, checkout, commits, time.sleep, say, ci_runner(folder / f"{name}-ci.log", CI_SECONDS, say, f"deploy-release-ci-{name}", removed_container))
else:
moved = cut(clone, checkout, time.sleep, say)
try:
if commits is not None:
moved = cut_patch(clone, checkout, commits, time.sleep, say, ci_runner(folder / f"{name}-ci.log", CI_SECONDS, say, f"deploy-release-ci-{name}", removed_container))
else:
moved = cut(clone, checkout, time.sleep, say)
except BaseException as stopped:
# Ctrl-C or a fault nobody foresaw: its traceback reaches only the terminal, so the trace says the run ended here.
trace.kept(file, f"stopped: {stopped!r}", now, sys.stderr)
raise
if isinstance(moved, Failure):
say(moved.reason)
return 1
+11 -11
View File
@@ -142,7 +142,7 @@ def changelog_entries(clone: str, ref: str, commits: list[str]) -> list[str] | F
if isinstance(changelog, Failure):
return changelog
unreleased = section(changelog, UNRELEASED_TITLE)
# The merge-back finds the heading with unreleased_start, after the tag is pushed, so that is asked here too.
# The merge-back finds the heading with unreleased_start only after the tag is pushed, so check it here first.
if unreleased is None or unreleased_start(changelog.split("\n")) is None:
return Failure(f"CHANGELOG.md on {ref} has no ## Unreleased section, which the patch's entries come from: add it on {ref}")
entries = [line for line in unreleased if line in added]
@@ -170,7 +170,7 @@ def tag_patch(clone: str, patch: Patch, say: Say, ci: Ci) -> Failure | None:
if isinstance(applied := apply_commit(clone, worktree, commit, patch), Failure):
return applied
head = lambda changelog: headed("# Changelog\n" if changelog is None else changelog, patch.entries, patch.named)
if isinstance(written := rewritten(worktree / "CHANGELOG.md", f"head CHANGELOG.md with ## {patch.named} in the patch's worktree, so nothing is tagged", head), Failure):
if isinstance(written := rewritten(worktree / "CHANGELOG.md", f"head CHANGELOG.md with ## {patch.named} in the patch's worktree", "Nothing is tagged.", head), Failure):
return written
if isinstance(committed := git("commit", "--quiet", "--all", "--message", title, cwd=str(worktree)), Failure):
return committed
@@ -205,7 +205,7 @@ def apply_commit(clone: str, worktree: pathlib.Path, commit: str, patch: Patch)
if not diff:
return None
patch_file = worktree.parent / "commit.patch"
if isinstance(written := rewritten(patch_file, f"write {commit[:12]}'s changes to a file to apply, so nothing is tagged", lambda _: diff), Failure):
if isinstance(written := rewritten(patch_file, f"write {commit[:12]}'s changes to a file to apply", "Nothing is tagged.", lambda _: diff), Failure):
return written
if isinstance(applied := git("apply", "--3way", "--index", str(patch_file), cwd=str(worktree)), Failure):
subject = git("log", "-1", "--format=%s", commit, cwd=clone)
@@ -224,7 +224,7 @@ def run_ci(worktree: pathlib.Path, ref: str, ci: Ci) -> Failure | None:
return Failure("the patch holds no ci.sh to test it with")
ran = ci(worktree)
if isinstance(ran, Failure):
return Failure(f"{ran.reason}, so nothing is tagged. Rerun once that is fixed.")
return Failure(f"{ran.reason}. Nothing is tagged: rerun once ci.sh passes.")
if ran.code == 0:
return None
tail = "\n".join(ran.output.strip().splitlines()[-30:])
@@ -239,23 +239,23 @@ def push_merge_back(clone: str, patch: Patch, replacing: str | None) -> Failure
if isinstance(merged := git("merge", "--quiet", "--no-ff", "--no-commit", "--strategy", "ours", f"v{patch.named}", cwd=str(worktree)), Failure):
return merged
# The tag is pushed by now, so each stop here says that a rerun with the same commits takes it and builds only this merge-back again.
rerun = f"v{patch.named} is pushed, and a rerun with the same commits merges it back"
rerun = f"v{patch.named} is pushed, and a rerun with the same commits merges it back."
def move(changelog: str | None) -> str | Failure:
moved = moved_entries(changelog or "", patch.entries, patch.named)
return Failure(f"{moved.reason}, on {patch.ref}: add the heading there; {rerun}") if isinstance(moved, Failure) else moved
if isinstance(written := rewritten(worktree / "CHANGELOG.md", f"move the entries of {patch.named} out of ## Unreleased in the merge-back's worktree; {rerun}", move), Failure):
moved = moved_entries(changelog or "", patch.entries, patch.named, patch.ref)
return Failure(f"{moved.reason}: add the heading there. {rerun}") if isinstance(moved, Failure) else moved
if isinstance(written := rewritten(worktree / "CHANGELOG.md", f"move the entries of {patch.named} out of ## Unreleased in the merge-back's worktree", rerun, move), Failure):
return written
if isinstance(committed := git("commit", "--quiet", "--all", "--message", f"Merge release {patch.named} into main", cwd=str(worktree)), Failure):
return committed
return push_branch(worktree, f"release-{patch.named}", replacing)
def moved_entries(changelog: str, entries: list[str], named: str) -> str | Failure:
"""changelog with entries taken out of its ## Unreleased section and put in a ## named section right below that section; a Failure where it has no such heading."""
def moved_entries(changelog: str, entries: list[str], named: str, ref: str) -> str | Failure:
"""changelog, as ref holds it, with entries taken out of its ## Unreleased section and put in a ## named section right below that section; a Failure where it has no such heading."""
lines = changelog.split("\n")
start = unreleased_start(lines)
if start is None:
return Failure(f"CHANGELOG.md has no ## Unreleased heading to move the entries of {named} from")
return Failure(f"CHANGELOG.md on {ref} has no ## Unreleased heading to move the entries of {named} from")
end = next((index for index in range(start + 1, len(lines)) if lines[index].startswith("## ")), len(lines))
kept = [line for line in lines[start + 1:end] if line not in entries]
while kept and not kept[-1].strip():
+45 -22
View File
@@ -1,5 +1,4 @@
import contextlib
import datetime
import io
import json
import os
@@ -485,9 +484,11 @@ class Cut(unittest.TestCase):
self.assert_cut(self.cut())
[kept] = self.traces()
lines = kept.splitlines()
self.assertRegex(lines[0], rf"^[0-9]{{4}}-[0-9]{{2}}-[0-9]{{2}}T[0-9:]{{8}}\S* deploy-release --cut {self.target} in {self.clone}$")
self.assertRegex(kept, r"(?m)^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9:]{8}\S* pushed the tag v0\.2\.0$")
self.assertRegex(lines[0], rf"^[0-9]{{4}}-[0-9]{{2}}-[0-9]{{2}}T[0-9:]{{8}}Z deploy-release --cut {self.target} in {self.clone}$")
self.assertRegex(kept, r"(?m)^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9:]{8}Z pushed the tag v0\.2\.0$")
self.assertIn("Done: v0.2.0 is cut and pushed", lines[-1])
[file] = (self.temp / "state" / "deploy-release").glob("*.log")
self.assertRegex(file.name, r"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}-[0-9]{2}-[0-9]{2}Z-[0-9]+\.log$")
def test_keeps_the_reason_a_cut_stopped_in_its_trace_and_a_rerun_writes_its_own(self):
self.assert_cut(self.cut())
@@ -496,6 +497,27 @@ class Cut(unittest.TestCase):
self.assertTrue(second.endswith(" release 0.3.0 still holds items in todo.md\n"), second)
self.assertNotIn("still holds items", first)
def test_refuses_a_release_whose_review_has_not_landed_naming_the_commit_title_that_counts(self):
self.assert_cut(self.cut())
self.git(self.clone, "pull", "-q", "--ff-only", "origin", "main")
self.commit({"CHANGELOG.md": "# Changelog\n\n## Unreleased\n\n- Third.\n\n## 0.2.0\n\n- Second.\n\n## 0.1.0\n\n- First.\n", "todo.md": TODO}, "Ship item 2")
self.git(self.clone, "push", "-q", "origin", "main")
ran = self.cut()
self.assertEqual(ran.returncode, 1)
self.assertIn("deploy-release: the release review of 0.3.0 hasn't landed: origin/main holds no commit titled `Release review of 0.3.0` after the newest tag. `chunk-preflight --help` says which commit counts.\n", ran.stderr)
def test_a_cut_stopped_by_ctrl_c_ends_its_trace_saying_so(self):
self.set_checks("pending")
process = subprocess.Popen([sys.executable, str(TOOL), "--cut", str(self.target)], cwd=self.clone, env=self.env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
self.addCleanup(process.kill)
deadline = time.monotonic() + 30
while not any("waiting for the checks" in kept for kept in self.traces()) and time.monotonic() < deadline:
time.sleep(0.05)
process.send_signal(signal.SIGINT)
self.assertNotEqual(process.wait(timeout=30), 0)
[kept] = self.traces()
self.assertRegex(kept.splitlines()[-1], r"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9:]{8}Z stopped: KeyboardInterrupt\(\)$")
def test_reads_whether_the_next_releases_review_landed_beside_the_release(self):
self.assertEqual(cut.ready_release(str(self.clone), "origin/main"), cut.Ready((0, 2, 0), reviewed=True))
self.plan_patch()
@@ -782,8 +804,8 @@ class PatchCi(unittest.TestCase):
def test_a_ci_sh_that_could_not_run_or_was_stopped_tags_nothing_and_gives_the_runners_reason(self):
(self.worktree / "ci.sh").write_text("exit 0\n")
failed = patch.run_ci(self.worktree, "origin/main", lambda worktree: Failure("ci.sh still ran after 30 minutes and was stopped"))
self.assertEqual(failed, Failure("ci.sh still ran after 30 minutes and was stopped, so nothing is tagged. Rerun once that is fixed."))
failed = patch.run_ci(self.worktree, "origin/main", lambda worktree: Failure("ci.sh still ran after 30 minutes and was stopped; /state/run-ci.log holds its output"))
self.assertEqual(failed, Failure("ci.sh still ran after 30 minutes and was stopped; /state/run-ci.log holds its output. Nothing is tagged: rerun once ci.sh passes."))
def test_refuses_a_patch_without_ci_sh_before_running_anything(self):
self.assertEqual(patch.run_ci(self.worktree, "origin/main", lambda worktree: self.fail("ran")), Failure("the patch holds no ci.sh to test it with"))
@@ -925,14 +947,15 @@ class Trace(unittest.TestCase):
def setUp(self):
self.temp = pathlib.Path(tempfile.mkdtemp())
self.addCleanup(subprocess.run, ["rm", "-rf", str(self.temp)])
self.now = lambda: datetime.datetime(2026, 11, 27, 9, 30, 5)
# 2026-11-27T09:30:05Z, in seconds since the epoch.
self.now = lambda: 1795771805.0
def test_keeps_traces_under_the_state_folder_xdg_names_else_under_homes(self):
self.assertEqual(trace.trace_folder({"XDG_STATE_HOME": "/x/state"}, pathlib.Path("/home/u")), pathlib.Path("/x/state/deploy-release"))
self.assertEqual(trace.trace_folder({}, pathlib.Path("/home/u")), pathlib.Path("/home/u/.local/state/deploy-release"))
def test_names_a_run_by_its_start_and_its_process(self):
self.assertEqual(trace.run_name(self.now(), 4711), "2026-11-27T09-30-05-4711")
self.assertEqual(trace.run_name(self.now(), 4711), "2026-11-27T09-30-05Z-4711")
def test_starts_a_trace_with_the_command_then_appends_each_step_with_its_time_and_says_it(self):
file = trace.started(self.temp / "state" / "deploy-release", "run", "deploy-release --cut", self.now)
@@ -942,15 +965,15 @@ class Trace(unittest.TestCase):
say("pushed the tag v0.2.0")
say("merged pull request 3")
self.assertEqual(out.getvalue(), "deploy-release: pushed the tag v0.2.0\ndeploy-release: merged pull request 3\n")
self.assertEqual(file.read_text(), "2026-11-27T09:30:05 deploy-release --cut\n2026-11-27T09:30:05 pushed the tag v0.2.0\n2026-11-27T09:30:05 merged pull request 3\n")
self.assertEqual(file.read_text(), "2026-11-27T09:30:05Z deploy-release --cut\n2026-11-27T09:30:05Z pushed the tag v0.2.0\n2026-11-27T09:30:05Z merged pull request 3\n")
def test_starts_a_later_runs_trace_beside_the_earlier_one(self):
folder = self.temp / "state" / "deploy-release"
first = trace.started(folder, "first", "deploy-release --cut", self.now)
second = trace.started(folder, "second", "deploy-release --cut-patch a..b", self.now)
self.assertEqual((first, second), (folder / "first.log", folder / "second.log"))
self.assertEqual(second.read_text(), "2026-11-27T09:30:05 deploy-release --cut-patch a..b\n")
self.assertEqual(first.read_text(), "2026-11-27T09:30:05 deploy-release --cut\n")
self.assertEqual(second.read_text(), "2026-11-27T09:30:05Z deploy-release --cut-patch a..b\n")
self.assertEqual(first.read_text(), "2026-11-27T09:30:05Z deploy-release --cut\n")
def test_a_trace_that_cannot_be_started_is_a_failure_naming_the_file(self):
(self.temp / "state").write_text("a file where the folder goes\n")
@@ -975,9 +998,9 @@ class Rewritten(unittest.TestCase):
def test_replaces_a_files_text_and_hands_none_for_a_file_that_is_not_there(self):
file = self.temp / "CHANGELOG.md"
self.assertIsNone(cut.rewritten(file, "head CHANGELOG.md", lambda text: f"{text!r} new\n"))
self.assertIsNone(cut.rewritten(file, "head CHANGELOG.md", "Nothing is tagged.", lambda text: f"{text!r} new\n"))
self.assertEqual(file.read_text(), "None new\n")
self.assertIsNone(cut.rewritten(file, "head CHANGELOG.md", lambda text: text.upper()))
self.assertIsNone(cut.rewritten(file, "head CHANGELOG.md", "Nothing is tagged.", lambda text: text.upper()))
self.assertEqual(file.read_text(), "NONE NEW\n")
def test_a_file_that_cannot_be_read_or_written_is_a_failure_naming_the_step_and_the_file(self):
@@ -986,26 +1009,26 @@ class Rewritten(unittest.TestCase):
# A folder can't be read as a file, and a file in a folder that isn't there can't be written.
for file in (folder, self.temp / "gone" / "commit.patch"):
with self.subTest(file=file):
failed = cut.rewritten(file, "head CHANGELOG.md with ## 0.1.1, so nothing is tagged", lambda text: "new\n")
failed = cut.rewritten(file, "head CHANGELOG.md with ## 0.1.1", "Nothing is tagged.", lambda text: "new\n")
self.assertIsInstance(failed, Failure)
self.assertTrue(failed.reason.startswith("could not head CHANGELOG.md with ## 0.1.1, so nothing is tagged: "), failed.reason)
self.assertTrue(failed.reason.startswith("could not head CHANGELOG.md with ## 0.1.1: "), failed.reason)
self.assertEqual(failed.reason.count(str(file)), 1, failed.reason)
self.assertTrue(failed.reason.endswith(f"'{file}'"), failed.reason)
self.assertTrue(failed.reason.endswith(f"'{file}'. Nothing is tagged."), failed.reason)
def test_a_file_that_is_not_utf_8_is_a_failure_naming_the_step_and_the_file(self):
file = self.temp / "CHANGELOG.md"
file.write_bytes(b"caf\xe9\n")
failed = cut.rewritten(file, "head CHANGELOG.md", lambda text: "new\n")
failed = cut.rewritten(file, "head CHANGELOG.md", "Nothing is tagged.", lambda text: "new\n")
self.assertIsInstance(failed, Failure)
self.assertTrue(failed.reason.startswith("could not head CHANGELOG.md: "), failed.reason)
self.assertTrue(failed.reason.endswith(f" ({file})"), failed.reason)
self.assertTrue(failed.reason.endswith(f" ({file}). Nothing is tagged."), failed.reason)
self.assertEqual(failed.reason.count(str(file)), 1, failed.reason)
self.assertEqual(file.read_bytes(), b"caf\xe9\n")
def test_gives_the_rewrites_own_failure_and_leaves_the_file(self):
file = self.temp / "CHANGELOG.md"
file.write_text("old\n")
self.assertEqual(cut.rewritten(file, "x", lambda text: Failure("no heading")), Failure("no heading"))
self.assertEqual(cut.rewritten(file, "x", "y", lambda text: Failure("no heading")), Failure("no heading"))
self.assertEqual(file.read_text(), "old\n")
@@ -1020,17 +1043,17 @@ class PatchChangelog(unittest.TestCase):
def test_moves_the_patchs_entries_from_unreleased_to_a_section_after_it(self):
changelog = "# Changelog\n\n## Unreleased\n\n- Second.\n- Fixed.\n\n## 0.1.0\n\n- First.\n"
self.assertEqual(patch.moved_entries(changelog, ["- Fixed."], "0.1.1"), "# Changelog\n\n## Unreleased\n\n- Second.\n\n## 0.1.1\n\n- Fixed.\n\n## 0.1.0\n\n- First.\n")
self.assertEqual(patch.moved_entries(changelog, ["- Fixed."], "0.1.1", "origin/main"), "# Changelog\n\n## Unreleased\n\n- Second.\n\n## 0.1.1\n\n- Fixed.\n\n## 0.1.0\n\n- First.\n")
def test_leaves_an_older_section_entry_that_reads_the_same(self):
changelog = "# Changelog\n\n## Unreleased\n\n- Fixed.\n\n## 0.1.0\n\n- Fixed.\n"
self.assertEqual(patch.moved_entries(changelog, ["- Fixed."], "0.1.1"), "# Changelog\n\n## Unreleased\n\n## 0.1.1\n\n- Fixed.\n\n## 0.1.0\n\n- Fixed.\n")
self.assertEqual(patch.moved_entries(changelog, ["- Fixed."], "0.1.1", "origin/main"), "# Changelog\n\n## Unreleased\n\n## 0.1.1\n\n- Fixed.\n\n## 0.1.0\n\n- Fixed.\n")
def test_puts_the_section_last_where_unreleased_is_the_last_section(self):
self.assertEqual(patch.moved_entries("# Changelog\n\n## Unreleased\n\n- Fixed.\n", ["- Fixed."], "0.1.1"), "# Changelog\n\n## Unreleased\n\n## 0.1.1\n\n- Fixed.\n")
self.assertEqual(patch.moved_entries("# Changelog\n\n## Unreleased\n\n- Fixed.\n", ["- Fixed."], "0.1.1", "origin/main"), "# Changelog\n\n## Unreleased\n\n## 0.1.1\n\n- Fixed.\n")
def test_a_changelog_without_an_unreleased_heading_is_a_failure_that_names_it(self):
self.assertEqual(patch.moved_entries("# Changelog\n\n## 0.1.0\n\n- First.\n", ["- Fixed."], "0.1.1"), Failure("CHANGELOG.md has no ## Unreleased heading to move the entries of 0.1.1 from"))
self.assertEqual(patch.moved_entries("# Changelog\n\n## 0.1.0\n\n- First.\n", ["- Fixed."], "0.1.1", "origin/main"), Failure("CHANGELOG.md on origin/main has no ## Unreleased heading to move the entries of 0.1.1 from"))
if __name__ == "__main__":
+10 -8
View File
@@ -1,13 +1,15 @@
"""What a cut says as each step finishes: on stderr, and in a file of the run's own, so the steps outlast the terminal."""
import datetime
import pathlib
import time
import typing
from failure import Failure
from text_files import utc_stamp
# Says that one step of a cut finished, as `saying` makes it.
Say = typing.Callable[[str], None]
Clock = typing.Callable[[], datetime.datetime]
# The time now, in seconds since the epoch, as time.time gives it.
Clock = typing.Callable[[], float]
def trace_folder(env: typing.Mapping[str, str], home: pathlib.Path) -> pathlib.Path:
@@ -16,13 +18,13 @@ def trace_folder(env: typing.Mapping[str, str], home: pathlib.Path) -> pathlib.P
return pathlib.Path(state) / "deploy-release"
def run_name(began: datetime.datetime, pid: int) -> str:
"""The name of the files one run keeps, which sorts by when it began."""
return f"{began:%Y-%m-%dT%H-%M-%S}-{pid}"
def run_name(began: float, pid: int) -> str:
"""The name of the files one run keeps, which sorts by when it began: that time in UTC, with no colon, so the name is valid on every disk."""
return f"{time.strftime('%Y-%m-%dT%H-%M-%SZ', time.gmtime(began))}-{pid}"
def stamped(at: datetime.datetime, line: str) -> str:
return f"{at.isoformat(timespec='seconds')} {line}\n"
def stamped(at: float, line: str) -> str:
return f"{utc_stamp.utc(at)} {line}\n"
def started(folder: pathlib.Path, name: str, command: str, now: Clock) -> pathlib.Path | Failure:
@@ -37,7 +39,7 @@ def started(folder: pathlib.Path, name: str, command: str, now: Clock) -> pathli
def kept(trace: pathlib.Path | None, line: str, now: Clock, out: typing.TextIO) -> None:
"""Append line with its time to trace, where there is one. A trace that can't be written only warns on out, since the cut's own steps count."""
"""Append line with its time, in UTC, to trace, where there is one. A trace that can't be written only warns on out, since the cut's own steps count."""
if trace is None:
return
try:
-3
View File
@@ -16,7 +16,6 @@ from do_epic.test_scheduler import issue
from chunk_driver.claims import LOCK
from do_epic.backend.fake import MemoryEpic
from loop_state.paths import paths_from
from plan.release import REVIEW_TITLE
from claude_code.session import session_named
from do_epic.test_do_epic import SETTINGS
@@ -65,8 +64,6 @@ class TheFinishingChunksTask(DoEpicTest):
self.assertIn("first, and api has none. ", finish.task("ABC-12", [issue("ABC-20", "repo:api", done=True)], {}, LAUNCHER, "Swedish"))
self.assertIn('`/b/do-epic ABC-12 --file "<summary>" --label <label> --label do-epic-release-review`', task)
self.assertIn("`Release review of ABC-12`", task)
self.assertIn(f"`{REVIEW_TITLE}ABC-12`", task)
self.assertEqual(REVIEW_TITLE, "Release review of ")
self.assertIn("in Swedish", task)
self.assertNotIn("--close-epic", task)
+1 -2
View File
@@ -354,7 +354,6 @@ def progress(line: str) -> None:
def bench(given: dict[str, str], env: typing.Mapping[str, str], read: typing.Callable[[pathlib.Path], str | Failure], home: pathlib.Path, name: str, user: str) -> list[str] | Failure:
"""The report of one bench of the checkout the process runs in, where `read` reads what `larv-review places` prints. Its
containers are named name and run as user. It tells its progress on stderr."""
# The one place that resolves the bench's kind from its options: SOURCES holds what reads each kind's tasks.
kind = KINDS[given[TASKS]]
# Each kind reads what it makes its tasks from before anything is copied or built, so a fault there stops the bench at once.
source = SOURCES[kind](Call(given, env, read, home), kind)
@@ -404,7 +403,7 @@ def bench_in(folder: pathlib.Path, image: str, containers: Containers, asked: As
def bugs_source(call: Call, kind: Kind) -> Source | Failure:
"""Reads the seats' places, where alone bugs are planted."""
"""Reads the seats' places, the only places bugs are planted."""
places = call.read(call.home)
if isinstance(places, Failure):
return places
+3 -1
View File
@@ -154,7 +154,9 @@ Valid while `~/.claude` is a checkout of this repo.
2026-11-08, lilleman, todo item 271. Serves goal 1.5 and goal 2. Nobody can push to `main` on the remote, and it merges only by fast-forward, so a cut that commits on `main` and pushes no longer works. The tool cuts only the release `chunk-preflight` would call ready to cut, through `bin/release_plan/release_standing.py`, so the two never disagree on which release is next or whether it is ready; the version is that release's, never the tool's choice. It builds the cut commit in a worktree of its own, so the clone's checkout stays as it is. It finds the merged commit on `main` by its title, `Cut release <version>`, since GitHub's nearest merge, a rebase merge, may give the commit a new hash. It takes only a pull request from origin's own branch whose head is the commit that branch points at, and has the forge merge it only while its head is still that commit, so a fork's pull request from a branch of the same name, or a push after the checks passed, is never merged and deployed. Each step first checks whether an earlier run did it, so a rerun continues. Releases stay the human's, so the human runs it, and the forge credentials stay theirs. Valid while `main` takes changes only through a pull request.
2026-11-24, lilleman, todo item 536. `deploy-release --cut-patch <commits>` cuts the newest tag's next patch release, holding only the commits named, for a fix that must ship before `main`'s other unreleased work. Before it, 0.15.1 was cut by those steps by hand. The patch's commit has the tag as its parent, not `main`'s head, so no pull request into `main` can merge it, and CI runs only on pull requests: the tool runs `ci.sh` on it, as CI does, before it tags. Then it merges the tag back into `main` with `-s ours` through a pull request, so the tag is in `main`'s history, where the next cut and `chunk-preflight` read it. 2026-11-27, lilleman, the release review of 0.16.0: a release review on `main` counts only for the release its title names, which must be the next release exactly, as `chunk-preflight --help` states. So the patch's own review, which the merge leaves on `main` after the tag, reviews no later release, and neither does a review opened under a release name todo.md has since changed. GitHub's rebase merge would drop that merge commit, so the tool refuses a GitHub origin. A patch skips the release review: `chunk-preflight` still calls it due until the patch is cut, so cut a patch as soon as its fix merges. Plain `--cut` refuses a patch of the newest tag, since it would ship all of `main` under a patch number. A panel of three readers seated as the owner picked the spelling `--cut-patch` over `--cut --patch` and `--hotfix`: one flag that names the action, which can't be read as a plain `--cut`.
2026-11-24, lilleman, todo item 536. `deploy-release --cut-patch <commits>` cuts the newest tag's next patch release, holding only the commits named, for a fix that must ship before `main`'s other unreleased work. Before it, 0.15.1 was cut by those steps by hand. The patch's commit has the tag as its parent, not `main`'s head, so no pull request into `main` can merge it, and CI runs only on pull requests: the tool runs `ci.sh` on it, as CI does, before it tags. Then it merges the tag back into `main` with `-s ours` through a pull request, so the tag is in `main`'s history, where the next cut and `chunk-preflight` read it. GitHub's rebase merge would drop that merge commit, so the tool refuses a GitHub origin. A patch skips the release review: `chunk-preflight` still calls it due until the patch is cut, so cut a patch as soon as its fix merges. Plain `--cut` refuses a patch of the newest tag, since it would ship all of `main` under a patch number. A panel of three readers seated as the owner picked the spelling `--cut-patch` over `--cut --patch` and `--hotfix`: one flag that names the action, which can't be read as a plain `--cut`.
2026-11-27, lilleman, the release review of 0.16.0. A release review on `main` counts only for the release its title names, which must be exactly the next release, as `chunk-preflight --help` states. So the patch's own review, which the merge leaves on `main` after the tag, doesn't review any later release, and neither does a review opened under a release name todo.md has since changed. Where todo.md names no next release, a review of any release after the last cut counts.
## do-epic: drives one Jira epic whose items span repos, or have none, ranked by the epic's goals, then code health, then each repo's goals, and closes the epic only once the human confirms every goal
+4 -3
View File
@@ -118,8 +118,9 @@ A fix that fits no row doesn't rerun any pass. So none of these does:
- a fix for a 🟢 or a ❓, whatever it changes;
- a fix for a 🟡 that does none of what the 🟡 row lists;
- a fix for a prose finding that rewords a claim and keeps what it says;
- a comment or doc edit inside a fix for another pass's finding, since no row reruns Prose for it.
- a fix for a prose finding that rewords a claim and keeps what it says.
A comment or doc edit inside a fix for another pass's finding adds no pass: no row reruns Prose for it.
One fix fits the 🟡 row and still doesn't rerun the pass: a fix that only kills a named mutant or makes a named failing test pass, once §2's tests and mutation command run clean on it and the named failing test is unedited ("Mechanical answers"). A skipped test kills no mutant.
@@ -151,7 +152,7 @@ A round's fixes re-enter together: run every pass the table names for any of the
The release review is a release's last chunk, run once the release holds no item and changes are unreleased, before it is ready to cut. It looks for the drift the release's small changes left, and fixes it.
- **When.** `chunk-preflight` reports a release review due. `chunk-preflight --help` says which commit it counts as the review landed.
- **When.** `chunk-preflight` reports a release review due. `chunk-preflight --help` says which commit counts as the review having landed.
- **Branch.** `release-review-<release>`, off the default branch. Open it with `git commit --allow-empty -m "Release review of <release>"`.
- **Passes.** Architecture, then Principles, each over the whole project, per "Waves". Tell both to refactor boldly where the code needs it. Each takes up to five rounds.
- **Their fixes** re-enter Stability, Security, Overrides and Prose per "Re-entry", each at most two rounds.