Skip to content

Commit 4081306

Browse files
committed
fix(ci): cover core-driven extension impact in the PR fallback plan
Fixes #124412
1 parent d437a4a commit 4081306

2 files changed

Lines changed: 98 additions & 15 deletions

File tree

‎scripts/lib/ci-changed-node-test-plan.mts‎

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
isTestSupportFileTarget,
1010
resolveChangedTestTargetPlan,
1111
} from "../test-projects.test-support.mts";
12+
import { listAvailableExtensionIds } from "./changed-extensions.mts";
1213
import {
1314
createNodeTestShards,
1415
isPolicyTestOwnedPath,
@@ -119,6 +120,11 @@ const PROMPT_SNAPSHOT_SURFACE_RE =
119120
// plugin-sdk agent harness, codex catalog fixtures).
120121
const PROMPT_SNAPSHOT_ENTRY = "test/helpers/agents/happy-path-prompt-snapshots.ts";
121122

123+
// The fallback planner and chunk-policy owner are part of the gate surface; changes to the
124+
// gate must not be able to skip the gated lane (#124412).
125+
const CORE_EXTENSION_IMPACT_SURFACE_RE =
126+
/^scripts\/lib\/(?:ci-changed-node-test-plan|extension-test-plan)\.mts$/u;
127+
122128
/**
123129
* True when a changed path can influence generated prompt snapshots: it
124130
* touches the snapshot surface directly, or the generator's import graph
@@ -351,14 +357,41 @@ function createChangedExtensionConfigShardsForPaths(changedPaths: string[], cwd:
351357
}
352358

353359
/**
354-
* The fail-safe cause leaves the non-extension diff's extension impact unbounded,
355-
* so whole extension configs are required; precise targets would under-cover.
360+
* True when core or fallback-gate changes can affect extension consumers beyond
361+
* the changed extension paths.
362+
*/
363+
export function hasCoreExtensionImpact(changedPaths: string[], options: CwdOptions = {}) {
364+
if (changedPaths.some((changedPath) => CORE_EXTENSION_IMPACT_SURFACE_RE.test(changedPath))) {
365+
return true;
366+
}
367+
const cwd = options.cwd ?? process.cwd();
368+
const regularLivePaths = changedPaths.filter(
369+
(changedPath) =>
370+
existsSync(path.join(cwd, changedPath)) &&
371+
!changedPath.startsWith("extensions/") &&
372+
!isPolicyTestOwnedPath(changedPath),
373+
);
374+
return (
375+
detectChangedLanes(changedPaths).extensionImpactFromCore ||
376+
(regularLivePaths.some((changedPath) => changedPath.startsWith("src/")) &&
377+
hasImportGraphImpactOnTargets(regularLivePaths, publicPluginSdkEntrySources, cwd))
378+
);
379+
}
380+
381+
/**
382+
* Covers changed extensions plus the full core-impact blast radius when precise
383+
* planning falls back. See #124412.
356384
*/
357385
export function createChangedExtensionFallbackShards(
358386
changedPaths: string[],
359387
options: CwdOptions = {},
360388
): ChangedNodeTestShard[] {
361389
const cwd = options.cwd ?? process.cwd();
390+
if (hasCoreExtensionImpact(changedPaths, { cwd })) {
391+
return createChangedExtensionConfigShards(
392+
listAvailableExtensionIds().map((extensionId) => `extensions/${extensionId}`),
393+
);
394+
}
362395
return createChangedExtensionConfigShardsForPaths(changedPaths, cwd);
363396
}
364397

@@ -405,11 +438,7 @@ export function createChangedNodeTestShards(
405438

406439
// Package-specifier consumers are invisible to the relative import graph.
407440
// Fail safe when a core change reaches a public SDK entrypoint indirectly.
408-
if (
409-
detectChangedLanes(changedPaths).extensionImpactFromCore ||
410-
(regularLivePaths.some((changedPath) => changedPath.startsWith("src/")) &&
411-
hasImportGraphImpactOnTargets(regularLivePaths, publicPluginSdkEntrySources, cwd))
412-
) {
441+
if (hasCoreExtensionImpact(changedPaths, { cwd })) {
413442
return null;
414443
}
415444

‎test/scripts/ci-changed-node-test-plan.test.ts‎

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
22
import { tmpdir } from "node:os";
33
import path from "node:path";
44
import { describe, expect, it } from "vitest";
5+
import { listAvailableExtensionIds } from "../../scripts/lib/changed-extensions.mts";
56
import {
67
createChangedExtensionFallbackShards,
78
createChangedNodeTestShards,
89
hasBuildArtifactAffectingChange,
10+
hasCoreExtensionImpact,
911
hasPromptSnapshotAffectingChange,
1012
hasQaSmokeAffectingChange,
1113
hasSqliteSessionLifecycleAffectingChange,
1214
} from "../../scripts/lib/ci-changed-node-test-plan.mts";
13-
import { listExtensionTestFilesForRoots } from "../../scripts/lib/extension-test-plan.mts";
15+
import {
16+
listExtensionTestFilesForRoots,
17+
resolveExtensionTestConfig,
18+
} from "../../scripts/lib/extension-test-plan.mts";
1419
import { hasImportGraphImpactOnTargets } from "../../scripts/test-projects.test-support.mts";
1520
import { listGitTrackedFiles } from "../../src/test-utils/repo-files.js";
1621
import { isGatewayServerTestFile } from "../vitest/vitest.gateway-server-paths.mjs";
@@ -35,6 +40,20 @@ function expectBoundedCodexFallback(
3540
expect(new Set(targets).size).toBe(targets.length);
3641
}
3742

43+
function expectAllExtensionConfigs(
44+
shards: ReturnType<typeof createChangedExtensionFallbackShards>,
45+
) {
46+
const configs = new Set(shards.flatMap((shard) => shard.configs));
47+
const expectedConfigs = new Set(
48+
listAvailableExtensionIds().map((extensionId) =>
49+
resolveExtensionTestConfig(`extensions/${extensionId}`),
50+
),
51+
);
52+
53+
expect(configs).toEqual(expectedConfigs);
54+
expect(configs).toContain("test/vitest/vitest.extension-codex.config.ts");
55+
}
56+
3857
describe("CI changed Node test plan", () => {
3958
it("routes Control UI style changes through source-scanning policy tests", () => {
4059
const shards = createChangedNodeTestShards(["ui/src/styles/chat/layout.css"]);
@@ -298,6 +317,46 @@ describe("CI changed Node test plan", () => {
298317
expectBoundedCodexFallback(createChangedExtensionFallbackShards(changedPaths));
299318
});
300319

320+
it("covers every extension config when core changes can impact extension consumers", () => {
321+
const shards = createChangedExtensionFallbackShards([
322+
"src/gateway/tool-resolution.ts",
323+
"src/agents/openclaw-tools.ts",
324+
"extensions/discord/src/channel.ts",
325+
]);
326+
327+
expectAllExtensionConfigs(shards);
328+
});
329+
330+
it("covers every extension config when the fallback planner itself changes", () => {
331+
expectAllExtensionConfigs(
332+
createChangedExtensionFallbackShards(["scripts/lib/ci-changed-node-test-plan.mts"]),
333+
);
334+
});
335+
336+
it("classifies core and fallback-gate extension impact", () => {
337+
expect(hasCoreExtensionImpact(["src/agents/openclaw-tools.ts"])).toBe(true);
338+
expect(hasCoreExtensionImpact(["scripts/lib/ci-changed-node-test-plan.mts"])).toBe(true);
339+
expect(hasCoreExtensionImpact(["scripts/lib/extension-test-plan.mts"])).toBe(true);
340+
expect(hasCoreExtensionImpact(["extensions/discord/src/channel.ts"])).toBe(false);
341+
expect(hasCoreExtensionImpact(["docs/ci.md"])).toBe(false);
342+
});
343+
344+
it("keeps extension-only fallbacks scoped to the changed extension config", () => {
345+
expect(createChangedExtensionFallbackShards(["extensions/discord/src/channel.ts"])).toEqual([
346+
{
347+
checkName: "checks-node-changed-extensions-config",
348+
configs: ["test/vitest/vitest.extension-discord.config.ts"],
349+
requiresDist: false,
350+
runner: "blacksmith-8vcpu-ubuntu-2404",
351+
shardName: "changed-extensions-config",
352+
},
353+
]);
354+
});
355+
356+
it("does not create extension fallback shards for docs-only diffs", () => {
357+
expect(createChangedExtensionFallbackShards(["docs/ci.md"])).toEqual([]);
358+
});
359+
301360
it.each([
302361
{
303362
changedPath: "extensions/browser/src/browser/cdp.helpers.test.ts",
@@ -352,13 +411,8 @@ describe("CI changed Node test plan", () => {
352411
expect(new Set(targets).size).toBe(targets.length);
353412
});
354413

355-
it("skips extension fallback when no extension paths changed", () => {
356-
expect(
357-
createChangedExtensionFallbackShards([
358-
"packages/gateway-protocol/src/frame-guards.ts",
359-
"src/agents/live-model-filter.ts",
360-
]),
361-
).toEqual([]);
414+
it("skips extension fallback when the core-impact predicate does not fire", () => {
415+
expect(createChangedExtensionFallbackShards(["src/agents/live-model-filter.ts"])).toEqual([]);
362416
});
363417

364418
it("falls back to bounded Codex config shards for deleted sources", () => {

0 commit comments

Comments
 (0)