Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README_de.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ellmos-module.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/githubbot_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
a plugin SPI and signed exact-SHA review receipts. Standard library only.
"""

__version__ = "0.2.2"
__version__ = "0.3.0"
134 changes: 133 additions & 1 deletion tests/test_coordination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down Expand Up @@ -1155,3 +1155,135 @@ 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"
Loading