Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

stop a full CI plan from running the whole Windows suite when nothing Windows-sensitive changed (#7440)

[._.]/ Adam Eivyf6f290af2fa6
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7b97317135..568811da54 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -716,7 +716,17 @@ jobs:
# It mirrors the aggregate gate rather than re-aggregating every job, so it
# costs one comparison instead of a second fan-in.
name: Full CI Gate
- if: always() && needs.impact.outputs.full == 'true'
+ # Both conditions, not just `full`. scripts/verify-ci-status.js lets a
+ # release skip its own suite on the strength of this check, so it must mean
+ # "the complete suite passed on this tree" on EVERY platform. A full plan
+ # can now leave the Windows job at the WINDOWS_CONTRACT_TESTS baseline when
+ # the trigger was Windows-irrelevant (see the FULL_TRIGGER_RULES
+ # windowsEscalates flag in the impact planner) — publishing the gate for
+ # one of those would vouch for Windows coverage that did not run. Every
+ # force-full path
+ # (nightly, push-to-main, the main -> release PR, release) keeps
+ # windows_mode == 'full', so the release optimization is unaffected.
+ if: always() && needs.impact.outputs.full == 'true' && needs.impact.outputs.windows_mode == 'full'
needs: [impact, gate]
runs-on: ubuntu-latest
steps:
diff --git a/docs/GITHUB_ACTIONS.md b/docs/GITHUB_ACTIONS.md
index 0165ef9e8c..04e75daabf 100644
--- a/docs/GITHUB_ACTIONS.md
+++ b/docs/GITHUB_ACTIONS.md
@@ -376,7 +376,8 @@ The selected work is split across parallel jobs:
Windows-sensitive surface changed (`.ps1` / `.cmd` spawn, PowerShell BOM,
`bufferedSpawn`, `cos-runner`, shell/PM2, etc.). Docs-only and ordinary
Linux-faithful PRs skip this job. `pinPlatform('win32')` tests still run on
- Linux.
+ Linux. A full plan does not automatically mean a full *Windows* run — see
+ "What a full plan costs the Windows job" below.
- **CI Gate** — always reports one stable required-check result and fails if any
selected job failed or was cancelled.
- **Full CI Gate** — published only when the plan chose the complete suite, and
@@ -413,6 +414,88 @@ free, so the fan-out costs only concurrency.
matrix from the planner, hands `CI_SHARD` to the runner, and gates its
once-only steps on shard 1.
+### What a full plan costs the Windows job
+
+Measured from 11 real full CI runs (`gh api repos/atomantic/PortOS/actions/runs/<id>/jobs`,
+September 2026). A full run is **12 jobs / 28.7 runner-minutes**:
+
+| Job | Jobs | Runner-min | At `windows-latest` 2x |
+| --- | --- | --- | --- |
+| Windows server tests | 3 | 11.8 | 23.5 |
+| Client tests and build | 3 | 8.3 | 8.3 |
+| Server tests | 2 | 6.8 | 6.8 |
+| DB tests, impact, both gates | 4 | 1.7 | 1.7 |
+| **Total** | **12** | **28.7** | **40.4** |
+
+Windows is 41% of a full run's runner occupancy, and 58% once GitHub's 2x
+`windows-latest` multiplier is applied. **This repository is public, so those
+minutes are not billed** — the cost that binds is runner occupancy and
+concurrent-job slots, which is what makes several simultaneous PR builds queue.
+The 2x column is kept because a fork on private billing does pay it.
+
+**Not every full plan needs a full Windows run.** Replaying 250 merge commits
+through `buildCiTestPlan`, 64 went full — and 25 of those (39%) went full for a
+reason `windows-server` cannot observe:
+
+| Full-plan reason | Runs | Windows-relevant? |
+| --- | --- | --- |
+| targeted test set exceeded safety cap | 17 | no — capacity, not risk |
+| wide change (>30 executable files) | 6 | no — capacity, not risk |
+| client composition root / build config / lint config / test setup | 2 | no — client-only |
+| dependency manifest, server contract, CI pipeline script, workflow, … | 39 | yes |
+
+So each full trigger in `FULL_TRIGGER_RULES` carries a `windowsEscalates` flag,
+and `fullPlan()` escalates Windows to the complete server suite only when **any**
+matching trigger is Windows-relevant, the diff touches `WINDOWS_RISK_RULES`, or
+the run is force-full. Otherwise the job drops to **one shard running
+`WINDOWS_CONTRACT_TESTS`** — reduced, never skipped, and exactly the depth a
+Windows-risk scoped PR already gets.
+
+Three properties keep that safe, each pinned by `scripts/ci-test-plan.test.js`:
+
+- **Fail-closed by default.** `windowsEscalates` defaults to `true`, so a
+ `fullPlan()` call site added later over-tests rather than under-tests.
+- **Fail-closed on an empty baseline.** `run-ci-tests.js` prints "No server
+ tests selected" and exits 0 for an empty `files` list, so a downgrade that
+ resolved to no tracked contract tests would be a green job that ran nothing.
+ The planner falls back to the full suite instead.
+- **Force-full keeps the discovery net.** Nightly, the `main` → `release` PR,
+ release, and an explicit full-CI request still run the complete Windows
+ matrix. `ci.yml` has no push trigger, so those are the whole net for a Windows
+ regression on a surface nobody has tagged yet (`staticImportGraph` in #5909,
+ `voice/fineTuning` in #6268), and worst-case detection latency for a
+ downgraded PR is the next nightly — always before a release, because the
+ `main` → `release` PR is force-full. That is not a new exposure: it is the
+ same net every PR touching no `WINDOWS_RISK_RULES` file already relies on,
+ which is most of them. This change widens that population by 25 runs in 250.
+
+**Before / after**, on the same 250-merge sample:
+
+| | Jobs | Runner-min | 2x-equivalent |
+| --- | --- | --- | --- |
+| Full run, Windows-relevant (39 of 64) — unchanged | 12 | 28.7 | 40.4 |
+| Full run, downgraded (25 of 64) — before | 12 | 28.7 | 40.4 |
+| Full run, downgraded (25 of 64) — after | **10** | **18.4** | **19.9** |
+| Per merged PR, averaged over all 250 — before | — | 10.25 | 13.78 |
+| Per merged PR, averaged over all 250 — after | — | **9.22** | **11.73** |
+
+That is −36% runner-minutes on a downgraded full run (−51% at the 2x multiplier),
+and **−10% overall runner-minutes / −15% 2x-equivalent** across the whole sample.
+The one estimated input is the baseline Windows shard at ~1.5 min (~0.83 min
+measured fixed overhead plus the contract suite); every other figure is measured.
+
+There is **no wall-clock regression**: a downgraded run's Windows job goes from 4.15 min to
+~1.5 min, so the full path gets *shorter*, and no full-Windows run changes at all.
+
+**Why the matrix is still 3 shards.** Dropping Windows to 2 was measured and
+rejected. Per-shard step timings put fixed overhead (checkout, setup-node, cache
+restore) at only ~0.83 min of the 4.15-min shard; the rest is the test step. Going
+3 → 2 therefore removes one setup (~1.7 equivalent-minutes, 7%) while adding
+~1.65 min to the full path's critical chain. Tightening the selection above beat
+that at zero wall-clock cost, so `FULL_SUITE_SHARDS.windows` stays at 3.
+`max-parallel` is not an alternative — it lowers peak concurrency, not total
+occupancy.
+
### Python sidecar scripts
`scripts/*.py` (the LTX-2, MiniMax, FastVideo, and download sidecars) used to
diff --git a/scripts/ci-base-sha.test.js b/scripts/ci-base-sha.test.js
index 15b579344e..d361e623d1 100644
--- a/scripts/ci-base-sha.test.js
+++ b/scripts/ci-base-sha.test.js
@@ -82,6 +82,15 @@ describe('ci.yml required checks', () => {
expect(jobs['full-gate']).toMatch(/name: Full CI Gate/);
});
+ it('withholds the full gate when the Windows job ran only the contract baseline', () => {
+ // verify-ci-status.js lets a release skip its own suite on this check, so
+ // `full: true` alone is not enough: a full plan may now leave Windows at
+ // the WINDOWS_CONTRACT_TESTS baseline (#7440). Publishing the gate then
+ // would vouch for Windows coverage that never ran.
+ expect(jobs['full-gate']).toMatch(/needs\.impact\.outputs\.full == 'true'/);
+ expect(jobs['full-gate']).toMatch(/needs\.impact\.outputs\.windows_mode == 'full'/);
+ });
+
it('no longer carries the retired legacy check-name jobs', () => {
// `lint` was a whole runner that echoed the client job's result, and the
// server job wore `test (24.x)`; the ruleset requires neither.
diff --git a/scripts/ci-test-plan.js b/scripts/ci-test-plan.js
index f58f3559d5..eceb281e4e 100644
--- a/scripts/ci-test-plan.js
+++ b/scripts/ci-test-plan.js
@@ -46,31 +46,47 @@ export const shardIndexes = (mode, count) => (
mode === 'full' ? Array.from({ length: count }, (_, index) => index + 1) : [1]
);
+// `windowsEscalates` decides whether a trigger widens the WINDOWS job too, not
+// only the Linux ones. Three windows-server shards are 3 of a full run's 12
+// jobs and 41% of its runner-minutes (58% at GitHub's 2x windows-latest
+// multiplier, which this public repo does not pay but a privately-billed fork
+// does), so a trigger that widens CI for a reason windows-server cannot
+// observe — a client build/lint/test-setup file it never loads — spends that
+// on coverage which does not exist. Those run the WINDOWS_CONTRACT_TESTS
+// baseline instead, the depth a Windows-risk scoped PR already gets. `true` is
+// the fail-closed default for anything unlisted, and a diff touching
+// WINDOWS_RISK_RULES escalates regardless of this flag (issue #7440).
const FULL_TRIGGER_RULES = [
- { re: /^\.github\/workflows\//, reason: 'workflow definition changed' },
- { re: /^(?:package|server\/package|client\/package|autofixer\/package)(?:-lock)?\.json$/, reason: 'dependency manifest changed' },
- { re: /^(?:server|client)\/vitest\.config(?:\.db)?\.js$/, reason: 'test runner configuration changed' },
- { re: /^scripts\/vitestCiPool(?:\.test)?\.js$/, reason: 'test runner pool configuration changed' },
- { re: /^server\/vitest\.setup\.js$/, reason: 'server test setup changed' },
- { re: /^client\/src\/test\/setup\.js$/, reason: 'client test setup changed' },
+ // Defines the windows-server job itself.
+ { re: /^\.github\/workflows\//, reason: 'workflow definition changed', windowsEscalates: true },
+ // Native rebuilds and platform-conditional resolution differ on Windows.
+ { re: /^(?:package|server\/package|client\/package|autofixer\/package)(?:-lock)?\.json$/, reason: 'dependency manifest changed', windowsEscalates: true },
+ { re: /^(?:server|client)\/vitest\.config(?:\.db)?\.js$/, reason: 'test runner configuration changed', windowsEscalates: true },
+ { re: /^scripts\/vitestCiPool(?:\.test)?\.js$/, reason: 'test runner pool configuration changed', windowsEscalates: true },
+ { re: /^server\/vitest\.setup\.js$/, reason: 'server test setup changed', windowsEscalates: true },
+ // Client-only: windows-server never loads the client setup file.
+ { re: /^client\/src\/test\/setup\.js$/, reason: 'client test setup changed', windowsEscalates: false },
// Biome config + its GritQL plugins (the former client/eslint.config.js). The
// .grit files carry real enforced rules — notably the crypto.randomUUID ban —
- // so a change there is as load-bearing as a change to the config itself.
- { re: /^client\/(?:biome\.jsonc|[^/]+\.grit)$/, reason: 'lint configuration changed' },
- { re: /^client\/vite\.config\.js$/, reason: 'client build configuration changed' },
- { re: /^server\/index\.js$/, reason: 'server composition root changed' },
- { re: /^server\/lib\/(?:schemaVersions|validation)\.js$/, reason: 'shared server contract changed' },
+ // so a change there is as load-bearing as a change to the config itself. It
+ // is still a client-lint surface, and the Windows job runs no lint.
+ { re: /^client\/(?:biome\.jsonc|[^/]+\.grit)$/, reason: 'lint configuration changed', windowsEscalates: false },
+ // Client-only: the Windows job builds no client bundle.
+ { re: /^client\/vite\.config\.js$/, reason: 'client build configuration changed', windowsEscalates: false },
+ { re: /^server\/index\.js$/, reason: 'server composition root changed', windowsEscalates: true },
+ { re: /^server\/lib\/(?:schemaVersions|validation)\.js$/, reason: 'shared server contract changed', windowsEscalates: true },
// The scripts that decide what CI runs, run it, and gate the release on it.
// A bug in any of them can make a scoped plan silently test nothing, so they
- // prove themselves against the complete suite rather than their own scope.
- { re: /^scripts\/(?:lib\/githubOutput|ci-base-sha|ci-test-plan|run-ci-(?:lint|tests)|scan-diff-hidden-content|verify-ci-status)(?:\.test)?\.js$/, reason: 'CI pipeline script changed' },
+ // prove themselves against the complete suite rather than their own scope —
+ // including on Windows, whose shard matrix ci-test-plan.js itself emits.
+ { re: /^scripts\/(?:lib\/githubOutput|ci-base-sha|ci-test-plan|run-ci-(?:lint|tests)|scan-diff-hidden-content|verify-ci-status)(?:\.test)?\.js$/, reason: 'CI pipeline script changed', windowsEscalates: true },
];
// Files whose Windows behavior is not faithfully exercised by pinPlatform()
// stubs on Linux: real .cmd spawn, PowerShell BOM, PTY wrap, path.basename
// on backslashes. A PR that does not touch these still gets a full Windows
// run nightly, on the main -> release PR, and on release.
-const WINDOWS_RISK_RULES = [
+export const WINDOWS_RISK_RULES = [
/\.(?:ps1|cmd|bat)$/i,
/^scripts\/fix-windows-console(?:\.test)?\.js$/,
/^scripts\/ps1-bom\.test\.js$/,
@@ -437,6 +453,18 @@ export const splitByRunner = (paths) => ({
});
const windowsContractTests = (trackedSet) => WINDOWS_CONTRACT_TESTS.filter((path) => trackedSet.has(path));
+/**
+ * Does this diff touch a surface only a real Windows runner can prove?
+ *
+ * Deliberately NOT restricted to isExecutable() paths: .ps1/.cmd/.bat are not
+ * in EXECUTABLE_RE, so a PowerShell change used to reach the Windows job only
+ * as a side effect of being an "unclassified changed file". This answers the
+ * question directly, and is what overrides a trigger's windowsEscalates:false.
+ */
+const hasWindowsRiskFile = (paths) => paths.some((path) => (
+ !isDocumentationOnly(path) && WINDOWS_RISK_RULES.some((rule) => rule.test(path))
+));
+
const skippedRunner = () => ({ mode: 'skip', files: [], sources: [] });
// Catalog barrels are validated by structural export guards. Feeding one to
@@ -487,7 +515,16 @@ const suiteReasonsFor = (plan, { appRouteOnly = false } = {}) => ({
lint: plan.lint.mode === 'skip' ? 'skipped: no changed client source needs linting' : plan.full ? `full matrix: ${plan.reason}` : 'changed client source',
build: plan.build ? (plan.full ? `full matrix: ${plan.reason}` : 'client-impacting source changed') : 'skipped: no client-impacting source changed',
smoke: plan.smoke ? (plan.full ? `full matrix: ${plan.reason}` : 'server-impacting source changed') : 'skipped: no server-impacting source changed',
- windows: plan.windows ? (plan.full ? `full matrix: ${plan.reason}` : 'Windows-sensitive surface changed') : 'skipped: no Windows-sensitive surface changed',
+ // A full plan whose Windows job stayed at the contract baseline says so
+ // explicitly, so the CI summary never reads "full matrix" beside a one-shard
+ // Windows run (issue #7440).
+ windows: !plan.windows
+ ? 'skipped: no Windows-sensitive surface changed'
+ : plan.full
+ ? (plan.windowsMode === 'full'
+ ? `full matrix: ${plan.reason}`
+ : `Windows contract baseline (full matrix elsewhere): ${plan.reason}`)
+ : 'Windows-sensitive surface changed',
});
/**
@@ -511,38 +548,38 @@ export function buildCiTestPlan(changedFiles, {
const changed = uniqueSorted(changedFiles.filter(Boolean));
const trackedSet = new Set(trackedFiles);
+ // Nightly, the main -> release PR, release, and an explicit "full CI"
+ // request keep the complete Windows matrix. ci.yml has no push trigger, so
+ // these ARE the discovery net for a Windows regression on a surface nobody
+ // has tagged — the same net every PR that touches no WINDOWS_RISK_RULES file
+ // already relies on. A downgrade below widens that existing population; it
+ // does not invent a new risk class.
if (forceFull) {
- const plan = {
- full: true,
- reason: forceFullReason,
- changedFiles: changed,
- server: { mode: 'full', files: [], sources: [] },
- client: { mode: 'full', files: [], sources: [] },
- db: true,
- lint: { mode: 'full', files: [] },
- build: true,
- smoke: true,
- windows: true,
- windowsMode: 'full',
- windowsFiles: [],
- windowsSources: [],
- };
- return finishPlan(plan, { appRouteOnly });
+ return fullPlan(changed, forceFullReason, { appRouteOnly, trackedSet, windowsEscalates: true });
}
const appCompositionChanged = changed.includes('client/src/App.jsx');
if (appCompositionChanged && !appRouteOnly) {
- return fullPlan(changed, 'client composition root changed: client/src/App.jsx', { appRouteOnly });
+ return fullPlan(changed, 'client composition root changed: client/src/App.jsx', { appRouteOnly, trackedSet, windowsEscalates: false });
}
- const fullTrigger = changed
+ // EVERY matching trigger, not just the reported one: the reason line is the
+ // first match in sorted-path order, but the Windows decision is the OR over
+ // all of them. Reporting alone would let an alphabetically earlier
+ // client-only trigger (client/vite.config.js) silently downgrade the Windows
+ // job on a diff that also changed server/index.js.
+ const fullTriggers = changed
.flatMap((path) => FULL_TRIGGER_RULES
.filter(({ re }) => re.test(path))
- .map(({ reason }) => ({ path, reason })))
- .at(0);
+ .map(({ reason, windowsEscalates }) => ({ path, reason, windowsEscalates })));
+ const fullTrigger = fullTriggers.at(0);
if (fullTrigger) {
- return fullPlan(changed, `${fullTrigger.reason}: ${fullTrigger.path}`, { appRouteOnly });
+ return fullPlan(changed, `${fullTrigger.reason}: ${fullTrigger.path}`, {
+ appRouteOnly,
+ trackedSet,
+ windowsEscalates: fullTriggers.some((trigger) => trigger.windowsEscalates),
+ });
}
const alwaysRun = alwaysRunTests(trackedSet);
@@ -571,10 +608,10 @@ export function buildCiTestPlan(changedFiles, {
const executable = relevant.filter(isExecutable);
const unknown = relevant.filter((path) => !isExecutable(path));
if (unknown.length > 0) {
- return fullPlan(changed, `unclassified changed file: ${unknown[0]}`, { appRouteOnly });
+ return fullPlan(changed, `unclassified changed file: ${unknown[0]}`, { appRouteOnly, trackedSet });
}
if (executable.length > MAX_CHANGED_CODE_FILES) {
- return fullPlan(changed, `wide change (${executable.length} executable files)`, { appRouteOnly });
+ return fullPlan(changed, `wide change (${executable.length} executable files)`, { appRouteOnly, trackedSet, windowsEscalates: false });
}
// `changed` includes deleted paths (diff-filter ACMRD), but a deleted test
@@ -586,14 +623,14 @@ export function buildCiTestPlan(changedFiles, {
!isServerRunnerFile(path) && !path.startsWith('client/')
));
if (unsupportedSources.length > 0) {
- return fullPlan(changed, `unmapped executable surface: ${unsupportedSources[0]}`, { appRouteOnly });
+ return fullPlan(changed, `unmapped executable surface: ${unsupportedSources[0]}`, { appRouteOnly, trackedSet });
}
const deletedSources = sourceFiles.filter((path) => !trackedSet.has(path));
if (deletedSources.length > 0) {
// `vitest related` needs a real source path. A deleted module can still
// affect importers, so widening is safer than silently dropping its side of
// the graph.
- return fullPlan(changed, `deleted executable source: ${deletedSources[0]}`, { appRouteOnly });
+ return fullPlan(changed, `deleted executable source: ${deletedSources[0]}`, { appRouteOnly, trackedSet });
}
// Python scripts never enter the import graph or a feature directory: their
// only selector is the per-script contract list, so they leave the JS-only
@@ -612,7 +649,7 @@ export function buildCiTestPlan(changedFiles, {
const pythonTests = (pathContractTests[script] || [])
.filter((path) => trackedSet.has(path) && runnerForTest(path));
if (pythonTests.length === 0) {
- return fullPlan(changed, `python script with no parsing contract: ${script}`, { appRouteOnly });
+ return fullPlan(changed, `python script with no parsing contract: ${script}`, { appRouteOnly, trackedSet });
}
selectedTests.push(...pythonTests);
}
@@ -637,7 +674,7 @@ export function buildCiTestPlan(changedFiles, {
const clientFiles = uniqueSorted(selectedTests.filter((path) => runnerForTest(path) === 'client'));
if (serverFiles.length > MAX_TARGETED_TEST_FILES || clientFiles.length > MAX_TARGETED_TEST_FILES) {
- return fullPlan(changed, 'targeted test set exceeded safety cap', { appRouteOnly });
+ return fullPlan(changed, 'targeted test set exceeded safety cap', { appRouteOnly, trackedSet, windowsEscalates: false });
}
const hasServerSource = jsSources.some(isServerRunnerFile);
@@ -669,7 +706,7 @@ export function buildCiTestPlan(changedFiles, {
? { mode: clientSources.length > 0 ? 'related' : 'files', files: [], sources: clientSources }
: skippedRunner();
- const windows = executable.some((path) => WINDOWS_RISK_RULES.some((rule) => rule.test(path)));
+ const windows = hasWindowsRiskFile(changed);
const windowsMode = windows
? (serverSources.length > 0 ? 'related' : 'files')
: 'skip';
@@ -712,7 +749,32 @@ const finishPlan = (plan, options) => ({
},
});
-function fullPlan(changedFiles, reason, options) {
+/**
+ * A full plan for every Linux suite — with the Windows job at the depth the
+ * diff actually justifies.
+ *
+ * `windowsEscalates` (default true, so an unlisted caller fails closed) is
+ * false only for a trigger windows-server cannot observe: a client-only
+ * surface, or a CAPACITY escalation (the targeted-test cap, a wide diff) that
+ * says the planner ran out of scoping headroom, not that anything risky
+ * changed. A touched WINDOWS_RISK_RULES path overrides it back to full.
+ *
+ * Downgraded does not mean skipped: the job still runs WINDOWS_CONTRACT_TESTS,
+ * the curated cross-platform baseline a Windows-risk scoped PR already gets.
+ * The complete Windows matrix stays the discovery net for surfaces nobody has
+ * tagged yet — it just runs nightly, on the main -> release PR, and on
+ * release, instead of on every capacity-widened PR (issue #7440).
+ *
+ * `options` is also forwarded to finishPlan(), which reads only appRouteOnly.
+ */
+function fullPlan(changedFiles, reason, options = {}) {
+ const { trackedSet = new Set(), windowsEscalates = true } = options;
+ // An empty `files` list makes run-ci-tests.js print "No server tests
+ // selected" and exit 0 — a green Windows job that ran nothing. So the
+ // baseline is only a downgrade while it actually resolves to tracked tests;
+ // otherwise this falls back to the complete suite rather than to silence.
+ const baseline = windowsContractTests(trackedSet);
+ const windowsFull = windowsEscalates || hasWindowsRiskFile(changedFiles) || baseline.length === 0;
return finishPlan({
full: true,
reason,
@@ -724,8 +786,8 @@ function fullPlan(changedFiles, reason, options) {
build: true,
smoke: true,
windows: true,
- windowsMode: 'full',
- windowsFiles: [],
+ windowsMode: windowsFull ? 'full' : 'files',
+ windowsFiles: windowsFull ? [] : baseline,
windowsSources: [],
}, options);
}
diff --git a/scripts/ci-test-plan.test.js b/scripts/ci-test-plan.test.js
index 28888d918f..db91e9fe70 100644
--- a/scripts/ci-test-plan.test.js
+++ b/scripts/ci-test-plan.test.js
@@ -17,6 +17,7 @@ import {
sourceReferencePattern,
splitByRunner,
WINDOWS_CONTRACT_TESTS,
+ WINDOWS_RISK_RULES,
} from './ci-test-plan.js';
const TRACKED = [
@@ -815,3 +816,146 @@ describe('needsSlashdoSubmodule', () => {
})).toBe(true);
});
});
+
+// windows-latest bills at GitHub's 2x minute multiplier, and three Windows
+// shards were ~58% of a full run's billable minutes (24.9 of 40.4, measured
+// over 11 real runs). These pin the rule that bought that back: a full plan
+// escalates the Windows job to the complete server suite only when the diff
+// gives windows-server something to prove. Everything else still runs the
+// WINDOWS_CONTRACT_TESTS baseline — reduced, never skipped (issue #7440).
+describe('Windows escalation on a full plan (#7440)', () => {
+ // The contract baseline resolves against tracked files, so a downgrade is
+ // only observable when the contract tests exist in the tree.
+ const TRACKED_WITH_CONTRACTS = [...TRACKED, ...WINDOWS_CONTRACT_TESTS];
+ const plan = (files, options = {}) => buildCiTestPlan(files, {
+ trackedFiles: TRACKED_WITH_CONTRACTS,
+ ...options,
+ });
+
+ it('runs the contract baseline for a full trigger windows-server cannot observe', () => {
+ const downgraded = plan(['client/vite.config.js']);
+
+ // Still a full plan for every Linux suite — only the 2x job narrows.
+ expect(downgraded.full).toBe(true);
+ expect(downgraded.server.mode).toBe('full');
+ expect(downgraded.client.mode).toBe('full');
+ expect(downgraded.shards.server).toEqual(shardIndexes('full', FULL_SUITE_SHARDS.server));
+
+ // Reduced, not skipped: the job runs, on one shard, over the baseline.
+ expect(downgraded.windows).toBe(true);
+ expect(downgraded.windowsMode).toBe('files');
+ expect(downgraded.shards.windows).toEqual([1]);
+ expect(downgraded.windowsFiles).toEqual(WINDOWS_CONTRACT_TESTS);
+ expect(downgraded.suiteReasons.windows).toContain('Windows contract baseline');
+ });
+
+ it('treats a capacity escalation as a scoping limit, not a Windows risk signal', () => {
+ // A diff wide enough to blow MAX_CHANGED_CODE_FILES says the planner ran
+ // out of scoping headroom. Nothing about it implicates Windows.
+ const wide = plan(Array.from({ length: 31 }, (_, i) => `server/services/wide${i}.js`));
+
+ expect(wide.full).toBe(true);
+ expect(wide.reason).toContain('wide change');
+ expect(wide.windowsMode).toBe('files');
+ expect(wide.shards.windows).toEqual([1]);
+ });
+
+ it('escalates when ANY matching trigger is Windows-relevant, not just the reported one', () => {
+ // The reason line reports the first match in sorted-path order, which here
+ // is the client-only one. The Windows decision must still see server/index.js.
+ const mixed = plan(['client/vite.config.js', 'server/index.js']);
+
+ expect(mixed.reason).toContain('client/vite.config.js');
+ expect(mixed.windowsMode).toBe('full');
+ expect(mixed.shards.windows).toEqual(shardIndexes('full', FULL_SUITE_SHARDS.windows));
+ });
+
+ it('escalates when a Windows-risk file rides along with a client-only trigger', () => {
+ // .ps1 is not in EXECUTABLE_RE, so risk detection must read every changed
+ // path, not only the executable ones.
+ const withPowerShell = plan(['client/vite.config.js', 'scripts/deploy.ps1']);
+
+ expect(withPowerShell.windowsMode).toBe('full');
+ expect(withPowerShell.windowsFiles).toEqual([]);
+ });
+
+ it('keeps the complete matrix on the runs that carry the discovery net', () => {
+ // Nightly, the main -> release PR, release, explicit full request. ci.yml
+ // has no push trigger, so these are the whole discovery net for an
+ // untagged Windows regression.
+ const forced = plan([], { forceFull: true, forceFullReason: 'full CI requested' });
+
+ expect(forced.windowsMode).toBe('full');
+ expect(forced.shards.windows).toEqual(shardIndexes('full', FULL_SUITE_SHARDS.windows));
+ });
+
+ it('fails closed for a trigger nobody classified', () => {
+ // fullPlan defaults windowsEscalates to true, so a call site added later
+ // without the flag over-tests rather than under-tests.
+ const unclassified = plan(['data.reference/bootstrap.bin']);
+
+ expect(unclassified.full).toBe(true);
+ expect(unclassified.windowsMode).toBe('full');
+ });
+
+ it('fails closed to the full suite rather than selecting zero Windows tests', () => {
+ // run-ci-tests.js prints "No server tests selected" and exits 0 on an empty
+ // files list. A downgrade that resolved to [] would be a green job that ran
+ // nothing, so the baseline has to actually exist first.
+ const noContracts = buildCiTestPlan(['client/vite.config.js'], { trackedFiles: [] });
+
+ expect(noContracts.windowsMode).toBe('full');
+ expect(noContracts.shards.windows).toEqual(shardIndexes('full', FULL_SUITE_SHARDS.windows));
+
+ // The downgrade is still reachable — this is a fail-closed fallback, not a
+ // rule that disabled it outright.
+ const withContracts = buildCiTestPlan(['client/vite.config.js'], {
+ trackedFiles: WINDOWS_CONTRACT_TESTS,
+ });
+ expect(withContracts.windowsMode).toBe('files');
+ });
+
+ describe('no Windows-sensitive surface loses coverage', () => {
+ // One representative path per WINDOWS_RISK_RULES entry. The coverage
+ // assertion below fails when a rule is added without a sample here, so a
+ // new Windows-sensitive surface cannot land untested.
+ const RISK_SAMPLES = [
+ 'scripts/deploy.ps1',
+ 'scripts/launch.cmd',
+ 'scripts/fix-windows-console.js',
+ 'scripts/ps1-bom.test.js',
+ 'server/lib/bufferedSpawn.js',
+ 'server/lib/pathSafety.js',
+ 'server/lib/staticImportGraph.js',
+ 'server/services/agentImportCycles.test.js',
+ 'server/services/worktreeManager.js',
+ 'server/lib/shellCd.js',
+ 'server/lib/agentGuard/index.js',
+ 'server/cos-runner/index.js',
+ 'server/services/shell.js',
+ 'server/services/agentTuiSpawning.js',
+ 'server/services/autonomousJobs/execution.shellSpawn.js',
+ 'server/services/voice/fineTuning.js',
+ 'server/routes/apps/index.js',
+ 'server/routes/scaffoldVite.js',
+ ];
+
+ it('covers every risk rule with a sample', () => {
+ const uncovered = WINDOWS_RISK_RULES
+ .filter((rule) => !RISK_SAMPLES.some((path) => rule.test(path)))
+ .map((rule) => String(rule));
+
+ expect(uncovered).toEqual([]);
+ });
+
+ it.each(RISK_SAMPLES)('routes %s to the Windows job', (path) => {
+ expect(plan([path]).windows).toBe(true);
+ });
+
+ it.each(RISK_SAMPLES)('never downgrades a full plan that touches %s', (path) => {
+ // Paired with a client-only trigger so the plan goes full for a reason
+ // that WOULD otherwise downgrade — the risk file has to override it.
+ expect(plan(['client/vite.config.js', path]).windowsMode).toBe('full');
+ });
+ });
+});