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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: include transitive browser consumers in test plans (#10838)
[._.]/ Adam Eivy2e5341a78379
diff --git a/scripts/ci-test-plan.js b/scripts/ci-test-plan.jsindex 60b18d9445..921f0a11cd 100644--- a/scripts/ci-test-plan.js+++ b/scripts/ci-test-plan.js@@ -660,6 +660,8 @@ export function buildCiTestPlan(changedFiles, {clientDependencies = [],// Includes literal deferred imports; null means discovery was inconclusive.dbDependencies = [],+ // Registered suite → reachable files; null retains that suite conservatively.+ browserDependencies = {},} = {}) {const changed = uniqueSorted(changedFiles.filter(Boolean));const trackedSet = new Set(trackedFiles);@@ -877,7 +879,12 @@ export function buildCiTestPlan(changedFiles, {changedFiles: changed,server,client,- browserFiles: browserSuitesIn(serverFiles),+ browserFiles: browserSuitesIn([+ ...serverFiles,+ ...BROWSER_SUITES.filter((suite) => trackedSet.has(suite)+ && serverSources.some((source) => browserDependencies[suite] === null+ || browserDependencies[suite]?.includes(source))),+ ]),db,lint: {// Same deleted-path guard as directTests above — ESLint given a@@ -1043,13 +1050,13 @@ function collectClientDependencies(trackedFiles, cwd) {return uniqueSorted([...seen].filter((path) => path.startsWith('server/lib/')));}-// DB suites are excluded from ordinary Vitest related selection. Walk their-// imports separately, including deferred literals, without importing test code-// or Vitest (the planner runs before npm installation). Unreadable or unresolved-// local imports and computed imports retain DB coverage for server sources.-function collectDbDependencies(files, cwd) {+// Project DB and browser consumers without importing test code or Vitest (the+// planner runs before npm installation). Include deferred literals; unreadable,+// unresolved and computed imports retain conservative prerequisite coverage.+// Share parsed edges between suite walks so common dependencies are read once.+function collectTestDependencies(entries, files, cwd, importCache) {const known = new Set(files);- const pending = resolveDbTestFiles(files);+ const pending = [...entries];const seen = new Set();const extensions = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs', '.mts', '.cts', '.json'];let inconclusive = false;@@ -1059,16 +1066,21 @@ function collectDbDependencies(files, cwd) {if (seen.has(file)) continue;seen.add(file);if (!MODULE_SOURCE_RE.test(file)) continue;- const source = readFileSync(join(cwd, file), 'utf8');- const specifiers = staticImportSpecifiersFromSource(source);- // Scan all import calls. A nonliteral expression cannot safely prove- // absence of a dependency; template literals are resolvable only when- // they contain no interpolation. Extra matches in comments widen safely.- for (const match of source.matchAll(/\bimport\s*\(\s*([^)]*)\)/g)) {- const literal = match[1].trim().match(/^(['"`])([^'"`]*?)\1\s*(?:,.*)?$/s);- if (!literal || literal[2].includes('${')) inconclusive = true;- else specifiers.push(literal[2]);+ if (!importCache.has(file)) {+ const source = readFileSync(join(cwd, file), 'utf8');+ const specifiers = staticImportSpecifiersFromSource(source);+ let computed = false;+ // A nonliteral cannot prove absence of a dependency; extra matches in+ // comments widen safely. Template literals resolve without interpolation.+ for (const match of source.matchAll(/\bimport\s*\(\s*([^)]*)\)/g)) {+ const literal = match[1].trim().match(/^(['"`])([^'"`]*?)\1\s*(?:,.*)?$/s);+ if (!literal || literal[2].includes('${')) computed = true;+ else specifiers.push(literal[2]);+ }+ importCache.set(file, { specifiers, computed });}+ const { specifiers, computed } = importCache.get(file);+ if (computed) inconclusive = true;for (const specifier of specifiers) {if (!specifier.startsWith('.')) continue;const path = posix.normalize(posix.join(posix.dirname(file), specifier.split(/[?#]/)[0]));@@ -1143,12 +1155,20 @@ export function collectPlanInputs({ baseSha, forceFull = false, changedFiles, cw? collectClientDependencies(hasChangedFilesOverride ? uniqueSorted([...presentFiles, ...untrackedFiles]) : presentFiles, cwd): [];- const dbDependencies = collectedChangedFiles.some((path) => isServerRunnerFile(path)- && MODULE_SOURCE_RE.test(path) && !isTestFile(path) && !isStructuralBarrel(path))- ? collectDbDependencies(hasChangedFilesOverride ? uniqueSorted([...presentFiles, ...untrackedFiles]) : presentFiles, cwd)+ const hasRelatedServerSource = collectedChangedFiles.some((path) => isServerRunnerFile(path)+ && MODULE_SOURCE_RE.test(path) && !isTestFile(path) && !isStructuralBarrel(path));+ const dependencyFiles = hasChangedFilesOverride ? uniqueSorted([...presentFiles, ...untrackedFiles]) : presentFiles;+ const importCache = new Map();+ const dbDependencies = hasRelatedServerSource+ ? collectTestDependencies(resolveDbTestFiles(dependencyFiles), dependencyFiles, cwd, importCache): [];+ const browserDependencies = hasRelatedServerSource+ ? Object.fromEntries(browserSuitesIn(presentFiles).map((suite) => [suite,+ collectTestDependencies([suite], dependencyFiles, cwd, importCache)]))+ : {};- return { changedFiles: collectedChangedFiles, trackedFiles: presentFiles, appDiff, pathContractTests, clientDependencies, dbDependencies };+ return { changedFiles: collectedChangedFiles, trackedFiles: presentFiles, appDiff, pathContractTests,+ clientDependencies, dbDependencies, browserDependencies };}function main() {@@ -1172,7 +1192,7 @@ function main() {&& (!Array.isArray(changedFilesOverride) || changedFilesOverride.some((path) => typeof path !== 'string'))) {throw new Error('CI_CHANGED_FILES must be a JSON array of repository-relative path strings.');}- const { changedFiles, trackedFiles, appDiff, pathContractTests, clientDependencies, dbDependencies } = collectPlanInputs({+ const { changedFiles, trackedFiles, appDiff, pathContractTests, clientDependencies, dbDependencies, browserDependencies } = collectPlanInputs({baseSha: base,forceFull,changedFiles: changedFilesOverride,@@ -1185,6 +1205,7 @@ function main() {pathContractTests,clientDependencies,dbDependencies,+ browserDependencies,}));}diff --git a/scripts/ci-test-plan.test.js b/scripts/ci-test-plan.test.jsindex be4b5ef2cb..f00a0b4148 100644--- a/scripts/ci-test-plan.test.js+++ b/scripts/ci-test-plan.test.js@@ -1391,6 +1391,65 @@ describe('Windows escalation on a full plan (#7440)', () => {});});+it('projects transitive browser consumers through the planner CLI without replacing related selection (#10838)', () => {+ const root = mkdtempSync(join(tmpdir(), 'portos-ci-related-browser-'));+ const planner = fileURLToPath(new URL('./ci-test-plan.js', import.meta.url));+ const git = (...args) => execFileSync('git', args, { cwd: root, encoding: 'utf8' }).trim();+ const write = (path, source) => {+ mkdirSync(dirname(join(root, path)), { recursive: true });+ writeFileSync(join(root, path), source);+ };+ const leaf = 'server/services/example/leaf.js';+ const unrelated = 'server/services/unrelated.js';+ const [staticSuite, deferredSuite, independentSuite] = BROWSER_SUITES;+ const plan = (changedFiles, forceFull = false) => JSON.parse(execFileSync(process.execPath, [planner], {+ cwd: root,+ encoding: 'utf8',+ env: { ...process.env, CI_BASE_SHA: 'HEAD', CI_BASE_REF: 'main', CI_FORCE_FULL: String(forceFull),+ CI_CHANGED_FILES: JSON.stringify(changedFiles), GITHUB_OUTPUT: '', GITHUB_STEP_SUMMARY: '' },+ }));+ const browsers = (result) => JSON.parse(result.browser_files);+ try {+ git('init', '-q');+ write(leaf, 'export const value = 1;\n');+ write(unrelated, 'export const value = 2;\n');+ write('server/services/bridge.js', "export { value } from './example/leaf';\n");+ write(staticSuite, "import '../services/bridge.js';\n");+ write(deferredSuite, "export const load = () => import('../services/bridge.js');\n");+ write(independentSuite, 'export const value = 3;\n');+ git('add', '--all');++ // Neither browser suite shares leaf's feature or names its basename. Only+ // transitive import discovery can report the real related-test consumers.+ const related = plan([leaf]);+ expect(related).toMatchObject({ full: false, server_mode: 'related', server_sources: JSON.stringify([leaf]) });+ expect(JSON.parse(related.server_files)).not.toContain(staticSuite);+ expect(JSON.parse(related.server_files)).not.toContain(deferredSuite);+ expect(browsers(related)).toEqual([staticSuite, deferredSuite]);+ expect(JSON.parse(related.suite_reasons).browser).toBe('2 cross-workspace browser suite(s) selected');+ expect(browsers(plan([leaf, staticSuite]))).toEqual([staticSuite, deferredSuite]);+ expect(browsers(plan([unrelated]))).toEqual([]);+ expect(browsers(plan(['docs/README.md']))).toEqual([]);+ expect(browsers(plan([staticSuite]))).toEqual([staticSuite]);+ expect(browsers(plan([], true))).toEqual([staticSuite, deferredSuite, independentSuite]);++ // Inconclusive discovery widens only the affected registered suite while+ // the ordinary server run keeps its existing related sources/selectors.+ for (const expression of ["'../services/missing.js'", 'modulePath']) {+ write(independentSuite, `export const load = () => import(${expression});\n`);+ const conservative = plan([unrelated]);+ expect(conservative).toMatchObject({ full: false, server_mode: 'related', server_sources: JSON.stringify([unrelated]) });+ expect(browsers(conservative)).toEqual([independentSuite]);+ expect(browsers(plan([leaf]))).toEqual([staticSuite, deferredSuite, independentSuite]);+ // No behavioral source traversal on test-only edits or documentation.+ expect(browsers(plan([staticSuite]))).toEqual([staticSuite]);+ expect(browsers(plan(['docs/README.md']))).toEqual([]);+ }+ } finally {+ rmSync(root, { recursive: true, force: true });+ }+});+describe('cross-workspace browser suites (#10312)', () => {it('selects every music-video browser suite when a client component they mount changes', () => {