Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Tests never write the owner's real Strata profile: pytest gets scratch LOCALAPPDATA/XDG state and data folders; the host test runner and the native-control test files get a scratch settings file, components folder and app data

Niko1221535cacb05212
diff --git a/apps/host/scripts/test.mjs b/apps/host/scripts/test.mjs
index 2941bd7ae..7090da0fe 100644
--- a/apps/host/scripts/test.mjs
+++ b/apps/host/scripts/test.mjs
@@ -5,6 +5,12 @@ import {spawn} from 'node:child_process';
import {resolve} from 'node:path';
const root=resolve(import.meta.dirname,'..');
const files=readdirSync(resolve(root,'tests')).filter(name=>name.endsWith('.test.mjs')).sort().map(name=>resolve(root,'tests',name));
-const child=spawn(process.execPath,['--test',...files],{cwd:root,stdio:'inherit'});
+/* Every test file runs against scratch copies of the per-user places the host writes to (the owner's real profile is never touched). */
+import {mkdtempSync} from 'node:fs';
+import {tmpdir} from 'node:os';
+import {join} from 'node:path';
+const scratch=mkdtempSync(join(tmpdir(),'strata-host-suite-profile-'));
+const env={...process.env,STRATA_SETTINGS_FILE:join(scratch,'app-settings.json'),STRATA_COMPONENTS_DIR:join(scratch,'components'),LOCALAPPDATA:join(scratch,'Local'),APPDATA:join(scratch,'Roaming'),XDG_DATA_HOME:join(scratch,'xdg-data'),XDG_STATE_HOME:join(scratch,'xdg-state'),XDG_CONFIG_HOME:join(scratch,'xdg-config')};
+const child=spawn(process.execPath,['--test',...files],{cwd:root,stdio:'inherit',env});
child.on('error',error=>{console.error(error.message);process.exitCode=1;});
child.on('exit',(code,signal)=>{process.exitCode=code??(signal?1:0);});
diff --git a/apps/host/tests/component-updates.test.mjs b/apps/host/tests/component-updates.test.mjs
index 13a336b68..34aadc0e0 100644
--- a/apps/host/tests/component-updates.test.mjs
+++ b/apps/host/tests/component-updates.test.mjs
@@ -1,3 +1,4 @@
+import './helpers/isolate-profile.mjs'; // a test run never writes the owner's real Strata profile
import test from 'node:test';
import assert from 'node:assert/strict';
import { EventEmitter } from 'node:events';
diff --git a/apps/host/tests/draft-layer.test.mjs b/apps/host/tests/draft-layer.test.mjs
index f182b4fba..dce7f2589 100644
--- a/apps/host/tests/draft-layer.test.mjs
+++ b/apps/host/tests/draft-layer.test.mjs
@@ -3,6 +3,7 @@
* Setup writes --mtp, --spec-min-p and --vision into the arguments every time it runs; the host applies the saved choices on every
* load. Nothing here starts an engine; Control is a fake that records what the host saved and asked it to start.
*/
+import './helpers/isolate-profile.mjs'; // a test run never writes the owner's real Strata profile
import test from 'node:test';
import assert from 'node:assert/strict';
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
diff --git a/apps/host/tests/helpers/isolate-profile.mjs b/apps/host/tests/helpers/isolate-profile.mjs
new file mode 100644
index 000000000..2da778986
--- /dev/null
+++ b/apps/host/tests/helpers/isolate-profile.mjs
@@ -0,0 +1,19 @@
+/**
+ * Import this FIRST in a test that builds the host's native control or starts the host: it points the per-user places the host writes to
+ * (the settings file Control reads, the components folder, the app's local data) at a scratch folder.
+ * On 2026-10-24 a host test run rewrote the owner's real %LOCALAPPDATA%\Strata\app-settings.json (its data_dir became a deleted test folder).
+ */
+import { mkdtempSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+
+if (!process.env.STRATA_TEST_KEEP_PROFILE) {
+ const scratch = mkdtempSync(join(tmpdir(), 'strata-host-test-profile-'));
+ process.env.STRATA_SETTINGS_FILE = join(scratch, 'app-settings.json');
+ process.env.STRATA_COMPONENTS_DIR = join(scratch, 'components');
+ process.env.LOCALAPPDATA = join(scratch, 'Local');
+ process.env.APPDATA = join(scratch, 'Roaming');
+ process.env.XDG_DATA_HOME = join(scratch, 'xdg-data');
+ process.env.XDG_STATE_HOME = join(scratch, 'xdg-state');
+ process.env.XDG_CONFIG_HOME = join(scratch, 'xdg-config');
+}
diff --git a/apps/host/tests/models-folder.test.mjs b/apps/host/tests/models-folder.test.mjs
index e3b4b0e1d..9f6f2cb8b 100644
--- a/apps/host/tests/models-folder.test.mjs
+++ b/apps/host/tests/models-folder.test.mjs
@@ -1,3 +1,4 @@
+import './helpers/isolate-profile.mjs'; // a test run never writes the owner's real Strata profile
import test from 'node:test';
import assert from 'node:assert/strict';
import { EventEmitter } from 'node:events';
diff --git a/apps/host/tests/no-acquire.test.mjs b/apps/host/tests/no-acquire.test.mjs
index be714dfaf..8806171ed 100644
--- a/apps/host/tests/no-acquire.test.mjs
+++ b/apps/host/tests/no-acquire.test.mjs
@@ -1,3 +1,4 @@
+import './helpers/isolate-profile.mjs'; // a test run never writes the owner's real Strata profile
import test from 'node:test';
import assert from 'node:assert/strict';
import { spawn } from 'node:child_process';
diff --git a/apps/host/tests/packaged-control.test.mjs b/apps/host/tests/packaged-control.test.mjs
index 4f156bba7..1ee4a7b65 100644
--- a/apps/host/tests/packaged-control.test.mjs
+++ b/apps/host/tests/packaged-control.test.mjs
@@ -1,3 +1,4 @@
+import './helpers/isolate-profile.mjs'; // a test run never writes the owner's real Strata profile
import test from 'node:test';
import assert from 'node:assert/strict';
import { EventEmitter } from 'node:events';
diff --git a/apps/host/tests/parallel-default.test.mjs b/apps/host/tests/parallel-default.test.mjs
index 59db83bc5..1cb9844f3 100644
--- a/apps/host/tests/parallel-default.test.mjs
+++ b/apps/host/tests/parallel-default.test.mjs
@@ -3,6 +3,7 @@
* retry with one when a load with several slots fails. Nothing here starts an engine; Control is a fake that records what
* the host saved and asked it to start.
*/
+import './helpers/isolate-profile.mjs'; // a test run never writes the owner's real Strata profile
import test from 'node:test';
import assert from 'node:assert/strict';
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
diff --git a/apps/host/tests/user-args.test.mjs b/apps/host/tests/user-args.test.mjs
index b3123f58a..8f2f972c5 100644
--- a/apps/host/tests/user-args.test.mjs
+++ b/apps/host/tests/user-args.test.mjs
@@ -3,6 +3,7 @@
* apps", and engine arguments the app does not know (the control vector options). Nothing here starts an engine; Control is a fake that
* records the run file the host saved and asked it to start.
*/
+import './helpers/isolate-profile.mjs'; // a test run never writes the owner's real Strata profile
import test from 'node:test';
import assert from 'node:assert/strict';
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
diff --git a/conftest.py b/conftest.py
index 43fe5c5e7..5617ecf7d 100644
--- a/conftest.py
+++ b/conftest.py
@@ -7,3 +7,9 @@ import tempfile
_home = tempfile.mkdtemp(prefix="strata-pytest-config-")
os.environ["APPDATA"] = _home
os.environ["XDG_CONFIG_HOME"] = _home
+# The per-user STATE and DATA folders too (%LOCALAPPDATA%\Strata: tuning/recheck.json, the engine store, the update records; ~/.local/state, ~/.local/share).
+# A test that installs a stub engine marks saved tuning presets for a re-check there: on 2026-10-24 one such run left an entry in the owner's real
+# tuning\recheck.json. A test that wants a place of its own still names it (STRATA_COMPONENTS_DIR, state_base=...).
+os.environ["LOCALAPPDATA"] = _home
+os.environ["XDG_STATE_HOME"] = _home
+os.environ["XDG_DATA_HOME"] = _home