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(macos): fill the merge queue's macOS runner and sweep main after the merge (#644)
Ruben Lütke80185fe09b21
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex ac737a408a..42c2666e26 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -41,7 +41,8 @@# lane on Linux and Windows. No macOS: five macOS slots serve# every run, and macOS legs on each push made pull requests wait.# queue merge-queue group: everything `pr` runs plus at most two macOS-# jobs: the macOS tests the change can reach, and the Apple Silicon+# jobs: the macOS tests the change can reach, filled up to about+# five minutes with the tests that name macOS, and the Apple Silicon# desktop bundle when the macOS lane is affected. Five macOS slots# serve every group; eleven macOS jobs a group waited 30-54 minutes.# full nightly, release tags, manual full dispatch: Intel macOS, the ARM@@ -52,6 +53,8 @@# but `detect` and the gate (`proven`); a push that bypassed the queue runs# the `queue` tier. A branch gets macOS feedback before the queue with# `gh workflow run ci.yml --ref <branch> -f full=false -f include_macos=true`.+# After the merge, macos-main-sweep.yml runs the whole suite on macOS on one+# runner, outside the gate.## Action SHAs are pinned to 40-char commits (CVE-2025-30066 hardening).@@ -223,25 +226,6 @@ jobs:git diff --name-only --no-renames "$BASE" HEAD | tee changed.txt | python3 scripts/ci/classify_changes.pyfi- # A merge group runs the macOS tests its change can reach, on ONE- # runner: the whole suite on macOS is 27 runner-minutes on five shared- # slots. A change that reaches everything (or no diff: changed.txt- # missing or empty) runs the macOS-focused set instead.- - name: Select the macOS tests this change can reach- id: mactests- shell: bash- env:- PYTHON_LANE: ${{ steps.lanes.outputs.python }}- MAC_IMPACT: ${{ steps.mode.outputs.mac_impact }}- run: |- : > mac_tests.txt- if [ "$PYTHON_LANE" = "true" ] && [ "$MAC_IMPACT" = "true" ]; then- test -f changed.txt || : > changed.txt- python3 scripts/ci/select_tests.py --one-runner --changed-from changed.txt --out mac_tests.txt- else- { echo "mode=none"; echo "shards=[]"; } | tee -a "$GITHUB_OUTPUT"- fi-# Resolve the mutable cache ONCE. All shards download the same immutable# snapshot; staggered runners must never compute different partitions.- name: Restore duration history once@@ -270,6 +254,28 @@ jobs:# Until Windows has a history it shards by the Linux one, as before.test -s test_durations_windows.json || cp test_durations.json test_durations_windows.jsonecho "name=test-duration-snapshot-${GITHUB_RUN_ATTEMPT}" >> "$GITHUB_OUTPUT"+ # A merge group runs the macOS tests its change can reach, on ONE+ # runner: the whole suite on macOS is 27 runner-minutes on five shared+ # slots. A change that reaches everything (or no diff: changed.txt+ # missing or empty) runs the macOS-focused set instead. The runner then+ # has minutes left before the Windows shards finish: the duration+ # history fills them with the tests that name macOS or belong to the+ # macOS lane, up to about five minutes of tests in all.+ - name: Select the macOS tests this change can reach+ id: mactests+ shell: bash+ env:+ PYTHON_LANE: ${{ steps.lanes.outputs.python }}+ MAC_IMPACT: ${{ steps.mode.outputs.mac_impact }}+ run: |+ : > mac_tests.txt+ if [ "$PYTHON_LANE" = "true" ] && [ "$MAC_IMPACT" = "true" ]; then+ test -f changed.txt || : > changed.txt+ python3 scripts/ci/select_tests.py --one-runner --changed-from changed.txt --out mac_tests.txt \+ --durations test_durations.json+ else+ { echo "mode=none"; echo "shards=[]"; } | tee -a "$GITHUB_OUTPUT"+ fi- name: Share duration snapshot with every shardif: steps.lanes.outputs.python == 'true'uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3diff --git a/.github/workflows/macos-main-sweep.yml b/.github/workflows/macos-main-sweep.ymlnew file mode 100644index 0000000000..ce5c418d12--- /dev/null+++ b/.github/workflows/macos-main-sweep.yml@@ -0,0 +1,77 @@+# macOS sweep of main: the whole Python suite on macOS, after the merge.+#+# A merge group proves on macOS only what its one runner does in about five+# minutes (ci.yml, `tests-macos-impact`); the whole suite there is 24 minutes+# on three workers, and five macOS slots serve every group. Without this+# workflow the rest waited for the nightly run: a macOS-only failure outside+# the selection showed up to a day and thirty to fifty merges later.+#+# One job, one macOS slot, never part of `CI gate`: nothing waits for it. Runs+# share one concurrency group, so a sweep covers every commit merged while the+# one before it ran; GitHub keeps a single pending run and replaces it with+# the newest push. A red sweep opens the issue "macOS tests are red on main"+# with the range of commits since the last green one (nightly-alert.yml), and+# the next green sweep closes it.+name: macOS main sweep++on:+ push:+ branches: [main]+ paths-ignore:+ - "docs/**"+ - "**/*.md"+ workflow_dispatch:++concurrency:+ group: macos-main-sweep+ cancel-in-progress: false++permissions:+ contents: read++env:+ PYTHONUTF8: "1"+ PIP_DISABLE_PIP_VERSION_CHECK: "1"++jobs:+ suite:+ name: whole suite on macOS+ # A branch asks ci.yml for macOS (`-f include_macos=true`); a sweep of+ # anything but main would only hold the slot main's sweep needs.+ if: github.ref == 'refs/heads/main'+ runs-on: macos-latest+ timeout-minutes: 60+ steps:+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2+ with:+ persist-credentials: false+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0+ with:+ python-version: "3.11"+ - name: Install+ uses: ./.github/actions/install-locked+ with:+ extras: dev telephony+ # One job runs every file, so nothing is partitioned by this history:+ # it only sizes the batches and their wall-clock budgets.+ - name: Restore duration history+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0+ with:+ path: test_durations.json+ key: test-durations-never-exact+ restore-keys: test-durations-+ - name: Run the whole suite+ continue-on-error: true+ run: >-+ python scripts/ci/run_tests_parallel.py tests+ --report out/test-report-macos-sweep.json+ --junit-out out/junit-macos-sweep.xml+ - name: Ratchet (a failure not in the baseline fails the sweep)+ run: python scripts/ci/ratchet_tests.py check --baseline scripts/ci/test-baseline-macos.json out/test-report-macos-sweep.json+ - name: Upload the report+ if: always()+ uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3+ with:+ name: tests-macos-sweep+ path: out/+ retention-days: 14diff --git a/.github/workflows/nightly-alert.yml b/.github/workflows/nightly-alert.ymlindex f4cf90fe1d..8ff3e450db 100644--- a/.github/workflows/nightly-alert.yml+++ b/.github/workflows/nightly-alert.yml@@ -1,4 +1,4 @@-# Nightly alert: a red nightly CI run opens (or updates) ONE issue.+# Nightly alert: a red run that blocks no pull request opens (or updates) ONE issue.## Several legs run only in the nightly and release runs: the real Hermes# install on Windows, the real runtimes and the real browser on macOS, Intel@@ -7,6 +7,11 @@# keeps one issue, "Nightly CI is red", with the failed jobs of the latest red# nightly, and closes it after the next green one.#+# The macOS sweep of main (macos-main-sweep.yml) is the same case, hours+# earlier: the whole suite on macOS after the merge, outside `CI gate`. It+# gets an issue of its own, "macOS tests are red on main", with the range of+# commits between the last green sweep and the first red one.+## A separate workflow for the same reason as flaky-tests.yml: `issues: write`# never reaches a pull-request run. Nothing is checked out; the run's job list# is read as data only.@@ -14,15 +19,15 @@ name: Nightly alerton:workflow_run:- workflows: [CI]+ workflows: [CI, macOS main sweep]types: [completed]branches: [main]- # A check by hand against a past nightly. It reports what it would do and+ # A check by hand against a past run. It reports what it would do and# writes nothing unless `dry_run` is switched off.workflow_dispatch:inputs:run_id:- description: "A finished nightly (scheduled) CI run on main"+ description: "A finished nightly (scheduled) CI run or a finished macOS sweep on main"required: truetype: stringdry_run:@@ -39,16 +44,17 @@ concurrency:jobs:alert:- name: track a red nightly+ name: track a red nightly or macOS sweep# A fork pull request can be named `main` too: the repository and event# checks, not the branch filter alone, keep its runs out.if: >-(github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') ||(github.event_name == 'workflow_run' &&- github.event.workflow_run.event == 'schedule' &&github.event.workflow_run.head_repository.full_name == github.repository &&github.event.workflow_run.head_branch == 'main' &&- contains(fromJSON('["success","failure"]'), github.event.workflow_run.conclusion))+ contains(fromJSON('["success","failure"]'), github.event.workflow_run.conclusion) &&+ (github.event.workflow_run.event == 'schedule' ||+ github.event.workflow_run.name == 'macOS main sweep'))runs-on: ubuntu-latesttimeout-minutes: 5permissions:@@ -59,44 +65,75 @@ jobs:env:GH_TOKEN: ${{ github.token }}RUN_ID: ${{ inputs.run_id || github.event.workflow_run.id }}- RUN_URL: ${{ github.event.workflow_run.html_url }}- CONCLUSION: ${{ github.event.workflow_run.conclusion }}DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}run: |- # A run id typed by hand is vetted like the event: only a finished- # nightly run of this repository's CI on main may feed the issue.- if [ -z "$RUN_URL" ]; then- case "$RUN_ID" in (''|*[!0-9]*) echo "::error::not a run id: $RUN_ID"; exit 1 ;; esac- vetted="$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID" --jq \- 'select(.head_repository.full_name == env.GITHUB_REPOSITORY and .path == ".github/workflows/ci.yml" and .head_branch == "main" and .event == "schedule" and .status == "completed") | "\(.conclusion) \(.html_url)"')"- [ -n "$vetted" ] || { echo "::error::run $RUN_ID is not a finished nightly CI run on main"; exit 1; }- CONCLUSION="${vetted%% *}"; RUN_URL="${vetted#* }"+ # The event and a run id typed by hand are vetted the same way: only+ # a finished nightly CI run or a finished macOS sweep of this+ # repository's main may feed an issue.+ case "$RUN_ID" in (''|*[!0-9]*) echo "::error::not a run id: $RUN_ID"; exit 1 ;; esac+ vetted="$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID" --jq \+ '(.path | split("@")[0]) as $path+ | select(.head_repository.full_name == env.GITHUB_REPOSITORY and .head_branch == "main" and .status == "completed")+ | select(($path == ".github/workflows/ci.yml" and .event == "schedule")+ or ($path == ".github/workflows/macos-main-sweep.yml" and (.event == "push" or .event == "workflow_dispatch")))+ | "\($path) \(.conclusion) \(.html_url)"')"+ [ -n "$vetted" ] || { echo "::error::run $RUN_ID is neither a finished nightly CI run nor a finished macOS sweep on main"; exit 1; }+ read -r path conclusion run_url <<< "$vetted"+ if [ "$path" = ".github/workflows/ci.yml" ]; then+ label=nightly-ci; title="Nightly CI is red"; what="nightly CI run"+ about="The nightly CI run on main is red"+ else+ label=macos-main; title="macOS tests are red on main"; what="macOS sweep"+ about="The whole suite on macOS is red on main"fi+ case "$conclusion" in+ (success|failure) ;;+ (*) echo "The $what ended as '$conclusion': nothing to record." | tee -a "$GITHUB_STEP_SUMMARY"; exit 0 ;;+ esacwrite() { if [ "$DRY_RUN" = "true" ]; then echo "dry run, not executed: gh $*"; else gh "$@"; fi; }# The label lists issues without the search index, which lags behind# a freshly created issue and would invite a duplicate.- number="$(gh issue list --repo "$GITHUB_REPOSITORY" --label nightly-ci --state open \+ number="$(gh issue list --repo "$GITHUB_REPOSITORY" --label "$label" --state open \--limit 1 --json number --jq '.[0].number // empty')"- if [ "$CONCLUSION" = "success" ]; then+ if [ "$conclusion" = "success" ]; thenif [ -n "$number" ]; thenwrite issue close "$number" --repo "$GITHUB_REPOSITORY" \- --comment "The nightly run is green again: $RUN_URL"+ --comment "The $what is green again: $run_url"echo "Closed issue #$number" | tee -a "$GITHUB_STEP_SUMMARY"else- echo "The nightly run is green and no issue is open." | tee -a "$GITHUB_STEP_SUMMARY"+ echo "The $what is green and no issue is open." | tee -a "$GITHUB_STEP_SUMMARY"fiexit 0fi{- echo "The nightly CI run on main failed: $RUN_URL"+ echo "The $what on main failed: $run_url"echoecho "Failed jobs:"echogh api "repos/$GITHUB_REPOSITORY/actions/runs/$RUN_ID/jobs?per_page=100&filter=latest" \--paginate --jq '.jobs[] | select(.conclusion == "failure" and .name != "CI gate") | "- [\(.name)](\(.html_url))"'echo- echo "Some of these legs run only at night and on release tags, so no pull request"- echo "was blocked by them. Reproduce on a branch with"+ if [ "$label" = "macos-main" ]; then+ # Sweeps run one after another, newest first in the list: the+ # red run right after the newest green one is where it broke.+ range="$(gh api "repos/$GITHUB_REPOSITORY/actions/workflows/macos-main-sweep.yml/runs?branch=main&status=completed&per_page=50" --jq \+ '[.workflow_runs[] | select(.conclusion == "success" or .conclusion == "failure")] as $runs+ | ($runs | map(.conclusion) | index("success")) as $green+ | if $green == null or $green == 0 then empty+ else "\($runs[$green].head_sha) \($runs[$green - 1].head_sha)" end' || true)"+ if [ -n "$range" ]; then+ echo "The last green sweep ran on \`${range%% *}\`, the first red one on \`${range#* }\`."+ echo "The change that broke macOS is in"+ echo "https://github.com/$GITHUB_REPOSITORY/compare/${range%% *}...${range#* }"+ echo+ fi+ echo "The merge queue runs on macOS only the tests a change can reach, so no pull"+ echo "request was blocked by these. The failed test ids are in the job's ratchet step."+ echo "Reproduce on a branch with"+ else+ echo "Some of these legs run only at night and on release tags, so no pull request"+ echo "was blocked by them. Reproduce on a branch with"+ fiecho '`gh workflow run ci.yml --ref <branch> -f full=false -f include_macos=true`.'} > "$RUNNER_TEMP/issue.md"tee -a "$GITHUB_STEP_SUMMARY" < "$RUNNER_TEMP/issue.md"@@ -104,9 +141,9 @@ jobs:write issue edit "$number" --repo "$GITHUB_REPOSITORY" --body-file "$RUNNER_TEMP/issue.md"echo "Updated issue #$number" | tee -a "$GITHUB_STEP_SUMMARY"else- write label create nightly-ci --repo "$GITHUB_REPOSITORY" --force \- --color B60205 --description "The nightly CI run on main is red"- url="$(write issue create --repo "$GITHUB_REPOSITORY" --title "Nightly CI is red" \- --label nightly-ci --body-file "$RUNNER_TEMP/issue.md")"+ write label create "$label" --repo "$GITHUB_REPOSITORY" --force \+ --color B60205 --description "$about"+ url="$(write issue create --repo "$GITHUB_REPOSITORY" --title "$title" \+ --label "$label" --body-file "$RUNNER_TEMP/issue.md")"echo "Created $url" | tee -a "$GITHUB_STEP_SUMMARY"fidiff --git a/.github/zizmor.yml b/.github/zizmor.ymlindex 394a5abfb7..de9c2bff3f 100644--- a/.github/zizmor.yml+++ b/.github/zizmor.yml@@ -17,9 +17,10 @@ rules:# checked in `if:` and again by flaky_report.py vet-run), checks out# `main`, and reads the downloaded shard reports as JSON data.- flaky-tests.yml- # Reacts to completed nightly CI runs on main only (repository, branch- # and the `schedule` event checked in `if:`), checks out nothing, uses- # no action, and reads the run's job names and links as data.+ # Reacts to completed nightly CI runs and macOS sweeps of main only+ # (repository and branch checked in `if:`, workflow and event again+ # against the API), checks out nothing, uses no action, and reads the+ # run's job names and links as data.- nightly-alert.ymlunpinned-uses:config:diff --git a/docs/ci-pipeline.md b/docs/ci-pipeline.mdindex c3831557a1..d4ec98d09c 100644--- a/docs/ci-pipeline.md+++ b/docs/ci-pipeline.md@@ -25,7 +25,7 @@ to prove (`scripts/ci/plan_run.py` emits the tier and every job matrix):| Tier | When | What runs | Target || --- | --- | --- | --- || `pr` | pull request, branch run dispatched by the merge train | Static gates, the whole Linux + Windows suite, every affected lane on Linux and Windows. No macOS. | ~10 min |-| `queue` | merge-queue group; a push that reached main without the queue | Everything `pr` runs plus at most two macOS jobs: the macOS tests the change can reach (one runner), and the Apple Silicon desktop bundle when the macOS lane is affected. The blocking proof of the exact tree main gets. | ~10-13 min |+| `queue` | merge-queue group; a push that reached main without the queue | Everything `pr` runs plus at most two macOS jobs: the macOS tests the change can reach, filled up to about five minutes with the tests that name macOS (one runner), and the Apple Silicon desktop bundle when the macOS lane is affected. The blocking proof of the exact tree main gets. | ~10-13 min || `full` | nightly, release tag, manual full dispatch | The wide matrix: Intel macOS, the ARM runners, every interpreter, the macOS test shards, all three macOS desktop rows, and the Hermes install on Windows. A red nightly opens the issue "Nightly CI is red" (`nightly-alert.yml`). | ~40 min || proven | push to main of a commit the merge queue already passed | `detect` and `CI gate` only. | under 1 min |@@ -58,14 +58,25 @@ arrangements were tried on 2026-10-13 and measured:the change can reach, on one runner (`tests macos impact`), and the AppleSilicon desktop bundle when the macOS lane is affected.+That one runner ended after one to three minutes while the gate waited+eight to nine for the Windows shards (14 groups on 2026-10-13 with slot+waits of 7 to 22 seconds; in six of them it ran 40 to 268 of 2,600 test+files). The selection is therefore+filled by the duration history up to 660 seconds of test history, about five+minutes on the runner's three workers (`MAC_BUDGET_SECONDS`): first the+macOS-focused set, then the tests of the other directories the macOS lane+watches (dictation, screen capture, install), then every test that names+macOS, cheapest first. What the change reaches always runs, whatever it+costs. Replayed on those six groups the job runs 295 to 392 files.+So a test that a change breaks on macOS stops it in the queue, and a broken-macOS bundle does too. What the queue does not prove on macOS runs nightly-and on release tags: the lanes themselves on macOS (realtime contract,-updater, agent-runtime unit suite on the portable base install, native-crypto on Intel), both real runtimes, the real browser, and the whole Python-suite. A macOS failure there is found by the next nightly run, which opens-the issue "Nightly CI is red", and at the latest by the release run, which-blocks publication. A branch can ask for all of it at any time with+macOS bundle does too. The whole Python suite on macOS runs after the merge+(see "macOS after the merge" below). What neither proves runs nightly and on+release tags: the lanes themselves on macOS (realtime contract, updater,+agent-runtime unit suite on the portable base install, native crypto on+Intel), both real runtimes and the real browser. A macOS failure there is+found by the next nightly run, which opens the issue "Nightly CI is red",+and at the latest by the release run, which blocks publication. A branch can ask for all of it at any time with`gh workflow run ci.yml --ref <branch> -f full=false -f include_macos=true`.The nightly run has no reader waiting for it, so its matrices run one leg at@@ -95,7 +106,7 @@ request, merge queue, and again on the push of the same commit).| `tests linux 1..6` | The whole suite in six shards. Batches of files run in fresh processes with a wall-clock budget; a failed batch is re-run file by file, a failed file once more (a pass there is reported as flaky). A file that runs out of its budget alone gets one more attempt with twice that budget, capped at the file ceiling: a file without history starts on the generic floor, and a pass there is reported as flaky and enters the history with its real duration. | `scripts/ci/run_tests_parallel.py` || `tests windows 1..6` | The whole suite in six shards on every tier, pull requests included, so a Windows-only failure blocks the pull request instead of ejecting it from the merge queue. | `scripts/ci/run_tests_parallel.py` || `tests macos 1..3` | The whole suite on macOS: nightly, release and manual runs with macOS only. | — |-| `tests macos impact` | Merge queue: the macOS tests the change can reach, before it lands, on one runner. A change that reaches everything (the pipeline, conftest, the lockfile) runs the macOS-focused set instead: the tests of the code that asks for or acts on a macOS facility, about 200 files. Selected once, in `detect`. | `scripts/ci/select_tests.py --one-runner` |+| `tests macos impact` | Merge queue: the macOS tests the change can reach, before it lands, on one runner. A change that reaches everything (the pipeline, conftest, the lockfile) runs the macOS-focused set instead: the tests of the code that asks for or acts on a macOS facility, about 200 files. Either selection is filled up to about five minutes with the tests that name macOS or belong to the macOS lane. Selected once, in `detect`. | `scripts/ci/select_tests.py --one-runner` || `test report + floor` | Proves the six Linux shards cover every discovered file exactly once, enforces the min-passed floor. Detection freezes one shared duration snapshot for all shards, including partial reruns. | `scripts/ci/ratchet_tests.py` || `duration cache` | Runs on main only (nightly, a manual run, a push that bypassed the queue) and only after every Linux and Windows shard succeeded: merges the shard timings into one history per OS, on top of the history the run started from, so a file that was flaky in one run keeps its timing. Windows shards by its own history; until one exists it uses the Linux one. | `scripts/ci/ratchet_tests.py durations` || Lanes | `frontend` (three test shards and the build, side by side), `jarvisctl`, `deps`, `realtime` (+ slim container), `updater` (in-app update, native handover, restart helper), `agent runtimes` (+ slim container + the real Hermes and OpenClaw at their pinned version; see [agent-runtimes.md](agent-runtimes.md#ci-and-release-gates)), `dragdrop`, `browser`, `macOS desktop`, `installer smoke` — each only when its paths change, each as wide as the tier: Linux + Windows on a pull request, + macOS in the merge queue, + Intel and ARM in the wide matrix. | `scripts/ci/plan_run.py` |@@ -116,6 +127,25 @@ cannot fall through to a retained API-key provider when its account is absentor unavailable. They make no paid inference calls. Real-account voice testsremain separate acceptance evidence.+### macOS after the merge: `.github/workflows/macos-main-sweep.yml`++The whole Python suite on macOS is 24 minutes on one runner, too long for+every merge group on five slots. It runs after the merge instead: every push+to main (documentation-only pushes excepted) starts a sweep, one job on one+macOS runner, with the same runner script and the same macOS baseline as the+nightly shards. Sweeps share one concurrency group and are never cancelled,+so one runs at a time and the pending one covers every commit merged+meanwhile. It is no part of `CI gate`: no pull request and no merge group+waits for it.++A red sweep opens the issue "macOS tests are red on main" (label+`macos-main`, written by `nightly-alert.yml`) with the failed job and the+range of commits between the last green sweep and the first red one; the+next green sweep closes it. Before, such a failure waited for the nightly+run, up to a day and thirty to fifty merges later. Check the alert against a+past sweep with `gh workflow run nightly-alert.yml --ref main -f run_id=<sweep+run id> -f dry_run=true`.+### Known failures: the ratchetThe suite carries a backlog of failures, mostly platform-specific. They arediff --git a/scripts/ci/select_tests.py b/scripts/ci/select_tests.pyindex 414bdd800f..a0f45bcbe7 100644--- a/scripts/ci/select_tests.py+++ b/scripts/ci/select_tests.py@@ -18,10 +18,13 @@ Selection is textual and deliberately generous — FAIL OPEN:* conftest, packaging, lockfiles or the pipeline itself select EVERYTHING,and so does a selection larger than :data:`ALL_RATIO` of the suite.-``--one-runner`` bounds the selection to what one runner does in a few-minutes: a change that reaches everything (or more than-:data:`SHARD_FILES` files) runs the macOS-focused set instead, the tests of-the code that asks for or acts on a macOS facility.+``--one-runner`` sizes the selection for the one macOS runner of a merge+group. A change that reaches everything (or more than :data:`SHARD_FILES`+files) runs the macOS-focused set instead, the tests of the code that asks+for or acts on a macOS facility. Every selection is then filled up to+:data:`MAC_BUDGET_SECONDS` of test history with the tests most likely to+behave differently on macOS: the focused set, the tests of the other+directories the macOS lane watches, and every test that names macOS itself.Writes the file list to ``--out`` and ``mode=all|selected|none``,``count=N`` and ``shards=[...]`` (how many runners the selection needs) to@@ -42,13 +45,19 @@ if str(REPO_ROOT) not in sys.path:sys.path.insert(0, str(REPO_ROOT))from scripts.ci import agent_runtime_suite, classify_changes # noqa: E402-from scripts.ci.run_tests_parallel import discover # noqa: E402+from scripts.ci.run_tests_parallel import discover, estimate, load_durations # noqa: E402ALL_RATIO = 0.35#: A selection up to this many files still fits one runner in about the time#: the other legs of a run take; a larger one gets two, everything gets three.SHARD_FILES = 450FULL_SHARDS = 3+#: What the macOS job of a merge group may spend on tests, as the sum of the+#: per-file history. The runner has three workers: 389 s of history ran in+#: 157 s and 384 s in 142 s (2026-10-13), so 660 s is about five minutes and+#: the job ends before the Windows shards the gate waits for (8 to 9 minutes).+MAC_BUDGET_SECONDS = 660.0+_MAC_WORDS = re.compile(r"darwin|macos", re.IGNORECASE)_EVERYTHING_PREFIXES = (".github/workflows/", "scripts/ci/", "tests/fakes/", "tests/fixtures/")_EVERYTHING_FILES = {"conftest.py",@@ -134,11 +143,50 @@ def mac_focus(tests: list[str]) -> list[str]:return sorted({t for t in tests if t.startswith(prefixes)} | {t for t in SMOKE if t in tests})-def one_runner(mode: str, chosen: list[str], tests: list[str]) -> tuple[str, list[str]]:- """Bound a selection to one runner; ``none`` stays ``none``."""- if mode == "all" or len(chosen) > SHARD_FILES:- return "selected", mac_focus(tests)- return mode, chosen+def mac_lane_tests(tests: list[str]) -> list[str]:+ """The unit tests of every product directory the macOS lane watches."""+ prefixes = tuple(+ "tests/unit/" + (p[len("jarvis/") :] if p.startswith("jarvis/") else p)+ for p in classify_changes._MACOS_PREFIXES+ if p.endswith("/") and not p.startswith(("tests/", "packaging/"))+ )+ return sorted(t for t in tests if t.startswith(prefixes))+++def mac_aware(tests: list[str], texts: dict[str, str]) -> list[str]:+ """The tests that name macOS: they branch on the platform or skip by it."""+ return sorted(t for t in tests if _MAC_WORDS.search(texts.get(t, "")))+++def one_runner(+ mode: str,+ chosen: list[str],+ tests: list[str],+ texts: dict[str, str] | None = None,+ durations: dict[str, float] | None = None,+ budget: float = MAC_BUDGET_SECONDS,+) -> tuple[str, list[str]]:+ """Size a selection for one macOS runner; ``none`` stays ``none``.++ What the change reaches always runs (the focused set for a change that+ reaches everything). The rest of the budget goes to the tests a macOS-only+ failure is most likely to show in, cheapest first so the budget covers as+ many files as it can.+ """+ if mode == "none":+ return mode, chosen+ history = durations or {}+ focus = mac_focus(tests)+ kept = set(focus if mode == "all" or len(chosen) > SHARD_FILES else chosen)+ spent = sum(estimate(file, history) for file in kept)+ for tier in (focus, mac_lane_tests(tests), mac_aware(tests, texts or {})):+ for file in sorted(set(tier) - kept, key=lambda f: (estimate(f, history), f)):+ cost = estimate(file, history)+ if spent + cost > budget:+ break+ kept.add(file)+ spent += cost+ return "selected", sorted(kept)def shards_for(mode: str, count: int) -> list[int]:@@ -157,7 +205,12 @@ def main(argv: list[str] | None = None) -> int:parser.add_argument("--one-runner",action="store_true",- help="Bound the selection to one runner (the macOS-focused set for a wide change).",+ help="Size the selection for the one macOS runner of a merge group.",+ )+ parser.add_argument(+ "--durations",+ type=Path,+ help="Per-file duration history: what the selection costs (--one-runner).",)args = parser.parse_args(argv)@@ -171,14 +224,20 @@ def main(argv: list[str] | None = None) -> int:for t in tests}mode, chosen = select(changed, tests, texts)+ shard_list = shards_for(mode, len(chosen))if args.one_runner:- mode, chosen = one_runner(mode, chosen, tests)+ reached = len(chosen) if mode == "selected" else 0+ history = load_durations(args.durations)+ mode, chosen = one_runner(mode, chosen, tests, texts, history)+ shard_list = [1] if chosen else []+ cost = sum(estimate(file, history) for file in chosen)+ print(f"reached={reached} one-runner files={len(chosen)} history={cost:.0f}s")args.out.write_text("\n".join(chosen) + ("\n" if chosen else ""), encoding="utf-8")print(f"mode={mode} count={len(chosen)} of {len(tests)}")output = os.environ.get("GITHUB_OUTPUT")if output:with open(output, "a", encoding="utf-8") as handle:- shards = json.dumps(shards_for(mode, len(chosen)), separators=(",", ":"))+ shards = json.dumps(shard_list, separators=(",", ":"))handle.write(f"mode={mode}\ncount={len(chosen)}\nshards={shards}\n")return 0diff --git a/tests/unit/ci/test_pipeline_audit.py b/tests/unit/ci/test_pipeline_audit.pyindex 121190fe75..0a177ee90b 100644--- a/tests/unit/ci/test_pipeline_audit.py+++ b/tests/unit/ci/test_pipeline_audit.py@@ -281,7 +281,8 @@ def test_a_merge_group_takes_at_most_two_macos_runners():"tests/unit/brain/test_routing.py","tests/unit/platform/test_a.py",]- assert select_tests.one_runner("selected", tests[:1], tests) == ("selected", tests[:1])+ # A narrow selection keeps what it reached and takes the focused set too.+ assert select_tests.one_runner("selected", tests[2:], tests) == ("selected", sorted(tests))assert select_tests.one_runner("none", [], tests) == ("none", [])assert select_tests.shards_for("selected", 2) == [1]# The wide matrix keeps every macOS leg of every lane.@@ -452,7 +453,8 @@ def test_a_red_nightly_reaches_someone_and_only_a_nightly_on_main_can_write_issu# No pull-request code runs next to the issue token.assert all("uses" not in step for step in job["steps"])script = job["steps"][0]["run"]- assert "--label nightly-ci" in script and "write issue close" in script+ assert "label=nightly-ci" in script and "write issue close" in script+ assert '--label "$label"' in script# A check by hand runs from main only, vets the run it is given like the# event, and writes nothing unless the dry run is switched off.by_hand = "github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'"@@ -529,6 +531,13 @@ def test_a_merge_group_runs_the_macos_tests_its_change_can_reach():detect = ci["detect"]select = next(s for s in detect["steps"] if s.get("id") == "mactests")["run"]assert "select_tests.py --one-runner --changed-from changed.txt --out mac_tests.txt" in select+ # The selection is sized by the duration history, so it runs after the+ # step that guarantees one exists.+ assert "--durations test_durations.json" in select+ names = [s.get("name") or s.get("id") for s in detect["steps"]]+ assert names.index("Ensure a duration snapshot exists") < names.index(+ "Select the macOS tests this change can reach"+ )assert "'[1]'" in detect["outputs"]["mac_test_shards"]shared = next(s for s in detect["steps"] if s.get("name") == "Share duration snapshot with every shard"@@ -549,6 +558,70 @@ def test_a_merge_group_runs_the_macos_tests_its_change_can_reach():assert "tests-macos-impact" not in required_results.expected_jobs(flags)+def test_the_macos_runner_of_a_merge_group_is_filled_up_to_its_budget():+ # The runner ended after one to three minutes while the gate waited eight+ # to nine for Windows: the rest goes to the tests a macOS-only failure is+ # most likely to show in, by the duration history.+ reached = "tests/unit/brain/test_reached.py"+ focus = "tests/unit/platform/test_focus.py"+ lane = ["tests/unit/dictation/test_cheap.py", "tests/unit/dictation/test_dear.py"]+ aware = "tests/unit/core/test_paths.py"+ plain = "tests/unit/core/test_plain.py"+ tests = sorted([reached, focus, *lane, aware, plain])+ texts = dict.fromkeys(tests, "import json")+ texts[aware] = 'if sys.platform == "darwin":'+ history = {reached: 500.0, focus: 10.0, lane[0]: 5.0, lane[1]: 40.0, aware: 20.0, plain: 1.0}+ assert select_tests.mac_lane_tests(tests) == sorted([*lane, focus])+ assert select_tests.mac_aware(tests, texts) == [aware]++ def sized(budget, mode="selected", chosen=(reached,)):+ return select_tests.one_runner(mode, list(chosen), tests, texts, history, budget)[1]++ # Enough budget: everything macOS-relevant, never an unrelated test.+ assert sized(1000.0) == sorted([reached, focus, *lane, aware])+ # What the change reached always runs, even alone above the budget.+ assert sized(100.0) == [reached]+ # The focused set first, then the lane's directories, then the tests+ # that name macOS; a file that no longer fits ends its tier only.+ assert sized(515.0) == sorted([reached, focus, lane[0]])+ assert sized(536.0) == sorted([reached, focus, lane[0], aware])+ # A change that reaches everything runs the whole focused set, then fills.+ assert sized(0.0, mode="all", chosen=tests) == [focus]+ assert sized(16.0, mode="all", chosen=tests) == sorted([focus, lane[0]])+ # A file the history never timed costs the runner's default, not nothing.+ assert select_tests.one_runner("selected", [reached], tests, texts, {}, 4.0)[1] == [reached]+ # Whatever the selection holds, it is one runner.+ assert select_tests.MAC_BUDGET_SECONDS <= 720+++def test_main_gets_the_whole_suite_on_macos_after_the_merge():+ sweep = workflows()["macos-main-sweep.yml"]+ triggers = sweep.get("on", sweep.get(True))+ assert triggers["push"]["branches"] == ["main"]+ # One sweep at a time and never cancelled: the pending one covers every+ # commit merged while the running one took its single macOS slot.+ assert sweep["concurrency"] == {"group": "macos-main-sweep", "cancel-in-progress": False}+ assert sweep["permissions"] == {"contents": "read"}+ assert list(sweep["jobs"]) == ["suite"]+ job = sweep["jobs"]["suite"]+ assert job["runs-on"] == "macos-latest" and "strategy" not in job+ assert job["if"] == "github.ref == 'refs/heads/main'"+ runs = "\n".join(step.get("run", "") for step in job["steps"])+ assert "run_tests_parallel.py tests" in runs and "--shard" not in runs+ assert "--files-from" not in runs and "test-baseline-macos.json" in runs+ # Nothing waits for it: it is no job of the workflow behind `CI gate`.+ assert "macos-main-sweep" not in yaml.safe_dump(workflows()["ci.yml"])+ # A red sweep reaches someone through the same job as a red nightly.+ alert = workflows()["nightly-alert.yml"]+ watched = alert.get("on", alert.get(True))["workflow_run"]+ assert watched["workflows"] == ["CI", sweep["name"]] and watched["branches"] == ["main"]+ job = alert["jobs"]["alert"]+ assert f"github.event.workflow_run.name == '{sweep['name']}'" in job["if"]+ script = job["steps"][0]["run"]+ assert '$path == ".github/workflows/macos-main-sweep.yml"' in script+ assert "label=macos-main" in script and "/compare/" in script++def test_only_a_complete_green_run_on_main_writes_the_duration_caches():ci = workflows()["ci.yml"]["jobs"]job = ci["duration-cache"]