Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree (570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base = the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main). Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details, conflict table and left-out files are in docs/upstream.md. Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61), docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out. scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run"). Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR macros on. No GPU run, no quality gate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
58 lines
3.8 KiB
JavaScript
58 lines
3.8 KiB
JavaScript
import { fileURLToPath } from 'node:url';
|
|
import assert from 'node:assert/strict';
|
|
import { test } from 'node:test';
|
|
import { readFile } from 'node:fs/promises';
|
|
import { transform } from 'esbuild';
|
|
import { migrateSetup } from '../server/setup.mjs';
|
|
const { code } = await transform(await readFile(new URL('../src/lib/lifecycle.ts', import.meta.url), 'utf8'), { loader: 'ts', format: 'esm' });
|
|
const { lifecyclePolicy } = await import(`data:text/javascript;base64,${Buffer.from(code).toString('base64')}`);
|
|
|
|
test('old setup steps map once and preserve selections and completed work', () => {
|
|
const choices = { variantId:'fixture', profile:'performance', contextLength:'8k', batch:1024, batchAuto:false };
|
|
const history = [{step:3, at:'fixture'}];
|
|
for (const [oldStep, expected] of [[1,1],[2,2],[3,2],[4,3],[5,4]]) {
|
|
const original = { step:oldStep, choices, history, dismissed:true, complete:false };
|
|
const migrated = migrateSetup(original);
|
|
assert.equal(migrated.step, expected); assert.equal(migrated.flowVersion, 2);
|
|
assert.deepEqual(migrated.choices, choices); assert.deepEqual(migrated.history, history);
|
|
assert.equal(migrated.dismissed, true); assert.equal(migrated.complete, false);
|
|
assert.deepEqual(migrateSetup(migrated), migrated);
|
|
assert.equal(original.step, oldStep);
|
|
}
|
|
});
|
|
|
|
test('shared lifecycle policy blocks queued, active, disconnected and unknown status', () => {
|
|
const idle = {connected:true, streaming:false, stats:{running:0, waiting:0}, busy:{}};
|
|
assert.equal(lifecyclePolicy(idle).allowed, true);
|
|
for (const patch of [
|
|
{stats:{running:0, waiting:2}}, {stats:{running:1, waiting:0}}, {streaming:true},
|
|
{connected:false}, {stats:null}, {stats:{running:0}}, {stats:{running:0,waiting:NaN}},
|
|
{busy:{restart:true}}, {busy:{unload:true}}, {busy:{'load:fixture':true}},
|
|
]) assert.equal(lifecyclePolicy({...idle, ...patch}).allowed, false, JSON.stringify(patch));
|
|
assert.match(lifecyclePolicy({...idle, stats:{running:0,waiting:2}}).reason, /2 queued/);
|
|
assert.match(lifecyclePolicy({...idle, stats:null}).reason, /unavailable/);
|
|
assert.equal(lifecyclePolicy({...idle, busy:{'install:fixture':true}}).allowed, true);
|
|
});
|
|
|
|
test('blocked lifecycle writes do not change config; save-only still works', async () => {
|
|
const { build } = await import('esbuild');
|
|
const { createRequire } = await import('node:module');
|
|
const { outputFiles } = await build({entryPoints:[fileURLToPath(new URL('../src/lib/store.ts',import.meta.url))],bundle:true,write:false,platform:'node',format:'cjs'});
|
|
const mod={exports:{}}; new Function('require','module','exports','matchMedia',outputFiles[0].text)(createRequire(import.meta.url),mod,mod.exports,()=>({addEventListener(){},matches:false}));
|
|
const store=mod.exports; const originalFetch=globalThis.fetch; const requests=[];
|
|
globalThis.fetch=async (url, options) => {requests.push([url,options]); return new Response(JSON.stringify({expert:[],beginner:{contextLength:'recommended'},engine:{running:false}}),{status:200});};
|
|
try {
|
|
for (const stats of [null,{running:0,waiting:2}]) {
|
|
Object.assign(store.getState(),{connection:'live',serving:stats ? {stats} : null,library:{mode:'real',variants:[],loaded:'fixture'},busy:{}});
|
|
await assert.rejects(store.saveEngine({expert:[]},true,true),/unavailable|queued/);
|
|
assert.equal(await store.loadVariant('fixture'),false);
|
|
assert.equal(await store.unloadModel(),false);
|
|
assert.equal(await store.restartEngine(),false);
|
|
assert.equal(requests.length,0);
|
|
for(const toast of store.getState().toasts) store.holdToast(toast.id);
|
|
}
|
|
await store.saveEngine({expert:[]},true,false);
|
|
assert.equal(requests.length,1); assert.equal(requests[0][1].method,'PATCH');
|
|
} finally {globalThis.fetch=originalFetch; for(const toast of store.getState().toasts)store.holdToast(toast.id);}
|
|
});
|