Skip to content
Open
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
3 changes: 2 additions & 1 deletion .github/actions/bookkeeping-gate/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ inputs:
os:
description:
"The value telling a matrix leg apart among its job name's values: the runner label (for example 'ubuntu-latest')
or 'shard N of M' for a shard; empty for a job without a matrix"
or 'shard N of M' for a shard, also when the macOS gate job passes the macOS leg it decides; empty for a job
without a matrix"
required: false
default: ""
outputs:
Expand Down
79 changes: 60 additions & 19 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ This directory contains the CI/CD workflows for the `holon-agentic-coder` projec
## Workflows

- `make.yml`: Runs on pushes to `main` and on pull requests into any base branch across both `ubuntu-latest` and
`macos-latest`. It verifies `uname -m`, `make help`, and default `make`.
`macos-latest`. It verifies `uname -m`, `make help`, and default `make`. The `macOS gate` job decides the macOS leg on
`ubuntu-latest`; see "The macOS gate job" below.
- `test-hygiene.yml`: Runs on pushes to `main` and on pull requests into any base branch on `ubuntu-latest`. It executes
fast repository hygiene in an isolated job:
- Verifying lockfile currency with `uv lock --check` and `git diff --exit-code uv.lock`.
Expand All @@ -19,7 +20,8 @@ This directory contains the CI/CD workflows for the `holon-agentic-coder` projec
The ubuntu leg runs the whole suite in one job; the macOS leg runs as two parallel shards, each running the test files
that `scripts/unit_test_shard.py` assigns to it by a stable sha256 hash of the file path, so every file runs exactly
once. On a pull request the macOS shards skip their expensive steps when no changed file is platform-sensitive; see
"macOS Relevance Gate" below.
"macOS Relevance Gate" below. The `macOS gate` job decides both shards on `ubuntu-latest`; see "The macOS gate job"
below.
- `test-stress.yml`: Runs on pushes to `main` and on pull requests into any base branch on `ubuntu-latest`. It runs the
stress suite (`uv run pytest -m stress`) -- the workspace-survival test and the hermetic canary guard, both of which
re-run the unit suite in a child process -- measuring the execution time explicitly in its own workflow.
Expand Down Expand Up @@ -217,6 +219,39 @@ passed. An earlier job counts as a real success only when this step succeeded. R
marker step, so the first bookkeeping-only push after the gate reaches a pull request runs in full once
(`previous-run-unverified`).

### The macOS gate job

A `macos-latest` leg that only skips its steps would still wait in the macOS runner queue, which is short of runners and
often the slowest part of a bookkeeping-only push. `test-unit.yml` and `make.yml` therefore decide their macOS legs in a
separate job, `macOS gate` (job key `gate`), on `ubuntu-latest`. It asks the bookkeeping gate once per macOS leg (`unit`
with `shard 1 of 2` and with `shard 2 of 2`; `build` with `macos-latest`), runs the macOS relevance gate in
`test-unit.yml` unless both bookkeeping decisions already skip, and ends with the step `macOS legs skipped`. That step
runs only when every macOS leg may skip, and the job output `skip` is `true` exactly when it succeeded.

The matrix job keeps its matrix, its check names and its own "Bookkeeping gate" step. It has `needs: gate` and the
job-level condition `!cancelled()` (written `${{ !cancelled() }}`), so a failed gate job leaves the output empty and
every leg runs in full. Its `runs-on` sends a macOS leg to `ubuntu-latest` when the gate job said "skip". The step
`macOS gate decision` (`id: macos_gate`) turns the same condition into a step output, and every expensive step and
`Full run completed` carry `steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'`. A
redirected leg therefore runs no test, never claims a full run, and still reports `success` under its usual required
check name, such as `unit (macos-latest, shard 1 of 2)`; the chain counts it as skipped by the gate, as before.

The ubuntu legs, and the jobs of `test-integration.yml`, `test-stress.yml`, `test-hygiene.yml` and `docker-build.yml`,
keep the in-job gate and need no gate job: they request no macOS runner. A job-level skip would also drop the matrix
part of a required check name, and the hygiene job must still run Prettier and jq on a skipped push.

A macOS leg that GitHub reports as skipped at job level has no steps, so it cannot carry `Full run completed`.
`scripts/ci_bookkeeping_gate_job.py` counts such a job as skipped by the gate only when the same run holds a successful
`macOS legs skipped` step, even when that run was later cancelled; any other job-level skip, such as one in a run whose
gate job never reached that step, is not successful and the next push runs in full.

### Verifying after merge

