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: re-root every data-rooted PATHS member in makePathsProxy (#3689)

[._.]/ Adam Eivyee23ec4237f0
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index f5c06d845f..34fb3be616 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -84,3 +84,5 @@
- Internal: audited the whole server test suite for the "test reads the checkout's real `data/`" class that #3683 fixed one instance of, and closed the one case that was actually a bug. The audit was empirical rather than static — a full-suite baseline against an empty `data/`, then a second run with obviously-fake probe records planted in all 74 `data/` subdirectories a service enumerates (prefix-aware, so the stores whose id allowlists require `iss-`/`ser-`/`stb-`/`game-` were actually reached, and including the dirs `data.reference/` seeds rather than only the ones the `PATHS` table names) — and exactly one of 1301 test files failed only in the second run: the missions suite, which addressed `<repo>/data/cos/missions` directly with no mock at all, so it read the developer's live missions *and* wrote its own fixtures into them. It now runs against a per-run temp root, with assertions pinning both the path it writes to and the set it reads back. The 67 suites that partial-mock `fileUtils.js` without redirecting `PATHS` were cleared by the same two-run diff — they replace the service graph wholesale and never reach a real `readdir`. Two further suites do read the live install on purpose and are left alone: the creative-director prompt suite prefers the installed prompt so it catches drift against a local edit, and the opt-in vision integration test enumerates real screenshots to feed a real model. Neither writes anything back. A new repo-wide guard now fails the suite when any other test names the checkout's own `data/` directory, through an install-root anchor or a parent-directory climb, with those two exemptions documented in place. It deliberately does not police the third spelling, importing the real `PATHS` and reading a data-rooted member: 50 files do that, nearly all safely, so that one stays covered by the two-run probe, whose recipe is now recorded beside the guard so it can be re-run. Test-only change; no production code touched.
- One malformed file in the CoS missions directory no longer takes out the whole Missions overview. `getStats()` dereferenced `mission.subTasks.length` on every record `loadMissions()` handed back, and that loader passed through anything that parsed as JSON — so a hand-edited file, a half-written record, or one written in an older shape threw a `TypeError` and blanked the page instead of costing one row. Records are now normalized at the single door they come through: `subTasks`, `goals` and `metrics` coerce to their expected shapes, `progress` to a finite number (no more `NaN%` average), and an absent status buckets under `unknown` rather than an `undefined` key. Anything that isn't a usable mission object is dropped with one `⚠️` line naming the file, so a corrupt record is visible rather than silently missing.
+
+- Internal: the shared test helper that redirects `PATHS.data` at a temp dir now re-roots *every* `PATHS` member that lives under `data/`, not just `data` itself. 45 of the 49 members are built as `join(INSTALL_ROOT, 'data/…')` independently of `PATHS.data`, so "redirect `data` and the suite is isolated" was false for almost every disk-touching test — each one had to independently rediscover that and restate the on-disk layout by hand, and the failure mode when it didn't was #3683/#3687: green CI, writes landing in the developer's live install. The whole `data/` subtree now moves with the temp root, preserving each member's relative layout, while explicit per-suite overrides still merge last as the escape hatch for a member that genuinely wants a different target (a scratch root, `~/Downloads`, a pre-seeded fixture dir). Twenty call sites that merely restated the shipped layout are gone. Test-only change; no production code touched.
diff --git a/server/lib/mockPathsDataRoot.js b/server/lib/mockPathsDataRoot.js
index 1a9538c1fd..0c7f405980 100644
--- a/server/lib/mockPathsDataRoot.js
+++ b/server/lib/mockPathsDataRoot.js
@@ -33,14 +33,16 @@
* - `mockNoPeerSync(actual?, overrides?)` — shared `peerSync.js` mock guard
* that makes fire-and-forget record auto-subscribe a clean no-op in tests.
*
- * Migration: tests that need MULTIPLE PATHS members redirected
- * (e.g. `images`, `videos`) can pass `extraOverrides` (object or function)
- * — the helper merges those on top of the `data: tempRoot` override.
+ * Every `PATHS` member that lives under the real `data/` is re-rooted at the
+ * temp dir automatically, so a suite that only wants the standard layout
+ * (`cos`, `brain`, `digitalTwin`, `images`, …) needs no `extraOverrides` at
+ * all. Pass `extraOverrides` (object or function) only when a member needs a
+ * target the default re-rooting wouldn't produce — it merges last.
*/
import { mkdtempSync, rmSync } from 'fs';
import { tmpdir } from 'os';
-import { join } from 'path';
+import { join, relative, sep } from 'path';
/**
* Allocate a unique temp dir suitable for use as `PATHS.data` in a test file.
@@ -62,10 +64,22 @@ export function createTempDataRoot(prefix = 'portos-test-') {
* (a `let tempRoot` that the per-test setup reassigns). The Proxy reads
* it through the getter so it always sees the current value.
*
+ * EVERY `PATHS` member that lives under the real `data/` directory is re-rooted
+ * at `dataRoot`, preserving its relative layout (`PATHS.cos` →
+ * `<dataRoot>/cos`, `PATHS.cosAgents` → `<dataRoot>/cos/agents`, and so on).
+ * 45 of the 49 members are `join(INSTALL_ROOT, 'data/…')`, so redirecting only
+ * `data` left almost every disk-touching suite pointed at the live install —
+ * see #3683 / #3687. The members outside `data/` (`root`, `installRoot`,
+ * `slashdo`, `browserDownloads`) are untouched by construction.
+ *
* `extraOverrides` is either:
- * - a plain object — merged over `{ data: <resolved root> }`, or
+ * - a plain object — merged over the re-rooted PATHS, or
* - a function `(dataRoot) => overridesObject` — for cases where the
* extra keys are derived (e.g. `images: join(dataRoot, 'images')`).
+ *
+ * Extras still merge LAST, so they remain the escape hatch for a member that
+ * needs a target the default re-rooting wouldn't produce — either a different
+ * temp location, or the real seeded directory pinned back in place.
*/
export function makePathsProxy(actual, { dataRoot, extraOverrides = null, overrides = null } = {}) {
const resolveRoot = typeof dataRoot === 'function' ? dataRoot : () => dataRoot;
@@ -74,7 +88,13 @@ export function makePathsProxy(actual, { dataRoot, extraOverrides = null, overri
const extras = typeof extraOverrides === 'function'
? extraOverrides(root)
: (extraOverrides || {});
- return { ...actual.PATHS, data: root, ...extras };
+ const realData = actual.PATHS.data;
+ const rebased = Object.fromEntries(
+ Object.entries(actual.PATHS)
+ .filter(([, v]) => typeof v === 'string' && (v === realData || v.startsWith(realData + sep)))
+ .map(([k, v]) => [k, join(root, relative(realData, v))]),
+ );
+ return { ...actual.PATHS, ...rebased, data: root, ...extras };
};
return new Proxy(actual, {
get(target, prop) {
diff --git a/server/lib/mockPathsDataRoot.test.js b/server/lib/mockPathsDataRoot.test.js
index fbdcd4b6bb..f83d816ef8 100644
--- a/server/lib/mockPathsDataRoot.test.js
+++ b/server/lib/mockPathsDataRoot.test.js
@@ -1,7 +1,7 @@
import { describe, it, expect, afterAll } from 'vitest';
import { existsSync, rmSync } from 'fs';
import { tmpdir } from 'os';
-import { join } from 'path';
+import { join, relative, sep } from 'path';
import { createTempDataRoot, makePathsProxy, mockNoPeers, mockNoPeerSync, mockPathsDataRoot } from './mockPathsDataRoot.js';
describe('mockPathsDataRoot', () => {
@@ -27,16 +27,50 @@ describe('mockPathsDataRoot', () => {
describe('makePathsProxy', () => {
const fakeActual = {
- PATHS: { data: '/real/data', images: '/real/images', logs: '/real/logs' },
+ PATHS: {
+ data: join('/real', 'data'),
+ images: join('/real', 'data', 'images'),
+ cosAgents: join('/real', 'data', 'cos', 'agents'),
+ // Outside data/ — must survive untouched, like PATHS.root / slashdo /
+ // browserDownloads do in the real fileUtils.
+ logs: join('/real', 'logs'),
+ // A near-miss sibling: `data-archive` shares the `data` PREFIX but is
+ // not INSIDE data/, so it must not be re-rooted.
+ dataArchive: join('/real', 'data-archive'),
+ },
ensureDir: () => 'ensureDir-fn',
otherFn: 42,
};
+ const TMP = join('/tmp', 'x');
- it('overrides only PATHS.data by default and passes other PATHS keys through', () => {
- const proxy = makePathsProxy(fakeActual, { dataRoot: '/tmp/x' });
- expect(proxy.PATHS.data).toBe('/tmp/x');
- expect(proxy.PATHS.images).toBe('/real/images');
- expect(proxy.PATHS.logs).toBe('/real/logs');
+ it('re-roots every PATHS member that lives under the real data/ dir', () => {
+ const proxy = makePathsProxy(fakeActual, { dataRoot: TMP });
+ expect(proxy.PATHS.data).toBe(TMP);
+ expect(proxy.PATHS.images).toBe(join(TMP, 'images'));
+ expect(proxy.PATHS.cosAgents).toBe(join(TMP, 'cos', 'agents'));
+ });
+
+ it('leaves PATHS members outside data/ alone, including prefix near-misses', () => {
+ const proxy = makePathsProxy(fakeActual, { dataRoot: TMP });
+ expect(proxy.PATHS.logs).toBe(join('/real', 'logs'));
+ expect(proxy.PATHS.dataArchive).toBe(join('/real', 'data-archive'));
+ });
+
+ it('re-roots the real fileUtils PATHS so no member still points into the live install', async () => {
+ const { PATHS } = await import('./fileUtils.js');
+ const proxy = makePathsProxy({ PATHS }, { dataRoot: TMP });
+ const dataRooted = Object.entries(PATHS)
+ .filter(([, v]) => typeof v === 'string' && (v === PATHS.data || v.startsWith(PATHS.data + sep)));
+
+ // Guard against a vacuous assertion if PATHS is ever restructured.
+ expect(dataRooted.length).toBeGreaterThan(40);
+ for (const [key] of dataRooted) {
+ expect(`${key}=${proxy.PATHS[key]}`).toBe(`${key}=${join(TMP, relative(PATHS.data, PATHS[key]))}`);
+ }
+ // The four members that live outside data/ are untouched by construction.
+ for (const key of ['root', 'installRoot', 'slashdo', 'browserDownloads']) {
+ expect(proxy.PATHS[key]).toBe(PATHS[key]);
+ }
});
it('passes non-PATHS exports through untouched', () => {
diff --git a/server/routes/brainSongbook.test.js b/server/routes/brainSongbook.test.js
index 2ecdde99a2..ae8a6c3c29 100644
--- a/server/routes/brainSongbook.test.js
+++ b/server/routes/brainSongbook.test.js
@@ -20,10 +20,7 @@ const songbookDir = () => join(getTempRoot(), 'brain', 'songbook');
vi.mock('../lib/fileUtils.js', async () => {
const actual = await vi.importActual('../lib/fileUtils.js');
- return makePathsProxy(actual, {
- dataRoot: () => getTempRoot(),
- extraOverrides: (root) => ({ brainSongbook: join(root, 'brain', 'songbook') }),
- });
+ return makePathsProxy(actual, { dataRoot: () => getTempRoot() });
});
vi.mock('../services/brainStorage.js', () => ({
diff --git a/server/services/agentFinalization.transcriptRescue.test.js b/server/services/agentFinalization.transcriptRescue.test.js
index aafa95c442..5ee1808631 100644
--- a/server/services/agentFinalization.transcriptRescue.test.js
+++ b/server/services/agentFinalization.transcriptRescue.test.js
@@ -24,10 +24,7 @@ const { TEMP_ROOT } = await vi.hoisted(async () => {
vi.mock('../lib/fileUtils.js', async () => {
const actual = await vi.importActual('../lib/fileUtils.js');
- return makePathsProxy(actual, {
- dataRoot: TEMP_ROOT,
- extraOverrides: root => ({ cosAgents: join(root, 'cos/agents') }),
- });
+ return makePathsProxy(actual, { dataRoot: TEMP_ROOT });
});
vi.mock('./cosAgentLifecycle.js', () => ({
diff --git a/server/services/appActivity.test.js b/server/services/appActivity.test.js
index 33bccb72a0..b41973e830 100644
--- a/server/services/appActivity.test.js
+++ b/server/services/appActivity.test.js
@@ -20,14 +20,10 @@ import { makePathsProxy } from '../lib/mockPathsDataRoot.js';
const TEST_DATA_ROOT = mkdtempSync(join(tmpdir(), 'app-activity-test-'));
-// appActivity.js reads PATHS.cos (data/cos), which is computed independently of
-// PATHS.data — so redirecting `data` alone leaves writes landing in the real
-// data/cos dir. Redirect `cos` too via extraOverrides.
+// appActivity.js reads PATHS.cos (data/cos) — re-rooted into the temp tree
+// along with every other data/-rooted PATHS member by makePathsProxy.
vi.mock('../lib/fileUtils.js', async (importOriginal) =>
- makePathsProxy(await importOriginal(), {
- dataRoot: TEST_DATA_ROOT,
- extraOverrides: (root) => ({ cos: join(root, 'cos') }),
- }));
+ makePathsProxy(await importOriginal(), { dataRoot: TEST_DATA_ROOT }));
const appActivity = await import('./appActivity.js');
diff --git a/server/services/autobiography.tombstone.test.js b/server/services/autobiography.tombstone.test.js
index 4e57cbf31d..725b6daf37 100644
--- a/server/services/autobiography.tombstone.test.js
+++ b/server/services/autobiography.tombstone.test.js
@@ -20,10 +20,7 @@ const twinDir = join(tempRoot, 'digital-twin');
vi.mock('../lib/fileUtils.js', async () => {
const actual = await vi.importActual('../lib/fileUtils.js');
- return makePathsProxy(actual, {
- dataRoot: tempRoot,
- extraOverrides: (root) => ({ digitalTwin: join(root, 'digital-twin') }),
- });
+ return makePathsProxy(actual, { dataRoot: tempRoot });
});
// The prompt scheduler is the only reason autobiography.js touches these — none
diff --git a/server/services/brainStorage.test.js b/server/services/brainStorage.test.js
index dc23a12dfe..1fd33bdbcf 100644
--- a/server/services/brainStorage.test.js
+++ b/server/services/brainStorage.test.js
@@ -17,10 +17,7 @@ function getTempRoot() {
vi.mock('../lib/fileUtils.js', async () => {
const actual = await vi.importActual('../lib/fileUtils.js');
- return makePathsProxy(actual, {
- dataRoot: () => getTempRoot(),
- extraOverrides: (dataRoot) => ({ brain: join(dataRoot, 'brain') }),
- });
+ return makePathsProxy(actual, { dataRoot: () => getTempRoot() });
});
// getInstanceId is used by create()/backfill; stub to a stable id.
diff --git a/server/services/browserService.test.js b/server/services/browserService.test.js
index ff17641f26..2753c60501 100644
--- a/server/services/browserService.test.js
+++ b/server/services/browserService.test.js
@@ -31,10 +31,9 @@ describe('browserService config persistence', () => {
const actual = await importOriginal();
return makePathsProxy(actual, {
dataRoot: tempRoot,
- extraOverrides: (root) => ({
- browserProfile: join(root, 'browser-profile'),
- browserDownloads: join(root, 'downloads'),
- }),
+ // browserDownloads is ~/Downloads, NOT under data/ — the automatic
+ // re-rooting can't reach it, so it still needs an explicit override.
+ extraOverrides: (root) => ({ browserDownloads: join(root, 'downloads') }),
});
});
return import('./browserService.js');
diff --git a/server/services/calendarAccounts.test.js b/server/services/calendarAccounts.test.js
index b78a6151fb..177f1cfcaa 100644
--- a/server/services/calendarAccounts.test.js
+++ b/server/services/calendarAccounts.test.js
@@ -7,10 +7,7 @@ import { makePathsProxy } from '../lib/mockPathsDataRoot.js';
const TEST_DATA_ROOT = mkdtempSync(join(tmpdir(), 'calendar-accounts-test-'));
vi.mock('../lib/fileUtils.js', async (importOriginal) =>
- makePathsProxy(await importOriginal(), {
- dataRoot: TEST_DATA_ROOT,
- extraOverrides: (root) => ({ calendar: join(root, 'calendar') }),
- }));
+ makePathsProxy(await importOriginal(), { dataRoot: TEST_DATA_ROOT }));
vi.mock('../lib/uuid.js', () => ({
v4: vi.fn().mockReturnValue('test-uuid-1234'),
diff --git a/server/services/digital-twin-documents.tombstone.test.js b/server/services/digital-twin-documents.tombstone.test.js
index 48adbfc896..6b0413e0a9 100644
--- a/server/services/digital-twin-documents.tombstone.test.js
+++ b/server/services/digital-twin-documents.tombstone.test.js
@@ -21,10 +21,7 @@ const twinDir = join(tempRoot, 'digital-twin');
vi.mock('../lib/fileUtils.js', async () => {
const actual = await vi.importActual('../lib/fileUtils.js');
- return makePathsProxy(actual, {
- dataRoot: tempRoot,
- extraOverrides: (root) => ({ digitalTwin: join(root, 'digital-twin') }),
- });
+ return makePathsProxy(actual, { dataRoot: tempRoot });
});
const { createDocument, updateDocument, deleteDocument } = await import('./digital-twin-documents.js');
diff --git a/server/services/digital-twin-personas.tombstone.test.js b/server/services/digital-twin-personas.tombstone.test.js
index e4c6e05752..6e77d5136f 100644
--- a/server/services/digital-twin-personas.tombstone.test.js
+++ b/server/services/digital-twin-personas.tombstone.test.js
@@ -21,10 +21,7 @@ const twinDir = join(tempRoot, 'digital-twin');
vi.mock('../lib/fileUtils.js', async () => {
const actual = await vi.importActual('../lib/fileUtils.js');
- return makePathsProxy(actual, {
- dataRoot: tempRoot,
- extraOverrides: (root) => ({ digitalTwin: join(root, 'digital-twin') }),
- });
+ return makePathsProxy(actual, { dataRoot: tempRoot });
});
const { createPersona, updatePersona, deletePersona, setActivePersona } = await import('./digital-twin-personas.js');
diff --git a/server/services/loraDatasets.test.js b/server/services/loraDatasets.test.js
index b77d0b36d5..890c137660 100644
--- a/server/services/loraDatasets.test.js
+++ b/server/services/loraDatasets.test.js
@@ -9,13 +9,7 @@ import { makePathsProxy } from '../lib/mockPathsDataRoot.js';
const TEST_DATA_ROOT = mkdtempSync(join(tmpdir(), 'lora-datasets-test-'));
vi.mock('../lib/fileUtils.js', async (importOriginal) =>
- makePathsProxy(await importOriginal(), {
- dataRoot: TEST_DATA_ROOT,
- extraOverrides: (root) => ({
- loraDatasets: join(root, 'lora-datasets'),
- images: join(root, 'images'),
- }),
- }));
+ makePathsProxy(await importOriginal(), { dataRoot: TEST_DATA_ROOT }));
const getUniverse = vi.fn();
vi.mock('./universeBuilder.js', () => ({ getUniverse: (...args) => getUniverse(...args) }));
diff --git a/server/services/loraTraining/checkpoints.test.js b/server/services/loraTraining/checkpoints.test.js
index 00d58469e6..89276ab19d 100644
--- a/server/services/loraTraining/checkpoints.test.js
+++ b/server/services/loraTraining/checkpoints.test.js
@@ -13,13 +13,7 @@ let dataRoot = tmpdir();
// filesystem-touching helpers (preview analysis, zip extraction) operate on
// fixtures instead of real run data.
vi.mock('../../lib/fileUtils.js', async (importOriginal) =>
- makePathsProxy(await importOriginal(), {
- dataRoot: () => dataRoot,
- extraOverrides: (root) => ({
- trainingRuns: join(root, 'training-runs'),
- loras: join(root, 'loras'),
- }),
- }));
+ makePathsProxy(await importOriginal(), { dataRoot: () => dataRoot }));
const {
listRunCheckpoints,
diff --git a/server/services/memoryStore.test.js b/server/services/memoryStore.test.js
index 7ea910adfb..aad9f0955e 100644
--- a/server/services/memoryStore.test.js
+++ b/server/services/memoryStore.test.js
@@ -18,13 +18,7 @@ import { makePathsProxy } from '../lib/mockPathsDataRoot.js';
const TEST_DATA_ROOT = mkdtempSync(join(tmpdir(), 'memorystore-test-'));
vi.mock('../lib/fileUtils.js', async (importOriginal) =>
- makePathsProxy(await importOriginal(), {
- dataRoot: TEST_DATA_ROOT,
- extraOverrides: (root) => ({
- cos: join(root, 'cos'),
- memory: join(root, 'cos', 'memory'),
- }),
- }));
+ makePathsProxy(await importOriginal(), { dataRoot: TEST_DATA_ROOT }));
// Pass-through mutex: no locking overhead in tests
vi.mock('../lib/asyncMutex.js', () => ({
diff --git a/server/services/messageAccounts.test.js b/server/services/messageAccounts.test.js
index cff0ccf58d..44b63f334f 100644
--- a/server/services/messageAccounts.test.js
+++ b/server/services/messageAccounts.test.js
@@ -7,10 +7,7 @@ import { makePathsProxy } from '../lib/mockPathsDataRoot.js';
const TEST_DATA_ROOT = mkdtempSync(join(tmpdir(), 'message-accounts-test-'));
vi.mock('../lib/fileUtils.js', async (importOriginal) =>
- makePathsProxy(await importOriginal(), {
- dataRoot: TEST_DATA_ROOT,
- extraOverrides: (root) => ({ messages: join(root, 'messages') }),
- }));
+ makePathsProxy(await importOriginal(), { dataRoot: TEST_DATA_ROOT }));
vi.mock('../lib/uuid.js', () => ({
v4: vi.fn().mockReturnValue('msg-uuid-5678'),
diff --git a/server/services/obsidian.test.js b/server/services/obsidian.test.js
index 4b3ad9453d..1a9284d7df 100644
--- a/server/services/obsidian.test.js
+++ b/server/services/obsidian.test.js
@@ -15,16 +15,12 @@ import { createTempDataRoot, makePathsProxy } from '../lib/mockPathsDataRoot.js'
// obsidian.js captures PATHS.brain at module load for its vaults file, so the
// root is fixed for the whole file and per-test isolation comes from wiping the
-// dir in beforeEach. PATHS.brain is derived from INSTALL_ROOT rather than
-// PATHS.data, so it needs its own override.
+// dir in beforeEach.
const tempRoot = createTempDataRoot('portos-obsidian-');
vi.mock('../lib/fileUtils.js', async () => {
const actual = await vi.importActual('../lib/fileUtils.js');
- return makePathsProxy(actual, {
- dataRoot: tempRoot,
- extraOverrides: (root) => ({ brain: join(root, 'brain') }),
- });
+ return makePathsProxy(actual, { dataRoot: tempRoot });
});
const { addVault, upsertNote, getNote } = await import('./obsidian.js');
diff --git a/server/services/productivity.test.js b/server/services/productivity.test.js
index 95ce6d3cb3..5a47020c33 100644
--- a/server/services/productivity.test.js
+++ b/server/services/productivity.test.js
@@ -24,14 +24,10 @@ const TEST_DATA_ROOT = mkdtempSync(join(tmpdir(), 'productivity-test-'));
const COS_DIR = join(TEST_DATA_ROOT, 'cos');
const PRODUCTIVITY_FILE = join(COS_DIR, 'productivity.json');
-// productivity.js anchors its store at PATHS.cos, which is computed
-// independently of PATHS.data — redirect both or writes land in the real
-// data/cos of the live install.
+// productivity.js anchors its store at PATHS.cos — re-rooted into the temp tree
+// along with every other data/-rooted PATHS member by makePathsProxy.
vi.mock('../lib/fileUtils.js', async (importOriginal) =>
- makePathsProxy(await importOriginal(), {
- dataRoot: TEST_DATA_ROOT,
- extraOverrides: (root) => ({ cos: join(root, 'cos') }),
- }));
+ makePathsProxy(await importOriginal(), { dataRoot: TEST_DATA_ROOT }));
const mock = vi.hoisted(() => ({ agents: [] }));
diff --git a/server/services/sharing/peerSyncAssets.test.js b/server/services/sharing/peerSyncAssets.test.js
index 824e405744..ceb7fc5c5d 100644
--- a/server/services/sharing/peerSyncAssets.test.js
+++ b/server/services/sharing/peerSyncAssets.test.js
@@ -12,10 +12,7 @@ let tempRoot = mkdtempSync(join(tmpdir(), 'portos-mv-assets-boot-'));
vi.mock('../../lib/fileUtils.js', async () => {
const actual = await vi.importActual('../../lib/fileUtils.js');
- return makePathsProxy(actual, {
- dataRoot: () => tempRoot,
- extraOverrides: (root) => ({ music: join(root, 'music'), images: join(root, 'images') }),
- });
+ return makePathsProxy(actual, { dataRoot: () => tempRoot });
});
// Tracks are db-primary; stub the dispatcher so the manifest builder never
diff --git a/server/services/socialAccounts.tombstone.test.js b/server/services/socialAccounts.tombstone.test.js
index 905c7db354..3cbc555142 100644
--- a/server/services/socialAccounts.tombstone.test.js
+++ b/server/services/socialAccounts.tombstone.test.js
@@ -21,10 +21,7 @@ const twinDir = join(tempRoot, 'digital-twin');
vi.mock('../lib/fileUtils.js', async () => {
const actual = await vi.importActual('../lib/fileUtils.js');
- return makePathsProxy(actual, {
- dataRoot: tempRoot,
- extraOverrides: (root) => ({ digitalTwin: join(root, 'digital-twin') }),
- });
+ return makePathsProxy(actual, { dataRoot: tempRoot });
});
const { createAccount, updateAccount, deleteAccount, getAllAccounts, loadAccounts, invalidateCache } =
diff --git a/server/services/taste-questionnaire.test.js b/server/services/taste-questionnaire.test.js
index 4879ee5cac..b2dd9e85a1 100644
--- a/server/services/taste-questionnaire.test.js
+++ b/server/services/taste-questionnaire.test.js
@@ -1,15 +1,10 @@
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
-import { join } from 'path';
import { mockPathsDataRoot } from '../lib/mockPathsDataRoot.js';
-const { tempRoot, makeProxy, cleanup } = mockPathsDataRoot({
- prefix: 'portos-taste-',
- // taste-questionnaire binds PATHS.digitalTwin at module load; redirect it
- // into the temp tree so tests never touch the real install profile.
- extraOverrides: (dataRoot) => ({
- digitalTwin: join(dataRoot, 'digital-twin'),
- }),
-});
+// taste-questionnaire binds PATHS.digitalTwin at module load; makePathsProxy
+// re-roots it (and every other data/-rooted member) into the temp tree so tests
+// never touch the real install profile.
+const { tempRoot, makeProxy, cleanup } = mockPathsDataRoot({ prefix: 'portos-taste-' });
vi.mock('../lib/fileUtils.js', async () => {
const actual = await vi.importActual('../lib/fileUtils.js');
diff --git a/server/services/universeCanon.test.js b/server/services/universeCanon.test.js
index 2d5d939b30..46596685c8 100644
--- a/server/services/universeCanon.test.js
+++ b/server/services/universeCanon.test.js
@@ -5,10 +5,7 @@ import { mockNoPeerSync, mockNoPeers, mockPathsDataRoot } from '../lib/mockPaths
// Real tmpdir backing the per-record store. `mockPathsDataRoot` redirects
// PATHS.data so collectionStore lands under tempRoot/universes/. Everything
// else from fileUtils (atomicWrite, readJSONFile, ensureDir) is the real impl.
-const { tempRoot, makeProxy, cleanup } = mockPathsDataRoot({
- prefix: 'portos-universe-canon-',
- extraOverrides: (root) => ({ imageRefs: `${root}/image-refs` }),
-});
+const { tempRoot, makeProxy, cleanup } = mockPathsDataRoot({ prefix: 'portos-universe-canon-' });
afterAll(cleanup);
vi.mock('../lib/fileUtils.js', async () => {
diff --git a/server/services/weeklyDigest.test.js b/server/services/weeklyDigest.test.js
index e1fccf2491..8f3db34763 100644
--- a/server/services/weeklyDigest.test.js
+++ b/server/services/weeklyDigest.test.js
@@ -21,13 +21,10 @@ import { makePathsProxy } from '../lib/mockPathsDataRoot.js';
const TEST_DATA_ROOT = mkdtempSync(join(tmpdir(), 'weekly-digest-test-'));
const DIGESTS_DIR = join(TEST_DATA_ROOT, 'cos', 'digests');
-// weeklyDigest.js anchors its store at PATHS.digests, computed independently of
-// PATHS.data — redirect it or digests land in the real install's data/cos.
+// weeklyDigest.js anchors its store at PATHS.digests — re-rooted into the temp
+// tree along with every other data/-rooted PATHS member by makePathsProxy.
vi.mock('../lib/fileUtils.js', async (importOriginal) =>
- makePathsProxy(await importOriginal(), {
- dataRoot: TEST_DATA_ROOT,
- extraOverrides: (root) => ({ digests: join(root, 'cos', 'digests') }),
- }));
+ makePathsProxy(await importOriginal(), { dataRoot: TEST_DATA_ROOT }));
const mock = vi.hoisted(() => ({
agents: [], // getAgents() — the live state index