Answer product-owner round 1: 1 🔴, 1 🟡 (1 misread); finish a chunk whose clean removed the worktree before failing, say its reason, and reword the help

This commit is contained in:
2026-12-03 13:07:27 +01:00
parent 0ea7c13673
commit d2bb2c56e1
5 changed files with 22 additions and 12 deletions
+7 -4
View File
@@ -21,7 +21,7 @@ class Merged:
def parked_through(repo: str, loop: Loop, epic: EpicRun, told: str | None, finished: bool, based: str | None) -> str | Stop | Merged:
"""Keeps the chunk in loop's window parked. Its work is in the repo called repo. It stays parked for as long as its pull request waits on a gate, and returns once its worker has something to do: what to tell that worker, or empty where the chunk was never parked. Or Merged, where the chunk's pull request merged and `merged_and_cleaned` removed its worktree, which needs no worker and no running slot. told is the news its last cycle's worker got, None where the window just started, and finished says the judge ruled the chunk finished. based is the epic's working branch that `epic_based` recorded as the chunk's base when the window started, None where it recorded none. A window that just started parks the chunk only if its file says so: the forge isn't read for a chunk that starts afresh.
"""Keeps the chunk in loop's window parked. Its work is in the repo called repo. It stays parked for as long as its pull request waits on a gate, and returns once its worker has something to do: what to tell that worker, or empty where the chunk was never parked. Or Merged, where the chunk's pull request merged and `merged_and_cleaned` removed its worktree: the chunk then needs no worker and no running slot. told is the news its last cycle's worker got, None where the window just started, and finished says the judge ruled the chunk finished. based is the epic's working branch that `epic_based` recorded as the chunk's base when the window started, None where it recorded none. A window that just started parks the chunk only if its file says so: the forge isn't read for a chunk that starts afresh.
Where a person merges, a worker ends its run with the pull request open, so the judge may rule the chunk finished before it is. For such a finished chunk, a gate that cannot be read is read again until it can (`Poll.first_gate`), and what the worker must still do is news (`news_after`), unless the pull request merged already and do-epic removes the worktree itself.
@@ -150,10 +150,13 @@ class Told:
def merged_and_cleaned(poll: Poll, unopened: gates.Unopened) -> Merged | Stop | None:
"""Runs `chunk-pr clean` in the worktree of a chunk whose pull request is no longer open, and removes the chunk's file: Merged where it removed the worktree. None where it didn't, so that the worker decides, as for a pull request closed unmerged. chunk-pr acts only on a pull request the forge reports merged at the commit checked out, and refuses a worktree with uncommitted or untracked files, so a worktree that holds work the merge lacks stays."""
if isinstance(poll.epic.forge_at(unopened.worktree)(["chunk-pr", "clean"]), Failure):
"""Runs `chunk-pr clean` in the worktree of a chunk whose pull request is no longer open, and removes the chunk's file once the worktree is gone: Merged then. None where the worktree stands, so that its worker decides, as for a pull request closed unmerged.
chunk-pr acts only on a pull request the forge reports merged at the commit checked out, and refuses a worktree with uncommitted or untracked files. It removes the worktree before it fails on the main checkout (another branch checked out, unsaved files or commits origin lacks), so a failure with the worktree gone still leaves the chunk merged, and its reason is said."""
cleaned = poll.epic.forge_at(unopened.worktree)(["chunk-pr", "clean"])
if isinstance(cleaned, Failure) and gates.worktree_of(poll.key, poll.epic.forge_at(poll.loop.root)) is not None:
return None
say(f"pull request merged: removed {unopened.worktree}", poll.epic.effects, stdout=True)
say(f"pull request merged: removed {unopened.worktree}" + (f", but {cleaned.reason}" if isinstance(cleaned, Failure) else ""), poll.epic.effects, stdout=True)
failed = parked.unpark(poll.folder, poll.key)
return Stop(1, failed.reason) if failed else Merged()