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

fix: catch non-literal cwd path builds in the fixture guard (#3823)

[._.]/ Adam Eivy448d51d5296f
diff --git a/server/lib/aiToolkit/providerStatus.test.js b/server/lib/aiToolkit/providerStatus.test.js
index ea6110c969..4931a5b440 100644
--- a/server/lib/aiToolkit/providerStatus.test.js
+++ b/server/lib/aiToolkit/providerStatus.test.js
@@ -4,7 +4,7 @@ import { tmpdir } from 'os';
import { join } from 'path';
import { createProviderStatusService, usableFallbackModel } from './providerStatus.js';
-// Temp dir, NOT `join(process.cwd(), …)` — a cwd-rooted fixture dir lands inside
+// Temp dir, NOT a cwd-rooted one — a fixture dir built from `process.cwd()` lands inside
// the checkout, and the afterEach cleanup only runs when the worker survives the
// file. A killed/timed-out worker left `server/test-data-status/` behind as
// untracked cruft, which was once swept into an unrelated commit (#3823).
diff --git a/server/lib/aiToolkit/providers.cliPathResolve.test.js b/server/lib/aiToolkit/providers.cliPathResolve.test.js
index 23a1d2865e..d7a8820b94 100644
--- a/server/lib/aiToolkit/providers.cliPathResolve.test.js
+++ b/server/lib/aiToolkit/providers.cliPathResolve.test.js
@@ -17,7 +17,7 @@ vi.mock('child_process', async (importOriginal) => {
import { execFile } from 'child_process';
import { createProviderService } from './providers.js';
-// Temp dir, NOT `join(process.cwd(), …)` — see providerStatus.test.js (#3823).
+// Temp dir, NOT a cwd-rooted one — see providerStatus.test.js (#3823).
let TEST_DATA_DIR;
describe('testProvider — cli command resolution (cross-platform PATH)', () => {
@@ -44,7 +44,7 @@ describe('testProvider — cli command resolution (cross-platform PATH)', () =>
afterEach(async () => {
Object.defineProperty(process, 'platform', { value: originalPlatform, configurable: true });
process.env.PATH = originalPath;
- await rm(fakePathDir, { recursive: true, force: true });
+ if (fakePathDir) await rm(fakePathDir, { recursive: true, force: true });
vi.mocked(execFile).mockReset();
if (TEST_DATA_DIR) await rm(TEST_DATA_DIR, { recursive: true, force: true });
});
diff --git a/server/lib/aiToolkit/providers.test.js b/server/lib/aiToolkit/providers.test.js
index 0d4d1e1715..81d109ef07 100644
--- a/server/lib/aiToolkit/providers.test.js
+++ b/server/lib/aiToolkit/providers.test.js
@@ -4,7 +4,7 @@ import { tmpdir } from 'os';
import { join } from 'path';
import { createProviderService, isOllamaBackedProvider } from './providers.js';
-// Temp dir, NOT `join(process.cwd(), …)` — see providerStatus.test.js (#3823).
+// Temp dir, NOT a cwd-rooted one — see providerStatus.test.js (#3823).
let TEST_DATA_DIR;
describe('Provider Service', () => {
diff --git a/server/lib/testDataIsolation.guards.test.js b/server/lib/testDataIsolation.guards.test.js
index f94229a723..9587de5a54 100644
--- a/server/lib/testDataIsolation.guards.test.js
+++ b/server/lib/testDataIsolation.guards.test.js
@@ -133,19 +133,22 @@ const scan = (source) => REAL_DATA_ROOT_RE.test(source);
// remaining occurrence in the suite.
//
// The join/resolve prefix on the first shape is load-bearing: without it, the
-// pattern is just "cwd, then a comma, then a string" and it flags every ordinary
+// pattern is just "cwd, then a comma, then something" and it flags every ordinary
// two-argument call that happens to take cwd first (`readFileSync(process.cwd(),
-// 'utf8')`). With the call named, the argument list may safely span lines —
-// a prettier-split `join(\n process.cwd(),\n 'test-data',\n)` is the same bug.
-// The concatenation shapes stay single-line and accept a path-ish first
-// character, so `process.cwd() + 'fixtures'` is caught while a log line like
+// 'utf8')`). With the call named, the rest can stay loose — the second argument
+// need not be a literal (`join(process.cwd(), FIXTURE_DIR)` is the same bug), and
+// the argument list may span lines, so a prettier-split
+// `join(\n process.cwd(),\n 'test-data',\n)` is caught too.
+// The concatenation shapes have no such anchor, so they stay single-line and
+// require a path-ish or interpolated first character: `process.cwd() + 'fixtures'`
+// and `${process.cwd()}${SEP}x` are caught, while a log line like
// `'cwd=' + process.cwd() + ', done'` is not.
const CWD = 'process\\??\\.cwd\\s*(?:\\?\\.)?\\(\\)';
const H = '[^\\S\\n]*';
const CWD_FIXTURE_DIR_RE = new RegExp([
- `(?:join|resolve)\\s*\\(\\s*${CWD}\\s*,\\s*[\`'"]`, // join(process.cwd(), 'fixture-dir')
- `${CWD}${H}\\+${H}[\`'"][/\\\\\\w.-]`, // process.cwd() + '/fixture-dir'
- `\\$\\{${CWD}\\}[/\\\\\\w.-]`, // `${process.cwd()}/fixture-dir`
+ `(?:join|resolve)\\s*\\(\\s*${CWD}\\s*,`, // join(process.cwd(), 'fixture-dir')
+ `${CWD}${H}\\+${H}[\`'"][/\\\\\\w.-]`, // process.cwd() + '/fixture-dir'
+ `\\$\\{${CWD}\\}[/\\\\\\w.\\-$]`, // `${process.cwd()}/fixture-dir`
].join('|'));
const scanCwdFixture = (source) => CWD_FIXTURE_DIR_RE.test(source);
@@ -194,6 +197,11 @@ describe('test-data isolation guard', () => {
expect(scanCwdFixture("process.cwd() + '/scratch'")).toBe(true);
expect(scanCwdFixture("process.cwd() + 'scratch'")).toBe(true);
expect(scanCwdFixture('`${process.cwd()}/scratch`')).toBe(true);
+ // A non-literal second argument builds the same path.
+ expect(scanCwdFixture('join(process.cwd(), FIXTURE_DIR)')).toBe(true);
+ expect(scanCwdFixture('resolve(process.cwd(), suiteName, `sub`)')).toBe(true);
+ // …as does an interpolated separator right after the cwd expression.
+ expect(scanCwdFixture('`${process.cwd()}${sep}fixtures`')).toBe(true);
// A formatter-split argument list is the same bug, so the named-call shape
// deliberately spans lines.
expect(scanCwdFixture("join(\n process.cwd(),\n 'test-data',\n )")).toBe(true);