Answer architecture round 2: 0 🔴, 3 🟡 (0 misread); the cycle's and the chunk run's suites sit beside their modules, and the claim rule and the model override have one home each
CI / tests (pull_request) Successful in 3m23s

This commit is contained in:
2026-11-19 11:29:32 +01:00
parent b8595db647
commit df210aaeca
31 changed files with 807 additions and 657 deletions
+9 -5
View File
@@ -5,7 +5,11 @@ import typing
from failure import Failure
from forge.commands import Forge, gitea, Run
# What `review_decision` returns in place of GitHub's `CHANGES_REQUESTED` once the worker answered those changes: GitHub keeps its decision until the reviewer reviews again.
# GitHub's review decisions on a pull request. CHANGES_REQUESTED is also the state of the review that asked for them.
APPROVED = "APPROVED"
REVIEW_REQUIRED = "REVIEW_REQUIRED"
CHANGES_REQUESTED = "CHANGES_REQUESTED"
# What `review_decision` returns in place of CHANGES_REQUESTED once the worker answered those changes: GitHub keeps its decision until the reviewer reviews again.
ANSWERED = "CHANGES_ANSWERED"
# What the title of a draft opens with on Gitea, in any case: Gitea's default `WORK_IN_PROGRESS_PREFIXES`.
GITEA_DRAFT = ("WIP:", "[WIP]")
@@ -22,7 +26,7 @@ def review_decision(forge: Forge, pull: str, head: str, run: Run) -> str | None
def github_decision(pull: str, run: Run) -> str | Failure:
"""GitHub's review decision on the pull request as it stands, read once: `APPROVED`, `REVIEW_REQUIRED`, `CHANGES_REQUESTED`, or empty where its branch protection asks for no review."""
"""GitHub's review decision on the pull request as it stands, read once: APPROVED, REVIEW_REQUIRED, CHANGES_REQUESTED, or empty where its branch protection asks for no review."""
viewed = run(["gh", "pr", "view", pull, "--json", "reviewDecision"])
if isinstance(viewed, Failure):
return viewed
@@ -34,7 +38,7 @@ def github_decision(pull: str, run: Run) -> str | Failure:
def answered_decision(pull: str, head: str, run: Run) -> str | None | Failure:
"""GitHub's review decision on the pull request, whose head commit is head, read once: `APPROVED`, `REVIEW_REQUIRED`, `CHANGES_REQUESTED`, or empty where its branch protection asks for no review. ANSWERED in place of `CHANGES_REQUESTED` once the worker answered those changes. None where it is a draft."""
"""GitHub's review decision on the pull request, whose head commit is head, read once: APPROVED, REVIEW_REQUIRED, CHANGES_REQUESTED, or empty where its branch protection asks for no review. ANSWERED in place of CHANGES_REQUESTED once the worker answered those changes. None where it is a draft."""
viewed = run(["gh", "pr", "view", pull, "--json", "isDraft,reviewDecision,author,reviews,comments"])
if isinstance(viewed, Failure):
return viewed
@@ -43,7 +47,7 @@ def answered_decision(pull: str, head: str, run: Run) -> str | None | Failure:
if parsed["isDraft"]:
return None
decision = str(parsed["reviewDecision"] or "")
return ANSWERED if decision == "CHANGES_REQUESTED" and answered(parsed, head) else decision
return ANSWERED if decision == CHANGES_REQUESTED and answered(parsed, head) else decision
except (ValueError, KeyError, TypeError):
return Failure(f"gh pr view printed no review decision: {viewed.strip()[:200]}")
@@ -53,7 +57,7 @@ def answered(pull: dict[str, typing.Any], head: str) -> bool:
The review names its commit, so no clock tells whether the worker pushed: a commit's date says when it was made, never when it was pushed.
"""
asked = max((review for review in pull["reviews"] if review["state"] == "CHANGES_REQUESTED"), key=lambda review: review["submittedAt"], default=None)
asked = max((review for review in pull["reviews"] if review["state"] == CHANGES_REQUESTED), key=lambda review: review["submittedAt"], default=None)
if asked is None:
return False
author = pull["author"]["login"]