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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: allocate AI-toolkit test fixture dirs in tmpdir, not the checkout (#3823)
[._.]/ Adam Eivy335dc1760160
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex af879a3e25..8ba020914a 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -95,3 +95,4 @@- **A generated Three.js model is now checked for parts modelled inside each other.** Every existing gate reads one part at a time — the schema proves each geometry is well formed, the coverage gate proves the assembly backs the inventory, and the cross-section gate proves the identity parts have real depth — so nothing ever compared two parts to each other, and the whole class of defect where sibling parts occupy the *same* space was invisible: a greeble modelled at the wrong scale and swallowed whole by the hull it was meant to sit on, a limb rooted a full radius inside a torso, an eye socket punched clean through the back of a skull. All of those render perfectly from the hero camera the model generated for itself and only read as broken once you orbit or explode the assembly. A new cross-part penetration gate reconstructs each part's world placement (the same rotation/scale composition the preview applies), derives an analytic solid per geometry type — a torus is measured as a ring rather than a filled disc, a hollow lathe as hollow, an extrude's hole as empty space — and samples one part's interior against another's, flagging a part that is entirely inside an unrelated one as an error and a pair that shares most of the smaller part's volume as a warning. It reports rather than rejects, and it is deliberately quiet where it cannot be sure: parts parented together or declared as attachments are exempt (embedding is what those relationships are *for*), and a shallow seated joint or anything inside a transparent part comes back as an undecided note that a refinement pass is never told to "fix". Findings land on the record, show up in a new panel on the model detail page, and an unsteered refinement now asks for each part to get its own volume alongside the existing coverage and depth feedback.- **A resumed arc verification no longer forgets why its last rewrite was rejected.** When Series Autopilot restored a safe checkpoint after a regressive rewrite, it persisted both the standing blockers and the rejected candidate's new blockers — but a fresh Resume discarded the latter before calling the resolver. That made the new run liable to repeat the same bad trade from the same checkpoint. A resumed arc gate now carries the bounded discarded set into every normal, corrective, and isolated resolve attempt as explicit avoid evidence, while non-arc and non-regression pauses start clean as before. If a discarded latent defect is later found in the checkpoint itself, it is removed from the avoid set while it is the active repair target, so the resolver never receives contradictory "fix this" and "avoid this" instructions.- **A fresh install's prompt migrations stopped silently skipping the character-foundation upgrades they exist to apply.** Several stage prompts are targeted by more than one hash-driven migration, and each one names the body it expects to end at. When later migrations re-shipped `pipeline-character-foundation.md`, `pipeline-judge-foundation.md`, and `universe-character-expand.md`, the earlier migrations that also target those files were left naming the superseded body as current — so on a fresh install they saw today's shipped prompt, classified it as "customized by the user", and skipped rather than upgraded: exactly the silent no-op the drift assertions exist to catch, and the reason the migration suites were failing on `main`. Migrations 027, 171, 240, 241, 243, 248, and 255 now point at the live bodies and carry every superseded hash in their accepted-old sets, so an install stopped at any intermediate body still upgrades. A new repo-wide guard sweeps every numbered migration against `data.reference` in one pass — including migrations that ship no test of their own — and fails with the full list of stale entries, so the next prompt edit that strands its predecessors names them all at once instead of hiding until CI turns red.+- **A server test run no longer drops fixture directories into the checkout.** Three AI-toolkit suites rooted their scratch directories at `process.cwd()` (`server/test-data`, `server/test-data-status`, `server/test-data-cli-resolve`), and their `afterEach` cleanup only ran when the worker survived the file — so a timed-out or killed worker left untracked cruft behind, one `git add -A` away from an unrelated commit (it reached a claim branch once). They now allocate a per-test temp directory under the OS temp dir, and the test-isolation guard grew a companion rule so a cwd-rooted fixture path fails the suite rather than the next `git status`. Reading cwd as a value — handing the checkout to code under test — stays legal.diff --git a/server/lib/aiToolkit/providerStatus.test.js b/server/lib/aiToolkit/providerStatus.test.jsindex ab6168ec6d..a8f5adabd3 100644--- a/server/lib/aiToolkit/providerStatus.test.js+++ b/server/lib/aiToolkit/providerStatus.test.js@@ -1,19 +1,20 @@import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';-import { mkdir, rm } from 'fs/promises';-import { existsSync } from 'fs';+import { mkdtemp, rm } from 'fs/promises';+import { tmpdir } from 'os';import { join } from 'path';import { createProviderStatusService, usableFallbackModel } from './providerStatus.js';-const TEST_DATA_DIR = join(process.cwd(), 'test-data-status');+// Temp dir, NOT `join(process.cwd(), …)` — a cwd-rooted fixture dir 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).+let TEST_DATA_DIR;describe('Provider Status Service', () => {let statusService;beforeEach(async () => {- // Create test data directory- if (!existsSync(TEST_DATA_DIR)) {- await mkdir(TEST_DATA_DIR, { recursive: true });- }+ TEST_DATA_DIR = await mkdtemp(join(tmpdir(), 'portos-provider-status-'));statusService = createProviderStatusService({dataDir: TEST_DATA_DIR,@@ -27,10 +28,7 @@ describe('Provider Status Service', () => {});afterEach(async () => {- // Clean up test data- if (existsSync(TEST_DATA_DIR)) {- await rm(TEST_DATA_DIR, { recursive: true });- }+ await rm(TEST_DATA_DIR, { recursive: true, force: true });});describe('getStatus', () => {diff --git a/server/lib/aiToolkit/providers.cliPathResolve.test.js b/server/lib/aiToolkit/providers.cliPathResolve.test.jsindex 7f31998d26..e0d32589d1 100644--- a/server/lib/aiToolkit/providers.cliPathResolve.test.js+++ b/server/lib/aiToolkit/providers.cliPathResolve.test.js@@ -1,6 +1,5 @@import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';-import { mkdir, mkdtemp, rm, writeFile } from 'fs/promises';-import { existsSync } from 'fs';+import { mkdtemp, rm, writeFile } from 'fs/promises';import { join } from 'path';import { tmpdir } from 'os';@@ -18,7 +17,8 @@ vi.mock('child_process', async (importOriginal) => {import { execFile } from 'child_process';import { createProviderService } from './providers.js';-const TEST_DATA_DIR = join(process.cwd(), 'test-data-cli-resolve');+// Temp dir, NOT `join(process.cwd(), …)` — see providerStatus.test.js (#3823).+let TEST_DATA_DIR;describe('testProvider — cli command resolution (cross-platform PATH)', () => {let providerService;@@ -28,7 +28,7 @@ describe('testProvider — cli command resolution (cross-platform PATH)', () =>beforeEach(async () => {originalPlatform = process.platform;- if (!existsSync(TEST_DATA_DIR)) await mkdir(TEST_DATA_DIR, { recursive: true });+ TEST_DATA_DIR = await mkdtemp(join(tmpdir(), 'portos-cli-resolve-'));providerService = createProviderService({ dataDir: TEST_DATA_DIR, providersFile: 'providers.json' });// testProvider's win32 path now ALSO does its own filesystem-based// re-resolution (resolveWindowsExecutable) independent of the mocked@@ -46,7 +46,7 @@ describe('testProvider — cli command resolution (cross-platform PATH)', () =>process.env.PATH = originalPath;await rm(fakePathDir, { recursive: true, force: true });vi.mocked(execFile).mockReset();- if (existsSync(TEST_DATA_DIR)) await rm(TEST_DATA_DIR, { recursive: true });+ await rm(TEST_DATA_DIR, { recursive: true, force: true });});const setPlatform = (value) => Object.defineProperty(process, 'platform', { value, configurable: true });diff --git a/server/lib/aiToolkit/providers.test.js b/server/lib/aiToolkit/providers.test.jsindex 47506279f4..1771371151 100644--- a/server/lib/aiToolkit/providers.test.js+++ b/server/lib/aiToolkit/providers.test.js@@ -1,19 +1,17 @@import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';-import { chmod, mkdir, rm, writeFile } from 'fs/promises';-import { existsSync } from 'fs';+import { chmod, mkdtemp, rm, writeFile } from 'fs/promises';+import { tmpdir } from 'os';import { join } from 'path';import { createProviderService, isOllamaBackedProvider } from './providers.js';-const TEST_DATA_DIR = join(process.cwd(), 'test-data');+// Temp dir, NOT `join(process.cwd(), …)` — see providerStatus.test.js (#3823).+let TEST_DATA_DIR;describe('Provider Service', () => {let providerService;beforeEach(async () => {- // Create test data directory- if (!existsSync(TEST_DATA_DIR)) {- await mkdir(TEST_DATA_DIR, { recursive: true });- }+ TEST_DATA_DIR = await mkdtemp(join(tmpdir(), 'portos-providers-'));providerService = createProviderService({dataDir: TEST_DATA_DIR,@@ -22,10 +20,7 @@ describe('Provider Service', () => {});afterEach(async () => {- // Clean up test data- if (existsSync(TEST_DATA_DIR)) {- await rm(TEST_DATA_DIR, { recursive: true });- }+ await rm(TEST_DATA_DIR, { recursive: true, force: true });});it('should create a provider', async () => {diff --git a/server/lib/testDataIsolation.guards.test.js b/server/lib/testDataIsolation.guards.test.jsindex e49dd09083..2e920cdc55 100644--- a/server/lib/testDataIsolation.guards.test.js+++ b/server/lib/testDataIsolation.guards.test.js@@ -118,6 +118,32 @@ const SCOPED_TESTS = execFileSync('git', ['ls-files', '*.test.js'], {const scan = (source) => REAL_DATA_ROOT_RE.test(source);+// Sibling rule, different blast radius: a fixture directory rooted at+// `process.cwd()` doesn't touch the user's records, but it DOES materialize+// inside the checkout. Three suites did this (`test-data`, `test-data-status`,+// `test-data-cli-resolve` — all under `server/`), and their `afterEach` cleanup+// only runs when the worker survives the file: a timed-out or killed worker+// leaves the directory behind as untracked cruft, which is then one `git add -A`+// away from an unrelated commit (#3823 — it reached a claim branch once).+//+// The match is narrow on purpose: a cwd anchor joined to a QUOTED literal path+// segment, which is what naming a directory looks like. Reading cwd as a value+// (`workspacePath: process.cwd()`, `repoPath: process.cwd()`) stays legal — those+// pass the checkout to code under test rather than writing into it, and account+// for every remaining occurrence in the suite.+// `H` is horizontal whitespace only: a `\s*` here would span the newline in a+// multi-line argument list (`process.cwd(),\n 'some string arg'`) and flag call+// sites that merely pass cwd as one argument among several.+const CWD = 'process\\??\\.cwd[^\\S\\n]*(?:\\?\\.)?\\(\\)';+const H = '[^\\S\\n]*';+const CWD_FIXTURE_DIR_RE = new RegExp([+ `${CWD}${H},${H}[\`'"]`, // join(process.cwd(), 'fixture-dir')+ `${CWD}${H}\\+${H}[\`'"][/\\\\]`, // process.cwd() + '/fixture-dir'+ `\\$\\{${CWD}\\}[/\\\\]`, // `${process.cwd()}/fixture-dir`+].join('|'));++const scanCwdFixture = (source) => CWD_FIXTURE_DIR_RE.test(source);+describe('test-data isolation guard', () => {it('finds test files to scan', () => {// Fails loudly if the glob or the path filter ever stops matching, rather@@ -139,6 +165,35 @@ describe('test-data isolation guard', () => {].join('\n')).toEqual([]);});+ it('no test roots a fixture directory at the checkout (process.cwd())', () => {+ const offenders = SCOPED_TESTS.filter((rel) => scanCwdFixture(readFileSync(join(REPO_ROOT, rel), 'utf8')));+ expect(offenders, [+ 'These tests build a fixture path under the checkout itself, so a worker that',+ 'dies before afterEach leaves an untracked directory in the repo. Allocate a',+ 'temp directory instead:',+ '',+ " const dir = await mkdtemp(join(tmpdir(), 'portos-<suite>-'));",+ '',+ 'Reading cwd as a value (workspacePath: process.cwd()) is fine — see #3823.',+ ].join('\n')).toEqual([]);+ });++ it('would have caught the cwd-rooted fixture dirs this repo shipped', () => {+ // The three exact lines removed in #3823, plus the spellings a rename away.+ expect(scanCwdFixture("const TEST_DATA_DIR = join(process.cwd(), 'test-data');")).toBe(true);+ expect(scanCwdFixture("const TEST_DATA_DIR = join(process.cwd(), 'test-data-status');")).toBe(true);+ expect(scanCwdFixture("const TEST_DATA_DIR = join(process.cwd(), 'test-data-cli-resolve');")).toBe(true);+ expect(scanCwdFixture("path.join(process.cwd(), `fixtures`)")).toBe(true);+ expect(scanCwdFixture("process.cwd() + '/scratch'")).toBe(true);+ expect(scanCwdFixture('`${process.cwd()}/scratch`')).toBe(true);+ // Passing the checkout to code under test is the legitimate use, and is what+ // every surviving occurrence in the suite does.+ expect(scanCwdFixture('workspacePath: process.cwd(),')).toBe(false);+ expect(scanCwdFixture('const TEST_WORKSPACE = process.cwd();')).toBe(false);+ expect(scanCwdFixture('getAppWorkspace.mockResolvedValue(process.cwd());')).toBe(false);+ expect(scanCwdFixture("const dir = await mkdtemp(join(tmpdir(), 'portos-x-'));")).toBe(false);+ });+it('would have caught every spelling found in this repo', () => {// A bypass probe, not a pattern unit test: these are the exact lines the// three known instances carried, so a rule that stops matching them fails