From 8749adefe5174b37ed6d7cb1cef2c7e17b17416f Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Mon, 16 Nov 2026 22:55:17 -0500 Subject: [PATCH] fix(ci): classify static/doc script inputs in change-plan and trace URL fixtures --- scripts/ci/change-plan.mjs | 50 ++++++++++++++++++- scripts/ci/scopes.mjs | 2 + scripts/ci/test-selection.mjs | 40 +++++++++++++-- .../boundary/filesystem/ciChangeScope.test.ts | 33 ++++++++++++ tests/evaluation/ciTestSelection.test.ts | 20 ++++++++ 5 files changed, 140 insertions(+), 5 deletions(-) diff --git a/scripts/ci/change-plan.mjs b/scripts/ci/change-plan.mjs index 1cc2bf4f80..d71fa40754 100644 --- a/scripts/ci/change-plan.mjs +++ b/scripts/ci/change-plan.mjs @@ -46,6 +46,42 @@ const PORTABLE_CI_REPORTERS = new Set([ "scripts/ci/test-timing-reporter.mjs", "scripts/ci/test-history.mjs", ]); +// Static architecture/lint/schema/test-project verifiers and baselines run in +// static/build/portable lanes (`code: true`) without requiring host package lanes. +const STATIC_CODE_ONLY_INPUTS = [ + "scripts/lib/module-layers.baseline.json", + "scripts/lib/module-layers.*", + "scripts/lib/module-boundaries.*", + "scripts/verify-module-boundaries.mjs", + "scripts/verify/architecture-guards.mjs", + "scripts/verify/*-guard.*", + "scripts/verify/rea-numeric-limits.mjs", + "scripts/verify/source-tokens.*", + "scripts/verify/keyed-first-match.*", + "scripts/verify/reason-marker.*", + "scripts/verify/baselines/*.json", + "scripts/lint/**", + ".oxlintrc.json", + ".oxfmtrc.json", + ".jscpd.json", + "knip.json", + "tsconfig.scripts.json", + "scripts/verify-advertised-schemas.mjs", + "scripts/verify/advertised-schemas/**", + "scripts/verify/mcp-client-validation.*", + "scripts/verify-test-discovery.mjs", + "scripts/verify-test-temp-hygiene.mjs", + "scripts/lib/test-projects.mjs", +]; +// Documentation and product-catalog verifiers/generators exercised by `docs:check` +// and portable tests without changing packaged host behavior. +const DOCS_AND_CODE_INPUTS = [ + "scripts/check-doc-facts.mjs", + "scripts/generate-error-schema.mjs", + "scripts/lib/product-catalog.*", + "scripts/lib/catalog-core.*", + "scripts/lib/catalog-cli.*", +]; const matchesAny = (file, patterns) => patterns.some((pattern) => matchesGlob(file, pattern)); @@ -234,6 +270,15 @@ export function planChanges(request, repository) { selected.code = true; return; } + if (matchesAny(file, DOCS_AND_CODE_INPUTS)) { + selected.docs = true; + selected.code = true; + return; + } + if (matchesAny(file, STATIC_CODE_ONLY_INPUTS)) { + selected.code = true; + return; + } // A shared boundary is not evidence that every provider or host changed. // One lane that names the file is path evidence; a lane that only covers // it through a `**` directory glob is not. Several naming lanes means the @@ -293,7 +338,10 @@ export function planChanges(request, repository) { // full qualification retains every native host. selected.runtime = true; reasons.push(`Unowned runtime source: ${file}`); - } else if (file.startsWith(".agents/skills/")) { + } else if ( + file.startsWith(".agents/skills/") || + file.startsWith(".cursor-plugin/skills/") + ) { selected.runtime = true; selected.docs = true; } else { diff --git a/scripts/ci/scopes.mjs b/scripts/ci/scopes.mjs index 10f39b2a56..78345942e9 100644 --- a/scripts/ci/scopes.mjs +++ b/scripts/ci/scopes.mjs @@ -813,4 +813,6 @@ export const MANUAL_VERIFIERS = [ "scripts/verify-packaged-ghidra-windows.mjs", "scripts/verify-wasm-artifact.mjs", "scripts/verify-packaged-wasm-artifact.mjs", + "scripts/lib/ghidra-*-snapshot-e2e.mjs", + "scripts/lib/real-ghidra-snapshot-lifecycle.mjs", ]; diff --git a/scripts/ci/test-selection.mjs b/scripts/ci/test-selection.mjs index 504d315f32..0ed4241aeb 100644 --- a/scripts/ci/test-selection.mjs +++ b/scripts/ci/test-selection.mjs @@ -58,6 +58,7 @@ const LAUNCHES_BUILT_RUNTIME = const isCheckerInput = (path) => /\.d\.m?ts$/u.test(path) || path === "scripts/lib/module-layers.baseline.json" || + path === "scripts/check-doc-facts.mjs" || path === ".git-blame-ignore-revs" || path === "scripts/run-python-tests.py" || /^tests\/support\/analysis-efficiency\/.+\.py$/u.test(path) || @@ -126,6 +127,12 @@ const isProse = (path) => !DOCS_CODE.test(path) && !path.endsWith("/package.json")) || path.startsWith("licenses/"); +const isNonModuleFixture = (path) => + path.startsWith("tests/fixtures/") && + !isModule(path) && + !isProse(path) && + !isCheckerInput(path) && + explicitFixtureOwners(path).length === 0; /** Why a changed path cannot be traced to tests, if it cannot. */ const untracedInput = (path) => !isTest(path) && SHARED_BOUNDARY.test(path) @@ -133,6 +140,7 @@ const untracedInput = (path) => : !isModule(path) && !isProse(path) && !isCheckerInput(path) && + !isNonModuleFixture(path) && explicitFixtureOwners(path).length === 0 ? `Input is not traced to tests: ${path}` : undefined; @@ -181,6 +189,7 @@ export function traceAffectedTests({ files, snapshot }) { const changedModules = files.filter( (path) => isModule(path) && !isTest(path), ); + const changedNonModuleFixtures = files.filter(isNonModuleFixture); for (const path of files) { if (isTest(path)) select(path, "changed"); for (const owner of explicitFixtureOwners(path)) { @@ -208,7 +217,10 @@ export function traceAffectedTests({ files, snapshot }) { }; // Close over test-only helpers, verifiers and shared script modules, then // take the tests that import a change. - const affected = throughHelpers(changedModules); + const affected = throughHelpers([ + ...changedModules, + ...changedNonModuleFixtures, + ]); for (const test of tests) if (imports.get(test).some((target) => affected.has(target))) select(test, "imports"); @@ -223,6 +235,25 @@ export function traceAffectedTests({ files, snapshot }) { const names = (test, paths) => paths.some((path) => (sources.get(test) ?? "").includes(path)); + // A changed non-module fixture under tests/fixtures/ that no test reaches + // via URL/import or path literal (for example, a directory-scanned asset) + // fails closed to the complete suite. + for (const fixture of changedNonModuleFixtures) { + const reached = throughHelpers([fixture]); + const paths = [ + fixture, + ...[...reached].filter((path) => path.startsWith("scripts/")), + ]; + if ( + !tests.some( + (test) => + imports.get(test).some((target) => reached.has(target)) || + names(test, paths), + ) + ) + untraced.push(`Input is not traced to tests: ${fixture}`); + } + // A changed shared module that no test reaches has no coverage in a // selection, even when other changes select tests. for (const library of changedModules.filter(isScriptLibrary)) { @@ -240,13 +271,14 @@ export function traceAffectedTests({ files, snapshot }) { // A shared script module that another script, configuration file, hook or // workflow imports or names as a standalone file name can shape every run. - // Require a token boundary before the basename so `verify-module-boundaries.mjs` - // in package.json does not falsely match `scripts/lib/module-boundaries.mjs`. + // Ignore single-line comments and require a non-hyphen token boundary before + // the basename so hyphenated wrapper names do not match shared library names. const namesScriptBasename = (source, libraryPath) => { + const code = source.replace(/^\s*(?:\/\/|#).*$/gmu, ""); const escaped = posix .basename(libraryPath) .replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"); - return new RegExp(`(? { diff --git a/tests/evaluation/ciTestSelection.test.ts b/tests/evaluation/ciTestSelection.test.ts index 131fca2bf5..bcb6feaecf 100644 --- a/tests/evaluation/ciTestSelection.test.ts +++ b/tests/evaluation/ciTestSelection.test.ts @@ -273,6 +273,7 @@ it("traces shared script modules to their tests and falls back for other consume '{"scripts":{"verify:shared":"node scripts/verify-shared.mjs"}}', "tsconfig.scripts.json": '{"include":["scripts/lib/shared.mjs"]}', "stryker.config.mjs": 'import "./scripts/lib/shared.mjs";', + "scripts/check-doc-facts.mjs": 'import "./lib/shared.mjs";', "scripts/ci/scopes.mjs": 'export const S = ["scripts/lib/shared.mjs"];', }, @@ -282,6 +283,25 @@ it("traces shared script modules to their tests and falls back for other consume "tests/boundary/filesystem/shared.test.ts", "tests/boundary/filesystem/verifier.test.ts", ]); + expect( + selectedFiles( + plan(["tests/fixtures/card.json"], { + "tests/fixtures/card.json": '{"ok":true}', + "tests/boundary/mcp/card.test.ts": + 'new URL("../../fixtures/card.json", import.meta.url);', + "tests/boundary/mcp/unrelated.test.ts": 'import "../../../src/a.js";', + }), + ), + ).toEqual(["tests/boundary/mcp/card.test.ts"]); + expect( + plan(["tests/fixtures/unreferenced.bin"], { + "tests/fixtures/unreferenced.bin": "raw", + "tests/boundary/mcp/unrelated.test.ts": 'import "../../../src/a.js";', + }), + ).toMatchObject({ + mode: "full", + reason: "Input is not traced to tests: tests/fixtures/unreferenced.bin", + }); expect( plan(["scripts/lib/shared.mjs"], { ...sources,