Answer stability round 1: 1 🔴, 0 🟡 (1 misread); tell a finished chunk's worker of a pull request that no longer merges, in place of handing the chunk on

This commit is contained in:
Lilleman
2026-11-19 22:04:59 +01:00
parent fc4b0387d6
commit 547afc6cf2
5 changed files with 34 additions and 12 deletions
+7 -3
View File
@@ -39,10 +39,15 @@ class Unopened(Open):
"""An Open whose worktree stands though no pull request is open at its head: one that was merged or closed, whose chunk still has its worktree to remove."""
@dataclasses.dataclass(frozen=True)
class Unmergeable(Open):
"""An Open whose pull request awaits a person's merge and doesn't merge into its base as it stands: its worker levels the branch."""
def gate(branch: str, checkout: str, at: typing.Callable[[str], Run], by_human: bool) -> Gate | Open | Failure:
"""What the chunk on branch waits on, in a worktree of checkout; at gives the runner of commands in a folder, and by_human says the project's config leaves the merge to a person (`merge = "human"`). A Failure where git or the forge cannot be read, which doesn't say anything about the gate.
A draft never waits on a gate: its worker still works on it. On Gitea only the checks are a gate, since chunk-pr reads approvals on GitHub only (`chunk_pr.approval.awaited`). Changes a reviewer requested are news until the worker answered them (`forge.reviews.answered`); from then on the pull request awaits a new review. Where a person merges, a pull request with nothing else to wait on awaits that merge. The chunk has news again once the pull request is no longer open, or no longer merges into its base as it stands (`forge.pulls.unmergeable`), so the worker levels it for that person.
A draft never waits on a gate: its worker still works on it. On Gitea only the checks are a gate, since chunk-pr reads approvals on GitHub only (`chunk_pr.approval.awaited`). Changes a reviewer requested are news until the worker answered them (`forge.reviews.answered`); from then on the pull request awaits a new review. Where a person merges, a pull request with nothing else to wait on awaits that merge. The chunk has news again once the pull request is no longer open. It has news too once the pull request no longer merges into its base as it stands (`forge.pulls.unmergeable`): the worker then levels the branch for that person.
"""
worktree = worktree_of(branch, at(checkout))
if not isinstance(worktree, str):
@@ -82,8 +87,7 @@ def gate(branch: str, checkout: str, at: typing.Callable[[str], Run], by_human:
blocked = unmergeable(forge, pull, run)
if isinstance(blocked, Failure):
return blocked
# The same flags, since merge passes over an item an earlier run finished, and finishes one that resolving a conflict brought back.
return Open(f"pull request #{pull} {blocked}; run chunk-pr merge again, with the flags it had, to level the branch") if blocked else Gate(worktree, pull, MERGE)
return Unmergeable(f"pull request #{pull} {blocked}; run chunk-pr merge again to level the branch") if blocked else Gate(worktree, pull, MERGE)
def worktree_of(branch: str, run: Run) -> str | None | Failure: