Skip to content

Commit e5cfe64

Browse files
Merge pull request #19 from dev-bricks/fix/stop-gate-0.2.2
fix(stop-gate): no release by indented code or by the bot under an owner account (0.2.2)
2 parents e270808 + afabc94 commit e5cfe64

10 files changed

Lines changed: 110 additions & 20 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,23 @@ Format: [Keep a Changelog](https://keepachangelog.com/de/1.1.0/), [Semantic Vers
66

77
## [Unreleased]
88

9+
## [0.2.2] - 2026-11-22
10+
11+
### Behoben / Fixed
12+
13+
- STOPP-Gate: Eine Freigabeformel in einem eingerückten Codeblock (Tab oder vier Leerzeichen)
14+
hebt nicht mehr auf, gleich behandelt wie Fences und Zitate / an indented code block line
15+
never counts as a release.
16+
- STOPP-Gate: Schreibt der Bot unter einem Owner-Konto (`multi_bot.owner_fallback: true` oder
17+
`merge_account` in `policy.stop_release_accounts`), verweigern `issue.comment`, `pr.review` und
18+
`api.request` auf Kommentar-/Review-Endpunkte jeden Text mit Freigabezeile. So hebt der Bot im
19+
Owner-Fallback keinen STOPP selbst auf / under an owner account the bot never posts a release
20+
line. Labels mit Auto-Merge-Wirkung wurden geprüft: Kein Workflow der betreuten Organisationen
21+
merged auf ein Label, daher keine Label-Sperre / no label-driven auto-merge workflow exists.
22+
923
### Hinzugefügt / Added
1024

11-
- STOPP-Gate für `pr.merge` und `pr.review` mit `APPROVE`: Ein STOPP-, „NICHT MERGEN“-,
25+
- STOPP-Gate für `pr.merge` und `pr.review` mit `APPROVE` (#18): Ein STOPP-, „NICHT MERGEN“-,
1226
„do not merge“- oder `REQUEST_CHANGES`-Signal in PR-Kommentaren, Inline-Review-Kommentaren
1327
oder Reviews hält Approve und Merge an, unabhängig vom Konto. Aufheben kann es nur eine spätere
1428
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
3448
by its `multi_bot` switch. New `act` command; the run contract reports `effective_enabled`.
3549
- Prompt und Rollen-JSON mit festem LF (`.gitattributes`), damit der Policy-Hash nicht vom
3650
Checkout abhängt / prompt and role JSON pinned to LF so the policy hash is checkout-independent.
51+
- Ship neutral MULTI-BOT Windows/POSIX starters, German prompt and runtime helpers in wheel/sdist.
52+
- Export separate MULTI-BOT role descriptors using the strict existing schema; preserve system-agent unchanged.
53+
- Delegate optional provider launching to TASKPLAN; missing dependency fails closed with an install hint.
54+
- Keep roots, accounts, authentication and full-access settings in explicit private instance configuration.
3755

3856
### Geändert / Changed
3957

@@ -76,11 +94,3 @@ Format: [Keep a Changelog](https://keepachangelog.com/de/1.1.0/), [Semantic Vers
7694
- Credential-Adapter (Umgebung, `gh auth token`) mit Schwärzung / credential adapter with redaction.
7795
- Namensraumunabhängiges Exact-SHA-Review-Gate samt Workflow-Scaffold /
7896
namespace-independent exact-SHA review gate with workflow scaffold.
79-
80-
81-
## Unreleased
82-
83-
- Ship neutral MULTI-BOT Windows/POSIX starters, German prompt and runtime helpers in wheel/sdist.
84-
- Export separate MULTI-BOT role descriptors using the strict existing schema; preserve system-agent unchanged.
85-
- Delegate optional provider launching to TASKPLAN; missing dependency fails closed with an install hint.
86-
- Keep roots, accounts, authentication and full-access settings in explicit private instance configuration.

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Vielen Dank für Ihr Interesse, zu diesem Projekt beizutragen!
66

7-
### Wie Sie beitragen koennen
7+
### Wie Sie beitragen können
88

99
1. **Bug melden:** Erstellen Sie ein Issue mit dem Label `bug`
1010
2. **Feature vorschlagen:** Erstellen Sie ein Issue mit dem Label `enhancement`

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pull-request summaries, read-only health/traffic/star reports, a preview/apply c
5454
write, a plugin SPI and signed exact-SHA review receipts. Pure Python standard library, no runtime
5555
dependencies.
5656

57-
> Status: alpha (0.2.1). The CLI, the JSON result envelope and SPI version 1 are the contract;
57+
> Status: alpha (0.2.2). The CLI, the JSON result envelope and SPI version 1 are the contract;
5858
> everything else may still change.
5959
6060
## Features

‎README_de.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Duplikaterkennung, Pull-Request-Zusammenfassungen, lesende Berichte zu Gesundhei
4747
Sternen, ein Vorschau-/Ausführungsvertrag für jede Schreibaktion, eine Plugin-Schnittstelle (SPI)
4848
und signierte Exact-SHA-Review-Belege. Reine Python-Standardbibliothek, keine Laufzeitabhängigkeiten.
4949

50-
> Status: Alpha (0.2.1). Verbindlich sind CLI, JSON-Ergebnishülle und SPI-Version 1; alles andere
50+
> Status: Alpha (0.2.2). Verbindlich sind CLI, JSON-Ergebnishülle und SPI-Version 1; alles andere
5151
> kann sich noch ändern.
5252
5353
## Funktionen

‎ellmos-module.v2.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"schema": "ellmos.module.v2",
33
"id": "githubbot-core",
44
"display_name": "githubbot-core",
5-
"version": "0.2.1",
5+
"version": "0.2.2",
66
"category": "tools",
77
"kind": "tool",
88
"status": "alpha",

‎src/githubbot_core/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
a plugin SPI and signed exact-SHA review receipts. Standard library only.
66
"""
77

8-
__version__ = "0.2.1"
8+
__version__ = "0.2.2"

‎src/githubbot_core/actions.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from pathlib import Path
1919
from typing import Any, Optional
2020

21-
from . import typed_actions, write_scope
21+
from . import stop_gate, typed_actions, write_scope
2222
from .coordination import Coordinator, Hold
2323

2424
WRITE_METHODS = {"POST", "PUT", "PATCH", "DELETE"}
@@ -55,8 +55,10 @@ def denial_reason(action: Action, config: dict) -> Optional[str]:
5555
return f"{action.kind} is not enabled in permissions.enabled"
5656
if action.kind not in EXECUTORS:
5757
return f"{action.kind} has no executor"
58-
reason = typed_actions.switch_denial(action.kind, config) or typed_actions.param_denial(
59-
action.kind, action.params, config
58+
reason = (
59+
typed_actions.switch_denial(action.kind, config)
60+
or typed_actions.param_denial(action.kind, action.params, config)
61+
or stop_gate.write_denial(action.kind, action.params, config)
6062
)
6163
if reason:
6264
return reason

‎src/githubbot_core/prompts/MULTI-BOT.de.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,13 @@ Inline-Review-Kommentare und Reviews. Ein STOPP, „NICHT MERGEN“, „do not m
140140
oder ein Review mit Änderungswunsch ist HOLD, egal unter welchem Konto er steht. Aufheben kann
141141
ihn nur dasselbe Konto oder ein Konto aus `stop_release_accounts`, und zwar mit einer eigenen
142142
Zeile, die nur die Formel enthält: `STOPP aufgehoben`, `STOP lifted`, `Merge freigegeben` oder
143-
`cleared to merge`. Fragen, Verneinungen und Zusätze in dieser Zeile zählen nicht. Daneben hebt
143+
`cleared to merge`. Fragen, Verneinungen und Zusätze in dieser Zeile zählen nicht. Eine Freigabe
144+
ist ein eigener Kommentar und enthält nur die Formelzeile. Das Wort STOPP und jedes andere
145+
Stoppsignal kommen sonst nirgends darin vor, auch nicht in Begründung oder Rückblick: Sonst zählt
146+
der Kommentar selbst als neuer STOPP. Befund und Begründung gehören in einen eigenen Kommentar
147+
davor. Zitierte, eingerückte oder in Codeblöcken stehende Formeln heben nicht auf. Schreibst du
148+
unter einem Owner-Konto (Fallback oder `stop_release_accounts`), postest du keine Freigabe; der
149+
Core verweigert sie. Daneben hebt
144150
ein späteres Approve desselben Kontos auf, wenn es auf einem nachweislich neueren Head steht als
145151
dem im STOPP genannten. Nennt der STOPP keinen Head, gilt nur die Formel. Das Merge-Konto hebt
146152
nie durch Approve auf. Ist Auto-Merge auf einem gehaltenen PR scharf, nennt der HOLD das. Dann

‎src/githubbot_core/stop_gate.py‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939

4040

4141
def _release_lines(text: str) -> list[tuple[str, bool]]:
42-
"""(line, counts as release). Quoted lines and lines in code fences never release:
43-
a quote-reply repeats someone else's words, a fence shows text instead of saying it."""
42+
"""(line, counts as release). Quoted lines, lines in code fences and indented lines never
43+
release: a quote-reply repeats someone else's words, a code block shows text instead of
44+
saying it. Any line indented by a tab or four spaces counts as an indented code block."""
4445
result, fence = [], None
4546
for raw in text.splitlines():
4647
stripped = raw.strip()
@@ -54,6 +55,9 @@ def _release_lines(text: str) -> list[tuple[str, bool]]:
5455
fence = marker[1]
5556
result.append((raw, False))
5657
continue
58+
if raw.startswith(("\t", " ")): # ponytail: also hides list-nested lines; strict on purpose
59+
result.append((raw, False))
60+
continue
5761
line = re.sub(r"\s+", " ", stripped.strip("*_#").strip())
5862
# ">" and backticks are deliberately not stripped: a quote line never fullmatches.
5963
result.append((raw, bool(_RELEASE_LINE.fullmatch(line))))
@@ -64,6 +68,35 @@ def _is_release(text: str) -> bool:
6468
return any(release for _, release in _release_lines(text))
6569

6670

71+
def write_denial(kind: str, params: dict, config: dict) -> Optional[str]:
72+
"""Under an owner account the bot never posts a STOPP release line.
73+
74+
A release is the act of the stopping instance or the owner. In the owner fallback
75+
(``multi_bot.owner_fallback``) or under a ``stop_release_accounts`` account the bot
76+
writes as that account, so its comment with the formula would lift stops itself.
77+
"""
78+
from .multibot import policy_settings
79+
80+
settings = config.get("multi_bot") or {}
81+
try:
82+
owners = {a.casefold() for a in policy_settings(settings.get("policy"))["stop_release_accounts"]}
83+
except ValueError:
84+
owners = set() # an invalid policy already denies through switch_denial/hold_reason
85+
account = str(settings.get("merge_account") or "").strip().casefold()
86+
if settings.get("owner_fallback") is not True and account not in owners:
87+
return None
88+
body = params.get("body")
89+
if kind == "api.request":
90+
if not str(params.get("endpoint", "")).rstrip("/").endswith(("/comments", "/reviews")):
91+
return None
92+
body = body.get("body") if isinstance(body, dict) else body
93+
elif kind not in ("issue.comment", "pr.review"):
94+
return None
95+
if isinstance(body, str) and _is_release(body):
96+
return f"{kind} body contains a STOPP release line; under an owner account the bot never lifts a stop"
97+
return None
98+
99+
67100
def _is_stop(text: str) -> bool:
68101
rest = "\n".join(line for line, release in _release_lines(text) if not release)
69102
rest = _NEGATED.sub(" ", rest)

‎tests/test_stop_gate.py‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def approved(login="instance", commit=SHA):
8282
"quote_only": ([STOP, later("> STOPP aufgehoben")], [], True),
8383
"fenced_formula": ([STOP, later("```\nSTOPP aufgehoben\n```")], [], True),
8484
"tilde_fenced_formula": ([STOP, later("~~~text\nSTOPP aufgehoben\n~~~")], [], True),
85+
# 0.2.2: an indented code block shows the formula instead of saying it
86+
"indented_code_formula": ([STOP, later("Beispiel:\n\n STOPP aufgehoben")], [], True),
87+
"tab_indented_formula": ([STOP, later("\tMerge freigegeben")], [], True),
8588
# lifts
8689
"release_after_closed_fence": ([STOP, later("```\nlog\n```\nSTOPP aufgehoben")], [], False),
8790
"release_own_line": ([STOP, later("Nachmessung grün.\nSTOPP aufgehoben")], [], False),
@@ -219,6 +222,42 @@ def test_without_stop_signal_merge_and_approve_proceed():
219222
assert approve(Transport(plain))["receipts"][0]["status"] == "applied"
220223

221224

225+
FORMULA = "Nachmessung grün.\nSTOPP aufgehoben"
226+
WRITES = [
227+
("issue.comment", {"repo": REPO, "number": 7, "body": FORMULA}),
228+
("pr.review", {"repo": REPO, "number": 7, "sha": SHA, "event": "COMMENT", "body": FORMULA}),
229+
("api.request", {"method": "POST", "endpoint": f"repos/{REPO}/issues/7/comments", "body": {"body": FORMULA}}),
230+
("api.request", {"method": "POST", "endpoint": f"/repos/{REPO}/pulls/7/reviews/", "body": {"body": FORMULA}}),
231+
]
232+
233+
234+
def fallback_config(**multi_bot):
235+
layer = {
236+
"permissions": {"enabled": ["issue.comment", "pr.review", "api.request"], "write_owners": ["example-org"]},
237+
"multi_bot": {"merge_account": "owner-account", "policy": {"publish_reviews": True}, **multi_bot},
238+
}
239+
return merge_layers([("default", default_config()), ("instance", layer)])
240+
241+
242+
@pytest.mark.parametrize("kind,params", WRITES)
243+
def test_bot_under_owner_account_never_posts_a_release_line(kind, params):
244+
for cfg in (
245+
fallback_config(owner_fallback=True),
246+
fallback_config(policy={"publish_reviews": True, "stop_release_accounts": ["Owner-Account"]}),
247+
):
248+
assert "release line" in (stop_gate.write_denial(kind, params, cfg) or "")
249+
assert "release line" in (actions.denial_reason(Action(kind, params), cfg) or "")
250+
251+
252+
def test_release_lines_stay_allowed_outside_the_owner_fallback():
253+
for kind, params in WRITES:
254+
assert stop_gate.write_denial(kind, params, fallback_config()) is None
255+
quoted = {"repo": REPO, "number": 7, "body": "> STOPP aufgehoben\n\nNoch offen."}
256+
assert stop_gate.write_denial("issue.comment", quoted, fallback_config(owner_fallback=True)) is None
257+
labels = {"repo": REPO, "number": 7, "labels": ["STOPP aufgehoben"]}
258+
assert stop_gate.write_denial("issue.add_labels", labels, fallback_config(owner_fallback=True)) is None
259+
260+
222261
@pytest.mark.parametrize("endpoint", [COMMENTS, INLINE, REVIEWS])
223262
def test_unreadable_lists_fail_closed(endpoint):
224263
transport = Transport(PROMPTBOARD_8)

0 commit comments

Comments
 (0)