On the first pull-request run after this change, check that `Test - Unit / unit (macos-latest, shard 1 of 2)`,
`Test - Unit / unit (macos-latest, shard 2 of 2)` and `Run Make / build (macos-latest)` still appear under these names.
On a bookkeeping-only push, the `macOS gate` job shows `macOS legs skipped` as run, and the macOS checks finish in
seconds on an `ubuntu-latest` runner.

### Reading the gate output

The gate prints one line in the "Bookkeeping gate" step log and adds the same line to the step summary, for example
Expand Down Expand Up @@ -307,6 +342,9 @@ An empty commit does not force a full run: it changes no path, so it counts as b
(`id: bookkeeping`) directly after the checkout, the guard `if: steps.bookkeeping.outputs.skip != 'true'` on every
later step that is not cheap, and `Full run completed` as its last step with exactly that guard. The job also needs
`actions: read`. `apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py` enforces this.
- A new `macos-latest` leg belongs in a workflow with a `macOS gate` job: one "Bookkeeping gate" step for the leg in
that job, the redirecting `runs-on`, `needs: gate` and the `macos_gate` guard. The same test file fails on a workflow
outside `test-unit.yml` and `make.yml` that names `macos-latest` outside a comment.
- A workflow whose jobs should skip on pushes to `main` must be added to `GATED_WORKFLOWS` in
`scripts/ci_main_push_gate.py`, hold `pull-requests: read` and a daily `schedule` trigger, and make its timing upload
ignore a missing record on a skip; the same test file checks the two workflows in that tuple.
Expand All @@ -322,19 +360,19 @@ The `macos-latest` leg of `test-unit.yml` is the slowest job of the pipeline (me
against 3.2 minutes for the ubuntu leg on the same heads), so it sets how long every pull request waits for CI.
`scripts/macos_relevance.py`, called through the composite action `.github/actions/macos-relevance-gate`, lets the macOS
leg of a pull-request run skip its expensive steps when no changed file can behave differently on macOS. The macOS leg
runs as two shards and the gate runs on each of them; both judge the same commits the same way, so both skip or both
run. Each shard still starts, reports as `unit (macos-latest, shard 1 of 2)` or `unit (macos-latest, shard 2 of 2)` and
ends green, so the required status checks are satisfied; the job has no job-level condition. The ubuntu leg, the
bookkeeping gate and the Workspace survival job are unchanged. The rule lives in `scripts/macos_relevance_rules.py` (its
content patterns in `scripts/macos_relevance_patterns.py`), the decision rules and log lines in
`scripts/macos_relevance_judgement.py` and the git reads in `scripts/macos_relevance_git.py`; all of them use the
standard library only and run on the runner's own `python3`.
runs as two shards and the gate runs once for both of them, in the `macOS gate` job on `ubuntu-latest` (see "The macOS
gate job" above), so both skip or both run. Each shard still starts, on `ubuntu-latest` when it skips, reports as
`unit (macos-latest, shard 1 of 2)` or `unit (macos-latest, shard 2 of 2)` and ends green, so the required status checks
are satisfied. The ubuntu leg, the bookkeeping gate and the Workspace survival job are unchanged. The rule lives in
`scripts/macos_relevance_rules.py` (its content patterns in `scripts/macos_relevance_patterns.py`), the decision rules
and log lines in `scripts/macos_relevance_judgement.py` and the git reads in `scripts/macos_relevance_git.py`; all of
them use the standard library only and run on the runner's own `python3`.

### When the leg runs

"macOS relevance gate" is the step directly after "Bookkeeping gate" in `test-unit.yml`. It runs only on the macOS leg
and only when the bookkeeping gate said "run". Its rules are checked in order; the first match decides and only the last
one skips:
"macOS relevance gate" is the step of the `macOS gate` job directly after its two "Bookkeeping gate" steps in
`test-unit.yml`. It runs only when the bookkeeping gate said "run" for at least one macOS shard. Its rules are checked
in order; the first match decides and only the last one skips:

- `event-not-pull-request`: a push to `main`, a manual run or any other event; on `main` the leg runs in full unless the
bookkeeping gate skipped the push ("Pushes to main").
Expand Down Expand Up @@ -439,10 +477,11 @@ macos-relevance-gate: run (sensitive-content): pkg/plain.py (old: process `impor
### Interaction with the bookkeeping gate

Every expensive step ("Install uv", "Run unit tests", "CI Timing Gate (compare with main)" and `Full run completed`)
carries both guards: `steps.bookkeeping.outputs.skip != 'true' && steps.macos_relevance.outputs.skip != 'true'`. Both
are written with `!= 'true'`, because on the ubuntu leg the relevance gate never runs and its output is empty. A
relevance skip leaves `Full run completed` skipped, so the bookkeeping gate never counts such a run as a real success;
on a later bookkeeping-only push it finds no real success to rely on, says "run", and the relevance gate decides again.
carries both guards: `steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'`, where
`macos_gate` is `true` only on a macOS leg that the `macOS gate` job skipped. Both are written with `!= 'true'`, so a
missing output runs the step. A relevance skip leaves `Full run completed` skipped, so the bookkeeping gate never counts
such a run as a real success; on a later bookkeeping-only push it finds no real success to rely on, says "run", and the
relevance gate decides again.

### Timing

Expand Down Expand Up @@ -647,7 +686,8 @@ Repository maintainers configuring branch protection rulesets on `main` should r
- `Run Make / build (macos-latest)`

The two macOS unit shards replaced the former `Test - Unit / unit (macos-latest)` check; maintainers must update the
ruleset when the sharded workflow merges, or the old check stays "Expected" and blocks merges.
ruleset when the sharded workflow merges, or the old check stays "Expected" and blocks merges. The `macOS gate` jobs
(`Test - Unit / macOS gate` and `Run Make / macOS gate`) need not be required: a failed gate job runs every leg in full.

## Composite Actions

Expand All @@ -667,12 +707,13 @@ ruleset when the sharded workflow merges, or the old check stays "Expected" and
- `job-name`: (required) The job's base name as the jobs API shows it, without the matrix part, for example `unit`
or `Workspace survival`.
- `os`: (optional, default: empty) The value that tells the matrix leg apart among the values of its job name: the
runner label, for example `ubuntu-latest`, or `shard N of M` for a unit shard.
runner label, for example `ubuntu-latest`, or `shard N of M` for a unit shard. A `macOS gate` job passes the value
of the macOS leg it decides, such as `shard 1 of 2` or `macos-latest`.
- **Outputs:**
- `skip`: `true` when the job may skip its expensive steps, `false` in every other case.
- **Prerequisites & Requirements:**
- Calling workflows must execute `actions/checkout` before invoking this local composite action, and the step needs
`id: bookkeeping`.
`id: bookkeeping`; in a `macOS gate` job each leg's step has its own id, such as `bookkeeping_shard_1`.
- The job must grant `actions: read` and `contents: read`.
- Guards are written as `steps.bookkeeping.outputs.skip != 'true'`, never as `== 'false'`, so a missing output runs
the step. A step that must also run after a failure combines both:
Expand Down
50 changes: 44 additions & 6 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ concurrency:

jobs:
build:
runs-on: ${{ matrix.os }}
needs: gate
# why: a failed gate job leaves its output empty, so every leg still runs in full on its own runner.
if: ${{ !cancelled() }}
# why: a skipped macOS leg keeps its matrix name and required check, but needs no macOS runner to skip its steps.
runs-on: ${{ matrix.os == 'macos-latest' && needs.gate.outputs.skip == 'true' && 'ubuntu-latest' || matrix.os }}
permissions:
contents: read
actions: read
Expand All @@ -42,29 +46,63 @@ jobs:
job-name: build
os: ${{ matrix.os }}

# why: the guards below must agree with runs-on, so both read the same gate job output.
- name: macOS gate decision
id: macos_gate
env:
MACOS_LEG_SKIPPED: ${{ matrix.os == 'macos-latest' && needs.gate.outputs.skip == 'true' }}
run: echo "skip=${MACOS_LEG_SKIPPED}" >> "$GITHUB_OUTPUT"

- name: CI Timing Gate (Start)
uses: ./.github/actions/ci-timing-gate
with:
phase: start

- name: Print uname -m
if: steps.bookkeeping.outputs.skip != 'true'
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'
run: uname -m

- name: Run make help
if: steps.bookkeeping.outputs.skip != 'true'
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'
run: make help

- name: Run make
if: steps.bookkeeping.outputs.skip != 'true'
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'
run: make

- name: CI Timing Gate (Check <= 5 min)
if: always() && steps.bookkeeping.outputs.skip != 'true'
if: always() && steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'
uses: ./.github/actions/ci-timing-gate
with:
phase: check

- name: Full run completed
if: steps.bookkeeping.outputs.skip != 'true'
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'
run: echo "Every step of the full run passed."

# why: deciding the macOS leg on ubuntu-latest means a skipped leg never waits in the macos-latest runner queue.
gate:
name: macOS gate
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
outputs:
skip: ${{ steps.legs_skipped.outcome == 'success' }}

steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Bookkeeping gate (macos-latest)
id: bookkeeping_macos
uses: ./.github/actions/bookkeeping-gate
with:
job-name: build
os: macos-latest

# why: the chain reads this step of the run as the proof that the macOS leg skipped on the gate's decision.
- name: macOS legs skipped
id: legs_skipped
if: steps.bookkeeping_macos.outputs.skip == 'true'
run: echo "The macOS gate skipped the macOS leg; it runs on ubuntu-latest with its expensive steps skipped."
70 changes: 59 additions & 11 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ jobs:
unit:
# why: without an explicit name GitHub appends the shard to every leg and renames the unit (ubuntu-latest) check.
name: unit (${{ matrix.os }}${{ matrix.shards > 1 && format(', {0}', matrix.gate-leg) || '' }})
runs-on: ${{ matrix.os }}
needs: gate
# why: a failed gate job leaves its output empty, so every leg still runs in full on its own runner.
if: ${{ !cancelled() }}
# why: a skipped macOS leg keeps its matrix name and required check, but needs no macOS runner to skip its steps.
runs-on: ${{ matrix.os == 'macos-latest' && needs.gate.outputs.skip == 'true' && 'ubuntu-latest' || matrix.os }}
permissions:
contents: read
actions: read
Expand Down Expand Up @@ -82,22 +86,22 @@ jobs:
job-name: unit
os: ${{ matrix.gate-leg }}

# A pull request that changes no platform-sensitive path or content skips the macOS leg's steps below; see
# "macOS Relevance Gate" in .github/workflows/README.md.
- name: macOS relevance gate
id: macos_relevance
if: matrix.os == 'macos-latest' && steps.bookkeeping.outputs.skip != 'true'
uses: ./.github/actions/macos-relevance-gate
# why: the guards below must agree with runs-on, so both read the same gate job output.
- name: macOS gate decision
id: macos_gate
env:
MACOS_LEG_SKIPPED: ${{ matrix.os == 'macos-latest' && needs.gate.outputs.skip == 'true' }}
run: echo "skip=${MACOS_LEG_SKIPPED}" >> "$GITHUB_OUTPUT"

- name: Install uv
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_relevance.outputs.skip != 'true'
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'
uses: astral-sh/setup-uv@v8.3.0
with:
python-version: "3.13"
enable-cache: true

- name: Run unit tests
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_relevance.outputs.skip != 'true'
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'
run: |
uv sync --locked
if [ "${{ matrix.shards }}" -gt 1 ]; then
Expand All @@ -109,7 +113,7 @@ jobs:
fi

- name: CI Timing Gate (compare with main)
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_relevance.outputs.skip != 'true'
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'
env:
GITHUB_TOKEN: ${{ github.token }}
TIMING_MODE: ${{ github.event_name == 'pull_request' && 'compare' || 'record' }}
Expand All @@ -132,5 +136,49 @@ jobs:
if-no-files-found: ${{ steps.bookkeeping.outputs.skip != 'true' && 'error' || 'ignore' }}

- name: Full run completed
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_relevance.outputs.skip != 'true'
if: steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'
run: echo "Every step of the full run passed."

# why: deciding the macOS legs on ubuntu-latest means a skipped leg never waits in the macos-latest runner queue.
gate:
name: macOS gate
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
pull-requests: read
outputs:
skip: ${{ steps.legs_skipped.outcome == 'success' }}

steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
submodules: true

- name: Bookkeeping gate (shard 1 of 2)
id: bookkeeping_shard_1
uses: ./.github/actions/bookkeeping-gate
with:
job-name: unit
os: shard 1 of 2

- name: Bookkeeping gate (shard 2 of 2)
id: bookkeeping_shard_2
uses: ./.github/actions/bookkeeping-gate
with:
job-name: unit
os: shard 2 of 2

- name: macOS relevance gate
id: macos_relevance
if: steps.bookkeeping_shard_1.outputs.skip != 'true' || steps.bookkeeping_shard_2.outputs.skip != 'true'
uses: ./.github/actions/macos-relevance-gate

# why: the chain reads this step of the run as the proof that the macOS legs skipped on the gate's decision.
- name: macOS legs skipped
id: legs_skipped
if:
(steps.bookkeeping_shard_1.outputs.skip == 'true' && steps.bookkeeping_shard_2.outputs.skip == 'true') ||
steps.macos_relevance.outputs.skip == 'true'
run: echo "The macOS gate skipped the macOS legs; they run on ubuntu-latest with their expensive steps skipped."
Loading
Loading