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: isolate unlockPass tests from the checkout's real data/ directory (#3683)

[._.]/ Adam Eivy020c23fd51f6
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 86e035b873..56cea94cab 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -78,3 +78,5 @@
- **Video Gen now tells you what runs where, and under whose terms.** Model names such as "LTX-2.3 Distilled Q4 (~22 GB)" carried the only provenance a user got, and the local/hosted backend switch offered a one-line tooltip — so "local" was easy to read as "no rules apply", which is wrong: a local runtime only means PortOS isn't sending your prompt to a hosted provider, it doesn't waive the weights or runtime license. A compact disclosure now sits under the backend and model controls and updates with them, showing whether inference runs on this machine or is submitted to xAI, the model card and pinned revision, the weights license and the (often different) runtime license, the pinned-snapshot download size, the memory minimum against what this machine actually has, supported modes and runtime name. Every value was checked against a primary upstream source — the HuggingFace model card's own license metadata, the runtime project's LICENSE file, the file listing at the pinned revision — and anything that could not be established renders as "Unknown" rather than being guessed from a repo name. Custom models you added yourself show Unknown throughout, and so does a shipped model whose repo you re-pointed at a fork. The local wording says plainly that PortOS applies no model-level prompt filter *and* that the licenses still apply; the hosted wording says the request leaves the machine and xAI's terms and retention apply independently. Nothing about downloads, verification, render arguments or prompt handling changed — this is disclosure only, and it deliberately avoids ranking backends as more or less restrictive.
- Internal: recorded a feasibility spike on Krea Realtime 14B as a local Apple Silicon video backend (`docs/research/2026-08-09-krea-realtime-apple-silicon.md`). The answer is **no-go for now** and nothing shipped: Krea's own runtime initializes CUDA at module import and pins `triton`, which publishes no macOS wheel, so it cannot even install on a Mac; its inference code is CC BY-NC-SA 4.0 (the weights are Apache-2.0 — two different licenses that PortOS has to track separately), and the only native-MLX implementation of the pipeline is a third party's unpublished, in-progress crate inside a product monorepo. The report pins every revision it inspected, distinguishes Krea 2 RAW/Turbo (image) from Krea Realtime 14B (video), marks every benchmark explicitly "not run" with the reason rather than guessing, and names the specific upstream change that would justify reevaluating.
+
+- Internal: the series-autopilot unlock-pass test suite no longer reads the checkout's real `data/` directory. It partial-mocked `fileUtils.js` with an in-memory store but left `PATHS.data` pointing at the repo, and the series collection store enumerates that directory with a real `readdir` the mock never intercepts — so on any checkout with real series on disk, two sole-universe-ownership tests failed with what looked like a regression on whatever branch happened to be checked out. CI never saw it because a fresh checkout has no `data/`. `PATHS.data` now resolves to a per-run temp dir via the shared `makePathsProxy` helper, and three added assertions pin the isolation so it cannot quietly come back. The three sibling pipeline suites named as suspects were audited and are already isolated — they replace `series.js` outright and never reach the store. Test-only change; no production code touched.
diff --git a/server/services/pipeline/seriesAutopilot/unlockPass.test.js b/server/services/pipeline/seriesAutopilot/unlockPass.test.js
index a771bc3f63..38e8621565 100644
--- a/server/services/pipeline/seriesAutopilot/unlockPass.test.js
+++ b/server/services/pipeline/seriesAutopilot/unlockPass.test.js
@@ -1,23 +1,39 @@
-import { describe, it, expect, vi, beforeEach } from 'vitest';
-import { readdirSync, readFileSync } from 'node:fs';
+import { describe, it, expect, vi, beforeEach, afterAll } from 'vitest';
+import { readdirSync, readFileSync, rmSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
-import { mockNoPeerSync, mockNoPeers } from '../../../lib/mockPathsDataRoot.js';
+import {
+ createTempDataRoot,
+ makePathsProxy,
+ mockNoPeerSync,
+ mockNoPeers,
+} from '../../../lib/mockPathsDataRoot.js';
// File-backed store (same idiom as seriesAutopilot.test.js) so the REAL
// series/issues services run against an in-memory map, not Postgres. Partial
// mock — this suite loads `./session.js` transitively (for `broadcast`), which
// pulls in the cos/apps graph, and those modules read fileUtils members the
// autopilot itself never touches.
+//
+// PATHS.data is redirected at a temp dir too (#3683): the collection store
+// behind `listSeries()` enumerates `PATHS.data/pipeline-series/` with a REAL
+// readdir that the fileUtils overrides below never intercept, so on a populated
+// checkout the developer's own series leaked into the fixture and broke the
+// sole-universe ownership assertions. See the isolation probe at the bottom.
+const tempRoot = createTempDataRoot('portos-unlock-pass-');
const fileStore = new Map();
-vi.mock('../../../lib/fileUtils.js', async (importOriginal) => ({
- ...(await importOriginal()),
- tryReadFile: vi.fn().mockResolvedValue(null),
- ensureDir: vi.fn().mockResolvedValue(undefined),
- atomicWrite: vi.fn(async (path, data) => { fileStore.set(path, data); }),
- readJSONFile: vi.fn(async (path, fallback) => (fileStore.has(path) ? fileStore.get(path) : fallback)),
+vi.mock('../../../lib/fileUtils.js', async (importOriginal) => makePathsProxy(await importOriginal(), {
+ dataRoot: tempRoot,
+ overrides: {
+ tryReadFile: vi.fn().mockResolvedValue(null),
+ ensureDir: vi.fn().mockResolvedValue(undefined),
+ atomicWrite: vi.fn(async (path, data) => { fileStore.set(path, data); }),
+ readJSONFile: vi.fn(async (path, fallback) => (fileStore.has(path) ? fileStore.get(path) : fallback)),
+ },
}));
+afterAll(() => rmSync(tempRoot, { recursive: true, force: true }));
+
let uuidCounter = 0;
vi.mock('crypto', async () => {
const actual = await vi.importActual('crypto');
@@ -307,6 +323,35 @@ describe('unlockPass — end-to-end over the real series/issue services', () =>
});
});
+// Isolation probe for #3683. The end-to-end suite above reaches `listSeries()`,
+// which enumerates PATHS.data/pipeline-series with a REAL readdir — the fileUtils
+// overrides do not intercept it. Before the PATHS redirect, the suite therefore
+// saw the developer's own series and two sole-universe assertions failed on any
+// checkout with a populated data/. These assertions fail the same way if the
+// redirect is ever dropped, so the leak can't come back silently.
+describe('unlockPass — the suite is isolated from the checkout\'s real data/', () => {
+ it('resolves PATHS.data to a temp dir outside the repo', async () => {
+ const { PATHS } = await import('../../../lib/fileUtils.js');
+ expect(PATHS.data).toBe(tempRoot);
+ expect(PATHS.data).not.toContain('PortOS');
+ });
+
+ it('anchors the series record directory under the temp root', () => {
+ expect(seriesSvc.seriesStore().recordDir('ser-probe')).toBe(join(tempRoot, 'pipeline-series', 'ser-probe'));
+ });
+
+ // The behavioral half: `listSeries()` must return the suite's own fixtures and
+ // nothing else. The store enumerates with a real `readdir` and only falls back
+ // to its in-process id set when the collection dir is ABSENT — so a real
+ // data/pipeline-series takes over the moment PATHS.data points at the
+ // checkout, replacing the fixtures with the developer's series.
+ it('lists only the series this suite created', async () => {
+ const mine = await seriesSvc.createSeries({ name: 'Isolation Probe', targetFormat: 'comic' });
+ const listed = await seriesSvc.listSeries();
+ expect(listed.map((s) => s.id)).toEqual([mine.id]);
+ });
+});
+
// Source-level guard, not a behavioral one: unlocking is what lets the autopilot
// FULLY EDIT a character/object/volume, and the standing rule is that it must
// never turn into permission to DELETE one. A record that has to leave is a