Answer stability round 2: 0 🔴, 1 🟡 (0 misread); keep a chunk open, and read its gate again, only where the judge ruled it finished
CI / tests (pull_request) Successful in 4m18s
CI / tests (pull_request) Successful in 4m18s
This commit is contained in:
+11
-9
@@ -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, told=None) if repo is not None else ""
|
||||
news = parked_through(repo, loop, epic, told=None, finished=False) if repo is not None else ""
|
||||
while True:
|
||||
if isinstance(news, Stop):
|
||||
return news
|
||||
@@ -276,16 +276,16 @@ def chunk_run(key: str, epic: EpicRun) -> Stop:
|
||||
if isinstance(closed, Stop):
|
||||
return closed
|
||||
run = closed
|
||||
news = parked_through(repo, loop, epic, told=news) if repo is not None else ""
|
||||
news = parked_through(repo, loop, epic, told=news, finished=isinstance(concluded.verdict, Finished)) 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, 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.
|
||||
def parked_through(repo: str, loop: Loop, epic: EpicRun, told: str | None, finished: 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. 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. 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.
|
||||
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, 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.
|
||||
"""
|
||||
@@ -299,11 +299,11 @@ def parked_through(repo: str, loop: Loop, epic: EpicRun, told: str | None) -> st
|
||||
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 told is None else poll.first_gate()
|
||||
entered = None if told is None else poll.first_gate(again=finished)
|
||||
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)
|
||||
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 ""
|
||||
uncleaned = f"{chunk_prompt.DRIVER} keeps the chunk open while its worktree stands: {entered.news}." if finished and 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)
|
||||
@@ -329,9 +329,11 @@ 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."""
|
||||
def first_gate(self, again: bool) -> gates.Gate | gates.Open | Failure:
|
||||
"""The gate as a cycle ends. Where again holds and a person merges, one that cannot be read is read again every POLL_SECONDS until it can."""
|
||||
now = self.gate()
|
||||
if not again:
|
||||
return now
|
||||
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):
|
||||
|
||||
@@ -746,6 +746,17 @@ class AChunkWhosePullRequestWaitsOnAGate(DoEpicTest):
|
||||
self.assertIn(fact, prompts[1].split("\n\n")[0])
|
||||
self.assertNotIn("parked: ", out)
|
||||
|
||||
def test_where_a_person_merges_an_unfinished_chunk_goes_on_without_news_or_a_wait(self) -> None:
|
||||
self.repo_config.write_text(self.repo_config.read_text(encoding="utf-8") + 'merge = "human"\n', encoding="utf-8")
|
||||
self.forges = [awaiting(pulls=""), awaiting(decision="APPROVED", fails="gh pr checks"), CLEANED]
|
||||
fake = FakeEffects(streams=[self.worker(), self.worker(), self.worker()], claude=[judged("unfinished"), judged("unfinished"), judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
|
||||
slept: list[object] = []
|
||||
fake.effects = lambda made=fake.effects(): dataclasses.replace(made, sleep=slept.append) # type: ignore[method-assign]
|
||||
code, out, err, prompts = self.parked_run(fake)
|
||||
self.assertEqual((code, len(prompts), slept), (0, 3, []), err)
|
||||
self.assertNotIn("keeps the chunk open", "".join(prompts))
|
||||
self.assertIn("so the chunk isn't parked: gh pr checks failed", out)
|
||||
|
||||
def test_where_the_chunk_merges_a_finished_chunk_whose_pull_request_is_no_longer_open_is_handed_on(self) -> None:
|
||||
self.forges = [awaiting(pulls="")]
|
||||
fake = FakeEffects(streams=[self.worker()], claude=[judged("finished")], git=UNREAD, windows=PARKED_WINDOW)
|
||||
|
||||
Reference in New Issue
Block a user