Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree (570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base = the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main). Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details, conflict table and left-out files are in docs/upstream.md. Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61), docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out. scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run"). Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR macros on. No GPU run, no quality gate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
75 lines
4.6 KiB
JavaScript
75 lines
4.6 KiB
JavaScript
/**
|
|
* The first workspace is never the app's own folder, and any workspace can be renamed (a display name; the path stays).
|
|
* A real host process with a scratch user profile; no STRATA_WORKSPACE, started inside the host folder like the installed app.
|
|
*/
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { spawn, spawnSync } from 'node:child_process';
|
|
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
import { createServer } from 'node:net';
|
|
import { tmpdir } from 'node:os';
|
|
import { join, resolve } from 'node:path';
|
|
|
|
const HOST_DIR = resolve(import.meta.dirname, '..');
|
|
const freePort = () => new Promise(r => { const s = createServer(); s.listen(0, '127.0.0.1', () => { const p = s.address().port; s.close(() => r(p)); }); });
|
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
|
|
|
async function start(t, { user, home }) {
|
|
const port = await freePort();
|
|
const env = { ...process.env, STRATA_HOME: home, STRATA_PORT: String(port), USERPROFILE: user, HOME: user, STRATA_REAL_ENGINE: '0', STRATA_COMPONENTS_DIR: join(home, 'components') };
|
|
delete env.STRATA_WORKSPACE;
|
|
const child = spawn(process.execPath, [join(HOST_DIR, 'server', 'index.mjs')], { cwd: HOST_DIR, env, stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
|
|
let log = ''; child.stdout.on('data', d => { log += d; }); child.stderr.on('data', d => { log += d; });
|
|
t.after(async () => {
|
|
if (child.exitCode !== null) return;
|
|
if (process.platform === 'win32') spawnSync('taskkill', ['/PID', String(child.pid), '/T', '/F'], { windowsHide: true }); else child.kill('SIGTERM');
|
|
await new Promise(r => child.once('exit', r));
|
|
});
|
|
const base = `http://127.0.0.1:${port}`;
|
|
for (let i = 0; i < 100; i++) {
|
|
try { if ((await fetch(`${base}/api/workspaces`)).ok) break; } catch { /* not up yet */ }
|
|
if (child.exitCode !== null) throw new Error(`the host exited: ${log.slice(-400)}`);
|
|
await sleep(200);
|
|
}
|
|
const call = async (method, path, body) => { const r = await fetch(base + path, { method, headers: { 'content-type': 'application/json' }, body: body ? JSON.stringify(body) : undefined }); return { status: r.status, body: await r.json().catch(() => null) }; };
|
|
return { call };
|
|
}
|
|
|
|
const scratch = () => { const dir = mkdtempSync(join(tmpdir(), 'strata-ws-')); const user = join(dir, 'user'); const home = join(dir, 'home'); mkdirSync(user, { recursive: true }); mkdirSync(home, { recursive: true }); return { dir, user, home }; };
|
|
|
|
test('item 6: with nothing chosen the first workspace is Documents\\Strata, never the app folder', async t => {
|
|
const s = scratch(); t.after(() => rmSync(s.dir, { recursive: true, force: true }));
|
|
const host = await start(t, s);
|
|
const { body } = await host.call('GET', '/api/workspaces');
|
|
const first = body.workspaces[0];
|
|
assert.equal(first.id, 'root');
|
|
assert.equal(resolve(first.path), join(s.user, 'Documents', 'Strata', 'Workspace'));
|
|
assert.equal(first.name, 'Strata');
|
|
assert.ok(existsSync(first.path), 'the folder is created');
|
|
assert.notEqual(resolve(first.path), HOST_DIR);
|
|
});
|
|
|
|
test('item 6: a saved first workspace that is the app folder moves to the default; its chats follow through an alias', async t => {
|
|
const s = scratch(); t.after(() => rmSync(s.dir, { recursive: true, force: true }));
|
|
mkdirSync(join(s.home, 'data'), { recursive: true });
|
|
writeFileSync(join(s.home, 'data', 'workspaces.json'), JSON.stringify([{ id: 'root', name: 'host', path: HOST_DIR }, { id: 'ws_a', name: 'Mine', path: s.user }]));
|
|
const host = await start(t, s);
|
|
const { body } = await host.call('GET', '/api/workspaces');
|
|
assert.equal(resolve(body.workspaces[0].path), join(s.user, 'Documents', 'Strata', 'Workspace'));
|
|
assert.equal(body.workspaces[0].name, 'Strata');
|
|
assert.deepEqual(body.workspaces[0].aliases, [HOST_DIR]);
|
|
assert.equal(body.workspaces[1].path, s.user, 'a folder the person added is left alone');
|
|
});
|
|
|
|
test('item 6: renaming changes the display name only', async t => {
|
|
const s = scratch(); t.after(() => rmSync(s.dir, { recursive: true, force: true }));
|
|
const host = await start(t, s);
|
|
const before = (await host.call('GET', '/api/workspaces')).body.workspaces[0];
|
|
const done = await host.call('PATCH', '/api/workspaces/root', { name: ' My projects ' });
|
|
assert.equal(done.status, 200);
|
|
assert.equal(done.body.name, 'My projects'); assert.equal(done.body.path, before.path);
|
|
assert.equal((await host.call('GET', '/api/workspaces')).body.workspaces[0].name, 'My projects', 'it is saved');
|
|
assert.equal((await host.call('PATCH', '/api/workspaces/root', { name: ' ' })).status, 400);
|
|
assert.equal((await host.call('PATCH', '/api/workspaces/nope', { name: 'x' })).status, 404);
|
|
});
|