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
ci: rebuild the frontend bundle on main instead of in every pull request (#875)
Ruben Lütke3c99ad3b8629
diff --git a/.github/workflows/frontend-bundle.yml b/.github/workflows/frontend-bundle.ymlnew file mode 100644index 0000000000..be2641f03b--- /dev/null+++ b/.github/workflows/frontend-bundle.yml@@ -0,0 +1,165 @@+# Rebuild the committed frontend bundle on main after a frontend merge.+#+# The repo ships dodaios/ui/web/dist so a fresh clone or install has a UI+# without Node. Until 2026-10-26 every frontend pull request carried its own+# build, so the moment one of them merged all the others conflicted with main+# and the merge queue ejected them (one PR took six rounds, about 6 h).+#+# Now pull requests leave dist/ alone (the merge train and agent_land.py put+# main's copy back, see pin_bundle in scripts/ci/agent_integrate.py), and this+# workflow builds dist/ from main's sources after the merge. It pushes the+# build to ONE bot branch, opens or updates its pull request and requests+# auto-merge, so the rebuild goes through CI and the merge queue like any+# other change. A newer frontend merge replaces an older rebuild that has not+# landed yet instead of stacking on it.+#+# Two jobs, two trust levels: `build` runs npm with no secrets; `publish`+# never runs npm or any repository code, it only commits the built files and+# talks to GitHub with the merge bot's token (the "PersonalJarvis Merge Bot"+# app that merge-train.yml names). Its key lives in the `merge-train`+# environment, which only main may use. The release bot's key stays reserved+# for release-cut.yml (check_workflow_policy.py).+#+# Action SHAs are pinned to the commits ci.yml already vetted.++name: Frontend bundle++on:+ push:+ branches: [main]+ paths:+ - "dodaios/ui/web/frontend/**"+ - ".github/workflows/frontend-bundle.yml"+ workflow_dispatch:++permissions:+ contents: read++concurrency:+ # Only the newest main matters: a newer run supersedes an older one.+ group: frontend-bundle+ cancel-in-progress: true++env:+ DIST: dodaios/ui/web/dist+ BRANCH: bot/frontend-bundle++jobs:+ build:+ name: build the bundle from main+ runs-on: ubuntu-latest+ timeout-minutes: 20+ permissions:+ contents: read+ steps:+ - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0+ with:+ persist-credentials: false+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0+ with:+ node-version: "22"+ cache: npm+ cache-dependency-path: dodaios/ui/web/frontend/package-lock.json+ - name: Build+ working-directory: dodaios/ui/web/frontend+ # `npm run build` empties dist/ first, so it holds exactly this build.+ run: |+ npm ci+ npm run build+ - name: Startup bundle budget+ run: python3 scripts/ci/check_frontend_bundle_budget.py+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2+ with:+ name: frontend-bundle+ path: ${{ env.DIST }}+ include-hidden-files: true+ if-no-files-found: error+ retention-days: 3++ publish:+ name: open the rebuild pull request+ needs: build+ runs-on: ubuntu-latest+ timeout-minutes: 10+ environment: merge-train+ permissions:+ contents: read+ steps:+ - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0+ with:+ ref: ${{ github.sha }}+ persist-credentials: false+ - name: Put the new build in place+ run: |+ set -euo pipefail+ rm -rf "$DIST"+ mkdir -p "$DIST"+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2+ with:+ name: frontend-bundle+ path: ${{ env.DIST }}+ - name: Stage it+ id: stage+ run: |+ set -euo pipefail+ git add -A -- "$DIST"+ if git diff --cached --quiet; then+ echo "frontend-bundle: main's bundle is already current."+ echo "changed=false" >> "$GITHUB_OUTPUT"+ exit 0+ fi+ # The artifact came from a job that ran npm: never let it reach+ # anything outside dist/.+ outside="$(git diff --cached --name-only | grep -v "^$DIST/" || true)"+ if [ -n "$outside" ]; then+ echo "::error::frontend-bundle: the build touched files outside $DIST:"+ echo "$outside"+ exit 1+ fi+ # Every chunk index.html reaches is tracked, nothing unreachable is+ # (the same prune the merge train ran after its rebuilds).+ python3 scripts/ci/check_dist_consistency.py --staged --prune+ python3 scripts/ci/check_dist_consistency.py --staged+ git diff --cached --stat | tail -1+ echo "changed=true" >> "$GITHUB_OUTPUT"+ - name: Mint a merge bot token+ id: bot+ if: steps.stage.outputs.changed == 'true' && vars.MERGE_APP_ID != ''+ uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0+ with:+ client-id: ${{ vars.MERGE_APP_ID }}+ private-key: ${{ secrets.MERGE_APP_PRIVATE_KEY }}+ permission-contents: write+ permission-pull-requests: write+ - name: Push the branch and request auto-merge+ if: steps.stage.outputs.changed == 'true'+ env:+ # An App token, unlike GITHUB_TOKEN, starts CI on the pull request+ # and lets the merge queue run its group.+ GH_TOKEN: ${{ steps.bot.outputs.token }}+ SOURCE: ${{ github.sha }}+ run: |+ set -euo pipefail+ if [ -z "$GH_TOKEN" ]; then+ echo "::error::frontend-bundle: MERGE_APP_ID is not set (merge-train.yml names the app), so main's bundle was not rebuilt."+ exit 1+ fi+ git config user.name "jarvis-merge-train[bot]"+ git config user.email "jarvis-merge-train[bot]@users.noreply.github.com"+ git commit -q -m "chore(dist): rebuild the frontend bundle from ${SOURCE:0:10}"+ remote="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"+ # One branch, rebuilt from main each run: an older rebuild that never+ # landed is replaced, never stacked on.+ git push --force "$remote" "HEAD:refs/heads/$BRANCH"+ title="chore(dist): rebuild the frontend bundle from main"+ body="Built from ${SOURCE} by frontend-bundle.yml. Pull requests no longer carry the bundle; this one brings main's up to date with its sources."+ pr="$(gh pr list --repo "$GITHUB_REPOSITORY" --head "$BRANCH" --state open --json number --jq '.[0].number // empty')"+ if [ -z "$pr" ]; then+ gh pr create --repo "$GITHUB_REPOSITORY" --base main --head "$BRANCH" --title "$title" --body "$body"+ pr="$(gh pr list --repo "$GITHUB_REPOSITORY" --head "$BRANCH" --state open --json number --jq '.[0].number')"+ else+ gh pr edit "$pr" --repo "$GITHUB_REPOSITORY" --body "$body"+ fi+ # A push switches auto-merge off; ask again every time.+ gh pr merge "$pr" --repo "$GITHUB_REPOSITORY" --auto --squash+ echo "frontend-bundle: pull request #$pr, auto-merge requested."diff --git a/AGENTS.md b/AGENTS.mdindex 2993095747..4745576f5b 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -6,4 +6,4 @@ A standing instruction from the user, the person you are working for. It is abouYou are done when `python scripts/agent_done_gate.py` says DONE; a Stop hook enforces it (docs/agent-done-gate.md).-A frontend change is done only when it is visible in the running desktop app: check that the bundle the app serves contains it (rebuild the committed `dist` if needed) before you report it as live.+A frontend change is done only when it is visible in the running desktop app: check that the bundle the app serves contains it (rebuild `dist` locally if needed) before you report it as live. Never commit `dist` in a pull request: a bot rebuilds it on main after the merge (docs/ci-pipeline.md, "Frontend bundle").diff --git a/docs/ci-pipeline.md b/docs/ci-pipeline.mdindex 04ddbb69e2..1a73b22320 100644--- a/docs/ci-pipeline.md+++ b/docs/ci-pipeline.md@@ -251,9 +251,10 @@ merge queue), and hourly as a safety net:with green CI that only conflict with main, then to red ones, and last tothose already labelled `needs-rebase`: in number order the three oldestpull requests, two of them unresolvable, had held every slot for days.-2. Conflicts resolve by file class: **generated** files (frontend `dist/`,- CLI reference docs, lockfiles, timing caches) take main's- copy and are regenerated; **append-only** files (CHANGELOG, allowlists,+2. Conflicts resolve by file class: **generated** files (CLI reference+ docs, lockfiles, timing caches) take main's copy and are regenerated;+ the frontend bundle `dist/` takes main's copy and stays that way (see+ "Frontend bundle" below); **append-only** files (CHANGELOG, allowlists,`.gitignore`) are union-merged; **everything else** goesto the optional AI resolver (`ANTHROPIC_API_KEY` → Claude Code,`OPENAI_API_KEY` → Codex CLI, both pinned to exact versions). Its result@@ -612,6 +613,33 @@ CodeQL's default setup, and none is part of the required `CI gate`:weekly. It reports and never blocks.* **OpenSSF Scorecard** publishes a weekly repository security score.+### Frontend bundle++The repo ships the built UI (`dodaios/ui/web/dist`) so a fresh clone or+install needs no Node. Pull requests do not carry it: `agent_land.py` and the+merge train put main's `dist/` back on every update (`pin_bundle` in+`scripts/ci/agent_integrate.py`). Before 2026-10-26 each frontend pull request+committed its own build, so every frontend merge put all the other frontend+pull requests in conflict and the merge queue ejected them.++After a merge that touches `dodaios/ui/web/frontend/**`,+`.github/workflows/frontend-bundle.yml` builds `dist/` from main (job `build`,+no secrets), then commits only `dist/` to the branch `bot/frontend-bundle`,+opens or updates its pull request and requests auto-merge with the merge+bot's token (job `publish`, environment `merge-train`, variable+`MERGE_APP_ID`; without the app the job fails red and main's bundle stays+behind). A newer frontend merge+replaces an unlanded rebuild. Between a frontend merge and its rebuild landing+(about one queue round), main's bundle is one step behind its sources; the+desktop app that follows main rebuilds locally anyway (`main_follow.py`), and+`check_release_completeness.py` refuses a release cut in that window.++To see a frontend change in the running app, build locally+(`npm run build` in `dodaios/ui/web/frontend`); do not commit the result.++Merge queue: `max_entries_to_build` is 3 (ruleset 24704136; raised from 2 on+2026-10-26, 12 pull requests were waiting at about 7.5 minutes each).+Dependabot covers npm through security updates only. Version updates for thefrontend stay off for the same reason as pip: a bump also needs a rebuilt`dist/` bundle, which Dependabot cannot produce.diff --git a/scripts/ci/agent_integrate.py b/scripts/ci/agent_integrate.pyindex ed3f254f34..c19bd425d1 100644--- a/scripts/ci/agent_integrate.py+++ b/scripts/ci/agent_integrate.py@@ -15,7 +15,11 @@ Conflicts are resolved by file class, cheapest first:1. **Generated files** (frontend ``dist/``, the .claude / .codex copies of.agents, the CLI reference docs, lockfiles, timing caches): take main'scopy, then REGENERATE from the merged sources. A hand-merge of generated- output is always wrong; a regeneration is always right.+ output is always wrong; a regeneration is always right. The frontend+ bundle is the exception: a branch never carries its own build. Every+ update puts main's ``dist/`` back (``pin_bundle``) and the Frontend bundle+ workflow rebuilds it on main after the merge, so two frontend pull+ requests can no longer knock each other out of the merge queue.2. **Append-only files** (CHANGELOG.md, allowlists, .gitignore): a unionmerge keeps both sides' lines.3. **Everything else**: handed to an optional resolver command@@ -69,7 +73,8 @@ FRONTEND = "dodaios/ui/web/frontend"# (glob, regenerator key). Main's copy is taken, then the key regenerates it.GENERATED: tuple[tuple[str, str], ...] = (- ("dodaios/ui/web/dist/*", "frontend-build"),+ # No regenerator: the branch keeps main's bundle (see ``pin_bundle``).+ ("dodaios/ui/web/dist/*", ""),("docs/dodaios-cli-reference.md", "reference-docs"),("docs/commands-reference.md", "reference-docs"),(f"{FRONTEND}/package-lock.json", "npm-lock"),@@ -90,6 +95,10 @@ UNION: tuple[str, ...] = (OLD_PACKAGE = "jarvis"NEW_PACKAGE = "dodaios"RENAME_SCRIPT = "scripts/rename/rewrite_package.py"+BUNDLE_DIR = "dodaios/ui/web/dist"+# The one branch that does carry a bundle: the Frontend bundle workflow's+# rebuild of main (.github/workflows/frontend-bundle.yml).+BUNDLE_BOT_BRANCH = "bot/frontend-bundle"AGENT_BRANCH_PREFIXES = ("codex/", "claude/", "agent/", "agents/", "gemini/", "cursor/", "bot/")OPT_OUT_LABELS = {"no-auto-merge", "do-not-merge", "wip", "needs-human"}OPT_IN_LABEL = "auto-merge"@@ -215,6 +224,36 @@ def take_side(path: str, side: str, cwd: Path) -> None:git("add", "--", path, cwd=cwd)+def pin_bundle(onto: str, cwd: Path, branch: str = "") -> bool:+ """Give HEAD the frontend bundle of ``onto`` and commit that if it changes+ anything. Returns whether a commit was made.++ The bundle is built from main by the Frontend bundle workflow after each+ merge. A branch that carries its own build conflicts with every other+ frontend pull request the moment one of them lands, and the merge queue+ ejects it, so its copy is dropped here. The workflow's own branch keeps+ its build: that build is the point of it.+ """+ if not branch:+ branch = git("rev-parse", "--abbrev-ref", "HEAD", check=False, cwd=cwd).stdout.strip()+ if branch == BUNDLE_BOT_BRANCH:+ return False+ if not git("diff", "--quiet", onto, "HEAD", "--", BUNDLE_DIR, check=False, cwd=cwd).returncode:+ return False+ git("rm", "-r", "-q", "--cached", "--ignore-unmatch", "--", BUNDLE_DIR, cwd=cwd)+ if _in_tree(onto, BUNDLE_DIR, cwd):+ git("checkout", onto, "--", BUNDLE_DIR, cwd=cwd)+ commit = git(+ "commit",+ "-q",+ "-m",+ "chore: keep main's frontend bundle, it is rebuilt on main after the merge",+ check=False,+ cwd=cwd,+ )+ return commit.returncode == 0++def regenerate(keys: set[str], cwd: Path) -> list[str]:"""Run the regenerators; return the ones that failed."""failures: list[str] = []@@ -478,6 +517,8 @@ def update(onto: str, mode: str, resolver_cmd: str, cwd: Path = REPO_ROOT) -> di"""Update HEAD with ``onto``. Returns a JSON-able report; ``status`` is``up-to-date`` | ``updated`` | ``conflict``."""if git("merge-base", "--is-ancestor", onto, "HEAD", check=False, cwd=cwd).returncode == 0:+ if pin_bundle(onto, cwd):+ return {"status": "updated", "bundle": "kept main's"}return {"status": "up-to-date"}report: dict[str, object] = {"status": "updated", "resolved": [], "ai_resolved": []}regen: set[str] = set()@@ -542,6 +583,8 @@ def update(onto: str, mode: str, resolver_cmd: str, cwd: Path = REPO_ROOT) -> diif outcome is None:return {"status": "conflict", "unresolved": ["<regenerated files rejected>"]}report.update(outcome)+ if pin_bundle(onto, cwd):+ report["bundle"] = "kept main's"report["resolved"] = sorted(set(resolved))report["ai_resolved"] = sorted(set(ai))return report@@ -1289,7 +1332,13 @@ def merge_main_into(git("worktree", "add", "--quiet", "--detach", str(wt), head, cwd=checkout)if git("merge-base", "--is-ancestor", main_sha, "HEAD", check=False, cwd=wt).returncode == 0:return {"status": "up-to-date"}- state: dict[str, object] = {"status": "merged", "resolved": [], "ai_resolved": [], "regen": []}+ state: dict[str, object] = {+ "status": "merged",+ "branch": branch,+ "resolved": [],+ "ai_resolved": [],+ "regen": [],+ }moved = package_move(main_sha, wt)if moved:before, move = moved@@ -1382,6 +1431,8 @@ def _finish_one(root: Path, wt: Path, number: int, state: dict, known: tuple[strif outcome is None:return {**state, "status": "conflict", "unresolved": ["<regenerated files rejected>"]}state = {**state, **outcome}+ if pin_bundle(str(state.get("onto") or known[1]), wt, str(state.get("branch", ""))):+ state = {**state, "bundle": "kept main's"}ref = f"refs/train/pr-{number}"git("update-ref", ref, "HEAD", cwd=wt)bundle = root / "bundles" / f"pr-{number}.bundle"diff --git a/tests/unit/ci/test_pin_bundle.py b/tests/unit/ci/test_pin_bundle.pynew file mode 100644index 0000000000..29d7686dfc--- /dev/null+++ b/tests/unit/ci/test_pin_bundle.py@@ -0,0 +1,146 @@+"""A branch never carries its own frontend bundle: updating it puts main's back.++Two frontend pull requests that each committed a build conflicted the moment+one of them merged, and the merge queue ejected the other. The bundle is now+rebuilt on main after the merge (frontend-bundle.yml), so ``pin_bundle`` drops+whatever build a branch carries, except on the rebuild workflow's own branch.+"""++from __future__ import annotations++import subprocess+from pathlib import Path++import pytest++from scripts.ci import agent_integrate++_NO_WINDOW = getattr(subprocess, "CREATE_NO_WINDOW", 0)+DIST = agent_integrate.BUNDLE_DIR+++def _git(repo: Path, *args: str) -> str:+ return subprocess.run(+ ["git", "-C", str(repo), *args],+ capture_output=True,+ text=True,+ encoding="utf-8",+ check=True,+ creationflags=_NO_WINDOW,+ ).stdout+++def _commit(repo: Path, message: str, files: dict[str, str | None]) -> str:+ for name, text in files.items():+ path = repo / name+ if text is None:+ path.unlink()+ continue+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(text, encoding="utf-8", newline="")+ _git(repo, "add", "-A", ".")+ _git(repo, "commit", "-q", "-m", message)+ return _git(repo, "rev-parse", "HEAD").strip()+++def repo(tmp_path: Path) -> Path:+ _git(tmp_path, "init", "-q", "-b", "main")+ _git(tmp_path, "config", "user.email", "[email protected]")+ _git(tmp_path, "config", "user.name", "test")+ _git(tmp_path, "config", "commit.gpgsign", "false")+ _commit(+ tmp_path,+ "base",+ {+ f"{DIST}/index.html": '<script src="/assets/index-AAAAAAAA.js"></script>\n',+ f"{DIST}/assets/index-AAAAAAAA.js": "base\n",+ "dodaios/ui/web/frontend/src/app.tsx": "base\n",+ },+ )+ return tmp_path+++def _branch_with_own_build(repo: Path, name: str) -> None:+ _git(repo, "checkout", "-q", "-b", name, "main")+ _commit(+ repo,+ "feature with its own build",+ {+ "dodaios/ui/web/frontend/src/app.tsx": "feature\n",+ f"{DIST}/index.html": '<script src="/assets/index-BBBBBBBB.js"></script>\n',+ f"{DIST}/assets/index-AAAAAAAA.js": None,+ f"{DIST}/assets/index-BBBBBBBB.js": "feature\n",+ },+ )+++def _bundle(repo: Path, rev: str) -> str:+ return _git(repo, "ls-tree", "-r", rev, "--", DIST)+++def test_branch_build_is_replaced_by_mains(repo: Path) -> None:+ _branch_with_own_build(repo, "claude/feature")++ assert agent_integrate.pin_bundle("main", repo) is True++ assert _bundle(repo, "HEAD") == _bundle(repo, "main")+ # The source change stays; only the build goes.+ assert _git(repo, "show", "HEAD:dodaios/ui/web/frontend/src/app.tsx") == "feature\n"+ assert _git(repo, "status", "--porcelain", "--untracked-files=no") == ""+++def test_nothing_to_do_when_the_branch_has_mains_bundle(repo: Path) -> None:+ _git(repo, "checkout", "-q", "-b", "claude/plain", "main")+ _commit(repo, "source only", {"dodaios/ui/web/frontend/src/app.tsx": "x\n"})+ head = _git(repo, "rev-parse", "HEAD")++ assert agent_integrate.pin_bundle("main", repo) is False+ assert _git(repo, "rev-parse", "HEAD") == head+++def test_the_rebuild_branch_keeps_its_build(repo: Path) -> None:+ _branch_with_own_build(repo, agent_integrate.BUNDLE_BOT_BRANCH)+ head = _git(repo, "rev-parse", "HEAD")++ assert agent_integrate.pin_bundle("main", repo) is False+ assert _git(repo, "rev-parse", "HEAD") == head+++def test_detached_train_worktree_uses_the_given_branch(repo: Path) -> None:+ _branch_with_own_build(repo, agent_integrate.BUNDLE_BOT_BRANCH)+ _git(repo, "checkout", "-q", "--detach")++ assert agent_integrate.pin_bundle("main", repo, agent_integrate.BUNDLE_BOT_BRANCH) is False+ assert agent_integrate.pin_bundle("main", repo, "claude/other") is True+ assert _bundle(repo, "HEAD") == _bundle(repo, "main")+++def test_update_drops_the_build_even_when_up_to_date(repo: Path) -> None:+ _branch_with_own_build(repo, "claude/feature")++ report = agent_integrate.update("main", "merge", "", repo)++ assert report["status"] == "updated"+ assert _bundle(repo, "HEAD") == _bundle(repo, "main")+++def test_conflicting_bundles_merge_without_a_rebuild(repo: Path) -> None:+ _branch_with_own_build(repo, "claude/feature")+ _git(repo, "checkout", "-q", "main")+ _commit(+ repo,+ "another frontend change landed with its build",+ {+ f"{DIST}/index.html": '<script src="/assets/index-CCCCCCCC.js"></script>\n',+ f"{DIST}/assets/index-AAAAAAAA.js": None,+ f"{DIST}/assets/index-CCCCCCCC.js": "main\n",+ },+ )+ _git(repo, "checkout", "-q", "claude/feature")++ report = agent_integrate.update("main", "merge", "", repo)++ assert report["status"] == "updated"+ assert "regenerated" not in report+ assert _bundle(repo, "HEAD") == _bundle(repo, "main")