diff --git a/src/githubbot_core/prompts/MULTI-BOT.de.md b/src/githubbot_core/prompts/MULTI-BOT.de.md index e372e7e..f65c8c7 100644 --- a/src/githubbot_core/prompts/MULTI-BOT.de.md +++ b/src/githubbot_core/prompts/MULTI-BOT.de.md @@ -121,6 +121,11 @@ Die Unabhängigkeitsregel ist verbindlich; ihre Strenge setzt der Schalter `revi (`Co-authored-by`, `Generated-with`, Sitzungslinks), PR-Text und Branch-Präfix ermitteln; fehlende oder widersprüchliche Autorinformation folgt `unknown_author`. Der unabhängige Reviewer liest den vollständigen Diff im isolierten Worktree und prüft Verhalten, Tests und CI. +Eine Review-Sandbox (`review_sandbox.py`) stellt ausschließlich Checkout, Metadaten und Closeout +bereit und führt selbst keine Testsuite aus. Teilmengen- oder Einzeltests (z. B. `followup1`, +einzelner Dialog-/Smoke-Test) ersetzen niemals die vollständige Testsuite inkl. E2E und dürfen im +`APPROVE`-Review nicht als Vollabnahme ausgegeben werden (`pr.review APPROVE` lehnt solche +Teilmengen-Behauptungen technisch ab). Der Autor repariert und öffnet PRs; der Reviewer darf erst nach belegter Prüfung mergen. `core/review_gate.py` und `docs/REVIEW_GATE_PILOT.md` nutzen, wenn das Repo den Pilot verlangt; Receipt muss zum exakten aktuellen `headRefOid` gehören. Niemals eine fehlende Receipt ersetzen. @@ -135,8 +140,8 @@ Merge ausschließlich über die Core-Aktion `pr.merge` (`githubbot-core --config --expect-plan `). Sie liest den PR frisch, verlangt exakten Head, Default-Base, keinen Draft und `mergeable_state = clean`, prüft das Merge-Konto, merged sha-gebunden ohne Admin-Bypass und liest das Ergebnis zurück. Kein `gh pr merge`, kein `--admin`/`--auto`. -`pr.merge` und `pr.review` mit `APPROVE` lesen zusätzlich alle PR-Kommentare, -Inline-Review-Kommentare und Reviews. Ein STOPP, „NICHT MERGEN“, „do not merge“, `REQUEST_CHANGES` +`pr.merge`, `pr.ready` und `pr.review` mit `APPROVE` lesen zusätzlich alle PR-Kommentare, +Inline-Review-Kommentare und Reviews. Ein STOPP, „NICHT MERGEN“, „do not merge“, `HOLD`, `REQUEST_CHANGES` oder ein Review mit Änderungswunsch ist HOLD, egal unter welchem Konto er steht. Aufheben kann ihn nur dasselbe Konto oder ein Konto aus `stop_release_accounts`, und zwar mit einer eigenen Zeile, die nur die Formel enthält: `STOPP aufgehoben`, `STOP lifted`, `Merge freigegeben` oder diff --git a/src/githubbot_core/stop_gate.py b/src/githubbot_core/stop_gate.py index cb1d2ff..6e36f62 100644 --- a/src/githubbot_core/stop_gate.py +++ b/src/githubbot_core/stop_gate.py @@ -1,9 +1,9 @@ """Stop-signal gate shared by every approve and merge path. A reviewing instance may stop a pull request in plain text ("STOPP", "NICHT MERGEN", -"do not merge", ...) in a PR comment, an inline review comment or a review body, or with -a CHANGES_REQUESTED review. Whatever account posted it, the stop holds ``pr.review`` -APPROVE and ``pr.merge`` until a *later* event lifts it: +"do not merge", "HOLD", ...) in a PR comment, an inline review comment or a review body, +or with a CHANGES_REQUESTED review. Whatever account posted it, the stop holds +``pr.review`` APPROVE, ``pr.ready`` and ``pr.merge`` until a *later* event lifts it: * a release line by the same account or by one of ``multi_bot.policy.stop_release_accounts``. The line must consist of the formula alone (``STOPP aufgehoben``, ``STOP lifted``, @@ -29,7 +29,9 @@ _NEGATED = re.compile(r"\b(?:kein(?:e[nr]?)?|no|ohne|without)\s+(?:stopp?|hold)\b", re.IGNORECASE) _STOP = re.compile(r"\bstopp\b|nicht\s+mergen|do[\s-]+not[\s-]+merge|don'?t\s+merge|\bREQUEST_CHANGES\b", re.IGNORECASE) -_STOP_UPPER = re.compile(r"\bSTOP\b") # English only in capitals, so prose like "stop the job" passes +_STOP_UPPER = re.compile( + r"\b(?:STOP|HOLD)\b" +) # English only in capitals, so prose like "stop the job" / "hold on" passes _RELEASE_LINE = re.compile( r"(?:stopp?\s+(?:ist\s+)?(?:aufgehoben|zurückgenommen)|stop\s+(?:lifted|released|withdrawn)" r"|merge\s+freigegeben|cleared\s+to\s+merge)[.!]?", diff --git a/src/githubbot_core/typed_actions.py b/src/githubbot_core/typed_actions.py index ee64081..92a466a 100644 --- a/src/githubbot_core/typed_actions.py +++ b/src/githubbot_core/typed_actions.py @@ -42,6 +42,25 @@ ) REVIEW_STATES = {"COMMENT": "COMMENTED", "APPROVE": "APPROVED", "REQUEST_CHANGES": "CHANGES_REQUESTED"} +_PARTIAL_TEST_RE = re.compile( + r"(?i)(?:\bfollowup\w*\b|\bdialog[- ]?test\b|\bteilmenge\b|" + r"\bpartial\s+(?:test|tests|suite|run)\b|\bsubset\b|\bsingle[- ]test\b|" + r"\bsmoke[- ]?only\b|\bonly\s+ran\b)" +) +_FULL_SUITE_RE = re.compile( + r"(?i)(?:\bfull\s+(?:test\s+)?suite\b|\bvollst[äa]ndige\s+testsuite\b|" + r"\ball(?:e)?\s+tests\b|\bentire\s+(?:test\s+)?suite\b|\bgesamt[- ]?testsuite\b)" +) + + +def _partial_review_claim_error(event: str, body: str) -> Optional[str]: + if event != "APPROVE": + return None + if _PARTIAL_TEST_RE.search(body) and not _FULL_SUITE_RE.search(body): + return "partial test verification cannot support APPROVE without full-suite evidence" + return None + + _git = subprocess.run # replaced in tests @@ -294,6 +313,9 @@ def exec_ready(transport, params: dict, config: dict): pull, error = _reviewed_pull(transport, params, draft=True) if error: return None, error + stop = stop_gate.hold_reason(transport, params["repo"], int(params["number"]), config, pull) + if stop: + return None, stop hold_reason = draft_auto_ready_hold_reason(params["repo"], pull, config) if hold_reason: return None, hold_reason @@ -357,6 +379,9 @@ def current_pull(): if review["user"]["login"].casefold() == account.casefold() and review["commit_id"] == sha: return None, f"review already exists for this account/head (id={review.get('id')}); nothing written" if params["event"] == "APPROVE": + partial_err = _partial_review_claim_error(params["event"], params["body"]) + if partial_err: + return None, partial_err stop = stop_gate.hold_reason(transport, repo, number, config, pull) if stop: return None, stop diff --git a/tests/test_stop_gate.py b/tests/test_stop_gate.py index 2b0259b..4c8333a 100644 --- a/tests/test_stop_gate.py +++ b/tests/test_stop_gate.py @@ -141,7 +141,9 @@ def get(self, endpoint): if endpoint == f"repos/{REPO}/pulls/7": return self.pulls[-1 if self.writes else 0], None if endpoint.startswith(f"repos/{REPO}/pulls/7/reviews/"): - return {**self.writes[-1][2], "id": 81, "user": {"login": "example-bot"}, "state": "APPROVED"}, None + req = self.writes[-1][2] + state = "COMMENTED" if req.get("event") == "COMMENT" else "APPROVED" + return {**req, "id": 81, "user": {"login": "example-bot"}, "state": state}, None if endpoint.startswith(f"repos/{REPO}/compare/"): old, new = endpoint.rsplit("/", 1)[1].split("...") return {"status": "ahead" if newer(old, new) else "behind"}, None @@ -264,3 +266,67 @@ def test_unreadable_lists_fail_closed(endpoint): del transport.lists[endpoint] assert "unreadable" in merge(transport)["receipts"][0]["detail"] assert transport.writes == [] + + +def test_uppercase_hold_blocks_and_negated_hold_passes(): + held = [comment("instance", "2026-01-01T10:00:00Z", "[HOLD] wait for fix")] + assert merge(Transport(held))["receipts"][0]["status"] == "failed" + assert approve(Transport(held))["receipts"][0]["status"] == "failed" + + cleared = [comment("bot", "2026-01-01T10:00:00Z", "No hold on this branch; please hold on review details.")] + assert merge(Transport(cleared))["receipts"][0]["status"] == "applied" + + +def test_ready_also_holds_on_active_stop_signal(): + transport = Transport(PROMPTBOARD_8, draft=True, title="feat: mature draft", labels=[]) + cfg = merge_layers( + [ + ("default", default_config()), + ( + "instance", + { + "permissions": {"enabled": ["pr.ready"], "write_owners": ["example-org"]}, + "multi_bot": { + "merge_account": "example-bot", + "policy": {"draft_ready_when_mature": True}, + }, + }, + ), + ] + ) + ready_act = Action("pr.ready", {"repo": REPO, "number": 7, "sha": SHA}) + receipt = actions.apply([ready_act], transport, cfg)["receipts"][0] + assert receipt["status"] == "failed" + assert "stop signal by 'owner-account'" in receipt["detail"] + assert transport.writes == [] + + +def test_partial_subset_review_claim_cannot_approve_without_full_suite(): + transport = Transport([]) + misleading = Action( + "pr.review", + { + "repo": REPO, + "number": 7, + "sha": SHA, + "event": "APPROVE", + "body": "Verified cleanly in review sandbox: sync_backend followup1 dialog test + 10/10 CI pass and CI checks pass.", + }, + ) + receipt = actions.apply([misleading], transport, config())["receipts"][0] + assert receipt["status"] == "failed" + assert "partial test verification" in receipt["detail"] + assert transport.writes == [] + + comment_only = Action( + "pr.review", + { + "repo": REPO, + "number": 7, + "sha": SHA, + "event": "COMMENT", + "body": "Ran followup1 dialog test only; full suite pending.", + }, + ) + assert actions.apply([comment_only], transport, config())["receipts"][0]["status"] == "applied" + assert approve(Transport([]))["receipts"][0]["status"] == "applied"