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: isolate backup boundary suites data root in CoS worktrees (#11477)

[._.]/ Adam Eivy51f76af24fcf
diff --git a/server/lib/backupSnapshotBoundary.maintenance.test.js b/server/lib/backupSnapshotBoundary.maintenance.test.js
index b7e603ac08..d6284ff869 100644
--- a/server/lib/backupSnapshotBoundary.maintenance.test.js
+++ b/server/lib/backupSnapshotBoundary.maintenance.test.js
@@ -1,4 +1,5 @@
-import { describe, expect, it, vi } from 'vitest';
+import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from './mockPathsDataRoot.js';
+import { describe, expect, it, vi, afterAll } from 'vitest';
// The real journal reads the install's data root; a seam stands in for its fence.
const fence = vi.hoisted(() => ({ fenced: false }));
@@ -10,6 +11,17 @@ vi.mock('./databaseMaintenanceJournal.js', () => ({
import { acquireBackupSnapshotCut, withBackupAssetPublication } from './backupSnapshotBoundary.js';
+// The admission lease is minted from PATHS.data (backupSharedAdmission.js). Redirect
+// PATHS so it lands in an OS temp dir: a checkout nested under the install's data/
+// (a CoS claim worktree) would otherwise resolve PATHS.data to its own data/, and the
+// real-data write guard refuses the lease write. Lazy because these suites import
+// their SUT statically and vi.mock is hoisted above any const here.
+vi.mock('./paths.js', async (importOriginal) => makePathsProxy(await importOriginal(), {
+ dataRoot: () => lazyTempDataRoot('portos-backup-boundary-'),
+}));
+
+afterAll(cleanupTempDataRoots);
+
const settle = () => new Promise(resolve => setTimeout(resolve, 10));
describe('backup snapshot boundary under database maintenance', () => {
diff --git a/server/lib/backupSnapshotBoundary.settlement.test.js b/server/lib/backupSnapshotBoundary.settlement.test.js
index a9e64fe64a..036ad4dcdd 100644
--- a/server/lib/backupSnapshotBoundary.settlement.test.js
+++ b/server/lib/backupSnapshotBoundary.settlement.test.js
@@ -1,7 +1,19 @@
-import { expect, it, vi } from 'vitest';
+import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from './mockPathsDataRoot.js';
+import { expect, it, vi, afterAll } from 'vitest';
import { maintenance } from './maintenanceAdmission.js';
import { acquireBackupSnapshotCut, withBackupAssetPublication } from './backupSnapshotBoundary.js';
+// The admission lease is minted from PATHS.data (backupSharedAdmission.js). Redirect
+// PATHS so it lands in an OS temp dir: a checkout nested under the install's data/
+// (a CoS claim worktree) would otherwise resolve PATHS.data to its own data/, and the
+// real-data write guard refuses the lease write. Lazy because these suites import
+// their SUT statically and vi.mock is hoisted above any const here.
+vi.mock('./paths.js', async (importOriginal) => makePathsProxy(await importOriginal(), {
+ dataRoot: () => lazyTempDataRoot('portos-backup-boundary-'),
+}));
+
+afterAll(cleanupTempDataRoots);
+
it('keeps waiting publication owned, retires only refused admission, and retains a started failed write', async () => {
vi.useFakeTimers();
const parent = maintenance.admit('agent', 'fixture-agent');
diff --git a/server/lib/backupSnapshotBoundary.test.js b/server/lib/backupSnapshotBoundary.test.js
index c5272a9ab5..da860bfa15 100644
--- a/server/lib/backupSnapshotBoundary.test.js
+++ b/server/lib/backupSnapshotBoundary.test.js
@@ -1,7 +1,19 @@
-import { afterEach, describe, expect, it, vi } from 'vitest';
+import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from './mockPathsDataRoot.js';
+import { afterEach, describe, expect, it, vi, afterAll } from 'vitest';
import { rmSync } from 'node:fs';
import { backupPublicationAdmissionStatus, acquireBackupSnapshotCut, runOutsideBackupAssetPublication, withBackupAssetPublication } from './backupSnapshotBoundary.js';
+// The admission lease is minted from PATHS.data (backupSharedAdmission.js). Redirect
+// PATHS so it lands in an OS temp dir: a checkout nested under the install's data/
+// (a CoS claim worktree) would otherwise resolve PATHS.data to its own data/, and the
+// real-data write guard refuses the lease write. Lazy because these suites import
+// their SUT statically and vi.mock is hoisted above any const here.
+vi.mock('./paths.js', async (importOriginal) => makePathsProxy(await importOriginal(), {
+ dataRoot: () => lazyTempDataRoot('portos-backup-boundary-'),
+}));
+
+afterAll(cleanupTempDataRoots);
+
const deferred = () => {
let resolve;
const promise = new Promise(done => { resolve = done; });