// The strata-q4-lite component holds two programs (`strata` for the GGUF build, `strata-q4-lite` for the .strata builds). The catalog row of a .strata size carries // `engine_has_program` (tools/strata_mcp.py qwen4_program_row); false makes the Models panel say "needs a newer engine" through the existing needsNewerEngine. import test from 'node:test'; import assert from 'node:assert/strict'; import { markEngine, engineRefusal, lacksProgram, engineTooOld } from '../server/engine-version.mjs'; import { isQwen4, QWEN4_COMPONENT } from '../server/qwen4.mjs'; const catalog = hasProgram => ({ families: [{ family: 'qwen4-35b-a3b', sizes: [ { id: 'qwen4-35b-a3b-compact', model: 'Compact', ...(hasProgram === undefined ? {} : { engine_has_program: hasProgram }) }, { id: 'qwen4-35b-a3b-ud-q4_k_xl', model: 'UD-Q4_K_XL' }, { id: 'gyro-s', model: 'Gyro-S', engine_min: '0.1.45.1' }, ] }] }); const sizes = marked => Object.fromEntries(marked.families[0].sizes.map(s => [s.id, s.needsNewerEngine])); test('a .strata size whose engine folder has no strata-q4-lite needs a newer engine; the GGUF build never does', () => { const marked = markEngine(catalog(false), { version: '0.2.30', source: 'feed' }); assert.deepEqual(sizes(marked), { 'qwen4-35b-a3b-compact': true, 'qwen4-35b-a3b-ud-q4_k_xl': false, 'gyro-s': false }); }); test('the program is present, not judged (null: no engine installed yet), or not in the catalog: no mark', () => { for (const has of [true, null, undefined]) { assert.equal(sizes(markEngine(catalog(has), { version: '0.2.30', source: 'feed' }))['qwen4-35b-a3b-compact'], false, String(has)); } assert.equal(lacksProgram({ engine_has_program: false }), true); assert.equal(lacksProgram({ engine_has_program: null }), false); assert.equal(lacksProgram(null), false); }); test('the version rule is untouched: a size with engine_min still compares the versions, and a local engine is never too old', () => { assert.equal(sizes(markEngine(catalog(true), { version: '0.1.45', source: 'feed' }))['gyro-s'], true); assert.equal(sizes(markEngine(catalog(true), { version: '0.1.46', source: 'feed' }))['gyro-s'], false); assert.equal(engineTooOld('0.1.45', '0.1.45.1', 'local'), false); assert.equal(sizes(markEngine(catalog(false), { version: '0.2.30', source: 'local' }))['qwen4-35b-a3b-compact'], true, 'a missing program is not a version question: a local engine lacks it too'); }); test('the refusal for a load or install says what is missing in plain words', () => { const cat = markEngine(catalog(false), { version: '0.2.30', source: 'feed' }); const said = engineRefusal(cat, 'qwen4-35b-a3b-compact', { version: '0.2.30' }); assert.match(said, /needs a newer engine/); assert.match(said, /Compact/); assert.doesNotMatch(said, /undefined|null/); assert.equal(engineRefusal(cat, 'qwen4-35b-a3b-ud-q4_k_xl', { version: '0.2.30' }), null); assert.match(engineRefusal(markEngine(catalog(true), { version: '0.1.45' }), 'gyro-s', { version: '0.1.45' }), /needs engine 0\.1\.45\.1 or newer/); }); test('a run config that names the program inside the component is still a Qwen4 config', () => { assert.equal(QWEN4_COMPONENT, 'strata-q4-lite'); for (const exe of ['component:strata-q4-lite', 'component:strata-q4-lite/strata-q4-lite', 'C:/c/shapes/q4_lite/engine/x/strata-q4-lite.exe']) { assert.equal(isQwen4({ exe }), true, exe); } assert.equal(isQwen4({ exe: 'component:strata-hy4' }), false); assert.equal(isQwen4({ exe: 'component:strata-q4-lite-other/x' }), false); });