okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
aff3a132f
main
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 () => { 13const home = mkdtempSync ( join ( tmpdir (), 'strata-autostart-' )); 14try { 15mkdirSync ( join ( home , 'data' ), { recursive :true }); 16const file = join ( home , 'data' , 'state.json' ); 17const 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 ); 18writeFileSync ( file , saved ); 19const before = readFileSync ( file ); 20process . env . STRATA_HOME = home ; 21const store = await import ( `../server/store.mjs?autostart= ${ Date . now ()} ` ); // the real store, on this folder 22const lines = []; 23const id = autostartModel ( store . get (), REAL , ( l ) => lines . push ( l )); 24assert . equal ( id , null ); 25assert . deepEqual ( lines , [ refusalLine ( 'deepseek-v4.1-flash-ist-das-2.00bpw' )]); 26assert . match ( lines [ 0 ], / is a DeepSeek model\. This version of Strata no longer runs DeepSeek models, so it was not started\.$ / ); 27assert . equal ( store . get (). loaded , 'deepseek-v4.1-flash-ist-das-2.00bpw' , 'the remembered value is kept' ); 28assert . deepEqual ( readFileSync ( file ), before , 'state.json is byte-identical' ); 29} finally { 30delete process . env . STRATA_HOME ; 31rmSync ( home , { recursive :true , force :true }); 32} 33}); 34 35test ( 'a remembered Qwen model is still started; nothing without a real engine' , () => { 36assert . equal ( autostartModel ({ loaded :'qwen3.8-flash-next-iq3_s' }, REAL , () => assert . fail ( 'no log' )), 'qwen3.8-flash-next-iq3_s' ); 37assert . equal ( autostartModel ({ current :'qwen3.8-flash-next-iq3_s' }, REAL ), 'qwen3.8-flash-next-iq3_s' ); 38assert . equal ( autostartModel ({ loaded :'qwen3.8-flash-next-iq3_s' }, {}), null ); 39assert . equal ( autostartModel ({ loaded :'deepseek-v4.1-flash' }, {}, () => assert . fail ( 'no log without a real engine' )), null ); 40});