diff --git a/CHANGELOG.md b/CHANGELOG.md index e8d0673..d8b6887 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,23 @@ Format: [Keep a Changelog](https://keepachangelog.com/de/1.1.0/), [Semantic Vers ## [Unreleased] +## [0.2.2] - 2026-11-22 + +### Behoben / Fixed + +- STOPP-Gate: Eine Freigabeformel in einem eingerückten Codeblock (Tab oder vier Leerzeichen) + hebt nicht mehr auf, gleich behandelt wie Fences und Zitate / an indented code block line + never counts as a release. +- STOPP-Gate: Schreibt der Bot unter einem Owner-Konto (`multi_bot.owner_fallback: true` oder + `merge_account` in `policy.stop_release_accounts`), verweigern `issue.comment`, `pr.review` und + `api.request` auf Kommentar-/Review-Endpunkte jeden Text mit Freigabezeile. So hebt der Bot im + Owner-Fallback keinen STOPP selbst auf / under an owner account the bot never posts a release + line. Labels mit Auto-Merge-Wirkung wurden geprüft: Kein Workflow der betreuten Organisationen + merged auf ein Label, daher keine Label-Sperre / no label-driven auto-merge workflow exists. + ### Hinzugefügt / Added -- STOPP-Gate für `pr.merge` und `pr.review` mit `APPROVE`: Ein STOPP-, „NICHT MERGEN“-, +- STOPP-Gate für `pr.merge` und `pr.review` mit `APPROVE` (#18): Ein STOPP-, „NICHT MERGEN“-, „do not merge“- oder `REQUEST_CHANGES`-Signal in PR-Kommentaren, Inline-Review-Kommentaren oder Reviews hält Approve und Merge an, unabhängig vom Konto. Aufheben kann es nur eine spätere eigene Zeile `STOPP aufgehoben` (o. ä.) desselben Kontos oder eines Kontos aus @@ -34,6 +48,10 @@ Format: [Keep a Changelog](https://keepachangelog.com/de/1.1.0/), [Semantic Vers by its `multi_bot` switch. New `act` command; the run contract reports `effective_enabled`. - Prompt und Rollen-JSON mit festem LF (`.gitattributes`), damit der Policy-Hash nicht vom Checkout abhängt / prompt and role JSON pinned to LF so the policy hash is checkout-independent. +- Ship neutral MULTI-BOT Windows/POSIX starters, German prompt and runtime helpers in wheel/sdist. +- Export separate MULTI-BOT role descriptors using the strict existing schema; preserve system-agent unchanged. +- Delegate optional provider launching to TASKPLAN; missing dependency fails closed with an install hint. +- Keep roots, accounts, authentication and full-access settings in explicit private instance configuration. ### Geändert / Changed @@ -76,11 +94,3 @@ Format: [Keep a Changelog](https://keepachangelog.com/de/1.1.0/), [Semantic Vers - Credential-Adapter (Umgebung, `gh auth token`) mit Schwärzung / credential adapter with redaction. - Namensraumunabhängiges Exact-SHA-Review-Gate samt Workflow-Scaffold / namespace-independent exact-SHA review gate with workflow scaffold. - - -## Unreleased - -- Ship neutral MULTI-BOT Windows/POSIX starters, German prompt and runtime helpers in wheel/sdist. -- Export separate MULTI-BOT role descriptors using the strict existing schema; preserve system-agent unchanged. -- Delegate optional provider launching to TASKPLAN; missing dependency fails closed with an install hint. -- Keep roots, accounts, authentication and full-access settings in explicit private instance configuration. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16169f6..6f56a84 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Vielen Dank für Ihr Interesse, zu diesem Projekt beizutragen! -### Wie Sie beitragen koennen +### Wie Sie beitragen können 1. **Bug melden:** Erstellen Sie ein Issue mit dem Label `bug` 2. **Feature vorschlagen:** Erstellen Sie ein Issue mit dem Label `enhancement` diff --git a/README.md b/README.md index 4b65c16..4a2b222 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ pull-request summaries, read-only health/traffic/star reports, a preview/apply c write, a plugin SPI and signed exact-SHA review receipts. Pure Python standard library, no runtime dependencies. -> Status: alpha (0.2.1). The CLI, the JSON result envelope and SPI version 1 are the contract; +> Status: alpha (0.2.2). The CLI, the JSON result envelope and SPI version 1 are the contract; > everything else may still change. ## Features diff --git a/README_de.md b/README_de.md index bc319d9..0f77a1a 100644 --- a/README_de.md +++ b/README_de.md @@ -47,7 +47,7 @@ Duplikaterkennung, Pull-Request-Zusammenfassungen, lesende Berichte zu Gesundhei Sternen, ein Vorschau-/Ausführungsvertrag für jede Schreibaktion, eine Plugin-Schnittstelle (SPI) und signierte Exact-SHA-Review-Belege. Reine Python-Standardbibliothek, keine Laufzeitabhängigkeiten. -> Status: Alpha (0.2.1). Verbindlich sind CLI, JSON-Ergebnishülle und SPI-Version 1; alles andere +> Status: Alpha (0.2.2). Verbindlich sind CLI, JSON-Ergebnishülle und SPI-Version 1; alles andere > kann sich noch ändern. ## Funktionen diff --git a/ellmos-module.v2.json b/ellmos-module.v2.json index 487ff29..e02a64a 100644 --- a/ellmos-module.v2.json +++ b/ellmos-module.v2.json @@ -2,7 +2,7 @@ "schema": "ellmos.module.v2", "id": "githubbot-core", "display_name": "githubbot-core", - "version": "0.2.1", + "version": "0.2.2", "category": "tools", "kind": "tool", "status": "alpha", diff --git a/src/githubbot_core/__init__.py b/src/githubbot_core/__init__.py index a08acfd..7871001 100644 --- a/src/githubbot_core/__init__.py +++ b/src/githubbot_core/__init__.py @@ -5,4 +5,4 @@ a plugin SPI and signed exact-SHA review receipts. Standard library only. """ -__version__ = "0.2.1" +__version__ = "0.2.2" diff --git a/src/githubbot_core/actions.py b/src/githubbot_core/actions.py index adffd92..8a08836 100644 --- a/src/githubbot_core/actions.py +++ b/src/githubbot_core/actions.py @@ -18,7 +18,7 @@ from pathlib import Path from typing import Any, Optional -from . import typed_actions, write_scope +from . import stop_gate, typed_actions, write_scope from .coordination import Coordinator, Hold WRITE_METHODS = {"POST", "PUT", "PATCH", "DELETE"} @@ -55,8 +55,10 @@ def denial_reason(action: Action, config: dict) -> Optional[str]: return f"{action.kind} is not enabled in permissions.enabled" if action.kind not in EXECUTORS: return f"{action.kind} has no executor" - reason = typed_actions.switch_denial(action.kind, config) or typed_actions.param_denial( - action.kind, action.params, config + reason = ( + typed_actions.switch_denial(action.kind, config) + or typed_actions.param_denial(action.kind, action.params, config) + or stop_gate.write_denial(action.kind, action.params, config) ) if reason: return reason diff --git a/src/githubbot_core/prompts/MULTI-BOT.de.md b/src/githubbot_core/prompts/MULTI-BOT.de.md index b425556..e372e7e 100644 --- a/src/githubbot_core/prompts/MULTI-BOT.de.md +++ b/src/githubbot_core/prompts/MULTI-BOT.de.md @@ -140,7 +140,13 @@ Inline-Review-Kommentare und Reviews. Ein STOPP, „NICHT MERGEN“, „do not m 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 -`cleared to merge`. Fragen, Verneinungen und Zusätze in dieser Zeile zählen nicht. Daneben hebt +`cleared to merge`. Fragen, Verneinungen und Zusätze in dieser Zeile zählen nicht. Eine Freigabe +ist ein eigener Kommentar und enthält nur die Formelzeile. Das Wort STOPP und jedes andere +Stoppsignal kommen sonst nirgends darin vor, auch nicht in Begründung oder Rückblick: Sonst zählt +der Kommentar selbst als neuer STOPP. Befund und Begründung gehören in einen eigenen Kommentar +davor. Zitierte, eingerückte oder in Codeblöcken stehende Formeln heben nicht auf. Schreibst du +unter einem Owner-Konto (Fallback oder `stop_release_accounts`), postest du keine Freigabe; der +Core verweigert sie. Daneben hebt ein späteres Approve desselben Kontos auf, wenn es auf einem nachweislich neueren Head steht als dem im STOPP genannten. Nennt der STOPP keinen Head, gilt nur die Formel. Das Merge-Konto hebt nie durch Approve auf. Ist Auto-Merge auf einem gehaltenen PR scharf, nennt der HOLD das. Dann diff --git a/src/githubbot_core/stop_gate.py b/src/githubbot_core/stop_gate.py index 9b190db..cb1d2ff 100644 --- a/src/githubbot_core/stop_gate.py +++ b/src/githubbot_core/stop_gate.py @@ -39,8 +39,9 @@ def _release_lines(text: str) -> list[tuple[str, bool]]: - """(line, counts as release). Quoted lines and lines in code fences never release: - a quote-reply repeats someone else's words, a fence shows text instead of saying it.""" + """(line, counts as release). Quoted lines, lines in code fences and indented lines never + release: a quote-reply repeats someone else's words, a code block shows text instead of + saying it. Any line indented by a tab or four spaces counts as an indented code block.""" result, fence = [], None for raw in text.splitlines(): stripped = raw.strip() @@ -54,6 +55,9 @@ def _release_lines(text: str) -> list[tuple[str, bool]]: fence = marker[1] result.append((raw, False)) continue + if raw.startswith(("\t", " ")): # ponytail: also hides list-nested lines; strict on purpose + result.append((raw, False)) + continue line = re.sub(r"\s+", " ", stripped.strip("*_#").strip()) # ">" and backticks are deliberately not stripped: a quote line never fullmatches. result.append((raw, bool(_RELEASE_LINE.fullmatch(line)))) @@ -64,6 +68,35 @@ def _is_release(text: str) -> bool: return any(release for _, release in _release_lines(text)) +def write_denial(kind: str, params: dict, config: dict) -> Optional[str]: + """Under an owner account the bot never posts a STOPP release line. + + A release is the act of the stopping instance or the owner. In the owner fallback + (``multi_bot.owner_fallback``) or under a ``stop_release_accounts`` account the bot + writes as that account, so its comment with the formula would lift stops itself. + """ + from .multibot import policy_settings + + settings = config.get("multi_bot") or {} + try: + owners = {a.casefold() for a in policy_settings(settings.get("policy"))["stop_release_accounts"]} + except ValueError: + owners = set() # an invalid policy already denies through switch_denial/hold_reason + account = str(settings.get("merge_account") or "").strip().casefold() + if settings.get("owner_fallback") is not True and account not in owners: + return None + body = params.get("body") + if kind == "api.request": + if not str(params.get("endpoint", "")).rstrip("/").endswith(("/comments", "/reviews")): + return None + body = body.get("body") if isinstance(body, dict) else body + elif kind not in ("issue.comment", "pr.review"): + return None + if isinstance(body, str) and _is_release(body): + return f"{kind} body contains a STOPP release line; under an owner account the bot never lifts a stop" + return None + + def _is_stop(text: str) -> bool: rest = "\n".join(line for line, release in _release_lines(text) if not release) rest = _NEGATED.sub(" ", rest) diff --git a/tests/test_stop_gate.py b/tests/test_stop_gate.py index 50270b9..2b0259b 100644 --- a/tests/test_stop_gate.py +++ b/tests/test_stop_gate.py @@ -82,6 +82,9 @@ def approved(login="instance", commit=SHA): "quote_only": ([STOP, later("> STOPP aufgehoben")], [], True), "fenced_formula": ([STOP, later("```\nSTOPP aufgehoben\n```")], [], True), "tilde_fenced_formula": ([STOP, later("~~~text\nSTOPP aufgehoben\n~~~")], [], True), + # 0.2.2: an indented code block shows the formula instead of saying it + "indented_code_formula": ([STOP, later("Beispiel:\n\n STOPP aufgehoben")], [], True), + "tab_indented_formula": ([STOP, later("\tMerge freigegeben")], [], True), # lifts "release_after_closed_fence": ([STOP, later("```\nlog\n```\nSTOPP aufgehoben")], [], False), "release_own_line": ([STOP, later("Nachmessung grün.\nSTOPP aufgehoben")], [], False), @@ -219,6 +222,42 @@ def test_without_stop_signal_merge_and_approve_proceed(): assert approve(Transport(plain))["receipts"][0]["status"] == "applied" +FORMULA = "Nachmessung grün.\nSTOPP aufgehoben" +WRITES = [ + ("issue.comment", {"repo": REPO, "number": 7, "body": FORMULA}), + ("pr.review", {"repo": REPO, "number": 7, "sha": SHA, "event": "COMMENT", "body": FORMULA}), + ("api.request", {"method": "POST", "endpoint": f"repos/{REPO}/issues/7/comments", "body": {"body": FORMULA}}), + ("api.request", {"method": "POST", "endpoint": f"/repos/{REPO}/pulls/7/reviews/", "body": {"body": FORMULA}}), +] + + +def fallback_config(**multi_bot): + layer = { + "permissions": {"enabled": ["issue.comment", "pr.review", "api.request"], "write_owners": ["example-org"]}, + "multi_bot": {"merge_account": "owner-account", "policy": {"publish_reviews": True}, **multi_bot}, + } + return merge_layers([("default", default_config()), ("instance", layer)]) + + +@pytest.mark.parametrize("kind,params", WRITES) +def test_bot_under_owner_account_never_posts_a_release_line(kind, params): + for cfg in ( + fallback_config(owner_fallback=True), + fallback_config(policy={"publish_reviews": True, "stop_release_accounts": ["Owner-Account"]}), + ): + assert "release line" in (stop_gate.write_denial(kind, params, cfg) or "") + assert "release line" in (actions.denial_reason(Action(kind, params), cfg) or "") + + +def test_release_lines_stay_allowed_outside_the_owner_fallback(): + for kind, params in WRITES: + assert stop_gate.write_denial(kind, params, fallback_config()) is None + quoted = {"repo": REPO, "number": 7, "body": "> STOPP aufgehoben\n\nNoch offen."} + assert stop_gate.write_denial("issue.comment", quoted, fallback_config(owner_fallback=True)) is None + labels = {"repo": REPO, "number": 7, "labels": ["STOPP aufgehoben"]} + assert stop_gate.write_denial("issue.add_labels", labels, fallback_config(owner_fallback=True)) is None + + @pytest.mark.parametrize("endpoint", [COMMENTS, INLINE, REVIEWS]) def test_unreadable_lists_fail_closed(endpoint): transport = Transport(PROMPTBOARD_8)