diff --git a/.github/actions/bookkeeping-gate/action.yml b/.github/actions/bookkeeping-gate/action.yml index 99944161c..8e635b52b 100644 --- a/.github/actions/bookkeeping-gate/action.yml +++ b/.github/actions/bookkeeping-gate/action.yml @@ -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: diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 3f7741c99..3a3566e2d 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -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`. @@ -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. @@ -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 @@ -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. @@ -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"). @@ -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 @@ -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 @@ -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: diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index 1a351052b..98ef7cbe3 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -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 @@ -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." diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index a53272fb5..9219470ef 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -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 @@ -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 @@ -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' }} @@ -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." diff --git a/apps/sandbox-executor/tests/ci_bookkeeping_fakes.py b/apps/sandbox-executor/tests/ci_bookkeeping_fakes.py index 0dd209f22..508d51469 100644 --- a/apps/sandbox-executor/tests/ci_bookkeeping_fakes.py +++ b/apps/sandbox-executor/tests/ci_bookkeeping_fakes.py @@ -9,6 +9,7 @@ from collections.abc import Mapping from scripts.ci_bookkeeping_chain import FULL_RUN_STEP +from scripts.ci_bookkeeping_gate_job import GATE_SKIP_STEP REPO = "acme/widgets" API = f"https://api.github.com/repos/{REPO}/" @@ -17,6 +18,8 @@ WORKFLOW = "test-unit.yml" UNIT_JOB = "unit (ubuntu-latest)" MACOS_JOB = "unit (macos-latest)" +MACOS_SHARD_1_JOB = "unit (macos-latest, shard 1 of 2)" +GATE_JOB = "macOS gate" _COMPARE = re.compile(r"^compare/([^/?]+)\.\.\.([^/?]+)$") _RUNS = re.compile(r"^actions/workflows/([^/?]+)/runs\?(.+)$") @@ -116,6 +119,19 @@ def legacy_success_job(name: str = UNIT_JOB) -> dict[str, object]: return job(name) +def job_skipped_at_job_level(name: str = MACOS_SHARD_1_JOB) -> dict[str, object]: + return {"name": name, "status": "completed", "conclusion": "skipped", "steps": []} + + +def gate_job(skipped: bool) -> dict[str, object]: + steps = [ + {"name": "Checkout repository", "conclusion": "success"}, + {"name": "Bookkeeping gate (shard 1 of 2)", "conclusion": "success"}, + {"name": GATE_SKIP_STEP, "conclusion": "success" if skipped else "skipped"}, + ] + return {"name": GATE_JOB, "status": "completed", "conclusion": "success", "steps": steps} + + def comparison(*files: str | tuple[str, str], status: str = "ahead") -> dict[str, object]: entries: list[dict[str, str]] = [] for item in files: diff --git a/apps/sandbox-executor/tests/flow/github/test_ci_policy.py b/apps/sandbox-executor/tests/flow/github/test_ci_policy.py index b52505b25..3c4a6ab5a 100644 --- a/apps/sandbox-executor/tests/flow/github/test_ci_policy.py +++ b/apps/sandbox-executor/tests/flow/github/test_ci_policy.py @@ -129,3 +129,26 @@ def test_extract_failed_ci_check_names_names_cancelled_and_stale_checks_but_not_ ] } assert _extract_failed_ci_check_names(ci_status) == ["unit", "lint"] + + +def macos_gate_checks(bucket: str, state: str) -> list[dict[str, str]]: + skipped = [{"name": f"unit (macos-latest, shard {n} of 2)", "bucket": bucket, "state": state} for n in (1, 2)] + passed = [{"name": name, "bucket": "pass", "state": "SUCCESS"} for name in ("unit (ubuntu-latest)", "macOS gate")] + return passed + skipped + + +@pytest.mark.parametrize( + ("bucket", "state"), + [("skipping", "SKIPPED"), ("skipping", "skipped"), ("skip", "SKIPPED"), ("skip", "")], +) +def test_job_level_skipped_macos_checks_are_neither_failed_nor_pending(bucket, state): + summary = summarise_ci_checks(macos_gate_checks(bucket, state)) + + assert (summary["passed"], summary["skipped"], summary["failed"], summary["pending"]) == (2, 2, 0, 0) + assert summary["all_passed"] is True + + +def test_extract_failed_ci_check_names_never_names_a_skipped_check(): + ci_status = summarise_ci_checks(macos_gate_checks("skipping", "SKIPPED")) + + assert _extract_failed_ci_check_names(ci_status) == [] diff --git a/apps/sandbox-executor/tests/test_ci_bookkeeping_chain.py b/apps/sandbox-executor/tests/test_ci_bookkeeping_chain.py index 6b242580a..9ad7f4c8c 100644 --- a/apps/sandbox-executor/tests/test_ci_bookkeeping_chain.py +++ b/apps/sandbox-executor/tests/test_ci_bookkeeping_chain.py @@ -34,9 +34,11 @@ verify_bookkeeping_chain, ) from scripts.ci_bookkeeping_gate import diff_rule +from scripts.ci_bookkeeping_gate_job import SKIPPED_BY_GATE_JOB, gate_job_skipped, with_gate_job_skips from tests.ci_bookkeeping_fakes import ( BRANCH, MACOS_JOB, + MACOS_SHARD_1_JOB, REPO, TOKEN, UNIT_JOB, @@ -44,8 +46,10 @@ FakeGitHub, cancelled_job, comparison, + gate_job, gate_skipped_job, job, + job_skipped_at_job_level, legacy_success_job, real_success_job, ) @@ -549,3 +553,99 @@ def test_find_real_success_for_merge_chain_rejects_unrelated_head_or_cancelled_o "cancelled in run 49", True, ) + + +def macos_query(target_sha: str = SHA_B) -> JobQuery: + return query(target_sha, os_name="shard 1 of 2") + + +def test_a_job_level_skip_beside_a_gate_job_that_skipped_is_walked_to_the_real_success() -> None: + fake = FakeGitHub() + fake.add_run(48, SHA_A, real_success_job(MACOS_SHARD_1_JOB)) + fake.add_run(49, SHA_B, gate_job(skipped=True), job_skipped_at_job_level()) + + jobs = list_jobs(client_for(fake), 1049) + result = find_real_success(client_for(fake), macos_query()) + + assert classify_job(match_job(jobs, "unit", "shard 1 of 2") or {}) == GATE_SKIPPED + assert (result.real_sha, result.rule) == (SHA_A, RULE_PREVIOUS_RUN_SUCCEEDED) + + +def test_a_job_level_skip_beside_a_gate_job_that_ran_is_not_successful() -> None: + fake = FakeGitHub() + fake.add_run(48, SHA_A, real_success_job(MACOS_SHARD_1_JOB)) + fake.add_run(49, SHA_B, gate_job(skipped=False), job_skipped_at_job_level()) + + result = find_real_success(client_for(fake), macos_query()) + + assert (result.real_sha, result.rule, result.detail) == ( + None, + RULE_PREVIOUS_RUN_NOT_SUCCESSFUL, + "skipped in run 49", + ) + + +def test_a_job_level_skip_in_a_cancelled_run_counts_as_gate_skipped_when_the_marker_succeeded() -> None: + fake = FakeGitHub() + fake.add_run(48, SHA_A, real_success_job(MACOS_SHARD_1_JOB)) + fake.add_run(49, SHA_B, gate_job(skipped=True), job_skipped_at_job_level(), conclusion="cancelled") + + result = find_real_success(client_for(fake), macos_query()) + + assert (result.real_sha, result.rule) == (SHA_A, RULE_PREVIOUS_RUN_SUCCEEDED) + + +def test_a_job_level_skip_without_a_gate_job_is_not_successful() -> None: + fake = FakeGitHub() + fake.add_run(48, SHA_A, real_success_job(MACOS_SHARD_1_JOB)) + fake.add_run(49, SHA_B, job_skipped_at_job_level()) + + jobs = list_jobs(client_for(fake), 1049) + result = find_real_success(client_for(fake), macos_query()) + + assert classify_job(jobs[0]) == NOT_SUCCESSFUL + assert (result.real_sha, result.rule) == (None, RULE_PREVIOUS_RUN_NOT_SUCCESSFUL) + + +def test_the_gate_marker_proves_no_job_level_skip_of_an_ubuntu_job() -> None: + jobs = with_gate_job_skips([gate_job(skipped=True), job_skipped_at_job_level(UNIT_JOB)]) + + assert SKIPPED_BY_GATE_JOB not in jobs[1] + assert classify_job(jobs[1]) == NOT_SUCCESSFUL + + +@pytest.mark.parametrize( + ("entry", "expected"), + [ + pytest.param(real_success_job(MACOS_SHARD_1_JOB), REAL_SUCCESS, id="marker step succeeded"), + pytest.param(gate_skipped_job(MACOS_SHARD_1_JOB), GATE_SKIPPED, id="marker step skipped"), + pytest.param(legacy_success_job(MACOS_SHARD_1_JOB), UNVERIFIED, id="no marker step"), + ], +) +def test_in_job_marker_jobs_beside_a_gate_job_classify_as_before(entry, expected) -> None: + jobs = with_gate_job_skips([gate_job(skipped=True), entry]) + + assert jobs[1] is entry + assert classify_job(jobs[1]) == expected + + +@pytest.mark.parametrize("conclusion", ["success", "failure", "cancelled"]) +def test_with_gate_job_skips_never_marks_a_job_that_was_not_skipped(conclusion: str) -> None: + entry = job_skipped_at_job_level() | {"conclusion": conclusion} + + jobs = with_gate_job_skips([gate_job(skipped=True), entry]) + + assert SKIPPED_BY_GATE_JOB not in jobs[1] + + +@pytest.mark.parametrize( + ("steps", "expected"), + [ + pytest.param(gate_job(skipped=True)["steps"], True, id="marker succeeded"), + pytest.param(gate_job(skipped=False)["steps"], False, id="marker skipped"), + pytest.param(None, False, id="no step list"), + pytest.param(["macOS legs skipped"], False, id="a step that is not an object"), + ], +) +def test_gate_job_skipped_needs_a_successful_marker_step(steps, expected) -> None: + assert gate_job_skipped([{"name": "macOS gate", "steps": steps}]) is expected diff --git a/apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py b/apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py index ef5dd96e9..9cf0d587d 100644 --- a/apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py +++ b/apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py @@ -31,6 +31,7 @@ from tests.ci_bookkeeping_fakes import ( BRANCH, MACOS_JOB, + MACOS_SHARD_1_JOB, NEW_HEAD_SHA, REPO, TOKEN, @@ -39,8 +40,10 @@ FakeGitHub, cancelled_job, comparison, + gate_job, gate_skipped_job, job, + job_skipped_at_job_level, legacy_success_job, merge_scene, real_success_job, @@ -833,3 +836,51 @@ def test_non_merge_bookkeeping_push_after_cancelled_run_stays_not_successful() - fake.compares[(SHA_A, SHA_B)] = comparison(REPORT_FILE) assert gate(fake) == Decision(False, "previous-run-not-successful", "cancelled in run 49") + + +MIXED_CODE_FILE = "scripts/ci_timing_gate.py" +MACOS_SHARD_1 = context(job_name="unit", os_name="shard 1 of 2") +MACOS_BUILD = context(workflow_file="make.yml", job_name="build", os_name="macos-latest") + + +def macos_leg_after_a_job_level_skip( + real_job_name: str, gate_skipped: bool, *files: str, workflow: str = WORKFLOW +) -> FakeGitHub: + fake = pushed(*files) + fake.compares[(SHA_A, SHA_C)] = comparison(*files) + fake.add_run(48, SHA_A, real_success_job(real_job_name), path=f".github/workflows/{workflow}") + skipped_leg = job_skipped_at_job_level(real_job_name) + fake.add_run(49, SHA_B, gate_job(gate_skipped), skipped_leg, path=f".github/workflows/{workflow}") + return fake + + +def test_bookkeeping_only_push_after_a_proved_job_level_skip_skips_the_macos_shard() -> None: + fake = macos_leg_after_a_job_level_skip(MACOS_SHARD_1_JOB, True, PLAN_FILE, REPORT_FILE) + + decision = gate(fake, MACOS_SHARD_1) + + assert decision == Decision(True, "bookkeeping-only", f"2 changed paths since the real success on {SHA_A[:12]}") + + +def test_mixed_commit_after_a_proved_job_level_skip_runs_the_macos_shard() -> None: + fake = macos_leg_after_a_job_level_skip(MACOS_SHARD_1_JOB, True, "plans/x.md", MIXED_CODE_FILE) + + decision = gate(fake, MACOS_SHARD_1) + + assert decision == Decision(False, "non-bookkeeping-change", MIXED_CODE_FILE) + + +def test_bookkeeping_only_push_after_an_unproved_job_level_skip_runs_the_macos_shard() -> None: + fake = macos_leg_after_a_job_level_skip(MACOS_SHARD_1_JOB, False, PLAN_FILE, REPORT_FILE) + + decision = gate(fake, MACOS_SHARD_1) + + assert decision == Decision(False, "previous-run-not-successful", "skipped in run 49") + + +def test_bookkeeping_only_push_after_a_proved_job_level_skip_skips_the_macos_build() -> None: + fake = macos_leg_after_a_job_level_skip("build (macos-latest)", True, PLAN_FILE, workflow="make.yml") + + decision = gate(fake, MACOS_BUILD) + + assert decision == Decision(True, "bookkeeping-only", f"1 changed paths since the real success on {SHA_A[:12]}") diff --git a/apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py b/apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py index b962fd2c0..f402139a9 100644 --- a/apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py +++ b/apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py @@ -8,12 +8,14 @@ import re from dataclasses import dataclass +from itertools import takewhile from pathlib import Path import pytest from scripts.ci_bookkeeping_chain import FULL_RUN_STEP from scripts.ci_bookkeeping_gate import BOOKKEEPING_ROOTS, RESULT_AFFECTING_LABELS, RUN_RULES, SKIP_RULES +from scripts.ci_bookkeeping_gate_job import GATE_SKIP_STEP from scripts.ci_main_push_gate import GATED_WORKFLOWS, MAIN_PUSH_RUN_RULES, MAIN_PUSH_SKIP_RULES from scripts.ci_merge_push_gate import MERGE_PUSH_RUN_RULES, MERGE_PUSH_SKIP_RULES from tests.test_workflow_triggers import parse_triggers @@ -31,14 +33,20 @@ MARKDOWN_STEP = "Check markdown formatting (bookkeeping-only push)" BEFORE_THE_GATE = ("Record job start time", "Checkout repository") UNGUARDED = {"CI Timing Gate (Start)", "Upload timing record"} -# The unit workflow's macOS leg also skips on the macOS relevance gate; see test_macos_relevance_wiring.py. -RELEVANCE_GATE_STEP = "macOS relevance gate" -RELEVANCE_GUARD = f"{GUARD} && steps.macos_relevance.outputs.skip != 'true'" +MACOS_GATED = ("make.yml", "test-unit.yml") +GATE_JOB_KEY = "gate" +GATE_JOB_NAME = "macOS gate" +GATE_OUTPUT = "${{ steps.legs_skipped.outcome == 'success' }}" +MACOS_GATE_STEP = "macOS gate decision" +MACOS_LEG_SKIPPED = "matrix.os == 'macos-latest' && needs.gate.outputs.skip == 'true'" +REDIRECTED_RUNS_ON = f" runs-on: ${{{{ {MACOS_LEG_SKIPPED} && 'ubuntu-latest' || matrix.os }}}}" +NOT_CANCELLED = " if: ${{ !cancelled() }}" +MACOS_GATE_GUARD = f"{GUARD} && steps.macos_gate.outputs.skip != 'true'" UNGUARDED_IN = { "test-hygiene.yml": {"Set up Node.js", JSON_STEP, MARKDOWN_STEP}, - "test-unit.yml": {RELEVANCE_GATE_STEP}, + **{workflow: {MACOS_GATE_STEP} for workflow in MACOS_GATED}, } -GUARDS_IN = {"test-unit.yml": (GUARD, RELEVANCE_GUARD)} +GUARDS_IN = dict.fromkeys(MACOS_GATED, (MACOS_GATE_GUARD,)) def guards_of(workflow: str) -> tuple[str, ...]: @@ -88,9 +96,21 @@ class Step: text: str -def split_steps(workflow_text: str) -> list[Step]: +def job_lines(workflow_text: str, job_key: str) -> list[str]: + lines = workflow_text.partition("\njobs:\n")[2].splitlines() + starts = [index for index, line in enumerate(lines) if line == f" {job_key}:"] + assert len(starts) == 1, f"the workflow has no job {job_key!r}" + block = [lines[starts[0]]] + for line in lines[starts[0] + 1 :]: + if line and not line.startswith(" "): + break + block.append(line) + return block + + +def split_steps(workflow_text: str, job_key: str = "") -> list[Step]: """Return the step blocks after the one ``steps:`` line of ``workflow_text``.""" - lines = workflow_text.splitlines() + lines = job_lines(workflow_text, job_key) if job_key else workflow_text.splitlines() starts = [index for index, line in enumerate(lines) if line.strip() == "steps:"] assert len(starts) == 1, "the splitter reads workflows with exactly one job" item = " " * (len(lines[starts[0]]) - len(lines[starts[0]].lstrip()) + 2) + "- " @@ -103,20 +123,27 @@ def split_steps(workflow_text: str) -> list[Step]: return [_step(block, item) for block in blocks] +def _condition(block: list[str], item: str) -> str: + key = " " * len(item) + "if:" + starts = [index for index, line in enumerate(block) if line == key or line.startswith(f"{key} ")] + assert len(starts) <= 1, f"a step has several if lines: {block[0]!r}" + if not starts: + return "" + folded = takewhile(lambda line: line.startswith(" " * (len(item) + 2)), block[starts[0] + 1 :]) + return " ".join([block[starts[0]][len(key) :].strip(), *(line.strip() for line in folded)]).strip() + + def _step(block: list[str], item: str) -> Step: assert block[0].startswith(f"{item}name: "), f"a step does not start with its name: {block[0]!r}" - key = " " * len(item) + "if: " - conditions = [line[len(key) :] for line in block if line.startswith(key)] - assert len(conditions) <= 1, f"a step has several if lines: {block[0]!r}" - return Step(block[0][len(f"{item}name: ") :], conditions[0] if conditions else "", "\n".join(block)) + return Step(block[0][len(f"{item}name: ") :], _condition(block, item), "\n".join(block)) def workflow_text(workflow: str) -> str: return (WORKFLOWS / workflow).read_text(encoding="utf-8") -def steps_of(workflow: str) -> list[Step]: - return split_steps(workflow_text(workflow)) +def steps_of(workflow: str, job_key: str = "") -> list[Step]: + return split_steps(workflow_text(workflow), job_key or WIRING[workflow].job_key) def gate_index(steps: list[Step]) -> int: @@ -148,6 +175,11 @@ def gate_index(steps: list[Step]) -> int: # A comment between the name and the condition. if: steps.bookkeeping.outputs.skip == 'true' run: make lint-md + - name: Fourth + if: + steps.bookkeeping.outputs.skip == 'true' || + steps.other.outputs.skip == 'true' + run: echo folded """ @@ -158,6 +190,7 @@ def test_split_steps_reads_names_and_conditions() -> None: ("First", ""), ("Second (with brackets)", f"always() && {GUARD}"), ("Third", SKIP_ONLY), + ("Fourth", f"{SKIP_ONLY} || steps.other.outputs.skip == 'true'"), ] assert "submodules: true" in steps[0].text assert "- name: not a step" in steps[1].text @@ -166,7 +199,21 @@ def test_split_steps_reads_names_and_conditions() -> None: def test_split_steps_refuses_a_workflow_with_two_jobs() -> None: with pytest.raises(AssertionError, match="exactly one job"): - split_steps(SNIPPET + " other:\n steps:\n - name: Fourth\n") + split_steps(SNIPPET + " other:\n steps:\n - name: Fifth\n") + + +def test_split_steps_reads_the_named_job_of_several() -> None: + text = SNIPPET + "\n # why: a comment between two jobs.\n other:\n steps:\n - name: Fifth\n" + + assert [step.name for step in split_steps(text, "example")] == [ + "First", + "Second (with brackets)", + "Third", + "Fourth", + ] + assert [step.name for step in split_steps(text, "other")] == ["Fifth"] + with pytest.raises(AssertionError, match="no job 'missing'"): + split_steps(text, "missing") def test_every_workflow_that_runs_on_a_pull_request_is_wired() -> None: @@ -183,16 +230,22 @@ def expected_shown_names(wiring: Wiring) -> list[str]: return [] if wiring.job_name == wiring.job_key else [wiring.job_name] +def gate_jobs_of(workflow: str) -> list[str]: + return [GATE_JOB_KEY] if workflow in MACOS_GATED else [] + + @EACH_WORKFLOW def test_job_keeps_its_key_and_its_name(workflow: str) -> None: text = workflow_text(workflow) wiring = WIRING[workflow] jobs = text.partition("\njobs:\n")[2] + gated = workflow in MACOS_GATED - assert re.findall(r"^ ([\w-]+):$", jobs, flags=re.MULTILINE) == [wiring.job_key] + assert re.findall(r"^ ([\w-]+):$", jobs, flags=re.MULTILINE) == [wiring.job_key, *gate_jobs_of(workflow)] shown_names = re.findall(r"^ name: (.+)$", jobs, flags=re.MULTILINE) - assert shown_names == expected_shown_names(wiring) - assert ("runs-on: ${{ matrix.os }}" in jobs) is wiring.matrix + assert shown_names == expected_shown_names(wiring) + ([GATE_JOB_NAME] if gated else []) + assert ("runs-on: ${{ matrix.os }}" in jobs) is (wiring.matrix and not gated) + assert (REDIRECTED_RUNS_ON in job_lines(text, wiring.job_key)) is gated @EACH_WORKFLOW @@ -390,3 +443,91 @@ def test_readme_documents_merge_pushes_and_every_merge_push_rule() -> None: ) assert "`main-push-head-skip-unproven`" in section assert "transitive import" in limits + + +MACOS_GATED_WORKFLOWS = pytest.mark.parametrize("workflow", MACOS_GATED) +GATE_LEGS = { + "test-unit.yml": [("unit", "shard 1 of 2", "bookkeeping_shard_1"), ("unit", "shard 2 of 2", "bookkeeping_shard_2")], + "make.yml": [("build", "macos-latest", "bookkeeping_macos")], +} + + +def gate_job_lines(workflow: str) -> list[str]: + return job_lines(workflow_text(workflow), GATE_JOB_KEY) + + +@MACOS_GATED_WORKFLOWS +def test_macos_gate_job_runs_on_ubuntu_and_ends_with_the_marker_step(workflow: str) -> None: + lines = gate_job_lines(workflow) + steps = steps_of(workflow, GATE_JOB_KEY) + + assert lines[1:4] == [f" name: {GATE_JOB_NAME}", " runs-on: ubuntu-latest", " permissions:"] + assert lines[4:6] == [" contents: read", " actions: read"] + assert [line for line in lines if line.startswith(" skip: ")] == [f" skip: {GATE_OUTPUT}"] + assert not [line for line in lines if line.startswith((" if:", " needs:", " strategy:"))] + assert steps[0].name == "Checkout repository" + assert steps[-1].name == GATE_SKIP_STEP + assert " id: legs_skipped\n" in steps[-1].text + assert [step.name for step in steps].count(GATE_SKIP_STEP) == 1 + + +@MACOS_GATED_WORKFLOWS +def test_macos_gate_job_asks_the_bookkeeping_gate_once_per_macos_leg(workflow: str) -> None: + steps = steps_of(workflow, GATE_JOB_KEY) + gates = [step for step in steps if ACTION_PATH in step.text] + marker = steps[-1] + + assert [step.name for step in gates] == [f"{GATE_STEP} ({leg})" for _, leg, _ in GATE_LEGS[workflow]] + for gate, (job_name, leg, step_id) in zip(gates, GATE_LEGS[workflow], strict=True): + assert gate.condition == "" + assert f" id: {step_id}\n" in gate.text + assert f" job-name: {job_name}\n os: {leg}" in gate.text + assert f"steps.{step_id}.outputs.skip == 'true'" in marker.condition + assert "always()" not in marker.text and "!= 'true'" not in marker.condition + + +@MACOS_GATED_WORKFLOWS +def test_matrix_job_needs_the_gate_and_sends_a_skipped_macos_leg_to_ubuntu(workflow: str) -> None: + lines = job_lines(workflow_text(workflow), WIRING[workflow].job_key) + decision = {step.name: step for step in steps_of(workflow)}[MACOS_GATE_STEP] + + assert " needs: gate" in lines + assert [line for line in lines if line.startswith(" if:")] == [NOT_CANCELLED] + assert REDIRECTED_RUNS_ON in lines + assert " os: [ubuntu-latest, macos-latest]" in lines + assert decision.condition == "" + assert " id: macos_gate\n" in decision.text + assert f" MACOS_LEG_SKIPPED: ${{{{ {MACOS_LEG_SKIPPED} }}}}\n" in decision.text + assert decision.text.rstrip().endswith('run: echo "skip=${MACOS_LEG_SKIPPED}" >> "$GITHUB_OUTPUT"') + + +@MACOS_GATED_WORKFLOWS +def test_the_macos_gate_decision_comes_right_after_the_bookkeeping_gate(workflow: str) -> None: + names = [step.name for step in steps_of(workflow)] + + assert names.index(MACOS_GATE_STEP) == names.index(GATE_STEP) + 1 + + +def test_no_other_workflow_runs_on_macos() -> None: + others = [path for path in sorted(WORKFLOWS.glob("*.yml")) if path.name not in MACOS_GATED] + code_lines = [ + f"{path.name}: {line.strip()}" + for path in others + for line in path.read_text(encoding="utf-8").splitlines() + if not line.lstrip().startswith("#") + ] + + assert others + assert [line for line in code_lines if "macos" in line.lower()] == [] + + +def test_readme_documents_the_macos_gate_job() -> None: + section = README.read_text(encoding="utf-8").partition("\n## Bookkeeping-Only Push Gate\n")[2].partition("\n## ")[0] + gate_job = section.partition("\n### The macOS gate job\n")[2].partition("\n### ")[0] + + assert gate_job, "the gate section has the subsection about the macOS gate job" + for text in (GATE_JOB_NAME, GATE_SKIP_STEP, MACOS_GATE_STEP, "ubuntu-latest", "needs: gate", "!cancelled()"): + assert f"`{text}`" in gate_job + for workflow in MACOS_GATED: + assert f"`{workflow}`" in gate_job + assert "### Verifying after merge" in section diff --git a/apps/sandbox-executor/tests/test_macos_relevance_wiring.py b/apps/sandbox-executor/tests/test_macos_relevance_wiring.py index 8ac07d459..e8bb6ce95 100644 --- a/apps/sandbox-executor/tests/test_macos_relevance_wiring.py +++ b/apps/sandbox-executor/tests/test_macos_relevance_wiring.py @@ -6,12 +6,13 @@ from scripts.macos_relevance import FORCE_LABEL, RUN_RULES, SKIP_RULES from scripts.macos_relevance_rules import CONTENT_PATTERNS from tests.test_ci_bookkeeping_wiring import ( + GATE_JOB_KEY, GATE_STEP, - GUARD, + MACOS_GATE_GUARD, + NOT_CANCELLED, README, - RELEVANCE_GATE_STEP, - RELEVANCE_GUARD, REPO_ROOT, + job_lines, steps_of, workflow_text, ) @@ -20,47 +21,50 @@ ACTION_PATH = "./.github/actions/macos-relevance-gate" ACTION_FILE = REPO_ROOT / ".github" / "actions" / "macos-relevance-gate" / "action.yml" WORKFLOWS_DIR = REPO_ROOT / ".github" / "workflows" -GATE_CONDITION = f"matrix.os == 'macos-latest' && {GUARD}" +RELEVANCE_GATE_STEP = "macOS relevance gate" +GATE_CONDITION = "steps.bookkeeping_shard_1.outputs.skip != 'true' || steps.bookkeeping_shard_2.outputs.skip != 'true'" EXPENSIVE_STEPS = ("Install uv", "Run unit tests", "CI Timing Gate (compare with main)", FULL_RUN_STEP) -def test_job_has_no_condition_and_keeps_both_runners() -> None: +def test_unit_job_keeps_both_runners_and_runs_unless_cancelled() -> None: job = workflow_text(WORKFLOW).partition("\njobs:\n")[2].partition("\n steps:\n")[0] - assert not re.search(r"^ if:", job, flags=re.MULTILINE) + assert re.findall(r"^ if: .+$", job, flags=re.MULTILINE) == [NOT_CANCELLED] assert " os: [ubuntu-latest, macos-latest]\n" in job - - -def test_both_macos_shards_run_the_relevance_gate() -> None: - job = workflow_text(WORKFLOW).partition("\njobs:\n")[2].partition("\n steps:\n")[0] - gate = steps_of(WORKFLOW)[[step.name for step in steps_of(WORKFLOW)].index(RELEVANCE_GATE_STEP)] - assert re.findall(r"^ shard: (.+)$", job, flags=re.MULTILINE) == ["[1, 2]"] assert " exclude:\n - os: ubuntu-latest\n shard: 2\n" in job - assert gate.condition == GATE_CONDITION - assert "matrix.shard" not in gate.condition -def test_relevance_gate_follows_the_bookkeeping_gate_on_the_macos_leg_only() -> None: - steps = steps_of(WORKFLOW) +def test_relevance_gate_runs_once_on_ubuntu_in_the_gate_job_after_both_bookkeeping_steps() -> None: + steps = steps_of(WORKFLOW, GATE_JOB_KEY) names = [step.name for step in steps] gate = steps[names.index(RELEVANCE_GATE_STEP)] - assert names.index(RELEVANCE_GATE_STEP) == names.index(GATE_STEP) + 1 + assert " runs-on: ubuntu-latest" in job_lines(workflow_text(WORKFLOW), GATE_JOB_KEY) + assert names.index(RELEVANCE_GATE_STEP) == names.index(f"{GATE_STEP} (shard 2 of 2)") + 1 + assert names.index(RELEVANCE_GATE_STEP) == names.index(f"{GATE_STEP} (shard 1 of 2)") + 2 assert gate.condition == GATE_CONDITION + assert "matrix." not in gate.text assert " id: macos_relevance\n" in gate.text assert f" uses: {ACTION_PATH}\n" in gate.text - assert [step.name for step in steps if ACTION_PATH in step.text] == [RELEVANCE_GATE_STEP] + assert workflow_text(WORKFLOW).count(ACTION_PATH) == 1 + assert [step.name for step in steps_of(WORKFLOW) if ACTION_PATH in step.text] == [] + + +def test_a_relevance_skip_feeds_the_gate_job_output() -> None: + marker = steps_of(WORKFLOW, GATE_JOB_KEY)[-1] + + assert marker.condition.endswith(" || steps.macos_relevance.outputs.skip == 'true'") def test_expensive_steps_carry_the_combined_guard() -> None: by_name = {step.name: step for step in steps_of(WORKFLOW)} - assert [by_name[name].condition for name in EXPENSIVE_STEPS] == [RELEVANCE_GUARD] * len(EXPENSIVE_STEPS) + assert [by_name[name].condition for name in EXPENSIVE_STEPS] == [MACOS_GATE_GUARD] * len(EXPENSIVE_STEPS) def test_no_guard_compares_with_false() -> None: - # On ubuntu the relevance gate never runs and its output is empty, so only "!= 'true'" leaves that leg unchanged. + # why: an output is empty when its step did not run, so only "!= 'true'" lets a missing decision run the step. assert "== 'false'" not in workflow_text(WORKFLOW) @@ -119,6 +123,7 @@ def test_readme_documents_the_gate_and_every_rule_it_prints() -> None: assert f"`{FORCE_LABEL}`" in section assert f"`{FULL_RUN_STEP}`" in section assert "### Forcing the macOS leg" in section + assert "`macOS gate`" in section assert set(re.findall(r"^- `([a-z-]+)`: ", section, flags=re.MULTILINE)) == set(RUN_RULES + SKIP_RULES) assert "- `.github/actions/macos-relevance-gate/action.yml`: " in text.partition("\n## Composite Actions\n")[2] diff --git a/executions/E-1796254438-CLA-CO5.5.md b/executions/E-1796254438-CLA-CO5.5.md new file mode 100644 index 000000000..f55b5e9d1 --- /dev/null +++ b/executions/E-1796254438-CLA-CO5.5.md @@ -0,0 +1,168 @@ +# Execution Record: E-1796254438-CLA-CO5.5 + +## Summary + +Implements plan `P-1796254031-CLA-CO5.5` for intent `I-1796254007-hac-ubuntu-bookkeeping-gate`: a `macOS gate` job on +`ubuntu-latest` decides the macOS legs of `test-unit.yml` and `make.yml`, and the bookkeeping chain recognises a +job-level skip proved by that gate job as `gate-skipped`. + +## Actual Metrics + +| metric | value | +| --------------------- | ----- | +| success_actual | 0.85 | +| entropy_actual | 9.5 | +| impact_actual | 70.0 | +| cost_actual | 20.0 | +| learning_value_actual | 5.0 | + +## Steps Executed + +### Step 1: Confirm the assumptions and pin the current behaviour + +- `macos-latest` as a runner appears only in `test-unit.yml` (matrix legs `unit (macos-latest, shard N of 2)`) and + `make.yml` (`build (macos-latest)`). `test-integration.yml` mentions it only in a comment; `test-stress.yml`, + `test-hygiene.yml` and `docker-build.yml` run only on `ubuntu-latest`. +- Out-of-scope text contracts on the two workflows: + - `test_ci_timing_gate.py`: the regexes `- os: ubuntu-latest\n\s+timing-min-delta: 120` and + `- os: macos-latest\n\s+timing-min-delta: 150`, the flags of the first `python3 scripts/ci_timing_gate.py` command, + the artefact name and the main-push upload condition; `make.yml` must keep its `ci-timing-gate` start and + `if: always()` check steps. + - `test_unit_test_shard.py` (not in the Touch Set): the exact matrix text + `os: [ubuntu-latest, macos-latest]\n shard: [1, 2]\n`, the `exclude` block, both macOS `include` entries with + `gate-leg: shard N of 2`, and the `if [ shards -gt 1 ] ... else ... fi` command. + - `test_ci_durations.py`: `load_ceilings` reads `("make.yml", "build"): 300` and `("test-unit.yml", "unit"): 900`. + - `test_final_head_timing_rerun.py` only names the path `.github/workflows/test-unit.yml` as a code path. +- `ci_policy.summarise_ci_checks` counts `bucket` `skipping`/`skip` and `state` `SKIPPED` as skipped, never failed, and + `all_passed` needs only no failed and no pending check; `flow/github/ci.py` returns that summary and gates on + `all_passed`, never on a check name. No `ci_policy.py` change is expected. +- `test_ci_bookkeeping_wiring.split_steps` refuses a workflow with two jobs; Step 6 generalises it. +- GitHub behaviour the plan relied on (not checkable from the sandbox): a job skipped by a job-level `if` reports + `skipped`, a skipped required check counts as passing, and a skipped matrix job is not expanded. + +**Guardrail fired: deviation from Steps 5 and 6.** The plan's design (split each macOS leg into its own statically named +job) cannot keep the `test_unit_test_shard.py` matrix contract: the shard axis, the `exclude` block and +`os: [ubuntu-latest, macos-latest]` exist only while the three legs share one matrix job. That test is not declared in +the plan, and `holon-config/world/ruleset.md` section 3 forbids changing an undeclared test. Instead of stopping, the +workflows use a design that keeps every pinned contract and still never requests a macOS runner for a skipped leg: + +- The `macOS gate` job (`gate`, `ubuntu-latest`) decides the macOS legs as planned (one bookkeeping decision per leg, + the macOS relevance gate in `test-unit.yml`, the `macOS legs skipped` marker step and the `skip` output). +- The matrix job keeps its matrix, its name and its in-job gate, gains `needs: gate` and `if: ${{ !cancelled() }}`, and + its `runs-on` sends a macOS leg to `ubuntu-latest` when `needs.gate.outputs.skip == 'true'`. A 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.macos_gate.outputs.skip != 'true'`, so a redirected leg runs no test and never + claims a full run. +- The leg still reports under its usual check name with conclusion `success` and a skipped `Full run completed`, which + the chain already classifies as `gate-skipped`. This removes the plan's two unverifiable GitHub assumptions (names of + skipped matrix jobs, skipped required checks). The job-level skip support of Steps 2 to 4 is still implemented as + planned, because the intent requires it and it covers a macOS job that GitHub reports as skipped at job level. +- Cost: the ubuntu legs now wait for the gate job (one checkout and three short script runs) before they start. + +### Step 2: Recognise a job-level skip proved by the gate job as gate-skipped + +- New `scripts/ci_bookkeeping_gate_job.py`: `GATE_SKIP_STEP = "macOS legs skipped"`, `SKIPPED_BY_GATE_JOB`, + `gate_job_skipped(jobs)` and `with_gate_job_skips(jobs)`. Deviation (tighter evidence): only a job whose name holds + `macos-latest` is marked, because the gate job decides the macOS legs only; a job-level skip of an ubuntu job stays + `not-successful`. +- `ci_bookkeeping_api.list_jobs` returns `with_gate_job_skips(jobs)` (module: 346 of 350 lines); + `ci_bookkeeping_chain.classify_job` returns `GATE_SKIPPED` first for a job marked `SKIPPED_BY_GATE_JOB`, so the chain + walk, the main-push gate and the merge-push gate all walk past it. +- Fakes: `job_skipped_at_job_level`, `gate_job`, `MACOS_SHARD_1_JOB`, `GATE_JOB`. Chain tests: proved skip walks to the + older real success, an unproved skip and a skip without a gate job are `previous-run-not-successful`, ubuntu skips are + never marked, in-job marker jobs classify as before, and `success`/`failure`/`cancelled` jobs are never marked. +- `uv run pytest test_ci_bookkeeping_chain.py test_ci_main_push_gate.py test_ci_merge_push_gate.py`: 251 passed in + 14.62s. + +### Step 3: Prove the per-leg gate decisions end to end, including a mixed commit + +- `test_ci_bookkeeping_gate.py` scene: run 48 is a real success of the macOS leg, run 49 (previous head) shows it + skipped at job level beside the `macOS gate` job. A bookkeeping-only push skips `unit`/`shard 1 of 2` + (`bookkeeping-only`); a mixed commit (`plans/x.md` plus `scripts/ci_timing_gate.py`) runs (`non-bookkeeping-change`, + detail names the code path); an unproved job-level skip runs (`previous-run-not-successful`); the `make.yml` leg + `build (macos-latest)` matches `build`/`macos-latest` and skips. +- `scripts/ci_bookkeeping_gate.py` unchanged. +- `uv run pytest apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py`: 151 passed in 8.26s. + +### Step 4: Pin the engine-side wait for job-level skipped checks + +- `test_ci_policy.py`: passing `unit (ubuntu-latest)` and `macOS gate` checks plus two skipped + `unit (macos-latest, shard N of 2)` checks (`skipping`/`skip` buckets, `SKIPPED`/`skipped`/empty states) give + `all_passed` true, 2 skipped, 0 failed, 0 pending; `_extract_failed_ci_check_names` names no skipped check. +- Every case passed against the unchanged `ci_policy.py`, so it is not edited: the engine wait and the gate agree + through the existing skipped-is-not-failed rule. +- `uv run pytest apps/sandbox-executor/tests/flow/github/test_ci_policy.py`: 37 passed in 2.75s. + +### Step 5: Put the macOS legs of test-unit.yml and make.yml behind an ubuntu-latest gate job + +Implemented with the runner redirect recorded under Step 1 instead of split jobs: + +- `test-unit.yml`: new job `gate` (`name: macOS gate`, `ubuntu-latest`, `contents`/`actions`/`pull-requests: read`) with + `Checkout repository`, `Bookkeeping gate (shard 1 of 2)` and `Bookkeeping gate (shard 2 of 2)` (`job-name: unit`), + `macOS relevance gate` (runs unless both bookkeeping decisions skip) and the marker step `macOS legs skipped` (id + `legs_skipped`, runs when both bookkeeping decisions skip or the relevance gate skips). The job output is + `skip: ${{ steps.legs_skipped.outcome == 'success' }}`, so the output and the marker evidence cannot disagree, and a + failure of any gate step leaves the output `false`. +- The `unit` matrix job keeps its matrix, name, in-job `Bookkeeping gate` and every pinned text. It gains `needs: gate`, + `if: ${{ !cancelled() }}` and + `runs-on: ${{ matrix.os == 'macos-latest' && needs.gate.outputs.skip == 'true' && 'ubuntu-latest' || matrix.os }}`. + The `macOS relevance gate` step moved to the gate job; in its place `macOS gate decision` (id `macos_gate`) writes the + same condition as a step output, and the expensive steps and `Full run completed` are guarded by + `steps.bookkeeping.outputs.skip != 'true' && steps.macos_gate.outputs.skip != 'true'`. +- `make.yml`: the same shape with one `Bookkeeping gate (macos-latest)` step (`job-name: build`, `os: macos-latest`). +- The gate jobs are written after the matrix jobs: `test_ci_timing_gate.py` requires `Record job start time` before the + first `actions/checkout` of `test-unit.yml`. +- `test-integration.yml`, `test-stress.yml`, `test-hygiene.yml` and `docker-build.yml` are byte-identical. +- `npx prettier --check` on both workflows: clean. PyYAML parses both and shows the expected jobs, needs, conditions and + outputs. +- `uv run pytest test_ci_timing_gate.py test_unit_test_shard.py test_ci_durations.py test_workflow_triggers.py test_final_head_timing_rerun.py` + (all unchanged): 210 passed in 24.26s. + +### Step 6: Update the wiring tests, the composite action description and the README + +- `test_ci_bookkeeping_wiring.py`: `job_lines` cuts one job out of a workflow, `split_steps(text, job_key)` and + `steps_of(workflow, job_key)` read one named job (default: the in-job-gated job of `WIRING`), and `_condition` joins a + folded `if:` that Prettier wraps. `RELEVANCE_GATE_STEP`/`RELEVANCE_GUARD` are replaced by `MACOS_GATE_GUARD` for + `test-unit.yml` and `make.yml`. New tests: the named-job splitter, the `macOS gate` job shape (ubuntu, static name, + permissions, `skip` output from the marker step's outcome, `macOS legs skipped` last), one bookkeeping step per macOS + leg with its job name, leg and id feeding the marker, `needs: gate` plus `${{ !cancelled() }}` plus the redirecting + `runs-on` on the matrix job, `macOS gate decision` right after the in-job gate with the same condition as `runs-on`, + no other workflow naming `macos-latest` outside a comment, the gate step name equal to `GATE_SKIP_STEP`, and the + README subsection. +- `test_macos_relevance_wiring.py`: the relevance gate runs once, in the gate job on `ubuntu-latest`, after both + bookkeeping steps; its skip feeds the marker step; the unit job keeps both runners and the shard axis and has only the + `!cancelled()` condition; expensive steps carry `MACOS_GATE_GUARD`; the README names the `macOS gate`. The stale + comment in `test_no_guard_compares_with_false` became a `# why:` comment. +- `.github/actions/bookkeeping-gate/action.yml`: the `os` description names the gate-job use; the interface is + unchanged. +- `.github/workflows/README.md`: new "The macOS gate job" and "Verifying after merge" subsections; the workflow list, + "macOS Relevance Gate", "When the leg runs", "Interaction with the bookkeeping gate", the checklist, branch protection + and the composite action notes describe the gate job. Section headings are unchanged; Prettier clean. +- `uv run pytest test_ci_bookkeeping_wiring.py test_macos_relevance_wiring.py`: 75 passed in 7.52s. + +### Step 7: Verify affected tests, lint and the full suite once + +- No environment variable, cwd or git config of any child process changed, so the environment-overlay discipline does + not apply. +- The intent sets no timing target, so every suite ran once. + +## Tests Run + +| command | result | pytest time | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ----------- | +| `uv run pytest test_ci_bookkeeping_chain.py test_ci_main_push_gate.py test_ci_merge_push_gate.py` (Step 2) | 251 passed | 17.49s | +| `uv run pytest test_ci_bookkeeping_gate.py` (Step 3) | 151 passed | 8.26s | +| `uv run pytest flow/github/test_ci_policy.py` (Step 4) | 37 passed | 2.75s | +| `uv run pytest test_ci_timing_gate.py test_unit_test_shard.py test_ci_durations.py test_workflow_triggers.py test_final_head_timing_rerun.py` (Step 5, unchanged tests) | 210 passed | 24.26s | +| `uv run pytest test_ci_bookkeeping_wiring.py test_macos_relevance_wiring.py` (Step 6) | 75 passed | 7.52s | +| `uv run pytest` on the ten Step 7 files (chain, gate, both wiring files, `test_ci_policy.py`, main-push, merge-push, timing gate, unit shard, workflow triggers) | 656 passed | 5.38s | +| `uv run task lint` (uv lock check, ruff check, ruff format, module budgets, self-explaining) | passed | n/a | +| `npx prettier --check` on every workflow, the composite actions, `.github/workflows/README.md` and these notes | passed | n/a | +| `uv run task test` (full suite, once) | 11364 passed, 1 failed, 8 skipped | 170.65s | +| `uv run pytest apps/sandbox-executor/tests/test_ledger_lock.py` | 15 passed | 4.47s | + +The one full-suite failure is `test_ledger_lock.py::test_concurrent_process_appends_do_not_interleave`, a multi-process +ledger append test that this change does not touch (no ledger code or fixture changed). Its whole module passed on its +own right after the full run; the failure is recorded as an unrelated concurrency flake under full-suite load. `uv.lock` +is unchanged. The live GitHub behaviour (the `needs`-based `runs-on` redirect and the gate job output) cannot run in the +sandbox; "Verifying after merge" in `.github/workflows/README.md` lists what to check on the first pull-request run. diff --git a/holon-knowledge/ledger/pending/executions/I-1796254007-hac-ubuntu-bookkeeping-gate.jsonl b/holon-knowledge/ledger/pending/executions/I-1796254007-hac-ubuntu-bookkeeping-gate.jsonl new file mode 100644 index 000000000..ca88f5f3b --- /dev/null +++ b/holon-knowledge/ledger/pending/executions/I-1796254007-hac-ubuntu-bookkeeping-gate.jsonl @@ -0,0 +1,29 @@ +{"action_id": "ACT-1796255398-c241e2e5", "execution_id": "E-1796254438-CLA-CO5.5", "action": "Executed agent claude-agent with model claude-opus-5-5", "category": "code", "target": "claude-agent:claude-opus-5-5", "outcome": "success", "entry_type": "action", "parent_action_id": null, "event_type": "command_execution", "labels": ["agent", "claude-agent", "execution"], "error_context": null, "mistake_category": null, "action_origin": "initial_implementation", "review_severity": null, "review_iteration": null, "review_finding_ids": null, "review_disposition": null, "rejection_reason": null, "introduced_by_action_id": null, "created_at": "2026-12-02T23:49:58.279216Z"} +{"action_id": "ACT-1796255467-ff6eafca", "execution_id": "E-1796254438-CLA-CO5.5", "action": "Formatted 1 markdown files with prettier", "category": "doc", "target": ".github/workflows/README.md", "outcome": "success", "entry_type": "action", "parent_action_id": null, "event_type": "doc_update", "labels": ["formatting", "prettier"], "error_context": null, "mistake_category": null, "action_origin": "initial_implementation", "review_severity": null, "review_iteration": null, "review_finding_ids": null, "review_disposition": null, "rejection_reason": null, "introduced_by_action_id": null, "created_at": "2026-12-02T23:51:07.502253Z"} +{"entry_type": "summary", "execution_id": "E-1796254438-CLA-CO5.5", "plan_branch": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/_", "agent": "claude-agent", "agent_version": "2.1.302", "model": "claude-opus-5-5", "status": "success", "summary": "Plan executed successfully", "created_at": "2026-12-02T23:34:01.968508Z", "agent_output_truncated": false, "agent_output_bytes": 591, "ledger_revision": 1, "execution_notes": "executions/E-1796254438-CLA-CO5.5.md", "execution_notes_valid": true, "elapsed_seconds": 1025.5, "budget_seconds": 604711.0, "test_pass_rate": 1.0, "tests_passed": 11365, "tests_failed": 0, "tests_errored": 0, "test_exit_code": 0, "test_source": "stage_3"} +{"action_id": "ACT-1796255467-33bb29ae", "execution_id": "E-1796254438-CLA-CO5.5", "action": "Committed execution changes: execute: E-1796254438-CLA-CO5.5 completed for plan I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/_", "category": "code", "target": "HEAD", "outcome": "success", "entry_type": "action", "parent_action_id": null, "event_type": "git_mutation", "labels": ["commit", "git"], "error_context": null, "mistake_category": null, "action_origin": "initial_implementation", "review_severity": null, "review_iteration": null, "review_finding_ids": null, "review_disposition": null, "rejection_reason": null, "introduced_by_action_id": null, "created_at": "2026-12-02T23:51:07.513037Z"} +{"action_id": "ACT-REV-1796256260-3d3f11d2", "execution_id": "REV-ITR-1-1796256260", "action": "Review Loop iteration 1 reviewer 1 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 1, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 1, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-03T00:04:20.076429Z"} +{"action_id": "ACT-REV-1796256260-4637e56d", "execution_id": "REV-ITR-1-1796256260", "action": "Review Loop iteration 1 reviewer 2 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R2-001-01"], "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 2, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "CHANGES_REQUESTED", "review_counts": {"critical": 0, "important": 0, "nit": 1}, "created_at": "2026-12-03T00:04:20.090424Z"} +{"action_id": "ACT-FIND-1796256260-0ac4fb5f", "execution_id": "REV-FIND-1-1796256260", "action": "Review Loop iteration 1 finding detected: FIND-R2-001-01", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R2-001-01"], "labels": ["review", "finding", "iteration-1"], "error_context": "The README says a cancelled run's job-level skip is not successful, but with_gate_job_skips/classify_job count it as gate-skipped when the gate marker succeeded; make them agree and add a test.", "review_reviewer_index": 2, "review_file": ".github/workflows/README.md", "review_line": 245, "created_at": "2026-12-03T00:04:20.095060Z"} +{"action_id": "ACT-REV-1796256260-8684ad9c", "execution_id": "REV-ITR-1-1796256260", "action": "Review Loop iteration 1 reviewer 3 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-01"], "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 3, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "CHANGES_REQUESTED", "review_counts": {"critical": 0, "important": 0, "nit": 1}, "created_at": "2026-12-03T00:04:20.098932Z"} +{"action_id": "ACT-FIND-1796256260-9cda5bb4", "execution_id": "REV-FIND-1-1796256260", "action": "Review Loop iteration 1 finding detected: FIND-R3-001-01", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-01"], "labels": ["review", "finding", "iteration-1"], "error_context": "README says a job-level skip in a cancelled run is never successful, but with_gate_job_skips counts the macOS legs of a cancelled run as gate-skipped when the gate's marker step succeeded; narrow the sentence or pin the case with a test.", "review_reviewer_index": 3, "review_file": ".github/workflows/README.md", "review_line": null, "created_at": "2026-12-03T00:04:20.102530Z"} +{"action_id": "ACT-REV-1796256313-d8a92e07", "execution_id": "REV-ITR-1-1796256313", "action": "Review Loop iteration 1 evaluation for I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R2-001-01", "FIND-R3-001-01"], "labels": ["review", "review-loop", "iteration-1"], "error_context": "Findings detected: ['FIND-R2-001-01', 'FIND-R3-001-01']", "created_at": "2026-12-03T00:05:13.034805Z"} +{"action_id": "ACT-REV-1796256313-67580045", "execution_id": "REV-ITR-1-1796256313", "action": "Review Loop iteration 1 reviewer 1 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 1, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 1, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-03T00:05:13.036445Z"} +{"action_id": "ACT-REV-1796256313-85e64055", "execution_id": "REV-ITR-1-1796256313", "action": "Review Loop iteration 1 reviewer 2 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R2-001-01"], "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 2, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "CHANGES_REQUESTED", "review_counts": {"critical": 0, "important": 0, "nit": 1}, "created_at": "2026-12-03T00:05:13.038215Z"} +{"action_id": "ACT-FIND-1796256313-16bf1d9d", "execution_id": "REV-FIND-1-1796256313", "action": "Review Loop iteration 1 finding detected: FIND-R2-001-01", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R2-001-01"], "labels": ["review", "finding", "iteration-1"], "error_context": "The README says a cancelled run's job-level skip is not successful, but with_gate_job_skips/classify_job count it as gate-skipped when the gate marker succeeded; make them agree and add a test.", "review_reviewer_index": 2, "review_file": ".github/workflows/README.md", "review_line": 245, "created_at": "2026-12-03T00:05:13.039428Z"} +{"action_id": "ACT-REV-1796256313-72fe0176", "execution_id": "REV-ITR-1-1796256313", "action": "Review Loop iteration 1 reviewer 3 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-01"], "labels": ["review", "reviewer", "iteration-1"], "error_context": null, "review_reviewer_index": 3, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "CHANGES_REQUESTED", "review_counts": {"critical": 0, "important": 0, "nit": 1}, "created_at": "2026-12-03T00:05:13.040839Z"} +{"action_id": "ACT-FIND-1796256313-0679a46b", "execution_id": "REV-FIND-1-1796256313", "action": "Review Loop iteration 1 finding detected: FIND-R3-001-01", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "failure", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["FIND-R3-001-01"], "labels": ["review", "finding", "iteration-1"], "error_context": "README says a job-level skip in a cancelled run is never successful, but with_gate_job_skips counts the macOS legs of a cancelled run as gate-skipped when the gate's marker step succeeded; narrow the sentence or pin the case with a test.", "review_reviewer_index": 3, "review_file": ".github/workflows/README.md", "review_line": null, "created_at": "2026-12-03T00:05:13.042079Z"} +{"action_id": "ACT-RES-1796257733-ed9180e5", "execution_id": "REV-RES-1-1796257733", "action": "Review Loop iteration 1 finding R2-F1 adjudicated: applied", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["R2-F1"], "review_disposition": "applied", "rejection_reason": null, "introduced_by_action_id": "ACT-FIND-1796256313-16bf1d9d", "labels": ["review", "resolver", "iteration-1"], "error_context": null, "created_at": "2026-12-03T00:28:53.271138Z"} +{"action_id": "ACT-RES-1796257733-d27f205c", "execution_id": "REV-RES-1-1796257733", "action": "Review Loop iteration 1 finding R3-F1 adjudicated: applied", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": "nit", "review_iteration": 1, "review_finding_ids": ["R3-F1"], "review_disposition": "applied", "rejection_reason": null, "introduced_by_action_id": "ACT-FIND-1796256313-0679a46b", "labels": ["review", "resolver", "iteration-1"], "error_context": null, "created_at": "2026-12-03T00:28:53.272664Z"} +{"action_id": "ACT-REV-1796258503-64de6091", "execution_id": "REV-ITR-2-1796258503", "action": "Review Loop iteration 2 reviewer 1 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 1, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-03T00:41:43.141985Z"} +{"action_id": "ACT-REV-1796258503-f38852b4", "execution_id": "REV-ITR-2-1796258503", "action": "Review Loop iteration 2 reviewer 2 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 2, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-03T00:41:43.198558Z"} +{"action_id": "ACT-REV-1796258503-d2ce2241", "execution_id": "REV-ITR-2-1796258503", "action": "Review Loop iteration 2 reviewer 3 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 3, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-03T00:41:43.329849Z"} +{"action_id": "ACT-REV-1796258510-7b511f2a", "execution_id": "REV-ITR-2-1796258510", "action": "Review Loop iteration 2 evaluation for I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "review-loop", "iteration-2"], "error_context": null, "created_at": "2026-12-03T00:41:50.019920Z"} +{"action_id": "ACT-REV-1796258510-5271e238", "execution_id": "REV-ITR-2-1796258510", "action": "Review Loop iteration 2 reviewer 1 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 1, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-03T00:41:50.023275Z"} +{"action_id": "ACT-REV-1796258510-512350ac", "execution_id": "REV-ITR-2-1796258510", "action": "Review Loop iteration 2 reviewer 2 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 2, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-03T00:41:50.025298Z"} +{"action_id": "ACT-REV-1796258510-5d16b25c", "execution_id": "REV-ITR-2-1796258510", "action": "Review Loop iteration 2 reviewer 3 completed", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": null, "labels": ["review", "reviewer", "iteration-2"], "error_context": null, "review_reviewer_index": 3, "review_agent": "claude-agent", "review_model": "claude-opus-5-5", "review_status": "COMPLETED", "review_verdict": "APPROVED", "review_counts": {"critical": 0, "important": 0, "nit": 0}, "created_at": "2026-12-03T00:41:50.026393Z"} +{"action_id": "ACT-POST-1796258514-6fe9eb5a", "execution_id": "REV-POST-1796258514", "action": "Review consensus dual-posted to GitHub for I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "review_iteration": 2, "labels": ["review", "github", "dual-post"], "created_at": "2026-12-03T00:41:54.389370Z"} +{"execution_id": "REV-1796258518-c37fbb18-claude-agent", "plan_branch": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/_", "execution_branch": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "agent": "claude-agent", "agent_version": "1.4.0", "model": "claude-opus-5-5", "status": "approved", "entry_type": "summary", "summary": "Review Loop reached consensus approval after 2 iteration(s); PR ready for maintainer merge; final verdicts: Reviewer 1 APPROVED (0/0/0); Reviewer 2 APPROVED (0/0/0); Reviewer 3 APPROVED (0/0/0)", "created_at": "2026-12-03T00:41:58.591Z", "total_iterations": 2, "max_iterations": 25, "ci_checks_summary": {"source": "github_cli", "total": 18, "passed": 18, "failed": 0, "pending": 0, "skipped": 0, "all_passed": true, "checks": [{"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634874/job/143902903235", "name": "unit (macos-latest, shard 2 of 2)", "state": "SUCCESS", "workflow": "Test - Unit"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634773/job/143902837525", "name": "build (macos-latest)", "state": "SUCCESS", "workflow": "Run Make"}, {"bucket": "pass", "event": "", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/runs/143902997188", "name": "CodeQL", "state": "SUCCESS", "workflow": ""}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634874/job/143902903113", "name": "unit (macos-latest, shard 1 of 2)", "state": "SUCCESS", "workflow": "Test - Unit"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634874/job/143902903116", "name": "unit (ubuntu-latest)", "state": "SUCCESS", "workflow": "Test - Unit"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634728/job/143902858096", "name": "Workspace survival (ubuntu-latest)", "state": "SUCCESS", "workflow": "Test - Stress"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634773/job/143902837560", "name": "build (ubuntu-latest)", "state": "SUCCESS", "workflow": "Run Make"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003635017/job/143902779525", "name": "integration (ubuntu-latest)", "state": "SUCCESS", "workflow": "Test - Integration"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634874/job/143902764412", "name": "macOS gate", "state": "SUCCESS", "workflow": "Test - Unit"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634781/job/143902761682", "name": "hygiene (ubuntu-latest)", "state": "SUCCESS", "workflow": "Test - Hygiene"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634703/job/143902760950", "name": "build", "state": "SUCCESS", "workflow": "Docker Build"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634835/job/143902760447", "name": "ledger-invariants", "state": "SUCCESS", "workflow": "Test - Ledger Invariants"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634773/job/143902753826", "name": "macOS gate", "state": "SUCCESS", "workflow": "Run Make"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634801/job/143902751770", "name": "self-doc-behavior", "state": "SUCCESS", "workflow": "Test - Self-Doc Behavior"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634755/job/143902745048", "name": "commit-trailers", "state": "SUCCESS", "workflow": "Test - Commit Trailers"}, {"bucket": "pass", "event": "dynamic", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003628335/job/143902720661", "name": "Analyze (python)", "state": "SUCCESS", "workflow": "CodeQL"}, {"bucket": "pass", "event": "pull_request", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003634736/job/143902734554", "name": "scan", "state": "SUCCESS", "workflow": "Test - No Harness References"}, {"bucket": "pass", "event": "dynamic", "link": "https://github.com/Holon-Agentic-Coder/holon-agentic-coder/actions/runs/47003628335/job/143902720236", "name": "Analyze (actions)", "state": "SUCCESS", "workflow": "CodeQL"}], "test_source": "ci_head", "test_head_sha": "854bc3fc9a44f378edda502a5a356ca782b6a9ba"}, "trailers": {"action_origin": "pr_review", "review_severity": null, "review_iteration": 2, "review_finding_ids": ["none"], "review_disposition": null, "rejection_reason": null, "introduced_by_action_id": null, "consulted_knowledge_ids": null}, "review_post_withheld": null} +{"execution_id": "REV-1796258518-c37fbb18-claude-agent", "action": "Review Loop executed for I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "category": "test", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "verdict": "success", "outcome": "success", "entry_type": "action", "context_fingerprint": "35ba05f15dc58cee", "labels": ["review", "review-loop", "claude-agent"], "error_context": null, "action_id": "ACT-1796258518-7095ca1f", "created_at": "2026-12-03T00:41:58.592218Z"} +{"action_id": "SYNC-1796258539-62d8b4a4", "execution_id": "E-1796254438-CLA-CO5.5", "action": "target_sync", "category": "code", "target": "main", "outcome": "success", "event_type": "target_sync", "labels": ["target_sync", "calibrate"], "stage": "calibrate", "boundary": "calibrate", "branch": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "target_sha": "c4cf01b9ff70e6d9cc16934ecfb37582434fa93f", "head_before": "59b58504b100e8bb6928c575af909a93bf7a4ae7", "conflicted_paths": [], "resolutions": [], "code_paths": [], "resolver_tier": "", "attempts": 0, "test_result": "", "supersedes": "", "entry_type": "action", "action_origin": "initial_implementation", "created_at": "2026-12-03T00:42:19.777271Z"} +{"action_id": "ACT-CARRY-1796258543-a6759eeb", "execution_id": "REV-CARRY-1796258543", "action": "Approval for I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_ carried over from 854bc3fc9a44f378edda502a5a356ca782b6a9ba to 1726ecd6e6c25831b75b8e99aefb4c2fbe3e72ff: same PR-own change (fingerprint pf2:083751218be13df5d113819e467cf0de672744f8)", "category": "code", "target": "I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-1796254438-CLA-CO5.5/_", "outcome": "success", "entry_type": "action", "action_origin": "pr_review", "labels": ["review", "conflict-gate", "approval-carry-over"], "approved_head": "854bc3fc9a44f378edda502a5a356ca782b6a9ba", "merged_head": "1726ecd6e6c25831b75b8e99aefb4c2fbe3e72ff", "approval_fingerprint": "pf2:083751218be13df5d113819e467cf0de672744f8", "created_at": "2026-12-03T00:42:23.820034Z"} diff --git a/holon-knowledge/ledger/pending/intents/I-1796254007-hac-ubuntu-bookkeeping-gate.jsonl b/holon-knowledge/ledger/pending/intents/I-1796254007-hac-ubuntu-bookkeeping-gate.jsonl new file mode 100644 index 000000000..d9fb09f48 --- /dev/null +++ b/holon-knowledge/ledger/pending/intents/I-1796254007-hac-ubuntu-bookkeeping-gate.jsonl @@ -0,0 +1 @@ +{"slug": "hac-ubuntu-bookkeeping-gate", "target_branch": "main", "description": "bookkeeping-gate and macos-relevance-gate currently run inside macos-latest matrix legs across workflows, forcing every bookkeeping-only push to queue for macos-latest runners only to skip.", "goal": "Move bookkeeping-gate (and macos-relevance-gate where applicable) out of macos-latest matrix legs into a single fast ubuntu-latest gate job (needs: gate, if: needs.gate.outputs.skip != 'true') across test-unit.yml, test-integration.yml, test-stress.yml, test-hygiene.yml, docker-build.yml, and make.yml, and update scripts/ci_bookkeeping_chain.py, scripts/ci_bookkeeping_gate.py, scripts/ci_bookkeeping_api.py, and apps/sandbox-executor/src/sandbox_executor/flow/github/ci_policy.py so job-level SKIPPED is recognized as gate-skipped rather than failed or unverified. Update wiring and chain tests under uv run pytest. Code is self-explaining: no docstrings and no comments except '# why:' comments that record a reason the code cannot show.", "rationale": "Eliminates macos-latest runner queueing and cancellations for bookkeeping-only commits.", "scope": [".github/workflows/test-unit.yml", ".github/workflows/test-integration.yml", ".github/workflows/test-stress.yml", ".github/workflows/test-hygiene.yml", ".github/workflows/docker-build.yml", ".github/workflows/make.yml", ".github/workflows/README.md", ".github/actions/bookkeeping-gate/action.yml", "scripts/ci_bookkeeping_api.py", "scripts/ci_bookkeeping_chain.py", "scripts/ci_bookkeeping_gate.py", "apps/sandbox-executor/src/sandbox_executor/flow/github/ci_policy.py", "apps/sandbox-executor/tests/test_ci_bookkeeping_chain.py", "apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py", "apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py", "apps/sandbox-executor/tests/test_macos_relevance_wiring.py", "apps/sandbox-executor/tests/flow/github/test_ci_policy.py", "apps/sandbox-executor/tests/ci_bookkeeping_fakes.py"], "acceptance_criteria": ["Bookkeeping-only pushes decide skip in a single fast ubuntu-latest gate job (needs: gate) in test-unit.yml, test-integration.yml, test-stress.yml, test-hygiene.yml, docker-build.yml, make.yml, action.yml, and .github/workflows/README.md (verified by test_ci_bookkeeping_wiring.py and test_ci_bookkeeping_gate.py using ci_bookkeeping_fakes.py) so macos-latest legs never request runners when skipped.", "scripts/ci_bookkeeping_chain.py, ci_bookkeeping_api.py, ci_bookkeeping_gate.py, and flow/github/ci_policy.py (tested by test_ci_bookkeeping_chain.py) treat job-level SKIPPED conclusions from the ubuntu-latest gate job as gate-skipped rather than failed or unverified.", "A push whose changes since the last fully tested commit lie only in plans/, executions/ and holon-knowledge/ finishes its required checks in seconds via an in-job gate or gate job.", "A change outside those paths, however small, always gets the full pipeline; the rule is tested with a mixed commit.", "Formatting checks that apply to these files (Prettier on the calibration report) still run.", "The engine-side wait treats a bookkeeping-only head as covered, or the gate and the engine wait are consistent with the one mechanism chosen."], "assumptions": [{"id": "A1", "statement": "test_ci_bookkeeping_wiring.py asserts workflow YAML structure across all six workflows and action.yml; updating the workflows and wiring assertions together keeps CI hygiene green (verified by inspecting workflows on origin/main).", "impact": "high"}, {"id": "A2", "statement": "GitHub check-runs/jobs report conclusion/state SKIPPED when skipped by an upstream job `if: needs.gate.outputs.skip != 'true'` condition.", "impact": "high"}], "assumption_validation": [{"assumption_id": "A1", "method": "Stage 3 runs test_ci_bookkeeping_wiring.py, test_ci_bookkeeping_chain.py, test_ci_bookkeeping_gate.py, and test_macos_relevance_wiring.py."}, {"assumption_id": "A2", "method": "Stage 3 tests job-level SKIPPED handling in test_ci_bookkeeping_chain.py and flow/github/ci_policy tests."}], "assumption_risk": [{"assumption_id": "A1", "likelihood": "medium", "testability": "testable", "score": 2, "response": "Preserve macOS relevance gate and required job check names on non-bookkeeping runs."}, {"assumption_id": "A2", "likelihood": "low", "testability": "testable", "score": 1, "response": "Keep previous in-job marker step fallback so historical runs remain verifiable."}], "branch": "I-1796254007-hac-ubuntu-bookkeeping-gate", "status": "proposed", "created_at": "2026-12-02T23:26:55.313Z"} diff --git a/holon-knowledge/ledger/pending/plans/I-1796254007-hac-ubuntu-bookkeeping-gate.jsonl b/holon-knowledge/ledger/pending/plans/I-1796254007-hac-ubuntu-bookkeeping-gate.jsonl new file mode 100644 index 000000000..669b4d3a9 --- /dev/null +++ b/holon-knowledge/ledger/pending/plans/I-1796254007-hac-ubuntu-bookkeeping-gate.jsonl @@ -0,0 +1 @@ +{"plan_id": "P-1796254031-CLA-CO5.5", "intent_branch": "I-1796254007-hac-ubuntu-bookkeeping-gate/_", "agent": "claude-agent", "agent_version": "2.1.302", "model": "claude-opus-5-5", "p_success": 0.7, "entropy": 10.5, "impact": 75.0, "cost": 21.5, "learning_value": 5.0, "ev": 30.35, "created_at": "2026-12-02T23:32:40.360Z", "plan_file": "plans/I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5.md", "status": "proposed", "entropy_budget": 15.0, "decomposition_decision": "execute", "touch_set": [{"path": ".github/workflows/test-unit.yml"}, {"path": ".github/workflows/make.yml"}, {"path": ".github/workflows/README.md"}, {"path": ".github/actions/bookkeeping-gate/action.yml"}, {"path": "scripts/ci_bookkeeping_gate_job.py"}, {"path": "scripts/ci_bookkeeping_api.py", "symbols": ["list_jobs"]}, {"path": "scripts/ci_bookkeeping_chain.py", "symbols": ["classify_job", "GATE_SKIPPED"]}, {"path": "apps/sandbox-executor/src/sandbox_executor/flow/github/ci_policy.py"}, {"path": "apps/sandbox-executor/tests/ci_bookkeeping_fakes.py"}, {"path": "apps/sandbox-executor/tests/test_ci_bookkeeping_chain.py"}, {"path": "apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py"}, {"path": "apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py"}, {"path": "apps/sandbox-executor/tests/test_macos_relevance_wiring.py"}, {"path": "apps/sandbox-executor/tests/flow/github/test_ci_policy.py"}]} diff --git a/plans/I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5.md b/plans/I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5.md new file mode 100644 index 000000000..319b65e37 --- /dev/null +++ b/plans/I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5.md @@ -0,0 +1,747 @@ +# Plan for I-1796254007-hac-ubuntu-bookkeeping-gate + +- **Plan ID:** P-1796254031-CLA-CO5.5 +- **Parent Intent ID:** NONE +- **Agent:** claude-agent/claude-opus-5-5 (version: 2.1.302) +- **Created At:** 2026-12-02T23:27:12.922Z + +## Planner Autonomy Summary + +- **Intent handling:** REFRAME +- **Reframed intent (if applicable):** + `{"change": "Add one ubuntu-latest gate job only to the two workflows that have macos-latest legs (test-unit.yml: the two unit shards; make.yml: build (macos-latest)). Split each macOS leg into its own job with a static name equal to its required status check, gated by needs: gate and if: !cancelled() && needs.gate.outputs.skip != 'true'. Keep the in-job bookkeeping gate on every ubuntu-latest job, including all of test-integration.yml, test-stress.yml, test-hygiene.yml and docker-build.yml, which have no macOS leg and stay byte-identical. Recognise a job-level skip as gate-skipped only when the same run's gate job carries a successful skip marker step."}` +- **Exploration stance:** balanced. The code changes are routine, but two GitHub behaviours cannot be checked from the + sandbox: how a skipped job is named, and how a skipped required check is reported. The design avoids depending on + either (static job names, a marker step as evidence), and one exploratory step records what CI actually does. +- **Safety priority level:** elevated +- **Priority Justification:** This change touches the CI gates that decide whether tests run before a merge to `main` + (`docs/safety.md` "Human review is the final gate" and "Safety invariants"). If a job-level skip is misread, macOS + tests can be skipped silently while branch protection treats the skipped check as passing. A misnamed skipped matrix + job can leave a required check stuck on "Expected" and block every merge. Neither failure is a sandbox or secrets + risk, so the level is elevated rather than critical. + +## Exploration + +- **Proportion of steps that are exploratory:** 0.14 +- **Justification:** One of seven steps (Step 1) is a bounded read-only check of the assumptions. Its findings go into + the execution notes, including what GitHub is expected to do with skipped job names and skipped required checks. The + other steps exploit existing patterns (marker steps, fakes, text-based wiring tests). + +## Overall Plan Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.70 | +| entropy_pred | 10.5 | +| impact_pred | 75.0 | +| cost_pred | 21.5 | +| learning_value_pred | 5.0 | +| ev_pred | 30.35 | + +### Strategy Rationale + +**Why the intent is reframed.** Read from origin/main state on this branch, only two workflows have a `macos-latest` +leg: `test-unit.yml` (matrix legs `unit (macos-latest, shard 1 of 2)` and `unit (macos-latest, shard 2 of 2)`) and +`make.yml` (`build (macos-latest)`). `test-integration.yml`, `test-stress.yml`, `test-hygiene.yml` and +`docker-build.yml` run only on `ubuntu-latest`. Taken literally, the intent would add a gate job and a job-level skip to +all six workflows. For the four Ubuntu-only workflows that saves no macOS runner time and adds a second Ubuntu job to +every push. It would also break two acceptance criteria and one invariant: + +- Every required check is a matrix-expanded name (`hygiene (ubuntu-latest)`, `unit (ubuntu-latest)`, + `integration (ubuntu-latest)`, `build (ubuntu-latest)`; README "Branch Protection Status Checks"). When a matrix job + is skipped by a job-level `if`, GitHub does not expand its matrix. The check then appears under an unexpanded or bare + name, and the required check stays "Expected" and blocks merges. This is why the README states that the gated jobs + have "no job-level condition". +- The criterion "Formatting checks that apply to these files (Prettier on the calibration report) still run" depends on + the hygiene job running its `make lint-md` and `make lint-json` steps on a bookkeeping-only push. A job-level skip of + hygiene would remove them. +- The third criterion explicitly allows "an in-job gate or gate job". + +The reframe therefore keeps the in-job gate wherever the runner is Ubuntu, and adds the gate job only where it removes +macOS runner requests. Each macOS leg becomes its own job with a static `name:` equal to its required check, so a +job-level skip reports a `skipped` check under that exact name. Branch protection counts a skipped check as passing. +This meets the rationale ("eliminates macos-latest runner queueing") in full, at lower risk. + +**Mechanism chosen.** Skip evidence comes from a marker step in the gate job. A job skipped at job level has no steps, +so it cannot carry the `Full run completed` evidence. The gate job ends with a step `macOS legs skipped` that runs only +when it decided "skip". When an earlier run shows a macOS job with conclusion `skipped` and that run's gate job shows +this marker step as `success`, the job is classified `gate-skipped`. Any other job-level skip, such as a skip caused by +a cancelled run, stays `not-successful` and the next push runs in full. + +The evidence is attached in `ci_bookkeeping_api.list_jobs`, which all three walkers share: the chain walk, the main-push +gate and the merge-push gate. `classify_job` in `ci_bookkeeping_chain.py` reads it, so every route classifies a +job-level skip the same way without editing the out-of-scope `ci_main_push_gate.py` or `ci_merge_push_gate.py`. + +`ci_bookkeeping_api.py` is at 345 of its 350-line budget, and the budget file is frozen. The evidence logic therefore +goes into a new focused module, `scripts/ci_bookkeeping_gate_job.py`, owned by the bookkeeping-gate family. The api +module gains only an import and a one-line call. This new module is the one touch outside the listed intent scope; the +module-budget rule forces it. + +**Engine-side wait.** `ci_policy.summarise_ci_checks` already counts a check with `bucket` `skipping` or `state` +`SKIPPED` as skipped, never as failed, and `all_passed` requires only no failed and no pending checks. The engine wait +and the gate therefore already agree, which satisfies the sixth acceptance criterion through one mechanism. Step 4 pins +this with tests and changes `ci_policy.py` only if a test exposes a gap. + +**Aggregation of metrics.** Entropy is the sum of the step entropies (`0.5 + 2.0 + 1.0 + 0.8 + 3.5 + 2.2 + 0.5 = 10.5`). +Cost is the sum of the step costs (`1.5 + 4.0 + 2.5 + 1.5 + 5.0 + 4.5 + 2.5 = 21.5`). A plain product of the step +success probabilities gives about 0.33. That understates the plan, because Steps 5 and 6 are coupled and fixed together +in the same Stage 3 loop. The overall p_success is set qualitatively at 0.70, bounded by Step 5, the bottleneck. Impact +75 is a qualitative judgement: the change removes every macOS runner request on bookkeeping-only and macOS-irrelevant +pull-request pushes. Derivation: +`EV = P * Impact + mu * LV - lambda * Delta_S - Cost = 0.70 * 75.0 + 0.5 * 5.0 - 0.3 * 10.5 - 21.5 = 52.5 + 2.5 - 3.15 - 21.5 = 30.35`. + +## Safety & Constraint Alignment + +- **Key world ruleset constraints that affect this plan:** + - `holon-config/world/constraints.md` section 1: scoped commits on the plan and execution branches only; no direct + push to `main`. + - `holon-config/world/constraints.md` section 3: ledgers are append-only. This plan touches no `.jsonl` file. + - `holon-config/world/ruleset.md` section 3: test changes must be declared in the plan. Every test file touched is + listed in the Touch Set and named in its step. + - `docs/safety.md` "Human review is the final gate" and "Safety invariants": CI evidence must never claim a test ran + when it did not. + - Repository rules: the module budgets are frozen (`holon-config/hygiene/module_budgets.json`, default 350 lines) and + the self-explaining code gate (`scripts/check_self_explaining.py`) allows only `# why:` comments and no new + docstrings. +- **Potential violations or edge cases:** + - A required check stays "Expected" when a skipped job's reported name differs from the required name. + - A gate job that fails or is cancelled could cascade into a `skipped` macOS check that branch protection treats as + green. + - The evidence could misclassify a skip caused by a cancelled run as `gate-skipped`. + - `ci_bookkeeping_api.py` could exceed its 350-line budget. + - Out-of-scope tests could break because they pin test-unit.yml text: `test_ci_timing_gate.py` matches the regex + `- os: macos-latest\n\s+timing-min-delta: 150` and the timing flags. +- **Mitigations built into the plan:** + - Each macOS leg gets a static job name that equals its required check, with no `${{ matrix.* }}` in the name. A + single-entry `include` matrix keeps the `matrix.*` values and the timing regex intact. + - The job-level condition is `!cancelled() && needs.gate.outputs.skip != 'true'`. A failed gate job leaves the output + empty and the macOS leg runs in full (fail to run, never fail to skip). The bookkeeping-gate action itself never + fails. + - `gate-skipped` requires positive evidence: the same run's gate job has a `macOS legs skipped` step with conclusion + `success`. Anything else is `not-successful`. + - The evidence logic goes into a new module; the api module gains at most 3 lines. + - Step 7 runs `test_ci_timing_gate.py`, `test_unit_test_shard.py`, `test_ci_main_push_gate.py` and + `test_ci_merge_push_gate.py` unchanged as regression guards. +- **Residual risk accepted (and why):** The sandbox cannot run GitHub Actions. Live behaviour (static names on skipped + jobs, a skipped required check counting as passing) is accepted on the strength of GitHub's documented rule that a job + skipped by a condition reports success to required checks, and is confirmed by the first pull-request run of this very + branch. In that run the macOS jobs must appear under their usual names. The README records how to check this. +- **Allocated Entropy Budget:** 15.0 +- **Predicted Plan Entropy:** 10.5 +- **Budget Compliance:** The strategy fits within budget (10.5 of 15.0), so it runs as one plan with no sub-intents. + +## Plan Description & Strategy + +The plan moves the skip decision for every macOS leg into one fast `ubuntu-latest` job named `macOS gate` (job key +`gate`) in `test-unit.yml` and `make.yml`. + +In `test-unit.yml`, the gate job asks the existing bookkeeping gate once per macOS leg (`unit` with `shard 1 of 2`, and +`unit` with `shard 2 of 2`) and runs the existing macOS relevance gate once. It outputs `skip=true` when both +bookkeeping decisions say skip, or when the relevance gate says skip. It then ends with the marker step +`macOS legs skipped` under the same condition. In `make.yml`, the gate job asks the bookkeeping gate once (`build` with +`macos-latest`). + +Each macOS leg becomes its own job with a static required-check name, `needs: gate`, and the condition +`!cancelled() && needs.gate.outputs.skip != 'true'`. It runs its expensive steps without the in-job gate guards and +still ends with `Full run completed`, so a run that happened is a real success. The ubuntu legs keep their in-job gate +unchanged. + +On the script side, `list_jobs` marks a job skipped at job level as `skipped_by_gate_job` when the same run's gate job +proves the skip. `classify_job` then returns `gate-skipped` for it, so the chain, the main-push route and the merge-push +route all walk past it to the last real success. A mixed commit still runs everything, because the per-leg bookkeeping +decision is unchanged. Tests pin the workflow shape, the marker evidence, the chain and gate behaviour (including a +mixed commit) and the engine-side check summary. + +## Touch Set + +- `.github/workflows/test-unit.yml` +- `.github/workflows/make.yml` +- `.github/workflows/README.md` +- `.github/actions/bookkeeping-gate/action.yml` +- `scripts/ci_bookkeeping_gate_job.py` +- `scripts/ci_bookkeeping_api.py` symbols: list_jobs +- `scripts/ci_bookkeeping_chain.py` symbols: classify_job, GATE_SKIPPED +- `apps/sandbox-executor/src/sandbox_executor/flow/github/ci_policy.py` +- `apps/sandbox-executor/tests/ci_bookkeeping_fakes.py` +- `apps/sandbox-executor/tests/test_ci_bookkeeping_chain.py` +- `apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py` +- `apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py` +- `apps/sandbox-executor/tests/test_macos_relevance_wiring.py` +- `apps/sandbox-executor/tests/flow/github/test_ci_policy.py` + +`scripts/ci_bookkeeping_gate.py` is in the intent scope but is expected to stay unchanged: the gate job reuses its +per-leg decision. It is added only if Step 3 finds a gap. `test-integration.yml`, `test-stress.yml`, `test-hygiene.yml` +and `docker-build.yml` stay unchanged on purpose (see Strategy Rationale). + +--- + +## Step 1: Confirm the assumptions and pin the current behaviour before editing + +- **Sub‑intent recommendation:** NO +- **Reasoning:** This is a short read-only step. It costs little, and it decides how Step 5 handles the out-of-scope + tests and whether `ci_policy.py` needs any code change. +- **Step Type:** INFO_GATHERING +- **Exploration level:** BALANCED + +- **Hypothesis being tested:** Four things hold together. Only `test-unit.yml` and `make.yml` contain `macos-latest`. + `ci_policy.summarise_ci_checks` already treats `bucket: skipping` or `state: SKIPPED` as non-failing. The engine wait + (`flow/github/ci.py`) gates on `all_passed` and on no particular check name. The only out-of-scope tests that pin + test-unit.yml or make.yml text are `test_ci_timing_gate.py` and `test_unit_test_shard.py`. +- **Learning target:** The exact text contracts Step 5 must keep, and whether the sixth acceptance criterion needs a + code change or only tests. +- **Maximum acceptable cost for this learning:** 1.5 cost units (about 10 minutes of reading); no code changes. + +### Intent & Git Integration + +- **Step Intent:** Turn the assumptions A1 and A2 into checked facts before any edit. +- **Git branch:** `I-1796254007-hac-ubuntu-bookkeeping-gate/P-1796254031-CLA-CO5.5/E-{timestamp}-CLA-CO5.5/_` (execution + branch) +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. Grep `.github/workflows/*.yml` for `macos-latest`. Expect only `test-unit.yml` and `make.yml`, and record this in the + execution notes. +2. Grep `apps/sandbox-executor/tests` for `test-unit.yml` and `make.yml`. For each hit outside the Touch Set (at least + `test_ci_timing_gate.py`, `test_unit_test_shard.py`, `test_ci_durations*.py` and `test_final_head_timing_rerun.py`), + list the literal text it asserts. Step 5 must keep every one of these strings. +3. Read `flow/github/ci.py` and its callers of `summarise_ci_checks`. Confirm the wait never requires a named check, and + that a check with `bucket` `skipping` leaves `all_passed` true. +4. Read `test_ci_bookkeeping_wiring.py` helpers (`split_steps`, `steps_of`, `WIRING`, `Wiring`). Note that `split_steps` + refuses a workflow with two jobs, which Step 6 must change. +5. Record in the execution notes the GitHub behaviour the design relies on. A job skipped by a job-level `if` reports + conclusion `skipped`, and a required check with conclusion `skipped` counts as passing. A skipped matrix job is not + expanded, which is why the static names are used. + +### Dependencies & Criticality + +- **Depends on:** NONE +- **Is Bottleneck:** NO + +### Safety & Constraint Considerations + +- **Relevant rules:** `docs/safety.md` "Git is the safety boundary" (read-only step). +- **Potential failure modes for this step:** A third workflow turns out to have a macOS leg; an unlisted test pins the + workflow text. +- **Guardrails and early‑abort checks:** If a third workflow has a macOS leg, give it the same treatment as make.yml in + Step 5 and record the deviation. If an unlisted test would have to change (rather than stay green), stop and record a + blocker instead of editing it. + +### Success & Discard Criteria + +- **Success:** The execution notes list the macOS-leg workflows, the pinned text contracts and the `ci_policy` + conclusion. +- **Discard:** Stop the exploration once it exceeds 2x its cost; carry on with the design as planned. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.95 | +| entropy_pred | 0.5 | +| impact_pred | 10.0 | +| cost_pred | 1.5 | +| learning_value_pred | 3.0 | +| ev_pred | 9.35 | + +### Step Metrics Rationale + +This step is read-only, so failure is unlikely. Its learning value is higher than its impact because it settles A1 and +A2 for the rest of the plan. `EV = 0.95 * 10.0 + 0.5 * 3.0 - 0.3 * 0.5 - 1.5 = 9.5 + 1.5 - 0.15 - 1.5 = 9.35`. + +--- + +## Step 2: Recognise a job-level skip proved by the gate job as gate-skipped + +- **Sub‑intent recommendation:** NO +- **Reasoning:** This step makes a small, well-tested change to pure functions and follows the existing marker-step + pattern. It is the safety core, but it is small enough to finish within the plan. +- **Step Type:** IMPLEMENTATION +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Make the chain walk, the main-push gate and the merge-push gate classify a macOS job skipped at job + level as `gate-skipped` only when the same run's gate job proves it. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. Create `scripts/ci_bookkeeping_gate_job.py`. It uses the standard library only, Python 3.9 syntax and + `from __future__ import annotations`, with no docstrings or comments, as the self-explaining gate requires. It holds: + - The constant `GATE_SKIP_STEP = "macOS legs skipped"`, the marker step name. + - The key `SKIPPED_BY_GATE_JOB = "skipped_by_gate_job"`. + - A function `gate_job_skipped(jobs)`, which returns true when any job of the run has a step dict named + `GATE_SKIP_STEP` with conclusion `success`. Non-dict steps and a missing step list are ignored. + - A function `with_gate_job_skips(jobs)`. It returns new dicts in which every job with status `completed` and + conclusion `skipped` carries `SKIPPED_BY_GATE_JOB` true exactly when `gate_job_skipped(jobs)` is true. All other + jobs come back unchanged. +2. In `scripts/ci_bookkeeping_api.py`, import `with_gate_job_skips` and make `list_jobs` return + `with_gate_job_skips(jobs)` after the existing validation. Add no other lines: the module must stay at or below 350 + lines (it is at 345 now). Check this with `uv run python scripts/check_module_budgets.py` or `uv run task lint`. +3. In `scripts/ci_bookkeeping_chain.py`, `classify_job` first returns `GATE_SKIPPED` for a job whose + `SKIPPED_BY_GATE_JOB` is true. That check comes before the existing `status` and `conclusion` test, which would + otherwise return `NOT_SUCCESSFUL`. Nothing else in the chain changes. `_visit`, `_visit_or_cancelled`, the main-push + gate and the merge-push gate already treat `GATE_SKIPPED` as "keep walking to the last real success". If a `# why:` + comment is needed, it says that a job skipped at job level has no steps to carry `Full run completed`. +4. Extend `apps/sandbox-executor/tests/ci_bookkeeping_fakes.py` with two job builders. `job_skipped_at_job_level(name)` + builds status `completed`, conclusion `skipped` and an empty step list. `gate_job(skipped)` builds the `macOS gate` + job with steps `Bookkeeping gate` and `macOS legs skipped`, the latter `success` when `skipped` is true and `skipped` + otherwise. +5. Add tests to `apps/sandbox-executor/tests/test_ci_bookkeeping_chain.py`: + - A job skipped at job level beside a gate job whose marker succeeded is `gate-skipped`, and `find_real_success` + walks past it to an older real success. + - The same job beside a gate job whose marker was skipped is `not-successful`, and the walk stops with + `previous-run-not-successful`. + - The same job in a run without a gate job (a cancelled run, or a historical run) is `not-successful`. + - Existing in-job marker jobs (`Full run completed` `success` or `skipped`) classify exactly as before. This is the + A2 fallback for historical runs. + - `with_gate_job_skips` never marks a job whose conclusion is `success`, `failure` or `cancelled`. + +### Dependencies & Criticality + +- **Depends on:** Step 1 +- **Is Bottleneck:** YES (the workflow change in Step 5 is only safe and useful if the walk understands job-level skips) + +### Safety & Constraint Considerations + +- **Relevant rules:** `docs/safety.md` "Safety invariants"; module budgets; the self-explaining code gate. +- **Potential failure modes for this step:** + - The evidence is too loose, so a cancelled run counts as gate-skipped. + - The api module goes over its budget. + - An import cycle appears. The new module imports nothing from the api or chain modules, so none is expected. +- **Guardrails and early‑abort checks:** + - The negative tests above are mandatory. + - Run + `uv run pytest apps/sandbox-executor/tests/test_ci_bookkeeping_chain.py apps/sandbox-executor/tests/test_ci_main_push_gate.py apps/sandbox-executor/tests/test_ci_merge_push_gate.py` + in the foreground before moving on. + +### Success & Discard Criteria + +- **Success:** The new chain tests pass. The unchanged main-push and merge-push tests pass. `ci_bookkeeping_api.py` is + at or below 350 lines. +- **Discard:** If a cycle-free placement cannot keep the api module within budget, fall back to annotating inside + `ci_bookkeeping_chain.py` (chain walk only). In that case, record that the main-push and merge-push routes run the + macOS legs in full after a job-level skip, which is fail-closed. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.85 | +| entropy_pred | 2.0 | +| impact_pred | 25.0 | +| cost_pred | 4.0 | +| learning_value_pred | 2.0 | +| ev_pred | 17.65 | + +### Step Metrics Rationale + +The change is small and pure-functional, and it follows an existing pattern. The residual risk is the line budget and +the size of the test fixtures. `EV = 0.85 * 25.0 + 0.5 * 2.0 - 0.3 * 2.0 - 4.0 = 21.25 + 1.0 - 0.6 - 4.0 = 17.65`. + +--- + +## Step 3: Prove the per-leg gate decisions end to end, including a mixed commit + +- **Sub‑intent recommendation:** NO +- **Reasoning:** This step is tests only. The fakes already exist; it adds scenarios. +- **Step Type:** TEST +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Show that the gate job's per-leg decision skips a bookkeeping-only push after a job-level-skipped + run, and that a mixed commit always runs. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. In `apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py`, add a scene with three runs, built with the fakes from + Step 2: + - Run N-2 is a real success of `unit (macos-latest, shard 1 of 2)`. + - Run N-1 is on the previous head and shows that job skipped at job level, with the gate job's marker `success`. + - The new push changes only `plans/…md` and `executions/…md`. + - Assert that `decide` with job name `unit` and os `shard 1 of 2` gives `skip=True`, rule `bookkeeping-only`. +2. Use the same scene with a push that adds `plans/x.md` and changes one line of `scripts/ci_timing_gate.py` (the mixed + commit). Assert `skip=False`, rule `non-bookkeeping-change`, and a detail that names the code path. +3. Use the same scene with N-1's gate marker `skipped` (a job skipped for another reason). Assert `skip=False`, rule + `previous-run-not-successful`. +4. Add a `make.yml` variant (job name `build`, os `macos-latest`, job name `build (macos-latest)`) to show that the + non-shard name matches. +5. Leave `scripts/ci_bookkeeping_gate.py` unchanged unless one of these tests fails because of the gate itself. Any fix + must stay within the existing functions' complexity limits. + +### Dependencies & Criticality + +- **Depends on:** Step 2 +- **Is Bottleneck:** NO + +### Safety & Constraint Considerations + +- **Relevant rules:** `holon-config/world/ruleset.md` section 3 (declared test changes); the acceptance criterion on + mixed commits. +- **Potential failure modes for this step:** + - `match_job` refuses a name. The static names match their legs: `unit (macos-latest, shard 1 of 2)` holds the value + `shard 1 of 2`. + - The fake run ordering is wrong. +- **Guardrails and early‑abort checks:** Run `uv run pytest apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py` in + the foreground. + +### Success & Discard Criteria + +- **Success:** All new scenarios pass with `ci_bookkeeping_gate.py` unchanged, or with a minimal recorded fix. +- **Discard:** If the gate needs more than a 20-line change, stop and record why. That would mean the per-leg reuse + premise is wrong. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.88 | +| entropy_pred | 1.0 | +| impact_pred | 12.0 | +| cost_pred | 2.5 | +| learning_value_pred | 1.5 | +| ev_pred | 8.51 | + +### Step Metrics Rationale + +This is test work on mature fakes, so the risk is low. Its impact is the mixed-commit acceptance criterion. +`EV = 0.88 * 12.0 + 0.5 * 1.5 - 0.3 * 1.0 - 2.5 = 10.56 + 0.75 - 0.3 - 2.5 = 8.51`. + +--- + +## Step 4: Pin the engine-side wait for job-level skipped checks + +- **Sub‑intent recommendation:** NO +- **Reasoning:** This is a characterisation test on a pure, 87-line policy module. A code change happens only if a test + exposes a gap. +- **Step Type:** TEST +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Make the engine wait and the gate consistent: a job-level skipped macOS check never counts as failed + or pending. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. In `apps/sandbox-executor/tests/flow/github/test_ci_policy.py`, add three cases to `summarise_ci_checks`: + - Passing `unit (ubuntu-latest)` and `macOS gate` checks plus two `unit (macos-latest, shard N of 2)` checks with + `bucket` `skipping` and `state` `SKIPPED` give `all_passed` true, `skipped` 2 and `failed` 0. + - The same with the state lowercase (`skipped`) and with `bucket` `skip` gives the same result. + - `_extract_failed_ci_check_names` never lists a skipped check. +2. Only if a case fails, adjust `_is_skipped` or `_is_failed` in `ci_policy.py` so that `SKIPPED` and `NEUTRAL` are + never failed. The module must stay I/O-free, and the existing `# why:` comment stays. + +### Dependencies & Criticality + +- **Depends on:** Step 1 +- **Is Bottleneck:** NO + +### Safety & Constraint Considerations + +- **Relevant rules:** `docs/safety.md` "Safety invariants" (an unmeasured CI status is never green; that rule stays + untouched). +- **Potential failure modes for this step:** Widening "skipped" turns a genuinely failed state green. +- **Guardrails and early‑abort checks:** Keep the existing tests in `test_ci_policy.py` passing. Do not touch + `_ci_green`. + +### Success & Discard Criteria + +- **Success:** The new tests pass, and any `ci_policy.py` diff is at most a few lines. +- **Discard:** Abort the code change if it would alter how `FAILURE`, `CANCELLED`, `TIMED_OUT`, `ACTION_REQUIRED` or + `STALE` are classified. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.92 | +| entropy_pred | 0.8 | +| impact_pred | 8.0 | +| cost_pred | 1.5 | +| learning_value_pred | 1.0 | +| ev_pred | 6.12 | + +### Step Metrics Rationale + +The current code very likely already behaves correctly, so this is mostly pinning. +`EV = 0.92 * 8.0 + 0.5 * 1.0 - 0.3 * 0.8 - 1.5 = 7.36 + 0.5 - 0.24 - 1.5 = 6.12`. + +--- + +## Step 5: Move the macOS legs of test-unit.yml and make.yml behind an ubuntu-latest gate job + +- **Sub‑intent recommendation:** NO +- **Reasoning:** This is the highest-risk step, but it spans only two YAML files and cannot be split usefully from its + wiring tests (Step 6). It stays in the plan, with strict text contracts from Step 1. +- **Step Type:** CONFIG +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Make sure no `macos-latest` runner is requested when the gate decided "skip", and keep every required + check name and every pinned text contract. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. **test-unit.yml: new job `gate`.** + - It has `name: macOS gate`, `runs-on: ubuntu-latest` and the permissions `contents: read`, `actions: read` and + `pull-requests: read`. + - Steps: + - `Checkout repository` (actions/checkout@v7 with `submodules: true`, as the unit job does). + - `Bookkeeping gate (shard 1 of 2)` with id `bookkeeping_shard_1`, using `./.github/actions/bookkeeping-gate` with + `job-name: unit` and `os: shard 1 of 2`. + - `Bookkeeping gate (shard 2 of 2)` with id `bookkeeping_shard_2`, the same with `os: shard 2 of 2`. + - `macOS relevance gate` with id `macos_relevance`, using `./.github/actions/macos-relevance-gate`. Its condition + is that not both bookkeeping outputs are `'true'`. + - The final marker step `macOS legs skipped` (`run: echo` of one line). Its condition is the skip expression: both + bookkeeping skips `'true'`, or the relevance skip `'true'`. + - The job output `skip` is that same expression rendered as `'true'` or `'false'`. +2. **test-unit.yml: the `unit` job keeps the ubuntu leg only.** + - Its matrix becomes `os: [ubuntu-latest]` with the ubuntu `include` entry (`timing-min-delta: 120`, `shards: 1`, + `timing-job: unit`, `gate-leg: ubuntu-latest`). + - The `shard` axis and its `exclude` go away. The `name:` expression must still render `unit (ubuntu-latest)`. + - Its in-job `Bookkeeping gate` stays. + - The `macOS relevance gate` step and the `steps.macos_relevance` part of every guard are removed from this job, + because it never runs on macOS. +3. **test-unit.yml: two new jobs, `unit-macos-shard-1` and `unit-macos-shard-2`.** + - They have the static names `unit (macos-latest, shard 1 of 2)` and `unit (macos-latest, shard 2 of 2)`, with + `needs: gate` and the condition `!cancelled() && needs.gate.outputs.skip != 'true'`. + - Each has a single-entry `include` matrix that keeps `- os: macos-latest` immediately followed by + `timing-min-delta: 150`, as `test_ci_timing_gate.py` requires, plus `shards: 2`, `shard: N` and + `timing-job: unit-shard-N`. `runs-on` stays `${{ matrix.os }}`. + - Steps: `Record job start time`, `Checkout repository`, `Install uv`, `Run unit tests` (the shard branch), + `CI Timing Gate (compare with main)` (same flags), `Upload timing record` (same main-push condition, with + `if-no-files-found: error`) and `Full run completed`. + - None of these steps carries a bookkeeping or relevance guard: the job-level condition replaces them. Both jobs have + identical step text, which Step 6 asserts. + - A `# why:` comment says the static name keeps the required check name when the job is skipped. +4. **make.yml.** + - Add a job `gate` (`name: macOS gate`, ubuntu-latest, the same permissions) with checkout, one + `Bookkeeping gate (macos-latest)` step (job-name `build`, os `macos-latest`), the marker step `macOS legs skipped` + and output `skip`. + - `build` keeps the ubuntu leg only (`os: [ubuntu-latest]`) with its in-job gate. + - Add a job `build-macos` with `name: build (macos-latest)`, `runs-on: macos-latest`, `needs: gate`, the same + condition and permissions, and the `build` steps without bookkeeping guards. The ci-timing-gate start/check steps + and `Full run completed` stay. +5. Leave `test-integration.yml`, `test-stress.yml`, `test-hygiene.yml` and `docker-build.yml` byte-identical. +6. Run `npx prettier --check` (through `uv run task lint` or `make lint-md`, whichever the repository uses for YAML) on + both workflows, in the foreground. + +### Dependencies & Criticality + +- **Depends on:** Step 1, Step 2 +- **Is Bottleneck:** YES + +### Safety & Constraint Considerations + +- **Relevant rules:** `docs/safety.md` "Human review is the final gate"; README "Branch Protection Status Checks"; the + self-explaining code gate (YAML comments only as `# why:`, existing comments may stay). +- **Potential failure modes for this step:** + - A required check name drifts. + - A matrix expression stays in a skippable job's name. + - The gate output expression is malformed, so the job always runs (safe, but no savings) or always skips (unsafe). + - `test_ci_timing_gate.py` regexes break. +- **Guardrails and early‑abort checks:** + - Each skippable job's `name:` contains no `${{`. + - The condition starts with `!cancelled()`. + - The marker step and the job output use the same expression text, which Step 6 asserts. + - Run + `uv run pytest apps/sandbox-executor/tests/test_ci_timing_gate.py apps/sandbox-executor/tests/test_unit_test_shard.py` + in the foreground right after editing. + +### Success & Discard Criteria + +- **Success:** Both workflows parse with PyYAML. The pinned out-of-scope tests pass unchanged. The macOS jobs have + static required-check names and job-level conditions, and the ubuntu jobs are unchanged apart from the leg removal. +- **Discard:** Stop and record a blocker if a required check name cannot be kept static, or if an out-of-scope test + would have to change. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.75 | +| entropy_pred | 3.5 | +| impact_pred | 35.0 | +| cost_pred | 5.0 | +| learning_value_pred | 4.0 | +| ev_pred | 22.2 | + +### Step Metrics Rationale + +This step carries most of the impact (the macOS runner savings) and most of the uncertainty (YAML expressions that +cannot run in the sandbox, plus the text contracts). Its learning value is the first live confirmation of static names +on skipped jobs. `EV = 0.75 * 35.0 + 0.5 * 4.0 - 0.3 * 3.5 - 5.0 = 26.25 + 2.0 - 1.05 - 5.0 = 22.2`. + +--- + +## Step 6: Update the wiring tests, the composite action description and the README + +- **Sub‑intent recommendation:** NO +- **Reasoning:** This step is coupled to Step 5. The text-based wiring tests must learn about multi-job workflows. The + risk is moderate and local. +- **Step Type:** TEST +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Make the wiring tests assert the new shape, so a regression (matrix names, missing `!cancelled()`, + guard drift) fails CI hygiene. Document the mechanism. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. In `apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py`: + - Generalise `split_steps` and `steps_of` to take a job key, defaulting to the in-job-gated job. Replace the "exactly + one job" refusal with a lookup that refuses an unknown key. + - Keep every existing assertion for the four unchanged workflows and for the ubuntu jobs of the two changed ones. + - Remove `UNGUARDED_IN["test-unit.yml"]` and `GUARDS_IN["test-unit.yml"]`. + - Add tests that: + - check `test-unit.yml` and `make.yml` have a `gate` job on `ubuntu-latest` with a static name, ending in the step + `macOS legs skipped`, whose condition text equals the job output's expression; + - check every job whose `runs-on` resolves to `macos-latest` has `needs: gate`, the condition + `!cancelled() && needs.gate.outputs.skip != 'true'`, a static `name:` without `${{`, and a name that appears in + the README "Branch Protection Status Checks" list; + - check no `macos-latest` job contains the bookkeeping-gate or macos-relevance-gate action; + - check the two unit shard jobs have identical step text, and `Full run completed` is the last step of each; + - check no workflow other than `test-unit.yml` and `make.yml` mentions `macos-latest`; + - check the gate step name matches `GATE_SKIP_STEP` from `scripts.ci_bookkeeping_gate_job`. + - Update `test_a_skipped_main_push_cannot_fail_the_timing_upload` so it applies to the ubuntu `unit` job only. +2. In `apps/sandbox-executor/tests/test_macos_relevance_wiring.py`, replace the "no job-level condition, both runners, + shard axis" assertions with the gate-job equivalents: + - The relevance gate appears only in the `gate` job. + - It runs on `ubuntu-latest`. + - It follows both bookkeeping steps. + - Its skip feeds the job output. + - Its `README` documentation is current. Keep the rules, labels and README rule-list tests. +3. In `.github/actions/bookkeeping-gate/action.yml`, update the `os` input description to name the gate-job use + (`shard N of M` or `macos-latest` passed by the `macOS gate` job). The interface does not change. +4. In `.github/workflows/README.md`: + - In "Bookkeeping-Only Push Gate", state that macOS legs are decided by the `macOS gate` job on `ubuntu-latest`. A + skipped macOS job requests no runner and reports `skipped` under its required name. The marker step + `macOS legs skipped` is the evidence that the chain reads. + - In "macOS Relevance Gate" and "What still runs on a skip", replace "the job has no job-level condition" with the + new mechanism. + - Explain why the ubuntu jobs keep the in-job gate: matrix names on required checks, and hygiene's Prettier on + bookkeeping pushes. + - Add a "Verifying after merge" note: on the first pull-request run, confirm that the two shard checks and + `build (macos-latest)` show as skipped under their usual names. + - Keep Prettier-clean formatting. + +### Dependencies & Criticality + +- **Depends on:** Step 5 +- **Is Bottleneck:** YES (CI hygiene fails without it) + +### Safety & Constraint Considerations + +- **Relevant rules:** Self-explaining code gate (no new docstrings in test helpers; names carry intent); markdown + Prettier formatting; `test_readme_documents_*` tests. +- **Potential failure modes for this step:** + - The generalised splitter mis-parses nested keys. + - Prettier reflows the README. + - README rule-list tests break because sections were renamed. +- **Guardrails and early‑abort checks:** + - Keep section headings unchanged. + - Run + `uv run pytest apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py apps/sandbox-executor/tests/test_macos_relevance_wiring.py` + and the markdown formatter in the foreground. + +### Success & Discard Criteria + +- **Success:** Both wiring test files pass and assert the new invariants, and the README passes Prettier. +- **Discard:** If generalising the splitter grows the test file past its budget, extract the helpers into a focused + helper module next to the tests and record the extra file. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.78 | +| entropy_pred | 2.2 | +| impact_pred | 15.0 | +| cost_pred | 4.5 | +| learning_value_pred | 1.5 | +| ev_pred | 7.29 | + +### Step Metrics Rationale + +The text-based tests are brittle and the README has rule-list tests, so the risk is moderate. +`EV = 0.78 * 15.0 + 0.5 * 1.5 - 0.3 * 2.2 - 4.5 = 11.7 + 0.75 - 0.66 - 4.5 = 7.29`. + +--- + +## Step 7: Verify affected tests, lint and the full suite once + +- **Sub‑intent recommendation:** NO +- **Reasoning:** This is standard verification. The intent has no timing target, so no repeated runs are needed. +- **Step Type:** TEST +- **Exploration level:** EXPLOIT + +### Intent & Git Integration + +- **Step Intent:** Prove that the change is green locally and that no out-of-scope contract moved. +- **Git branch:** same execution branch +- **Sub‑intent:** NONE + +### Implementation Details (No code blocks, only logic/steps) + +1. In the foreground, run + `uv run pytest apps/sandbox-executor/tests/test_ci_bookkeeping_chain.py apps/sandbox-executor/tests/test_ci_bookkeeping_gate.py apps/sandbox-executor/tests/test_ci_bookkeeping_wiring.py apps/sandbox-executor/tests/test_macos_relevance_wiring.py apps/sandbox-executor/tests/flow/github/test_ci_policy.py apps/sandbox-executor/tests/test_ci_main_push_gate.py apps/sandbox-executor/tests/test_ci_merge_push_gate.py apps/sandbox-executor/tests/test_ci_timing_gate.py apps/sandbox-executor/tests/test_unit_test_shard.py apps/sandbox-executor/tests/test_workflow_triggers.py`. +2. In the foreground, run `uv run task lint`. This covers ruff complexity, module budgets, the self-explaining gate and + Prettier. +3. Run the full suite once in the foreground with `uv run task test`. Report the pass/fail counts and the + pytest-reported time. +4. No environment variables, cwd or git config change for any child process, so the environment-overlay discipline does + not apply. Record this in the execution notes. + +### Dependencies & Criticality + +- **Depends on:** Steps 2 to 6 +- **Is Bottleneck:** NO + +### Safety & Constraint Considerations + +- **Relevant rules:** Test-run discipline (foreground, single full run); `docs/safety.md` failure containment. +- **Potential failure modes for this step:** Unrelated flakes, or an out-of-scope test pinned to workflow text. +- **Guardrails and early‑abort checks:** If an out-of-scope test fails because of the workflow change, fix the workflow + to meet the contract rather than editing that test. + +### Success & Discard Criteria + +- **Success:** All targeted tests and lint pass, and the full suite is green. +- **Discard:** If verification costs more than 1.5x its predicted cost because of unrelated failures, record them and + hand off to review. + +### Metrics + +| metric | value | +| ------------------- | ----- | +| p_success_pred | 0.85 | +| entropy_pred | 0.5 | +| impact_pred | 10.0 | +| cost_pred | 2.5 | +| learning_value_pred | 1.0 | +| ev_pred | 6.35 | + +### Step Metrics Rationale + +This is a routine verification step; the main risk is suite-level flakiness. +`EV = 0.85 * 10.0 + 0.5 * 1.0 - 0.3 * 0.5 - 2.5 = 8.5 + 0.5 - 0.15 - 2.5 = 6.35`. + +--- + +## Sub-intent list + +- None diff --git a/scripts/ci_bookkeeping_api.py b/scripts/ci_bookkeeping_api.py index 5d731709e..254834f76 100644 --- a/scripts/ci_bookkeeping_api.py +++ b/scripts/ci_bookkeeping_api.py @@ -29,6 +29,7 @@ from dataclasses import dataclass, field from scripts.ci_bookkeeping_context import GateContext, _text, context_from, load_event +from scripts.ci_bookkeeping_gate_job import with_gate_job_skips from scripts.ci_timing_gate import API_ROOT, build_request, default_opener COMPARE_FILE_CAP = 300 # the compare API lists at most 300 changed files, whatever the size of the diff @@ -183,7 +184,7 @@ def list_jobs(client: GateClient, run_id: int) -> list[dict[str, object]]: jobs = answer.get("jobs") if not isinstance(jobs, list) or not all(isinstance(job, dict) for job in jobs): raise ValueError("the jobs answer has no job list") - return jobs + return with_gate_job_skips(jobs) @dataclass(frozen=True) diff --git a/scripts/ci_bookkeeping_chain.py b/scripts/ci_bookkeeping_chain.py index cbcb1876a..6bec53162 100644 --- a/scripts/ci_bookkeeping_chain.py +++ b/scripts/ci_bookkeeping_chain.py @@ -20,6 +20,7 @@ from dataclasses import dataclass from scripts.ci_bookkeeping_api import CommitRef, GateClient, RunRef, commit_ref, list_earlier_runs, list_jobs +from scripts.ci_bookkeeping_gate_job import SKIPPED_BY_GATE_JOB FULL_RUN_STEP = "Full run completed" MAX_CHAIN_HOPS = 20 @@ -112,6 +113,9 @@ def match_job(jobs: Sequence[dict[str, object]], job_name: str, os_name: str) -> def classify_job(job: dict[str, object]) -> str: """Return ``REAL_SUCCESS``, ``GATE_SKIPPED``, ``UNVERIFIED`` or ``NOT_SUCCESSFUL`` for a job of an earlier run.""" + # why: a job skipped at job level has no steps, so only the gate job's marker step can prove the skip. + if job.get(SKIPPED_BY_GATE_JOB) is True: + return GATE_SKIPPED if job.get("status") != "completed" or job.get("conclusion") != "success": return NOT_SUCCESSFUL steps = job.get("steps") diff --git a/scripts/ci_bookkeeping_gate_job.py b/scripts/ci_bookkeeping_gate_job.py new file mode 100644 index 000000000..c5ed7f367 --- /dev/null +++ b/scripts/ci_bookkeeping_gate_job.py @@ -0,0 +1,30 @@ +from __future__ import annotations + +from collections.abc import Sequence + +GATE_SKIP_STEP = "macOS legs skipped" +SKIPPED_BY_GATE_JOB = "skipped_by_gate_job" +MACOS_RUNNER = "macos-latest" + + +def _steps_of(job: dict[str, object]) -> list[dict[str, object]]: + steps = job.get("steps") + return [step for step in steps if isinstance(step, dict)] if isinstance(steps, list) else [] + + +def gate_job_skipped(jobs: Sequence[dict[str, object]]) -> bool: + return any( + step.get("name") == GATE_SKIP_STEP and step.get("conclusion") == "success" + for job in jobs + for step in _steps_of(job) + ) + + +def _is_macos_leg_skipped_at_job_level(job: dict[str, object]) -> bool: + is_skipped = job.get("status") == "completed" and job.get("conclusion") == "skipped" + return is_skipped and MACOS_RUNNER in str(job.get("name", "")) + + +def with_gate_job_skips(jobs: Sequence[dict[str, object]]) -> list[dict[str, object]]: + proved = gate_job_skipped(jobs) + return [{**job, SKIPPED_BY_GATE_JOB: proved} if _is_macos_leg_skipped_at_job_level(job) else job for job in jobs]