From 2b9b6fb28727e1116a98cc7838ec5ed5f7bf9dae Mon Sep 17 00:00:00 2001 From: Lukas Geiger Date: Mon, 30 Nov 2026 08:52:16 +0100 Subject: [PATCH 1/2] release: 0.3.0, journal-block tests for all bound kinds - Version 0.3.0 (marker schema gained `read` and `action`; older versions fail closed into HOLD, so all runtimes of a host switch together). - Tests: the action journal keeps blocking after the cooldown for every journal-bound kind (not only pr.merge); rename the stale timeout test. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01THB2EzGbmyMB2S1P43LDZb --- CHANGELOG.md | 10 +++ README.md | 2 +- README_de.md | 2 +- ellmos-module.v2.json | 2 +- src/githubbot_core/__init__.py | 2 +- tests/test_coordination.py | 114 ++++++++++++++++++++++++++++++++- 6 files changed, 127 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f505756..a521dbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ Format: [Keep a Changelog](https://keepachangelog.com/de/1.1.0/), [Semantic Vers ## [Unreleased] +## [0.3.0] - 2026-11-30 + +### Geändert / Changed + +- Transport-Koordination, Marker-Schema: Die Marker-Datei `github-com-request.json` trägt zwei neue optionale Felder, `read` (ein unbestätigter Lesezugriff, wird nach 60 s Abkühlung selbst aufgelöst) und `action` (Schlüssel des Aktionsjournals, an das ein Schreibzugriff vor dem Effekt gebunden wurde). **Ältere Versionen werten Marker mit diesen Feldern als ungültig und gehen fail-closed in HOLD; deshalb alle Runtimes, die dasselbe Koordinationsverzeichnis nutzen, eines Hosts gemeinsam auf 0.3.0 umstellen.** Marker ohne `read`/`action` (auch Altmarker) bleiben operator HOLD und lösen sich nicht selbst auf / the request marker gains two optional fields, `read` and `action`; older versions treat such a marker as invalid and fail closed into HOLD, so upgrade every runtime sharing one coordination directory on a host together; markers without them stay operator HOLD (T-20261130-823189295). + +### Tests + +- Das Aktionsjournal blockiert nach Ablauf der Abkühlung weiter für alle journalgebundenen Kinds (`issue.comment`, `issue.add_labels`, `actions.dispatch`, `actions.rerun`, `pr.create`, `pr.review`, `pr.close`, `git.push_branch`), nicht nur für `pr.merge`; `test_timeout_and_restart_keep_request_marker_without_retry` heißt jetzt `test_timeout_settles_read_marker_into_cooldown_and_restart_sends_nothing` / the action journal keeps blocking after the cooldown for every journal-bound kind, not only `pr.merge`; one test renamed to match its behaviour (#24 follow-up). + ### Behoben / Fixed - Transport-Koordination: Ein unbestätigter Lesezugriff (GET) hinterlässt keinen dauerhaften host-weiten Unsicherheitsmarker mehr, sondern eine 60-Sekunden-Abkühlung; ebenso ein an das Aktionsjournal gebundener Schreibzugriff, dessen Wirkungsunsicherheit im Journal bleibt, bis der Ziel-Readback sie auflöst (Merge: eingetreten oder ausgeblieben). Ungebundene Schreibzugriffe und Marker älterer Versionen bleiben im HOLD. Ein Transportfehler beim Identitätsabruf (`pr.merge`, `pr.review`, `pr.close`, `git.push_branch`) wird nicht mehr als falsche Identität gemeldet. Der Merge-Readback nutzt bei fehlendem `merge_commit_sha` (REST 2026-03-10) die GraphQL-Leseabfrage / an unconfirmed GET now settles into a 60 s cooldown instead of a permanent host-wide uncertainty HOLD, as does a journal-bound write whose effect uncertainty stays in the action journal until the target readback resolves it; identity transport failures get their own error text (T-20261130-841353723). diff --git a/README.md b/README.md index 4a2b222..a86bdad 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.2). The CLI, the JSON result envelope and SPI version 1 are the contract; +> Status: alpha (0.3.0). 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 0f77a1a..8c7e62c 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.2). Verbindlich sind CLI, JSON-Ergebnishülle und SPI-Version 1; alles andere +> Status: Alpha (0.3.0). 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 e02a64a..a4f1ad2 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.2", + "version": "0.3.0", "category": "tools", "kind": "tool", "status": "alpha", diff --git a/src/githubbot_core/__init__.py b/src/githubbot_core/__init__.py index 7871001..f31d9e9 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.2" +__version__ = "0.3.0" diff --git a/tests/test_coordination.py b/tests/test_coordination.py index 6418f90..6ddeb47 100644 --- a/tests/test_coordination.py +++ b/tests/test_coordination.py @@ -737,7 +737,7 @@ def run(*args, **kw): assert Coordinator(root).load("github-com-rate")["not_before"] > time.time() -def test_timeout_and_restart_keep_request_marker_without_retry(tmp_path): +def test_timeout_settles_read_marker_into_cooldown_and_restart_sends_nothing(tmp_path): root = tmp_path / "timeout-marker" calls = [] @@ -1155,3 +1155,115 @@ def puts(): # Negative control: no definitive readback -> the action stays in HOLD. assert second["status"] == "failed" and "unknown write HOLD" in second["detail"] assert c.load(key)["status"] == "unknown" + + +def _failing_write_cases(): + """(id, action, transport factory, config) per journal-bound kind; every write fails without a trace.""" + import datetime + + import test_pr_close_action as close + import test_pr_review_action as review + import test_typed_actions as typed + from githubbot_core.actions import Action + + class Failing(typed.Transport): + def request(self, method, endpoint, body=None): + self.writes.append((method, endpoint, body)) + return None, "HTTP 500" + + def review_transport(): + t = review.Transport() + t.write_error = "HTTP 500" + t.request = lambda m, e, b: (t.writes.append((m, e, b)), (None, "HTTP 500"))[1] # no review is left behind + return t + + def close_transport(): + t = close.Transport() + t.write_error = "HTTP 500" + return t + + def gets(**more): + return {**typed.base_gets(), **more} + + run = {"head_sha": typed.SHA, "status": "completed", "head_repository": {"full_name": typed.REPO}} + run["created_at"] = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") + cfg = typed.config(enabled=[*typed.ALL, "issue.add_labels"]) + repo = typed.REPO + return [ + ("issue.comment", Action("issue.comment", {"repo": repo, "number": 1, "body": "synthetic"}), + lambda: Failing(gets()), cfg), + ("issue.add_labels", Action("issue.add_labels", {"repo": repo, "number": 1, "labels": ["bug"]}), + lambda: Failing(gets()), cfg), + ("actions.dispatch", Action("actions.dispatch", {"repo": repo, "workflow": "ci.yml", "ref": "bot/fix"}), + lambda: Failing(gets(**{f"repos/{repo}/actions/workflows/ci.yml": {"state": "active"}})), cfg), + ("actions.rerun", Action("actions.rerun", {"repo": repo, "run_id": 5, "sha": typed.SHA}), + lambda: Failing(gets(**{f"repos/{repo}/actions/runs/5": run})), cfg), + ("pr.create", Action("pr.create", {"repo": repo, "branch": "bot/fix", "title": "fix: x", "body": "Problem, tests"}), + lambda: Failing(gets()), cfg), + ("pr.review", review.action(), review_transport, review.config()), + ("pr.close", close.action(), close_transport, close.config()), + ] + + +@pytest.mark.parametrize("case", range(7)) +def test_unknown_write_journal_keeps_blocking_after_cooldown_for_every_bound_kind(tmp_path, case): + # Pattern of review probe P2b: after the cooldown the journal alone must still stop a fresh write. + # (Fake transports set no cooldown, so everything that blocks here is the journal.) + from githubbot_core.actions import apply + + name, action, make, cfg = _failing_write_cases()[case] + c = Coordinator(tmp_path / name) + key = c.action_key(action.action_id) + + first = make() + first.coordinator = c + r = apply([action], first, cfg)["receipts"][0] + assert r["status"] == "failed" and len(first.writes) == 1, (name, r) + assert c.load(key)["status"] == "unknown" + + for _ in range(2): # a fresh process, repeatedly: read-only reconciliation never repeats the write + second = make() + second.coordinator = Coordinator(c.root, clock=lambda: 2 * 10**9) + r = apply([action], second, cfg)["receipts"][0] + assert r["status"] == "failed" and "unknown write HOLD" in r["detail"], (name, r) + assert second.writes == [] and c.load(key)["status"] == "unknown" + + +def test_unknown_push_journal_keeps_blocking_after_cooldown(tmp_path, monkeypatch): + import test_typed_actions as typed + from githubbot_core import typed_actions + from githubbot_core.actions import apply + + typed._mock_push_token(monkeypatch) + pushes = [] + + def git(cmd, **kw): + if "push" in cmd: + pushes.append(cmd) + return typed._fake_git_output( + cmd, + origin=f"https://github.com/{typed.REPO}.git", + pushurl=f"https://github.com/{typed.REPO}.git", + fail_push="push" in cmd, + ) + + monkeypatch.setattr(typed_actions, "_git", git) + c = Coordinator(tmp_path / "push") + action = typed._push_action() + key = c.action_key(action.action_id) + t = typed._push_transport() + t.coordinator = c + assert apply([action], t, typed.config())["receipts"][0]["status"] == "failed" and len(pushes) == 1 + assert c.load(key)["status"] == "unknown" + # The failed push left a journal-bound marker. The next transport holder (a read here) settles it + # into the cooldown; once that has passed, only the journal still blocks the push. + now = [2 * 10**9] + reader = GhCliTransport(runner=lambda *a, **kw: reply(), coordinator=Coordinator(c.root, clock=lambda: now[0])) + assert reader.get("user")[1] and not (c.root / "github-com-request.json").exists() + for step in (61, 10**6): + now[0] = 2 * 10**9 + step + t = typed._push_transport() + t.coordinator = Coordinator(c.root, clock=lambda: now[0]) + r = apply([action], t, typed.config())["receipts"][0] + assert r["status"] == "failed" and "unknown write HOLD" in r["detail"] and len(pushes) == 1 + assert c.load(key)["status"] == "unknown" From cb9aab1227b1d978eb144cde777abb838771185b Mon Sep 17 00:00:00 2001 From: Lukas Geiger Date: Mon, 30 Nov 2026 08:56:43 +0100 Subject: [PATCH 2/2] style(tests): ruff format test_coordination.py (review #25) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die CI scheiterte an `ruff format --check`. Die Tupelliste in `_failing_write_cases` war nicht formatiert. Der Inhalt ist unverändert. Lokale Prüfung: - `ruff format --check .` und `ruff check .` sind sauber. - `tests/test_coordination.py`: 98 passed. T-20261130-823189295 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01THB2EzGbmyMB2S1P43LDZb --- tests/test_coordination.py | 40 ++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/tests/test_coordination.py b/tests/test_coordination.py index 6ddeb47..fbe00a4 100644 --- a/tests/test_coordination.py +++ b/tests/test_coordination.py @@ -1190,16 +1190,36 @@ def gets(**more): cfg = typed.config(enabled=[*typed.ALL, "issue.add_labels"]) repo = typed.REPO return [ - ("issue.comment", Action("issue.comment", {"repo": repo, "number": 1, "body": "synthetic"}), - lambda: Failing(gets()), cfg), - ("issue.add_labels", Action("issue.add_labels", {"repo": repo, "number": 1, "labels": ["bug"]}), - lambda: Failing(gets()), cfg), - ("actions.dispatch", Action("actions.dispatch", {"repo": repo, "workflow": "ci.yml", "ref": "bot/fix"}), - lambda: Failing(gets(**{f"repos/{repo}/actions/workflows/ci.yml": {"state": "active"}})), cfg), - ("actions.rerun", Action("actions.rerun", {"repo": repo, "run_id": 5, "sha": typed.SHA}), - lambda: Failing(gets(**{f"repos/{repo}/actions/runs/5": run})), cfg), - ("pr.create", Action("pr.create", {"repo": repo, "branch": "bot/fix", "title": "fix: x", "body": "Problem, tests"}), - lambda: Failing(gets()), cfg), + ( + "issue.comment", + Action("issue.comment", {"repo": repo, "number": 1, "body": "synthetic"}), + lambda: Failing(gets()), + cfg, + ), + ( + "issue.add_labels", + Action("issue.add_labels", {"repo": repo, "number": 1, "labels": ["bug"]}), + lambda: Failing(gets()), + cfg, + ), + ( + "actions.dispatch", + Action("actions.dispatch", {"repo": repo, "workflow": "ci.yml", "ref": "bot/fix"}), + lambda: Failing(gets(**{f"repos/{repo}/actions/workflows/ci.yml": {"state": "active"}})), + cfg, + ), + ( + "actions.rerun", + Action("actions.rerun", {"repo": repo, "run_id": 5, "sha": typed.SHA}), + lambda: Failing(gets(**{f"repos/{repo}/actions/runs/5": run})), + cfg, + ), + ( + "pr.create", + Action("pr.create", {"repo": repo, "branch": "bot/fix", "title": "fix: x", "body": "Problem, tests"}), + lambda: Failing(gets()), + cfg, + ), ("pr.review", review.action(), review_transport, review.config()), ("pr.close", close.action(), close_transport, close.config()), ]