Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(ci): wait for GitHub to compute mergeability before the merge train plans (#565)
Ruben Lütkec3218ad9f1b3
diff --git a/docs/ci-pipeline.md b/docs/ci-pipeline.mdindex dfa5c64248..7c36b360d4 100644--- a/docs/ci-pipeline.md+++ b/docs/ci-pipeline.md@@ -185,6 +185,9 @@ merge queue), and hourly as a safety net:(`scripts/ci/agent_integrate.py`). No force push, so an agent that keepspushing to its branch is never overwritten. A pull request that is merelybehind is left alone: the queue re-tests it on the newest main anyway.+ GitHub computes mergeability on demand, so right after a push to main+ the train asks again (up to a minute) until it knows which branches+ that push put in conflict.Three branches are updated per tick. The slots go first to pull requestswith green CI that only conflict with main, then to red ones, and last tothose already labelled `needs-rebase`: in number order the three oldestdiff --git a/scripts/ci/agent_integrate.py b/scripts/ci/agent_integrate.pyindex 38d474ab2c..723f8cff80 100644--- a/scripts/ci/agent_integrate.py+++ b/scripts/ci/agent_integrate.py@@ -47,6 +47,8 @@ import shutilimport subprocessimport sysimport tempfile+import time+from collections.abc import Callablefrom dataclasses import dataclass, fieldfrom pathlib import Path@@ -648,23 +650,54 @@ def grant_updates(wanted: list[dict[str, object]], max_updates: int) -> set[int]return {int(str(entry["number"])) for entry in chosen}+# GitHub computes mergeability on demand: the first listing after a push to+# main answers UNKNOWN for every pull request and only starts the computation.+SETTLE_ATTEMPTS = 6+SETTLE_SECONDS = 10.0+++def open_pull_requests(+ repo: str,+ attempts: int = SETTLE_ATTEMPTS,+ pause: float = SETTLE_SECONDS,+ sleep: Callable[[float], None] = time.sleep,+) -> list[dict]:+ """Open pull requests against main, asked again while GitHub still computes+ whether the eligible ones merge.++ The tick a push to main starts is the one that should update the branches+ that push put in conflict, and it read UNKNOWN for all of them: it waited+ on every pull request and did nothing.+ """+ prs: list[dict] = []+ for attempt in range(max(1, attempts)):+ listing = gh_json(+ "pr",+ "list",+ "--repo",+ repo,+ "--state",+ "open",+ "--base",+ "main",+ "--limit",+ "100",+ "--json",+ "id,number,title,headRefName,headRefOid,isDraft,labels,baseRefName,"+ "isCrossRepository,mergeable",+ )+ prs = listing if isinstance(listing, list) else []+ computing = sum(1 for pr in prs if eligible(pr) and pr.get("mergeable") == "UNKNOWN")+ if not computing or attempt + 1 >= attempts:+ break+ print(f"[train] mergeability of {computing} pull request(s) not computed yet; asking again")+ sleep(pause)+ return prs++def plan(repo: str, max_updates: int) -> dict[str, object]:"""Decide what the train does this tick. Reads only; runs no PR code."""- prs = gh_json(- "pr",- "list",- "--repo",- repo,- "--state",- "open",- "--base",- "main",- "--limit",- "100",- "--json",- "id,number,title,headRefName,headRefOid,isDraft,labels,baseRefName,"- "isCrossRepository,mergeable",- )+ prs = open_pull_requests(repo)queued = merge_queue_numbers(repo)queue_runs = queue_runs_by_pr(queue_group_runs(repo)) if queued is not None else {}git("fetch", "--quiet", "origin", "main")diff --git a/tests/unit/ci/test_pipeline_scripts.py b/tests/unit/ci/test_pipeline_scripts.pyindex 7181b85260..aefb198496 100644--- a/tests/unit/ci/test_pipeline_scripts.py+++ b/tests/unit/ci/test_pipeline_scripts.py@@ -581,6 +581,33 @@ def test_train_gives_its_update_slots_to_the_pull_requests_that_can_land():assert agent_integrate.grant_updates(wanted, 0) == set()+def test_train_asks_again_while_github_computes_mergeability(monkeypatch):+ def listing(state: str) -> list[dict]:+ own = {"baseRefName": "main", "isDraft": False, "labels": [], "mergeable": state}+ return [+ {**own, "number": 1, "headRefName": "claude/a"},+ {**own, "number": 2, "headRefName": "feature/not-on-the-train", "mergeable": "UNKNOWN"},+ ]++ answers = [listing("UNKNOWN"), listing("UNKNOWN"), listing("CONFLICTING")]+ asked: list[tuple[str, ...]] = []+ naps: list[float] = []++ def fake_gh_json(*args: str) -> object:+ asked.append(args)+ return answers[min(len(asked), len(answers)) - 1]++ monkeypatch.setattr(agent_integrate, "gh_json", fake_gh_json)+ prs = agent_integrate.open_pull_requests("example/project", pause=7.0, sleep=naps.append)+ # An ineligible pull request never keeps the train waiting.+ assert prs[0]["mergeable"] == "CONFLICTING" and len(asked) == 3 and naps == [7.0, 7.0]++ asked.clear(), naps.clear()+ answers[:] = [listing("UNKNOWN")]+ prs = agent_integrate.open_pull_requests("example/project", attempts=3, sleep=naps.append)+ assert prs[0]["mergeable"] == "UNKNOWN" and len(asked) == 3 and len(naps) == 2++def test_train_leaves_a_queued_pull_request_to_the_queue():decide = agent_integrate.decideassert decide("MERGEABLE", "success", True, queued=True) == "queued"