Answer stability round 1: 0 🔴, 2 🟡 (0 misread); keep a finished chunk open until a person's merge is read and its worktree removed, and assert facts in place of sentences

This commit is contained in:
Lilleman
2026-11-19 18:07:54 +01:00
parent 2e0ceef6ae
commit 24bd382d48
7 changed files with 77 additions and 27 deletions
+22 -9
View File
@@ -56,8 +56,8 @@ A repo takes as many chunks as its `parallel-chunks`, and none while loop-claude
A chunk whose worker ends its run while its pull request waits on its checks, an approval or a new review
is parked: it frees its place for the next chunk, and its window's name says what it awaits. Its worker goes
on once the checks pass, the approval comes or a reviewer comments, and a place is free; until one is, the
name says `awaits a slot`. In a repo whose config sets `merge = "human"`, a chunk never merges: its pull
request, ready and with nothing else to wait on, `awaits your merge`, and its worker goes on once you merged it. A parked chunk survives a reboot: run do-epic <EPIC-KEY> again to go on polling.
name says `awaits a slot`. In a repo whose config sets `merge = "human"`, a chunk never merges: once its pull
request is ready, with nothing else to wait on, the window's name says `awaits your merge`, and its worker goes on once you merged it. A parked chunk survives a reboot: run do-epic <EPIC-KEY> again to go on polling.
--status doesn't start any chunk. It prints a line per open issue: that its chunk runs or asks you a question, or why it waits, such as the gate a parked chunk awaits and since when.
{findings.HELP}
{finish.HELP}
@@ -258,7 +258,7 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
loop = Loop(root=root, session=session, window=tmux.Window(epic.session, key, pane), paths=epic.paths, env=epic.env, launcher=epic.launcher, effects=epic.effects)
run = ChunkRun()
# What a chunk that was parked is told as it resumes; empty for a chunk that wasn't.
news = parked_through(repo, loop, epic, starts=True) if repo is not None else ""
news = parked_through(repo, loop, epic, told=None) if repo is not None else ""
while True:
if isinstance(news, Stop):
return news
@@ -276,14 +276,16 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
if isinstance(closed, Stop):
return closed
run = closed
news = parked_through(repo, loop, epic, starts=False) if repo is not None else ""
news = parked_through(repo, loop, epic, told=news) if repo is not None else ""
# A chunk that was parked has work again, whatever the judge ruled before its pull request passed the gate.
if isinstance(concluded.verdict, Finished) and news == "":
return handed_on(key, epic)
def parked_through(repo: str, loop: Loop, epic: EpicRun, starts: bool) -> str | Stop:
"""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. starts says the window just started, where the chunk is parked only if its file says so: the forge isn't read for a chunk that starts afresh.
def parked_through(repo: str, loop: Loop, epic: EpicRun, told: str | None) -> str | Stop:
"""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. told is the news its last cycle's worker got, None where the window just started. 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. There a gate that cannot be read is read again until it can, and a pull request no longer open, in a worktree that still stands, is news the worker hasn't been told: the worker removes the worktree.
A chunk parks in three steps: its file is written, its window is shown as parked, and the epic's next chunks start in the slot it frees. It resumes in the reverse order: `scheduler.resume` gives it a running slot, then its file is removed. So a window that ends in between finds the chunk parked when it starts again.
"""
@@ -297,11 +299,12 @@ def parked_through(repo: str, loop: Loop, epic: EpicRun, starts: bool) -> str |
poll = Poll(key, repo, config.merge == "human", folder, loop, epic)
if key in recorded_as:
return resumed_news(poll, recorded_as[key].on, shown=None)
entered = None if starts else poll.gate()
entered = None if told is None else poll.first_gate()
if not isinstance(entered, gates.Gate):
if isinstance(entered, Failure):
say(f"cannot tell whether the chunk's pull request waits on a gate, so the chunk isn't parked: {entered.reason}", epic.effects, stdout=True)
return ""
uncleaned = f"{chunk_prompt.DRIVER} keeps the chunk open while its worktree stands: {entered.news}." if poll.by_human and isinstance(entered, gates.Unopened) else ""
return "" if uncleaned in (told or "") else uncleaned
if failed := poll.record(entered):
return Stop(1, failed.reason)
tmux.park(loop.window, entered.on, epic.effects.tmux)
@@ -326,6 +329,16 @@ class Poll:
def gate(self) -> gates.Gate | gates.Open | Failure:
return gates.gate(self.key, self.loop.root, self.epic.forge_at, self.by_human)
def first_gate(self) -> gates.Gate | gates.Open | Failure:
"""The gate as a cycle ends. Where a person merges, one that cannot be read is read again every POLL_SECONDS until it can."""
now = self.gate()
if self.by_human and isinstance(now, Failure):
say(f"cannot read the gate of a pull request a person merges: {now.reason}; trying again every {POLL_SECONDS} seconds", self.epic.effects, stdout=True)
while self.by_human and isinstance(now, Failure):
self.epic.effects.sleep(POLL_SECONDS)
now = self.gate()
return now
def record(self, gate: gates.Gate) -> Failure | None:
"""Writes the chunk's file as parked on gate, and says so."""
failed = parked.park(self.folder, parked.Parked(self.key, gate.worktree, gate.pull, str(self.loop.session.id), gate.on))
@@ -352,7 +365,7 @@ def resumed_news(poll: Poll, on: str, shown: str | None) -> str | Stop:
full = resumed(poll.repo, poll.loop, poll.epic)
if full is None:
failed = parked.unpark(poll.folder, poll.key)
return Stop(1, failed.reason) if failed is not None else f"{DRIVER_PARKED} its pull request awaited {on}. It resumes now: {now.news}."
return Stop(1, failed.reason) if failed is not None else f"{DRIVER_PARKED} its pull request awaited {"a person's merge" if on == gates.MERGE else on}. It resumes now: {now.news}."
awaits, stays = parked.SLOT, f"{now.news}, but the chunk stays parked: {full}"
if awaits != shown:
tmux.park(poll.loop.window, awaits, poll.epic.effects.tmux)