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>
64 lines
4.3 KiB
JavaScript
64 lines
4.3 KiB
JavaScript
/** Settings shows the last known update check from this computer and never asks the network when it opens. */
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFile } from 'node:fs/promises';
|
|
import { transform } from 'esbuild';
|
|
|
|
const load = async name => {
|
|
const { code } = await transform(await readFile(new URL(`../src/lib/${name}.ts`, import.meta.url), 'utf8'), { loader: 'ts', format: 'esm' });
|
|
return import(`data:text/javascript;base64,${Buffer.from(code).toString('base64')}`);
|
|
};
|
|
const { readUpdateCache, saveUpdateCache, clearUpdateCache } = await load('update-cache');
|
|
|
|
const store = new Map();
|
|
globalThis.localStorage = { getItem: k => store.get(k) ?? null, setItem: (k, v) => void store.set(k, String(v)), removeItem: k => void store.delete(k) };
|
|
const result = (status = 'available') => ({ checkedAt: '2026-10-19T10:00:00Z', strata: { status: 'current', message: 'ok' }, engine: { status, message: 'x' } });
|
|
|
|
test('a saved check is read back for the same installed versions', () => {
|
|
clearUpdateCache();
|
|
assert.equal(readUpdateCache({ appVersion: '0.2.0', engineVersion: '0.1.45' }), null, 'never checked');
|
|
saveUpdateCache(result(), { appVersion: '0.2.0', engineVersion: '0.1.45' });
|
|
assert.equal(readUpdateCache({ appVersion: '0.2.0', engineVersion: '0.1.45' }).engine.status, 'available');
|
|
});
|
|
|
|
test('a check made for other versions is ignored, so an old "Update available" does not linger after an update', () => {
|
|
saveUpdateCache(result(), { appVersion: '0.2.0', engineVersion: '0.1.45' });
|
|
assert.equal(readUpdateCache({ appVersion: '0.2.0', engineVersion: '0.1.46' }), null);
|
|
assert.equal(readUpdateCache({ appVersion: '0.2.1', engineVersion: '0.1.45' }), null);
|
|
});
|
|
|
|
test('a new Control version, or a version that is not known yet, hides the old result', () => {
|
|
saveUpdateCache(result(), { appVersion: '0.2.0', engineVersion: '0.1.45', controlVersion: '0.1.45' });
|
|
assert.equal(readUpdateCache({ appVersion: '0.2.0', engineVersion: '0.1.45', controlVersion: '0.1.45' }).engine.status, 'available');
|
|
assert.equal(readUpdateCache({ appVersion: '0.2.0', engineVersion: '0.1.45', controlVersion: '0.1.46' }), null, 'Control changed');
|
|
assert.equal(readUpdateCache({ appVersion: null, engineVersion: '0.1.45', controlVersion: '0.1.45' }), null, 'app version still loading');
|
|
assert.equal(readUpdateCache({ appVersion: '0.2.0', engineVersion: '0.1.45' }), null, 'Control version not known');
|
|
});
|
|
|
|
test('unreadable or blocked storage is harmless', () => {
|
|
store.set('strata.update-check.v1', '{not json');
|
|
assert.equal(readUpdateCache({}), null);
|
|
const saved = globalThis.localStorage;
|
|
globalThis.localStorage = { getItem() { throw new Error('blocked'); }, setItem() { throw new Error('blocked'); }, removeItem() { throw new Error('blocked'); } };
|
|
assert.equal(readUpdateCache({}), null);
|
|
assert.doesNotThrow(() => saveUpdateCache(result(), {}));
|
|
assert.doesNotThrow(() => clearUpdateCache());
|
|
globalThis.localStorage = saved;
|
|
});
|
|
|
|
test('opening the Engine and Update settings makes no update call: only a button press does', async () => {
|
|
const src = async name => (await readFile(new URL(`../src/${name}`, import.meta.url), 'utf8')).replace(/\r\n/g, '\n');
|
|
const ops = await src('components/NativeOperations.tsx'), upd = await src('components/SettingsUpdates.tsx'), lib = await src('lib/update-check.ts');
|
|
assert.doesNotMatch(ops, /\/api\/updates\/check/, 'NativeOperations has no direct call');
|
|
assert.doesNotMatch(upd, /\/api\/updates\/check/);
|
|
assert.equal(lib.match(/\/api\/updates\/check/g).length, 1, 'one place asks the host');
|
|
// every caller of the check sits inside a function that only a click starts
|
|
for (const [name, text] of [['NativeOperations', ops], ['SettingsUpdates', upd]]) {
|
|
const body = text.replace(/async function (checkForUpdates|check)\(\) \{[\s\S]*?\n \}\n/, '');
|
|
assert.doesNotMatch(body, /fetchUpdateCheck\(/, `${name}: the check runs only inside the button handler`);
|
|
assert.match(text, /void (checkForUpdates|check)\(\)/, `${name}: a button starts it`);
|
|
}
|
|
// nothing in either component runs a check from an effect
|
|
for (const text of [ops, upd]) for (const effect of text.match(/useEffect\(\(\) => \{[\s\S]*?\n \}, \[[^\]]*\]\);/g) ?? []) assert.doesNotMatch(effect, /fetchUpdateCheck|updates\/check/);
|
|
});
|