Files
strata/apps/host/tests/model-storage.test.mjs
T
Niko1221 0b3299a019 apps/host: the owner's UI and the Node App Host
The UI source from the 14 October handoff (src/, public/, index.html, vite and
tsconfig, tests, audit-fixes, design docs) and the App Host (server/*.mjs): model
import and monitor routes, API-provider catalog and streaming (OpenAI chat, OpenAI Responses,
the Messages API), serving, tunnel, tasks, plus the host routes for Time-skip
(server/timeskip.mjs) and the tuning plan/reports. src/lib/time-skip.ts renders a real
job's own record.

The UI design is unchanged. The rebuild routed #/tuning to a new TunePanel; that is
reverted: src/screens/ModelRun.tsx and src/main.tsx are the handoff's again (#/tuning
goes where the handoff sends it), and src/components/TunePanel.tsx and
src/styles/tuning.css, which only that route used, are not carried over. Left out of
git on purpose: dist/ (build output), node_modules, and docs/evidence + docs/checkpoints
(170 MB of screenshots, kept in StrataSplit\evidence-archive).

From the owner's rebuild branch strata/rebuild-2026-10.
2026-10-15 10:24:09 +02:00

37 lines
2.2 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { mkdtempSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { spawnSync } from 'node:child_process';
test('model deletion requires unloading, deletes files, and preserves installation on a file error', t => {
const directory=mkdtempSync(join(tmpdir(),'strata-storage-test-'));
t.after(()=>rmSync(directory,{recursive:true,force:true}));
const result=spawnSync(process.execPath,['--input-type=module','-e',`
import assert from 'node:assert/strict';
import fs from 'node:fs';
import {syncBuiltinESMExports} from 'node:module';
import {join} from 'node:path';
const store=await import('./server/store.mjs');
const models=await import('./server/models.mjs');
const {VARIANTS}=await import('./server/catalog.mjs');
const id=VARIANTS[0].id, folder=join(store.MODELS_DIR,id);
const file=join(folder,VARIANTS[0].source.file);
fs.mkdirSync(folder,{recursive:true});fs.writeFileSync(file,'GGUFdisposable fixture');fs.writeFileSync(join(folder,'unrelated.txt'),'keep me');
store.update({installed:{[id]:{installedAt:new Date().toISOString(),simulated:true}},loaded:id,current:id});
models.init({send(){}});
assert.throws(()=>models.remove(id),/Unload/);
assert.ok(fs.existsSync(folder));assert.ok(store.get().installed[id]);
store.update({loaded:null});
const original=fs.rmSync;fs.rmSync=()=>{throw new Error('Permission denied fixture');};syncBuiltinESMExports();
assert.throws(()=>models.remove(id),/Permission denied/);
assert.ok(store.get().installed[id]);assert.ok(fs.existsSync(folder));
fs.rmSync=original;syncBuiltinESMExports();
const library=models.remove(id);
assert.equal(fs.existsSync(file),false);assert.equal(fs.readFileSync(join(folder,'unrelated.txt'),'utf8'),'keep me');assert.equal(store.get().installed[id],undefined);
assert.equal(library.variants.find(v=>v.id===id).state,'available');
`],{cwd:new URL('..',import.meta.url).pathname,env:{...process.env,STRATA_HOME:directory,STRATA_MODELS_DIR:join(directory,'models'),STRATA_REAL_ENGINE:'0'},encoding:'utf8'});
assert.equal(result.status,0,result.stderr||result.stdout);
});