Files
Strata/app/host/tests/engine-program.test.mjs
Niko1221 7525355088 qwen4: one component, two programs: the GGUF builds run on strata, the Compact / Balanced / Ultra builds on strata-q4-lite, from the same installed folder
- engine_component: component:strata-q4-lite/<program> resolves the component as before (hashes and signature checked) and returns the sibling program; a package without it says Qwen4-35B-A3B needs a newer engine (exit 5); a program name is a plain file name; plain references are byte-identical.
- qwen4_family: STRATA_PROGRAM, GGUF_PROGRAM, exe_reference(build), program_of, engine_has_program, QWEN4_STRATA_ENGINE_MIN (None until packaging reports the first version); shape_engine.exe_name("q4_lite") stays strata.
- shape_engine: EXTRA_PROGRAMS, the install test-start also runs strata-q4-lite --version when present (first token must be its name); a package with only strata still installs and the GGUF build works.
- setup, adopt, launcher, serve, MCP and the host write and read the right reference per build; the catalog row carries engine_has_program for the .strata sizes and the Models panel shows the existing needs-a-newer-engine text and update button.
- package_engine chmods the shape extra programs; Q4-GGUF's packager must --include strata-q4-lite.
- tests: test_q4_programs (23), engine-program.test.mjs, launch tests and the spawn-site count updated.
2026-12-04 09:47:13 +01:00

54 lines
3.5 KiB
JavaScript

// 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);
});