okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-ds-out ac306afb2 into f-own-intaff3a132f

main
2.4 KiB40 linesraw
1/** A remembered DeepSeek model (Strata 0.2.13 and earlier) at the host's start: not started, the approved refusal logged, and the app's
2 *  settings file (data/state.json) byte-identical afterwards: the product changes nothing of the person's. */
3import test from 'node:test';
4import assert from 'node:assert/strict';
5import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
6import { tmpdir } from 'node:os';
7import { join } from 'node:path';
8import { autostartModel, refusalLine } from '../server/autostart.mjs';
9
10const REAL = { STRATA_REAL_ENGINE: '1' };
11
12test('a remembered DeepSeek model is not started, the refusal is logged, and state.json stays byte-identical', async () => {
13  const home = mkdtempSync(join(tmpdir(), 'strata-autostart-'));
14  try {
15    mkdirSync(join(home, 'data'), { recursive: true });
16    const file = join(home, 'data', 'state.json');
17    const saved = JSON.stringify({ loaded: 'deepseek-v4.1-flash-ist-das-2.00bpw', current: 'deepseek-v4.1-flash-ist-das-2.00bpw', beginner: { x: 1 } }, null, 2);
18    writeFileSync(file, saved);
19    const before = readFileSync(file);
20    process.env.STRATA_HOME = home;
21    const store = await import(`../server/store.mjs?autostart=${Date.now()}`);      // the real store, on this folder
22    const lines = [];
23    const id = autostartModel(store.get(), REAL, (l) => lines.push(l));
24    assert.equal(id, null);
25    assert.deepEqual(lines, [refusalLine('deepseek-v4.1-flash-ist-das-2.00bpw')]);
26    assert.match(lines[0], /is a DeepSeek model\. This version of Strata no longer runs DeepSeek models, so it was not started\.$/);
27    assert.equal(store.get().loaded, 'deepseek-v4.1-flash-ist-das-2.00bpw', 'the remembered value is kept');
28    assert.deepEqual(readFileSync(file), before, 'state.json is byte-identical');
29  } finally {
30    delete process.env.STRATA_HOME;
31    rmSync(home, { recursive: true, force: true });
32  }
33});
34
35test('a remembered Qwen model is still started; nothing without a real engine', () => {
36  assert.equal(autostartModel({ loaded: 'qwen3.8-flash-next-iq3_s' }, REAL, () => assert.fail('no log')), 'qwen3.8-flash-next-iq3_s');
37  assert.equal(autostartModel({ current: 'qwen3.8-flash-next-iq3_s' }, REAL), 'qwen3.8-flash-next-iq3_s');
38  assert.equal(autostartModel({ loaded: 'qwen3.8-flash-next-iq3_s' }, {}), null);
39  assert.equal(autostartModel({ loaded: 'deepseek-v4.1-flash' }, {}, () => assert.fail('no log without a real engine')), null);
40});