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

test: always run directory-walking guards and detect them in repo-scan-guards (#8723)

[._.]/ Adam Eivyb183c2e626e1
diff --git a/scripts/ci-test-plan.js b/scripts/ci-test-plan.js
index c18893f1ed..592044c690 100644
--- a/scripts/ci-test-plan.js
+++ b/scripts/ci-test-plan.js
@@ -237,6 +237,13 @@ export const ALWAYS_RUN_TESTS = [
// Whole-tree scanner: any server file can add a `process.env` read, and
// `.env.example` itself is not a scope the selector routes to a runner.
'server/envExampleDrift.test.js',
+ // Whole-tree scanners over the shared collectServerSources/collectClientSources
+ // walkers (#8723): the offending file is never imported by the guard, so
+ // impact selection only reaches them when the guard itself changes.
+ 'server/lib/apiRouteGraph.test.js',
+ 'server/lib/childProcess.guards.test.js',
+ 'server/lib/cliChildEnv.test.js',
+ 'server/lib/editorial/proseTics.test.js',
'server/lib/generatedManifests.test.js',
// Base-relative server import-growth guard (#7993). A new eager edge in a
// widely reached module multiplies across suites this file does not import,
@@ -247,12 +254,16 @@ export const ALWAYS_RUN_TESTS = [
// Pregate copies the sha into the test process so the local run uses this
// plan's base, not a second guess.
'server/lib/importScoping.test.js',
+ // Whole-tree scanner over collectServerSources: every cwd-passing spawn pins PWD (#8723).
+ 'server/lib/spawnCwd.test.js',
// Whole-tree scanner: any server/client file can add a hardcoded "Models →"
// breadcrumb, with no import edge back to this file.
'server/lib/localProviderRuntime.test.js',
'server/lib/qwenAgentParsers.test.js',
'server/lib/testDataIsolation.guards.test.js',
'server/lib/testHelper.test.js',
+ // Whole-tree scanner: any server/client file can re-inline a RegExp escape (#8723).
+ 'server/lib/textUtils.test.js',
// Whole-tree scanner: any server file can log a failure through
// `console.log`, and the guard only ever sees it as a path string.
'server/logLevelConventions.test.js',
@@ -260,6 +271,10 @@ export const ALWAYS_RUN_TESTS = [
// `pm2 jlist` execution/parsing outside the two designated readers (#8164).
'server/pm2JlistOwnership.guard.test.js',
'server/services/imageGen/renderTargets.guard.test.js',
+ // Whole-tree scanners over collectServerSources (#8723).
+ 'server/services/gitlab.glabFlags.test.js',
+ 'server/services/orphanedPartialGc.test.js',
+ 'server/services/providers.shape.test.js',
'server/services/taskPromptDefaults.test.js',
'server/timerCallbackConventions.test.js',
];
diff --git a/scripts/repo-scan-guards.test.js b/scripts/repo-scan-guards.test.js
index daf65e196f..373d1f6f66 100644
--- a/scripts/repo-scan-guards.test.js
+++ b/scripts/repo-scan-guards.test.js
@@ -88,10 +88,22 @@ const GIT_ENUMERATION = /['"](?:ls-files|grep)['"]/;
*/
const TRACKED_HELPER = /from\s+['"](?:[^'"]*\/)?trackedFiles\.js['"]/;
+/**
+ * A recursive directory walk (#8723): a call to one of the shared source
+ * walkers in server/lib/testHelper.js, or a `readdirSync(…, { recursive: true })`.
+ * Matched against comment-stripped source so a comment describing a walk
+ * does not register one.
+ */
+const SHARED_WALKER_CALL = /\bcollect(?:Server|Client)Sources\s*\(/;
+const RECURSIVE_READDIR = /readdirSync\s*\([^)]*\brecursive\s*:\s*true/;
+const stripLineComments = (source) => source.replace(/^\s*(?:\/\/|\*|\/\*).*$/gm, '');
+
/** True when `source` asserts over the tracked tree instead of over its imports. */
-export const scansTrackedTree = (source) => (
- (GIT_CALL.test(source) && GIT_ENUMERATION.test(source)) || TRACKED_HELPER.test(source)
-);
+export const scansTrackedTree = (source) => {
+ const code = stripLineComments(source);
+ return (GIT_CALL.test(source) && GIT_ENUMERATION.test(source)) || TRACKED_HELPER.test(source)
+ || SHARED_WALKER_CALL.test(code) || RECURSIVE_READDIR.test(code);
+};
/** Which runner owns `relPath` (a `git ls-files`-relative path): 'client' or 'server'. */
const ownerRootFor = (relPath) => (relPath.startsWith('client/src/') ? 'client' : 'server');
@@ -154,11 +166,18 @@ describe('repo-scanning guards are reachable by CI selection (#5055)', () => {
expect(scansTrackedTree("import { thing } from './thing.js';\nexpect(thing()).toBe(1);")).toBe(false);
// A comment mentioning the command is not an invocation.
expect(scansTrackedTree('// enumerated via git ls-files rather than a walk')).toBe(false);
+ // Directory walkers (#8723): the shared source walkers and a recursive readdir.
+ expect(scansTrackedTree("const offenders = collectServerSources().filter(bad);")).toBe(true);
+ expect(scansTrackedTree("for (const f of collectClientSources()) check(f);")).toBe(true);
+ expect(scansTrackedTree("const all = readdirSync(root, { recursive: true });")).toBe(true);
+ expect(scansTrackedTree("// a readdirSync(root, { recursive: true }) walk is too slow")).toBe(false);
+ expect(scansTrackedTree("rmSync(dir, { recursive: true, force: true });")).toBe(false);
});
it('finds the known scanners', () => {
expect(scanners).toContain('scripts/agent-instructions-files.test.js');
expect(scanners).toContain('scripts/tailnet-identity-leak.test.js');
+ expect(scanners).toContain('server/lib/textUtils.test.js');
expect(scanners.length).toBeGreaterThanOrEqual(8);
});