From 96bd80c64dfc62ee009d9889c0c708acd089a90a Mon Sep 17 00:00:00 2001 From: Kit <344842+roodboi@users.noreply.github.com> Date: Sat, 14 Nov 2026 10:09:51 +0000 Subject: [PATCH 1/3] fix(ci): gate CLI changes on relocated acceptance --- .ai/skills/hack-repo-verify/SKILL.md | 10 ++++- .github/workflows/ci.yml | 23 ++++++++++- docs/reference/ci-test-selection.md | 36 ++++++++++++++-- docs/reference/ci-test-selection.mmd | 4 +- docs/reference/ci-test-selection.svg | 2 +- scripts/ci-change-scope.ts | 11 +++++ scripts/ci-pr-plan.ts | 11 ++++- tests/ci-test-selection.test.ts | 62 +++++++++++++++++++++++++++- tests/ci-trusted-policy.test.ts | 41 ++++++++++++++++-- tests/test-shard.test.ts | 43 +++++++++++++++++++ 10 files changed, 227 insertions(+), 16 deletions(-) diff --git a/.ai/skills/hack-repo-verify/SKILL.md b/.ai/skills/hack-repo-verify/SKILL.md index b8ca1ba9d..44bfa9ca9 100644 --- a/.ai/skills/hack-repo-verify/SKILL.md +++ b/.ai/skills/hack-repo-verify/SKILL.md @@ -149,7 +149,11 @@ does not mean CI ran. Hosted CI runs the `bun run test` file set on eight `test shard i/8` jobs; light PRs run only the five Linux shards and report selected macOS paths as deferred to the integration run. `ci:mac`/`ci:e2e` opt into selected tiers; -`ci:full` opts into all ordinary PR tiers. Ready Rust-input PRs retain Linux +`ci:full` opts into all ordinary PR tiers. Ready CLI-source PRs (`src/`, `index.ts`, `packages/cli/`) retain Linux x64 +Config compiler and relocated acceptance, including refusal HOME/output contracts. +The required test fan-in rejects selected compiler failures, cancellations and +unexpected skips. This adds no default Mac minutes; the existing Linux lane also +builds the release bundle. Ready Rust-input PRs retain Linux candidate/compiler checks while deferring macOS. Full tiers run automatically on ready PRs changing protected CI inputs or targeting `main`; the latter retains Intel. Light PRs skip build smoke, macOS and Docker; @@ -160,7 +164,9 @@ The required `test` check is their fan-in. Every planned shard and the enabled Linux process-lifetime job must succeed; failure, cancellation or an unexpected skip fails. A planned out-of-scope lifetime skip passes. Drafts deliberately fail with `skipped: draft`. Next pushes can select tests only after a successful predecessor; -superseded pushes cancel. Main and explicit full dispatches retain release-host +the active next push finishes while newer pushes replace only the pending run. +After a batch merges, no further merge proceeds until a next run completes, +unless the batch verifier ran the same checks on the combined tree. Main and explicit full dispatches retain release-host coverage. Prerelease plan/publish require exact-head `release-full` evidence from the selected run's latest attempt, including every shard and compiler host. [`scripts/test-shard-plan.ts`](../../../scripts/test-shard-plan.ts) splits the files diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 602a4e469..19a4a745b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,8 @@ concurrency: # Let the active next run finish, including jobs waiting for macOS capacity. # New next pushes replace only the pending run. PRs still cancel stale runs; # main pushes and explicit release qualification keep unique groups. + # The lead waits for a completed next run between batches unless its batch + # verifier ran the same checks: pending revisions may still be replaced. group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || (github.event_name == 'push' && github.ref == 'refs/heads/next' && 'push-next') || format('push-{0}', github.run_id) }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} @@ -90,6 +92,7 @@ jobs: # This guard is independent of the selector and its fallback list. full=false linux_rust=false + relocated_cli=false base="" if [ "$EVENT_NAME" = "pull_request" ]; then parents=$(git rev-list --parents -n 1 HEAD) || parents="" @@ -114,6 +117,10 @@ jobs: else if [ ! -s "$RUNNER_TEMP/ci-paths" ]; then full=true; fi while IFS= read -r -d '' path; do + case "$path" in + src/*|index.ts|packages/cli/*|scripts/check-*-cli.ts|scripts/check-native-plan-clis.ts) + relocated_cli=true ;; + esac case "$path" in packages/runtime-core/*.md|packages/config-compiler/*.md) ;; packages/runtime-core/*|packages/config-compiler/*|packages/relay-guest/*) @@ -200,6 +207,8 @@ jobs: compiler='[{"os":"ubuntu-latest","platform":"linux","arch":"x64"},{"os":"ubuntu-24.04-arm","platform":"linux","arch":"arm64"}]' native=true echo 'compiler_rust=true' >> "$GITHUB_OUTPUT" + elif [ "$PR_DRAFT" != "true" ] && [ "$relocated_cli" = "true" ]; then + compiler='[{"os":"ubuntu-latest","platform":"linux","arch":"x64"}]' fi printf 'compiler_hosts=%s\nruntime_core=%s\ntest_shards=[4,5,6,7,8]\ndefer_macos=true\n' "$compiler" "$native" >> "$GITHUB_OUTPUT" else @@ -208,11 +217,15 @@ jobs: compiler=$(sed -n 's/^compiler_hosts=//p' "$GITHUB_OUTPUT" | tail -n 1) compiler=$(jq -c '. + [{"os":"ubuntu-latest","platform":"linux","arch":"x64"},{"os":"ubuntu-24.04-arm","platform":"linux","arch":"arm64"}] | unique_by(.os) | map(select(.os != "macos-15-intel"))' <<< "${compiler:-[]}") printf 'compiler_hosts=%s\ncompiler_rust=true\nruntime_core=true\n' "$compiler" >> "$GITHUB_OUTPUT" + elif [ "$relocated_cli" = "true" ] && [ "$full" != "true" ]; then + compiler=$(sed -n 's/^compiler_hosts=//p' "$GITHUB_OUTPUT" | tail -n 1) + compiler=$(jq -c '. + [{"os":"ubuntu-latest","platform":"linux","arch":"x64"}] | unique_by(.os)' <<< "${compiler:-[]}") + printf 'compiler_hosts=%s\n' "$compiler" >> "$GITHUB_OUTPUT" fi fi if [ "$e2e" != "true" ]; then echo 'docker_suite=false' >> "$GITHUB_OUTPUT"; fi printf 'build_smoke=%s\n' "$builds" >> "$GITHUB_OUTPUT" - echo 'Light PRs defer macOS, Docker and build smoke to integration; Rust crate inputs keep Linux candidate/compiler checks. Labels opt in; protected inputs, unavailable policy/diff and ready PRs into main automatically run full tiers.' >> "$GITHUB_STEP_SUMMARY" + echo 'Light PRs defer macOS, Docker and build smoke to integration; CLI inputs keep Linux relocated acceptance, and Rust crate inputs keep Linux candidate/compiler checks. Labels opt in; protected inputs, unavailable policy/diff and ready PRs into main automatically run full tiers.' >> "$GITHUB_STEP_SUMMARY" else printf 'defer_macos=false\nbuild_smoke=true\n' >> "$GITHUB_OUTPUT" fi @@ -909,7 +922,7 @@ jobs: # succeed; when it runs a focus instead, the focused job must. A cancelled # result fails, as do a failure, a failed scope or any skip of # the job in scope still fails rather than surfacing as a skipped check. - needs: [changes, test-shard, test-focus, linux-process-lifetime] + needs: [changes, test-shard, test-focus, linux-process-lifetime, config-compiler] if: ${{ always() }} runs-on: ubuntu-latest timeout-minutes: 5 @@ -924,6 +937,8 @@ jobs: TEST_FOCUS: ${{ needs.changes.outputs.test_focus }} SHARD_RESULT: ${{ needs.test-shard.result }} FOCUS_RESULT: ${{ needs.test-focus.result }} + COMPILER_ENABLED: ${{ needs.changes.outputs.compiler_hosts != '[]' }} + COMPILER_RESULT: ${{ needs.config-compiler.result }} LIFETIME_ENABLED: ${{ needs.changes.outputs.docker_suite }} LIFETIME_RESULT: ${{ needs.linux-process-lifetime.result }} run: | @@ -939,6 +954,10 @@ jobs: echo "change scope did not succeed (result: $CHANGES_RESULT)" exit 1 fi + case "$COMPILER_ENABLED:$COMPILER_RESULT" in + true:success|false:skipped) ;; + *) echo "Compiler acceptance evidence did not match its plan (enabled: $COMPILER_ENABLED, result: $COMPILER_RESULT)" >&2; exit 1 ;; + esac if [ "$FOCUS_RESULT" != "success" ]; then echo "test focus did not succeed (result: $FOCUS_RESULT)" exit 1 diff --git a/docs/reference/ci-test-selection.md b/docs/reference/ci-test-selection.md index b7521b68f..afc959a4a 100644 --- a/docs/reference/ci-test-selection.md +++ b/docs/reference/ci-test-selection.md @@ -2,7 +2,13 @@ A PR uses a light tier by default: typecheck, lint/privacy, secret scan, docs checks when relevant, and selected Linux unit files on five Linux shards. It runs -no macOS jobs, Docker E2E shards, state-model job or CLI/release build smoke. +no macOS jobs, Docker E2E shards or state-model job. Ready PRs changing CLI +source (`src/`, `index.ts`, `packages/cli/`) retain the existing Linux x64 +Config compiler job, including its release build and relocated CLI acceptance. +This deliberately covers activity recording, HOME writes, output envelopes and +refusals through any shared CLI source, rather than maintaining a fragile list +of lifecycle helpers. Changes to acceptance scripts retain that job through the +protected-script full-tier rule. Unrelated test/docs PRs retain the lighter tier. Ready Rust-input PRs retain the Linux Candidate core leg and both Linux compiler hosts (including Rust checks); macOS stays in the heavy tier. This covers non-Markdown inputs under runtime-core/config-compiler (including pins, fixtures @@ -28,7 +34,11 @@ fallback alone widens files; the independent shell guard also enables full tiers Adding/removing labels, pushing, changing readiness or retargeting recomputes scope; metadata edits can cancel the active run. -The required `test` fan-in also depends on `linux-process-lifetime`. When that +The required `test` fan-in also depends on `config-compiler` and +`linux-process-lifetime`. Every selected compiler host must succeed; its planned +out-of-scope skip passes. When native tiers are selected, the required check +also waits for their macOS compiler hosts, including Intel on release/full-main +runs. When that tier is enabled, failure, cancellation, missing results or an unexpected skip fails `test`, even when every unit shard passed. Its planned out-of-scope skip passes. Branch rules are unchanged. @@ -105,9 +115,21 @@ working directory and Bun preload. The candidate job follows its crate, its config-compiler path dependency, guest, launcher, helper/toolchain and CI inputs. The compiler's native host matrix follows its crate/build/toolchain/CI -inputs. Other compiler checks retain the previous Linux scope. These are job +inputs. CLI source changes retain Linux x64 compiler acceptance even when +macOS is deferred. These are job input gates, separate from the unit import graph. +Cost: this adds **0 macOS minutes** to an ordinary CLI PR and one Linux x64 +Config compiler job, without adding a second release build. A Linux measurement +on the 5002cf87 base with Bun 1.4.4 and Rust 1.97.1 took 59.5 seconds for the +eight relocated CLI scripts, 0.7 seconds for the CLI build, and 41.9 seconds for +compiler preparation with cached dependencies (102.1 seconds combined). These +are component timings, not the whole hosted lane: that job also runs schema, +transport/unit and release-install checks plus setup. Its separate release-install +check needs host sandbox privileges and is verified in hosted CI. The lead's +Mac batch reported roughly 80 seconds for all nine acceptance scripts once the +release build exists; that is Mac evidence, separate from this Linux measurement. + The Intel compiler lane runs on ready PRs into `main`, `main` pushes and explicit full dispatches. Native-tier PRs into `next` and ordinary `next` integration runs retain ARM macOS and both Linux compiler hosts. Intel-specific regressions on @@ -121,6 +143,14 @@ including jobs waiting for macOS capacity. GitHub retains at most one pending ru a newer push replaces that pending run, so intermediate revisions may not run. As described above, a cancelled or missing predecessor forces full selection, so replacing a pending run cannot omit its merged changes from coverage. +After one batch merges, the lead makes no further merge until a `next` run +completes, unless the batch verifier ran the same checks on the combined tree. +A cancelled or merely queued run does not satisfy that rule. The existing +non-cancelling workflow group protects the active run, but GitHub can replace +pending runs, so it cannot enforce a completed checkpoint between batches. +No job-class concurrency split is needed: it would duplicate scheduling and +could leave acceptance without matching platform evidence. + This preserves all selected macOS coverage without changing runner capacity or the PR layout. It does not reserve macOS slots or guarantee a queue wait bound. PRs still cancel stale runs for the same PR. `main` pushes retain unique, diff --git a/docs/reference/ci-test-selection.mmd b/docs/reference/ci-test-selection.mmd index c8450d1ea..7fee358a8 100644 --- a/docs/reference/ci-test-selection.mmd +++ b/docs/reference/ci-test-selection.mmd @@ -7,9 +7,9 @@ flowchart TD guard -->|Yes or unavailable policy| allpr event -->|Draft PR| draft[Draft Linux tier] draft --> draftgate[Fan-ins fail: skipped draft] - labels -->|Default| light[Linux checks plus relevant Rust legs] + labels -->|Default| light[Linux plus CLI acceptance or Rust legs] light --> deferred[Name deferred macOS files] - deferred --> prgate[Required test and docs checks] + deferred --> prgate[Test fan-in includes compiler acceptance] labels -->|ci:mac or ci:e2e| tier[Selected opted-in tier] labels -->|ci:full| allpr[Full PR tiers] tier --> prgate diff --git a/docs/reference/ci-test-selection.svg b/docs/reference/ci-test-selection.svg index 3eece0431..ccbd3829e 100644 --- a/docs/reference/ci-test-selection.svg +++ b/docs/reference/ci-test-selection.svg @@ -63,4 +63,4 @@ .pele .ok .pele-label { fill: var(--hd-ok); font-weight: 600; } .pele .fail .pele-label { fill: var(--hd-fail); font-weight: 600; } .pele .idle .pele-label { fill: var(--hd-idle); } -]]>Main or full dispatchReady PRNoYes or unavailable policyDraft PRDefaultci:mac or ci:e2eci:fullNext pushNo or unknownYesCI eventEvery test and releasehostExact-head release-fullgateMain or protected inputs?Tier labelsFull PR tiersDraft Linux tierFan-ins fail: skipped draftLinux checks plus relevantRust legsName deferred macOSfilesRequired test and docschecksSelected opted-in tierBefore push passed?Full integration selectionTrusted selection from diffSelected platform andDocker jobsIntegration fan-ins \ No newline at end of file +]]>Main or full dispatchReady PRNoYes or unavailable policyDraft PRDefaultci:mac or ci:e2eci:fullNext pushNo or unknownYesCI eventEvery test and releasehostExact-head release-fullgateMain or protected inputs?Tier labelsFull PR tiersDraft Linux tierFan-ins fail: skipped draftLinux plus CLI acceptanceor Rust legsName deferred macOSfilesTest fan-in includescompiler acceptanceSelected opted-in tierBefore push passed?Full integration selectionTrusted selection from diffSelected platform andDocker jobsIntegration fan-ins \ No newline at end of file diff --git a/scripts/ci-change-scope.ts b/scripts/ci-change-scope.ts index d5bef73b5..40e2ec42c 100644 --- a/scripts/ci-change-scope.ts +++ b/scripts/ci-change-scope.ts @@ -111,6 +111,17 @@ export function touchesDocsSite(path: string): boolean { return DOCS_SITE_PATHS.some((pattern) => pattern.test(path)); } +/** + * Relocated bundles exercise CLI refusals as well as compiler transports. Any + * CLI source may change HOME writes, output or dispatch before the refusal. + * Keep this independent of the unit-test import graph and compiler Rust inputs. + */ +export function touchesRelocatedCli(path: string): boolean { + return /^(?:src\/|index\.ts$|packages\/cli\/|scripts\/check-(?:.+-cli|native-plan-clis)\.ts$)/.test( + path + ); +} + /** The scope of a pull request that changes `paths`; empty means `full`. */ export function changeScope(paths: readonly string[]): ChangeScope { if (paths.length === 0) { diff --git a/scripts/ci-pr-plan.ts b/scripts/ci-pr-plan.ts index aeb4f3f8c..f9fb482aa 100644 --- a/scripts/ci-pr-plan.ts +++ b/scripts/ci-pr-plan.ts @@ -1,5 +1,10 @@ /** PR and next-push policy layered over the coarse change-scope classifier. */ -import { COMPILER_HOSTS, planScope, scopeOutputs } from "./ci-change-scope.ts"; +import { + COMPILER_HOSTS, + planScope, + scopeOutputs, + touchesRelocatedCli, +} from "./ci-change-scope.ts"; import { selectTests, type TestSelection } from "./ci-test-selection.ts"; import { requiresWorkflowFull } from "./ci-workflow-guard.ts"; import { classifyTestPools } from "./test-shard-plan.ts"; @@ -29,6 +34,7 @@ function selectedCompilerHosts(opts: { readonly draft: boolean; readonly mac: boolean; readonly linuxRust: boolean; + readonly changed: readonly string[] | null; readonly releaseHosts: boolean; readonly nativeHosts: boolean; readonly coarseHosts: string; @@ -36,9 +42,11 @@ function selectedCompilerHosts(opts: { if (opts.draft) { return []; } + const relocatedCli = opts.changed?.some(touchesRelocatedCli) ?? true; return compilerHosts(opts.releaseHosts).filter( (host) => (opts.linuxRust && host.platform === "linux") || + (relocatedCli && host.os === "ubuntu-latest") || (opts.mac && (opts.nativeHosts || opts.coarseHosts.includes(JSON.stringify(host.os)))) @@ -139,6 +147,7 @@ export async function planPullRequest(opts: { draft: opts.draft, mac, linuxRust, + changed: opts.changed, releaseHosts: stablePr || opts.releaseHosts === true, nativeHosts: allJobs || (opts.changed?.some(touchesCompilerHost) ?? false), coarseHosts: coarse.compiler_hosts, diff --git a/tests/ci-test-selection.test.ts b/tests/ci-test-selection.test.ts index da60998b6..7c38fb228 100644 --- a/tests/ci-test-selection.test.ts +++ b/tests/ci-test-selection.test.ts @@ -391,7 +391,7 @@ describe("PR matrix policy", () => { } as const; for (const changed of [ ["docs/a.md"], - ["src/a.ts"], + ["tests/a.test.ts"], ["packages/runtime-core/README.md"], ]) { const plan = await planPullRequest({ @@ -477,6 +477,66 @@ describe("PR matrix policy", () => { defer_macos: true, }); }); + test("a PR changing refused lifecycle HOME writes gets relocated acceptance on Linux", async () => { + for (const path of [ + "src/lib/activity-log.ts", + "src/commands/project.ts", + "src/backends/native-project-start.ts", + "src/cli/run.ts", + "src/ui/logger.ts", + "src/index.ts", + "index.ts", + "packages/cli/index.ts", + ]) { + expect(await Bun.file(resolve(repoRoot, path)).exists(), path).toBe(true); + const plan = await planPullRequest({ + repoRoot, + changed: [path], + draft: false, + full: false, + selection: { mode: "selected", reason: "fixture", files: [] }, + }); + expect(plan.compiler_hosts, path).toBe( + JSON.stringify([ + { os: "ubuntu-latest", platform: "linux", arch: "x64" }, + ]) + ); + expect(plan).toMatchObject({ + compiler_rust: false, + runtime_core: false, + defer_macos: true, + docker_suite: false, + build_smoke: false, + }); + expect( + await planPullRequest({ + repoRoot, + changed: [path], + draft: true, + full: false, + selection: { mode: "selected", reason: "fixture", files: [] }, + }) + ).toMatchObject({ compiler_hosts: "[]" }); + } + }); + test("relocated acceptance scripts retain a compiler job on ready PRs", async () => { + for (const path of [ + "scripts/check-native-env-plan-cli.ts", + "scripts/check-native-plan-clis.ts", + ]) { + const plan = await planPullRequest({ + repoRoot, + changed: [path], + draft: false, + full: false, + }); + expect(JSON.parse(plan.compiler_hosts)).toContainEqual({ + os: "ubuntu-latest", + platform: "linux", + arch: "x64", + }); + } + }); test("protected inputs and main PRs automatically run full tiers", async () => { for (const input of [ { changed: [".github/workflows/ci.yml"] }, diff --git a/tests/ci-trusted-policy.test.ts b/tests/ci-trusted-policy.test.ts index b9a36bb06..440c666db 100644 --- a/tests/ci-trusted-policy.test.ts +++ b/tests/ci-trusted-policy.test.ts @@ -175,7 +175,7 @@ test("trusted base policy executes against merge-tree data, not merge-tree code" policy: "base", data: "topic", ci_evidence: "scoped", - compiler_hosts: "[]", + compiler_hosts: '[{"os":"ubuntu-latest","platform":"linux","arch":"x64"}]', runtime_core: "false", test_shards: "[4,5,6,7,8]", defer_macos: "true", @@ -311,6 +311,34 @@ for (const path of [ expect(mac.defer_macos).toBe("false"); }); } +test("the inline boundary keeps relocated acceptance for HOME-writing CLI changes even with old base policy", async () => { + for (const path of [ + "src/lib/activity-log.ts", + "src/commands/project.ts", + "src/backends/native-project-start.ts", + "src/cli/run.ts", + "index.ts", + "packages/cli/index.ts", + ]) { + expect(await scope({ path, tamper: true })).toMatchObject({ + policy: "base", + compiler_hosts: + '[{"os":"ubuntu-latest","platform":"linux","arch":"x64"}]', + runtime_core: "false", + test_shards: "[4,5,6,7,8]", + defer_macos: "true", + docker_suite: "false", + }); + expect(await scope({ path, mac: true, tamper: true })).toMatchObject({ + compiler_hosts: + '[{"os":"ubuntu-latest","platform":"linux","arch":"x64"}]', + defer_macos: "false", + }); + expect(await scope({ path, draft: true })).toMatchObject({ + compiler_hosts: "[]", + }); + } +}); test("retargeting reclassifies through the ordinary pull_request event", () => { expect(workflow.on.pull_request.types).toContain("edited"); }); @@ -399,8 +427,13 @@ test("manual qualification refuses full=false before launching a suite", async ( test("PR labels opt into independent tiers without widening the other tier", async () => { const input = { path: "src/value.ts", tierPlan: true }; - expect(await scope({ ...input, mac: true })).toMatchObject({ - compiler_hosts: fullPushPlan({ releaseHosts: false }).compiler_hosts, + const mac = await scope({ ...input, mac: true }); + expect(JSON.parse(mac.compiler_hosts ?? "null")).toEqual( + JSON.parse(fullPushPlan({ releaseHosts: false }).compiler_hosts).sort( + (a: { os: string }, b: { os: string }) => a.os.localeCompare(b.os) + ) + ); + expect(mac).toMatchObject({ runtime_core: "true", test_shards: "[1,2,3,4,5,6,7,8]", docker_suite: "false", @@ -408,7 +441,7 @@ test("PR labels opt into independent tiers without widening the other tier", asy build_smoke: "false", }); expect(await scope({ ...input, e2e: true })).toMatchObject({ - compiler_hosts: "[]", + compiler_hosts: '[{"os":"ubuntu-latest","platform":"linux","arch":"x64"}]', runtime_core: "false", test_shards: "[4,5,6,7,8]", docker_suite: "true", diff --git a/tests/test-shard.test.ts b/tests/test-shard.test.ts index bfe45b267..bee670e20 100644 --- a/tests/test-shard.test.ts +++ b/tests/test-shard.test.ts @@ -1315,6 +1315,7 @@ describe("hosted test CI fan-in", () => { "test-shard", "test-focus", "linux-process-lifetime", + "config-compiler", ]); expect(fanIn?.if).toBe("${{ always() }}"); const gate = fanIn?.steps.find( @@ -1323,6 +1324,12 @@ describe("hosted test CI fan-in", () => { expect(gate?.env?.SHARD_RESULT).toBe("${{ needs.test-shard.result }}"); expect(gate?.env?.FOCUS_RESULT).toBe("${{ needs.test-focus.result }}"); expect(gate?.env?.CHANGES_RESULT).toBe("${{ needs.changes.result }}"); + expect(gate?.env?.COMPILER_RESULT).toBe( + "${{ needs.config-compiler.result }}" + ); + expect(gate?.env?.COMPILER_ENABLED).toBe( + "${{ needs.changes.outputs.compiler_hosts != '[]' }}" + ); expect(gate?.env?.LIFETIME_RESULT).toBe( "${{ needs.linux-process-lifetime.result }}" ); @@ -1367,6 +1374,8 @@ describe("hosted test CI fan-in", () => { TEST_FOCUS: focus, SHARD_RESULT: shards, FOCUS_RESULT: focused, + COMPILER_ENABLED: "false", + COMPILER_RESULT: "skipped", LIFETIME_ENABLED: "false", LIFETIME_RESULT: "skipped", }, @@ -1398,6 +1407,8 @@ describe("hosted test CI fan-in", () => { SUITE: "true", SHARD_RESULT: "success", FOCUS_RESULT: "success", + COMPILER_ENABLED: "false", + COMPILER_RESULT: "skipped", LIFETIME_ENABLED: enabled, LIFETIME_RESULT: result, }, @@ -1408,6 +1419,38 @@ describe("hosted test CI fan-in", () => { exitCode ); } + for (const [enabled, result, exitCode] of [ + ["true", "success", 0], + ["true", "failure", 1], + ["true", "cancelled", 1], + ["true", "skipped", 1], + ["true", "", 1], + ["false", "skipped", 0], + ["false", "failure", 1], + ["false", "success", 1], + ["", "skipped", 1], + ] as const) { + const run = Bun.spawnSync(["bash", "-e", "-u", "-c", gate.run], { + env: { + ...process.env, + PR_DRAFT: "false", + CHANGES_RESULT: "success", + SCOPE: "fixture", + SUITE: "true", + SHARD_RESULT: "success", + FOCUS_RESULT: "success", + LIFETIME_ENABLED: "false", + LIFETIME_RESULT: "skipped", + COMPILER_ENABLED: enabled, + COMPILER_RESULT: result, + }, + stdout: "ignore", + timeout: 5000, + }); + expect(run.exitCode, `compiler enabled=${enabled} result=${result}`).toBe( + exitCode + ); + } const named = Object.entries(workflow.jobs).filter( ([key, job]) => (job.name ?? key) === "test" ); From a314c2d242bd5d200b259af363942fa28a2bc43e Mon Sep 17 00:00:00 2001 From: Kit <344842+roodboi@users.noreply.github.com> Date: Sat, 14 Nov 2026 10:21:08 +0000 Subject: [PATCH 2/3] test(ci): isolate draft fan-in environment --- tests/ci-test-selection.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ci-test-selection.test.ts b/tests/ci-test-selection.test.ts index 7c38fb228..2eedd86ad 100644 --- a/tests/ci-test-selection.test.ts +++ b/tests/ci-test-selection.test.ts @@ -760,7 +760,6 @@ test("draft fan-ins fail explicitly even when the light set passes or scope is c for (const changes of ["success", "cancelled", "failure"]) { const result = Bun.spawnSync(["bash", "-e", "-u", "-c", gate.run], { env: { - ...process.env, PR_DRAFT: "true", CHANGES_RESULT: changes, SUITE: "true", From 2c3b39dc5efb992c3593ec39f2b028179434df63 Mon Sep 17 00:00:00 2001 From: Kit <344842+roodboi@users.noreply.github.com> Date: Sat, 14 Nov 2026 11:50:49 +0000 Subject: [PATCH 3/3] test(ci): bound relocated policy fixture work per case --- tests/ci-test-selection.test.ts | 3 ++ tests/ci-trusted-policy.test.ts | 62 +++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/tests/ci-test-selection.test.ts b/tests/ci-test-selection.test.ts index 2eedd86ad..70ea4d710 100644 --- a/tests/ci-test-selection.test.ts +++ b/tests/ci-test-selection.test.ts @@ -8,6 +8,7 @@ import { touchesCompilerHost, } from "../scripts/ci-pr-plan.ts"; import { selectTests } from "../scripts/ci-test-selection.ts"; +import { requiresWorkflowFull } from "../scripts/ci-workflow-guard.ts"; import { buildVerifiedPlan, classifyTestPools, @@ -523,7 +524,9 @@ describe("PR matrix policy", () => { for (const path of [ "scripts/check-native-env-plan-cli.ts", "scripts/check-native-plan-clis.ts", + "scripts/lib/native-plan-home.ts", ]) { + expect(requiresWorkflowFull([path]), path).toBe(true); const plan = await planPullRequest({ repoRoot, changed: [path], diff --git a/tests/ci-trusted-policy.test.ts b/tests/ci-trusted-policy.test.ts index 440c666db..bd4b9fc28 100644 --- a/tests/ci-trusted-policy.test.ts +++ b/tests/ci-trusted-policy.test.ts @@ -184,6 +184,7 @@ test("trusted base policy executes against merge-tree data, not merge-tree code" }); }); for (const path of [ + "scripts/lib/native-plan-home.ts", "scripts/ci-test-selection.ts", "scripts/ci-change-scope.ts", "scripts/ci-pr-plan.ts", @@ -311,33 +312,40 @@ for (const path of [ expect(mac.defer_macos).toBe("false"); }); } -test("the inline boundary keeps relocated acceptance for HOME-writing CLI changes even with old base policy", async () => { - for (const path of [ - "src/lib/activity-log.ts", - "src/commands/project.ts", - "src/backends/native-project-start.ts", - "src/cli/run.ts", - "index.ts", - "packages/cli/index.ts", - ]) { - expect(await scope({ path, tamper: true })).toMatchObject({ - policy: "base", - compiler_hosts: - '[{"os":"ubuntu-latest","platform":"linux","arch":"x64"}]', - runtime_core: "false", - test_shards: "[4,5,6,7,8]", - defer_macos: "true", - docker_suite: "false", - }); - expect(await scope({ path, mac: true, tamper: true })).toMatchObject({ - compiler_hosts: - '[{"os":"ubuntu-latest","platform":"linux","arch":"x64"}]', - defer_macos: "false", - }); - expect(await scope({ path, draft: true })).toMatchObject({ - compiler_hosts: "[]", - }); - } +// Each case owns one repository. Exercise the host-tier variants once rather +// than rebuilding all six repositories for each variant (18 fixtures in one test). +test.each([ + "src/lib/activity-log.ts", + "src/commands/project.ts", + "src/backends/native-project-start.ts", + "src/cli/run.ts", + "index.ts", + "packages/cli/index.ts", +])("the inline boundary keeps relocated acceptance with old base policy: %s", async (path) => { + expect(await scope({ path, tamper: true })).toMatchObject({ + policy: "base", + compiler_hosts: '[{"os":"ubuntu-latest","platform":"linux","arch":"x64"}]', + runtime_core: "false", + test_shards: "[4,5,6,7,8]", + defer_macos: "true", + docker_suite: "false", + }); +}); +test("the inline boundary retains the HOME-write acceptance leg with ci:mac", async () => { + expect( + await scope({ path: "src/lib/activity-log.ts", mac: true, tamper: true }) + ).toMatchObject({ + policy: "base", + compiler_hosts: '[{"os":"ubuntu-latest","platform":"linux","arch":"x64"}]', + defer_macos: "false", + }); +}); +test("the inline boundary keeps HOME-write acceptance deferred for drafts", async () => { + expect( + await scope({ path: "src/lib/activity-log.ts", draft: true }) + ).toMatchObject({ + compiler_hosts: "[]", + }); }); test("retargeting reclassifies through the ordinary pull_request event", () => { expect(workflow.on.pull_request.types).toContain("edited");