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): merge train updates only conflicting branches and merges green ones
rubenluetke10-beepea8e55e9c678
diff --git a/.github/workflows/merge-train.yml b/.github/workflows/merge-train.ymlindex 85171e78ee..ab69840975 100644--- a/.github/workflows/merge-train.yml+++ b/.github/workflows/merge-train.yml@@ -6,12 +6,16 @@# codex/ claude/ agent/ gemini/ cursor/ bot/ — or labelled `auto-merge`.# `no-auto-merge`, `do-not-merge`, `wip` or `needs-human` opt a PR out.# Forks and Dependabot never qualify (supply-chain bumps stay human).-# 2. A PR behind main is brought up to date by merging main into it-# (scripts/ci/agent_integrate.py): generated files are regenerated,-# append-only files union-merged, everything else goes to the optional AI-# resolver or is reported with a `needs-rebase` label. No force push.-# 3. The first up-to-date PR whose `CI gate` is green is squash-merged —-# one per tick, so every landing is tested on top of the main it lands on.+# 2. A PR that CONFLICTS with main (or whose CI failed while it was behind)+# gets main merged into it (scripts/ci/agent_integrate.py): generated+# files are regenerated, append-only files union-merged, everything else+# goes to the optional AI resolver or is reported with a `needs-rebase`+# label. No force push. A PR that is merely behind is left alone — with+# several agents pushing to main, re-testing every PR on every push meant+# nothing ever landed.+# 3. The first green, conflict-free PR is squash-merged — one per tick. The+# full post-merge run on main is the backstop for changes that pass alone+# and break together (the same model as GitHub's non-strict checks).## Tokens: with the optional INTEGRATION_TOKEN secret (a fine-grained PAT or App# token with contents + pull-requests write), pushes and merges fire the normaldiff --git a/docs/ci-pipeline.md b/docs/ci-pipeline.mdindex d32716b38b..25858c01fb 100644--- a/docs/ci-pipeline.md+++ b/docs/ci-pipeline.md@@ -57,9 +57,12 @@ Agents push branches named `codex/…`, `claude/…`, `agent/…`, `gemini/…`,merge train runs on every push to main, after every CI run, and every 15minutes:-1. A pull request behind main gets main merged into it- (`scripts/ci/agent_integrate.py`). No force push, so an agent that keeps- pushing to its branch is never overwritten.+1. A pull request that **conflicts** with main (or whose CI failed while it+ was behind) gets main merged into it (`scripts/ci/agent_integrate.py`).+ No force push, so an agent that keeps pushing to its branch is never+ overwritten. A pull request that is merely behind is left alone: with+ several agents pushing to main, re-testing every PR on every push meant+ nothing ever landed.2. Conflicts resolve by file class: **generated** files (frontend `dist/`,agent mirrors, CLI reference docs, lockfiles, timing caches) take main'scopy and are regenerated; **append-only** files (CHANGELOG, allowlists,@@ -69,9 +72,9 @@ minutes:and must still parse, and CI re-runs on it before anything lands. Whatstays unresolved aborts cleanly, gets the `needs-rebase` label and acomment listing the files. `git rerere` replays recorded resolutions.-3. The first up-to-date pull request with a green `CI gate` is squash-merged.- One merge per tick means every landing was tested on top of the exact main- it lands on.+3. The first green, conflict-free pull request is squash-merged, one per+ tick. Main's full post-merge test run is the backstop for changes that+ pass alone and break together — GitHub's non-strict model, as in Hermes.Opt out with `no-auto-merge`, `do-not-merge`, `wip` or `needs-human`.`priority` moves a pull request to the front. Forks and Dependabot never ridediff --git a/scripts/ci/agent_integrate.py b/scripts/ci/agent_integrate.pyindex ec76b5ef09..4dcc304235 100644--- a/scripts/ci/agent_integrate.py+++ b/scripts/ci/agent_integrate.py@@ -445,6 +445,30 @@ def dispatch_ci(ref: str) -> None:gh("workflow", "run", "ci.yml", "--ref", ref, "-f", "full=false")+def decide(mergeable: str, state: str, behind: bool) -> str:+ """The train's action for one pull request.++ Mirrors GitHub's non-strict model (and Hermes Agent's): a branch is NOT+ brought up to date just because main moved — with several agents pushing+ to main, that re-ran every PR's CI on every push and nothing ever landed.+ A branch is updated only when it CONFLICTS with main (or its last CI failed+ while it was behind, since a newer main may be the fix). A green,+ conflict-free PR merges; main's full post-merge run is the backstop for+ changes that are fine alone and break together.+ """+ if mergeable == "CONFLICTING":+ return "update"+ if mergeable not in ("MERGEABLE", ""):+ return "wait" # GitHub is still computing mergeability+ if state == "success":+ return "merge"+ if state == "missing":+ return "dispatch"+ if state == "failure" and behind:+ return "update"+ return "wait"++def train(repo: str, max_updates: int, resolver_cmd: str, dry_run: bool, token_is_bot: bool) -> int:prs = gh_json("pr",@@ -458,7 +482,7 @@ def train(repo: str, max_updates: int, resolver_cmd: str, dry_run: bool, token_i"--limit","100","--json",- "number,title,headRefName,headRefOid,isDraft,labels,baseRefName,isCrossRepository",+ "number,title,headRefName,headRefOid,isDraft,labels,baseRefName,isCrossRepository,mergeable",)queue = sorted((p for p in prs or [] if eligible(p)), # type: ignore[union-attr]@@ -471,10 +495,14 @@ def train(repo: str, max_updates: int, resolver_cmd: str, dry_run: bool, token_ifor pr in queue:number, branch, sha = pr["number"], pr["headRefName"], pr["headRefOid"]git("fetch", "--quiet", "origin", "main", branch)- behind = git("merge-base", "--is-ancestor", "origin/main", sha, check=False).returncode- if behind != 0:+ behind = git("merge-base", "--is-ancestor", "origin/main", sha, check=False).returncode != 0+ state = gate_state(repo, sha)+ action = decide(pr.get("mergeable") or "", state, behind)+ if action == "merge" and merged:+ action = "wait" # one landing per tick; the next tick sees the new main+ if action == "update":if updates >= max_updates:- summary.append(f"#{number}: behind main, waits for a free update slot")+ summary.append(f"#{number}: needs an update, waits for a free slot")continueupdates += 1try:@@ -489,9 +517,7 @@ def train(repo: str, max_updates: int, resolver_cmd: str, dry_run: bool, token_igit("reset", "-q", "--hard", check=False)git("clean", "-fdq", "--", "jarvis/ui/web/dist", check=False)summary.append(f"#{number}: {outcome}")- continue- state = gate_state(repo, sha)- if state == "success" and not merged:+ elif action == "merge":if dry_run:summary.append(f"#{number}: would merge")continue@@ -502,12 +528,12 @@ def train(repo: str, max_updates: int, resolver_cmd: str, dry_run: bool, token_idispatch_ci("main") # a GITHUB_TOKEN merge fires no push eventelse:summary.append(f"#{number}: merge refused (protection or conflict)")- elif state == "missing":+ elif action == "dispatch":summary.append(f"#{number}: no CI on {sha[:8]}, dispatching")if not dry_run:dispatch_ci(branch)else:- summary.append(f"#{number}: CI gate {state}")+ summary.append(f"#{number}: waiting (CI {state}, {pr.get('mergeable') or 'unknown'})")lines = ["## Merge train", "", *[f"- {line}" for line in summary]]print("\n".join(lines))target = os.environ.get("GITHUB_STEP_SUMMARY")diff --git a/tests/unit/ci/test_pipeline_scripts.py b/tests/unit/ci/test_pipeline_scripts.pyindex f5ab3acf44..23f15d9e8c 100644--- a/tests/unit/ci/test_pipeline_scripts.py+++ b/tests/unit/ci/test_pipeline_scripts.py@@ -307,6 +307,17 @@ def test_train_uses_the_newest_verdict_and_redispatches_a_cancelled_run():assert agent_integrate.run_state([old, new, cancelled]) == "missing"+def test_train_updates_only_conflicting_or_stale_red_branches():+ decide = agent_integrate.decide+ assert decide("CONFLICTING", "success", True) == "update"+ assert decide("MERGEABLE", "success", True) == "merge" # behind main is fine+ assert decide("MERGEABLE", "pending", True) == "wait"+ assert decide("MERGEABLE", "missing", False) == "dispatch"+ assert decide("MERGEABLE", "failure", True) == "update"+ assert decide("MERGEABLE", "failure", False) == "wait"+ assert decide("UNKNOWN", "success", False) == "wait"++# --------------------------------------------------------------------------- release