okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-ds-out ac306afb2 into f-own-intaff3a132f

main
21.3 KiB279 linesraw
1// The 0.2.7 speed features have a switch in Expert settings (the model's "Native engine settings"). "Faster long prompts" (Qwen KVA) is OFF by default (owner
2// decision, 26 October) and STRATA_KVA=1 turns it on; the Radeon RX 9000 one is on by default and turning it off writes its entry.
3// Back in its default a switch removes its entries, so a default launch carries none of them. strata_control/speed_switches.py says the same for the
4// Terminal (tests/terminal/test_speed_switches.py).
5import test from 'node:test';
6import assert from 'node:assert/strict';
7import { readFileSync, writeFileSync } from 'node:fs';
8import { join } from 'node:path';
9import { fileURLToPath } from 'node:url';
10import { SPEED_SWITCHES, speedSwitchApplies, speedSwitchIsSet, speedSwitchIsOn, speedSwitchRows, setSpeedSwitch, validateNativeSettings, publicNativeEnv, restoreNativeEnv } from '../server/native-settings.mjs';
11import { nativeFixture } from './helpers/native-fixture.mjs';
12
13const read = rel => readFileSync(fileURLToPath(new URL(rel, import.meta.url)), 'utf8').replace(/\r\n/g, '\n');
14const ENV = {      // what each switch writes outside its default
15  faster_long_prompts: { STRATA_KVA: '1' },
16  faster_12gb_nvidia: { STRATA_ROUTE_PRIOR: '1.5' },
17  faster_radeon_9000: { STRATA_PCIE_FRAC_DEFAULT: 'old' },
18  picture_reader: { STRATA_VISION_TOWER: 'mtmd' },
19};
20/* The fixture's run configs read pictures ("vision"), so a Qwen model also gets the picture reader row (Image reading); the Speed tests below leave it out. */
21const speed = rows => rows.filter(s => s.id !== 'picture_reader');
22const DEFAULT = { faster_long_prompts: 'off', faster_12gb_nvidia: 'off', faster_radeon_9000: 'on', picture_reader: 'on' };
23const RTX3060 = { index: 0, name: 'NVIDIA GeForce RTX 3060', vendor: 'nvidia', arch: '86', vram_gb: 12 };
24const R9700 = { index: 0, name: 'AMD Radeon AI PRO R9700', vendor: 'amd', arch: 'gfx1201', vram_gb: 32 };
25const RX7900 = { index: 0, name: 'AMD Radeon RX 7900 XTX', vendor: 'amd', arch: 'gfx1100', vram_gb: 24 };
26const RTX = { index: 0, name: 'NVIDIA GeForce RTX 4090', vendor: 'nvidia', arch: '89', vram_gb: 24 };
27const STRIX = { index: 0, name: 'AMD Radeon 8060S', vendor: 'amd', arch: 'gfx1151', vram_gb: 96, uma: true };
28
29test('there are exactly five switches in the app, the picture reader among them (the Terminal has one more); each writes the engine names of the contract and has its default (KVA and the 12 GB routing off, the other two on)', () => {
30  assert.deepEqual(SPEED_SWITCHES.map(s => s.id), Object.keys(ENV));
31  for (const sw of SPEED_SWITCHES) {
32    assert.deepEqual(sw.env, ENV[sw.id], sw.id);
33    assert.equal(sw.default, DEFAULT[sw.id], sw.id);
34  }
35});
36
37test('the Terminal\'s Qwen "0.2.6 behaviour" switch is not in the app', () => {
38  assert.ok(!SPEED_SWITCHES.some(s => s.env.STRATA_DEFAULTS || /0\.2\.6 behaviour/.test(s.label)));
39  assert.ok(!Object.values(SPEED_SWITCHES.flatMap(s => Object.keys(s.env))).includes('STRATA_DEFAULTS'));
40});
41
42test('Faster answers on 12 GB NVIDIA cards: only for Qwen on a discrete CUDA card of 13 GiB or less; off by default since 0.2.8 (#4402), On writes STRATA_ROUTE_PRIOR=1.5', () => {
43  const ids = context => speedSwitchRows({}, context).map(r => r.id);
44  assert.deepEqual(ids({ backend: 'cuda', gpus: [RTX3060] }), ['faster_long_prompts', 'faster_12gb_nvidia']);
45  assert.deepEqual(ids({ backend: 'cuda', gpus: [{ ...RTX3060, vram_gb: 13 }] }), ['faster_long_prompts', 'faster_12gb_nvidia'], '13 GiB counts');
46  assert.deepEqual(ids({ backend: 'cuda', gpus: [{ ...RTX3060, vram_gb: 13.5 }] }), ['faster_long_prompts']);
47  assert.deepEqual(ids({ backend: 'cuda', gpus: [{ ...RTX3060, vram_gb: 16 }] }), ['faster_long_prompts'], 'a 16 GB card is not a 12 GB card');
48  assert.deepEqual(ids({ backend: 'cuda', gpus: [RTX] }), ['faster_long_prompts']);
49  assert.deepEqual(ids({ backend: 'cuda', gpus: [RTX, RTX3060] }), ['faster_long_prompts', 'faster_12gb_nvidia'], 'one small card among others');
50  assert.deepEqual(ids({ backend: 'cuda', gpus: [{ ...RTX3060, uma: true }] }), ['faster_long_prompts'], 'not a chip that shares system memory');
51  assert.deepEqual(ids({ backend: 'cuda', gpus: [{ ...RTX3060, integrated: true }] }), ['faster_long_prompts']);
52  assert.deepEqual(ids({ backend: 'cuda', gpus: [{ ...RTX3060, usable: false }] }), ['faster_long_prompts']);
53  assert.deepEqual(ids({ backend: 'cuda', gpus: [{ name: 'GeForce RTX 3060', vram_gb: 12 }] }), ['faster_long_prompts', 'faster_12gb_nvidia'], 'no vendor reported: the name decides');
54  assert.deepEqual(ids({ backend: 'cuda', gpus: [{ name: 'Mystery card', vram_gb: 12 }] }), ['faster_long_prompts']);
55  assert.deepEqual(ids({ backend: 'hip', gpus: [{ name: 'AMD Radeon RX 7700 XT', vendor: 'amd', arch: 'gfx1101', vram_gb: 12 }] }), ['faster_long_prompts'], 'not a Radeon');
56  assert.deepEqual(ids({ backend: 'sycl', gpus: [RTX3060] }), [], 'not a CUDA build');
57  assert.deepEqual(ids({ backend: 'cuda', gpus: [RTX3060], arch: 'qwen35moe' }), [], 'Qwen3.6-35B-A3B: the routing needs 512 experts');
58  assert.deepEqual(ids({ deepseek: true, backend: 'cuda', gpus: [RTX3060] }), [], 'a DeepSeek settings file (no longer run): no switch');
59  // a default launch carries nothing: the engine then runs as 0.2.6 did (STRATA_ROUTE_PRIOR unset = 0)
60  assert.equal(speedSwitchIsOn({}, 'faster_12gb_nvidia'), false);
61  assert.equal(speedSwitchRows({}, { backend: 'cuda', gpus: [RTX3060] }).find(r => r.id === 'faster_12gb_nvidia').on, false);
62  assert.deepEqual(setSpeedSwitch({ PATH: '/bin' }, 'faster_12gb_nvidia', false), { PATH: '/bin' }, 'Off is the default: it writes nothing');
63  // the explicit opt-in the row writes
64  const on = setSpeedSwitch({ PATH: '/bin' }, 'faster_12gb_nvidia', true);
65  assert.deepEqual(on, { PATH: '/bin', STRATA_ROUTE_PRIOR: '1.5' });
66  assert.equal(speedSwitchIsOn(on, 'faster_12gb_nvidia'), true);
67  assert.deepEqual(setSpeedSwitch(on, 'faster_12gb_nvidia', false), { PATH: '/bin' }, 'back to Off removes the entry');
68  // the 0.2.7 "Off" wrote STRATA_ROUTE_PRIOR=0: that file is in the default state now, and On replaces it with 1.5
69  assert.equal(speedSwitchIsOn({ STRATA_ROUTE_PRIOR: '0' }, 'faster_12gb_nvidia'), false);
70  assert.deepEqual(setSpeedSwitch({ STRATA_ROUTE_PRIOR: '0' }, 'faster_12gb_nvidia', true), { STRATA_ROUTE_PRIOR: '1.5' });
71  assert.deepEqual(setSpeedSwitch({ STRATA_ROUTE_PRIOR: '0' }, 'faster_12gb_nvidia', false), {}, 'and Off clears it');
72  // the words say both sides
73  const hint = SPEED_SWITCHES.find(s => s.id === 'faster_12gb_nvidia').hint;
74  assert.match(hint, /faster on 12 GB cards/);
75  assert.match(hint, /Off by default/);
76  assert.match(hint, /long agent sessions it can repeat itself/);
77});
78
79test('a default launch has none of the new environment entries: KVA reads as off, the others as on, and an environment in its default stays as it is', () => {
80  for (const sw of SPEED_SWITCHES) assert.equal(speedSwitchIsSet({}, sw.id), false);
81  const env = { PATH: '/native/bin', STRATA_PREFILL: '2' };
82  for (const sw of SPEED_SWITCHES) assert.deepEqual(setSpeedSwitch(env, sw.id, sw.default === 'on'), env, 'the default state removes nothing that is not the switch\'s');
83  const rows = speedSwitchRows({}, { backend: 'hip', gpus: [R9700] });
84  assert.deepEqual(rows.map(r => [r.id, r.on]), [['faster_long_prompts', false], ['faster_radeon_9000', true]]);
85  assert.deepEqual(rows.map(r => r.default), ['off', 'on']);
86});
87
88test('Faster long prompts: On writes STRATA_KVA=1, Off removes it, and an earlier test build\'s STRATA_KVA=0 shows as Off', () => {
89  const env = { PATH: '/native/bin' };
90  assert.deepEqual(setSpeedSwitch(env, 'faster_long_prompts', true), { PATH: '/native/bin', STRATA_KVA: '1' });
91  assert.deepEqual(setSpeedSwitch({ ...env, STRATA_KVA: '1' }, 'faster_long_prompts', false), env);
92  assert.equal(speedSwitchIsOn({ STRATA_KVA: '1' }, 'faster_long_prompts'), true);
93  assert.equal(speedSwitchIsOn({ STRATA_KVA: '0' }, 'faster_long_prompts'), false, 'stored by the off switch of an earlier build: harmless, and Off is what it is now');
94  assert.equal(speedSwitchIsOn({}, 'faster_long_prompts'), false);
95  assert.deepEqual(setSpeedSwitch({ ...env, STRATA_KVA: '0' }, 'faster_long_prompts', false), env, 'choosing Off again cleans it up');
96  assert.deepEqual(speedSwitchRows({ STRATA_KVA: '0' }, { backend: 'cuda', gpus: [RTX] }).map(r => [r.id, r.on]), [['faster_long_prompts', false]]);
97});
98
99test('each switch outside its default yields exactly its entries and nothing else; back in the default gives back the same environment', () => {
100  const env = { PATH: '/native/bin', STRATA_PREFILL: '2' };
101  for (const sw of SPEED_SWITCHES) {
102    const other = setSpeedSwitch(env, sw.id, sw.default !== 'on');          // the non-default state: KVA on, the others off
103    assert.deepEqual(other, { ...env, ...ENV[sw.id] }, sw.id);
104    assert.equal(speedSwitchIsSet(other, sw.id), true);
105    assert.equal(speedSwitchIsOn(other, sw.id), sw.default !== 'on');
106    for (const another of SPEED_SWITCHES) if (another.id !== sw.id) assert.equal(speedSwitchIsSet(other, another.id), false, `${sw.id} does not touch ${another.id}`);
107    const back = setSpeedSwitch(other, sw.id, sw.default === 'on');
108    assert.deepEqual(back, env, sw.id);
109    assert.equal(JSON.stringify(back), JSON.stringify(env), 'byte for byte, key order included');
110  }
111  assert.throws(() => setSpeedSwitch({}, 'nothing', false), /Unknown speed switch/);
112});
113
114test('a hand-edited file with only some of a switch\'s entries reads as its default and is left alone by an unchanged save', () => {
115  const partial = { STRATA_VISION_TOWER: 'other' };
116  assert.equal(speedSwitchIsOn(partial, 'picture_reader'), true);
117  assert.deepEqual(setSpeedSwitch(partial, 'faster_long_prompts', false), partial);
118  assert.equal(speedSwitchIsOn({ STRATA_KVA: 'yes' }, 'faster_long_prompts'), false, 'only 1 turns it on');
119});
120
121test('a switch shows only where it applies: Qwen on CUDA or HIP, Qwen on a Radeon RX 9000 / R9700; none for a DeepSeek settings file', () => {
122  const ids = context => speedSwitchRows({}, context).map(r => r.id);
123  assert.deepEqual(ids({ backend: 'cuda', gpus: [RTX] }), ['faster_long_prompts']);
124  assert.deepEqual(ids({ backend: 'hip', gpus: [RX7900] }), ['faster_long_prompts']);
125  assert.deepEqual(ids({ backend: 'hip', gpus: [STRIX] }), ['faster_long_prompts'], 'Strix Halo (gfx1151) is not gfx12');
126  assert.deepEqual(ids({ backend: 'hip', gpus: [R9700] }), ['faster_long_prompts', 'faster_radeon_9000']);
127  assert.deepEqual(ids({ backend: 'hip', gpus: [{ name: 'AMD Radeon RX 9070 XT', vendor: 'amd' }] }), ['faster_long_prompts', 'faster_radeon_9000'], 'no arch reported: the card name decides');
128  assert.deepEqual(ids({ backend: 'hip', gpus: [{ name: 'AMD Radeon RX 7900 XT', vendor: 'amd' }] }), ['faster_long_prompts']);
129  assert.deepEqual(ids({ backend: 'cuda', gpus: [RTX, R9700] }), ['faster_long_prompts'], 'the Radeon switch needs the HIP engine');
130  for (const backend of ['sycl', 'metal', 'cpu', null]) assert.deepEqual(ids({ backend, gpus: [R9700] }), [], `Qwen on ${backend}`);
131  assert.deepEqual(ids({ deepseek: true, backend: 'hip', gpus: [R9700] }), [], 'a DeepSeek settings file (no longer run): no switch');
132  assert.deepEqual(ids({ deepseek: true, backend: 'cuda', gpus: [RTX] }), []);
133  assert.deepEqual(ids({}), [], 'nothing is known: nothing is offered');
134});
135
136test('Faster long prompts is for Qwen3.8-Flash-Next only: no row for Qwen3.6-35B-A3B (a run config with an arch)', () => {
137  const ids = context => speedSwitchRows({}, context).map(r => r.id);
138  assert.deepEqual(ids({ backend: 'cuda', gpus: [RTX], arch: null }), ['faster_long_prompts'], 'Flash-Next files have no arch');
139  assert.deepEqual(ids({ backend: 'cuda', gpus: [RTX], arch: 'qwen35moe' }), [], 'Qwen3.6-35B-A3B on CUDA');
140  assert.deepEqual(ids({ backend: 'hip', gpus: [RX7900], arch: 'qwen35moe' }), [], 'and on HIP');
141  assert.deepEqual(ids({ backend: 'hip', gpus: [R9700], arch: 'qwen35moe' }), ['faster_radeon_9000'], 'the Radeon switch is not tied to the model\'s shape');
142  assert.equal(speedSwitchApplies('faster_long_prompts', { backend: 'cuda', gpus: [RTX], arch: 'qwen35moe' }), false);
143});
144
145test('the picture reader: offered for a Qwen model that reads pictures, in the Image reading group, with Strata\'s own and llama.cpp\'s as the two options', () => {
146  const ids = context => speedSwitchRows({}, context).map(r => r.id);
147  for (const backend of ['cuda', 'hip', 'sycl', 'metal', 'cpu', null]) assert.ok(ids({ backend, gpus: [R9700], vision: true }).includes('picture_reader'), `${backend}`);
148  assert.ok(!ids({ backend: 'cuda', gpus: [RTX] }).includes('picture_reader'), 'pictures off');
149  assert.ok(!ids({ deepseek: true, backend: 'cuda', gpus: [RTX], vision: true }).includes('picture_reader'), 'a DeepSeek settings file: no switch');
150  const sw = SPEED_SWITCHES.find(s => s.id === 'picture_reader');
151  assert.deepEqual([sw.group, sw.default, sw.words], ['Image reading', 'on', { on: 'Strata\'s own (recommended)', off: 'llama.cpp\'s' }]);
152  assert.deepEqual(setSpeedSwitch({ PATH: '/bin' }, 'picture_reader', false), { PATH: '/bin', STRATA_VISION_TOWER: 'mtmd' });
153  assert.deepEqual(setSpeedSwitch({ PATH: '/bin', STRATA_VISION_TOWER: 'mtmd' }, 'picture_reader', true), { PATH: '/bin' });
154  const screen = read('../src/components/NativeSettings.tsx');
155  assert.match(screen, /options=\{sw\.words \? \[\{ value: sw\.default, label: sw\.words\[sw\.default\] \}/, 'the two option names, the default first');
156  assert.match(screen, /\{tr\(switchRows\.filter\(sw => switchGroup\(sw\) === group\)\.map\(switchRow\)\)\}<\/section>/, 'a switch of a field group is shown in that group');
157});
158
159test('the environment names round-trip through the validator, the public view and the restore, and other names stay untouched', () => {
160  const all = Object.assign({}, ...Object.values(ENV));
161  assert.deepEqual(validateNativeSettings({ env: all }), { env: all });
162  assert.throws(() => validateNativeSettings({ env: { HOME: '/tmp' } }));
163  assert.throws(() => validateNativeSettings({ env: { DS4_FAST_ATTN: '0' } }), undefined, 'the DeepSeek engine\'s names are no longer shown or edited');
164  const previous = { PATH: '/native/bin', HIP_VISIBLE_DEVICES: '0', ...all };
165  assert.deepEqual(publicNativeEnv(previous), all);
166  assert.deepEqual(restoreNativeEnv({}, previous), { PATH: '/native/bin', HIP_VISIBLE_DEVICES: '0' }, 'every switch back in its default removes only theirs');
167  assert.deepEqual(restoreNativeEnv(all, { PATH: '/native/bin' }), { PATH: '/native/bin', ...all });
168});
169
170function setConfig(f, model, patch) {
171  const path = join(f.repo, `strata-${model}.json`);
172  writeFileSync(path, JSON.stringify({ ...JSON.parse(readFileSync(path, 'utf8')), ...patch }));
173  return path;
174}
175
176test('through the host: the settings answer lists the switches that apply, and KVA on then off gives back the same file', async () => {
177  const f = nativeFixture();
178  try {
179    f.setHardware({ ram_gb: 64, gpus: [R9700] });
180    const path = setConfig(f, 'iq2_xs', { backend: 'hip' });
181    await f.control.refresh();
182    const before = readFileSync(path, 'utf8');
183    const first = f.control.settings('iq2_xs');
184    assert.deepEqual(speed(first.speedSwitches).map(s => [s.id, s.on]), [['faster_long_prompts', false], ['faster_radeon_9000', true]]);
185    assert.deepEqual(speed(first.speedSwitches).map(s => [s.default, s.env]), [['off', ENV.faster_long_prompts], ['on', ENV.faster_radeon_9000]], 'the client writes what the host says');
186    assert.equal('STRATA_KVA' in first.values.env, false, 'default: nothing in the environment');
187
188    // the client turns "Faster long prompts" on: it sends the environment with the entry added
189    const off = f.control.save('iq2_xs', { values: { env: { ...first.values.env, ...ENV.faster_long_prompts } } });
190    const file = JSON.parse(readFileSync(path, 'utf8'));
191    assert.equal(file.env.STRATA_KVA, '1');
192    assert.equal(file.env.PATH, '/native/bin');
193    assert.equal(file.env.STRATA_TOKEN, 'private', 'a credential is kept, not lost behind its mask');
194    assert.equal('STRATA_PCIE_FRAC_DEFAULT' in file.env, false);
195    assert.deepEqual(speed(off.speedSwitches).map(s => [s.id, s.on]), [['faster_long_prompts', true], ['faster_radeon_9000', true]]);
196
197    // and Off again: the entry is gone and the file is as it was
198    const env = { ...off.values.env };
199    delete env.STRATA_KVA;
200    const on = f.control.save('iq2_xs', { values: { env } });
201    assert.deepEqual(speed(on.speedSwitches).map(s => s.on), [false, true]);
202    const after = JSON.parse(readFileSync(path, 'utf8'));
203    assert.deepEqual(after, JSON.parse(before));
204    assert.equal(JSON.stringify(after.env), JSON.stringify(JSON.parse(before).env), 'the same environment, same order');
205  } finally { await f.cleanup(); }
206});
207
208test('through the host: Qwen3.6-35B-A3B (its run config has an arch) gets no Faster long prompts row, a Flash-Next model does', async () => {
209  const f = nativeFixture();
210  try {
211    f.setHardware({ ram_gb: 64, gpus: [RTX] });
212    setConfig(f, 'iq2_xs', { backend: 'cuda' });
213    setConfig(f, 'iq3_s', { backend: 'cuda', arch: 'qwen35moe', model_name: 'qwen3.6-35b-a3b-ud-q4_k_xl' });
214    await f.control.refresh();
215    assert.deepEqual(f.control.settings('iq2_xs').speedSwitches.map(s => s.id), ['faster_long_prompts', 'picture_reader']);
216    assert.deepEqual(f.control.settings('iq3_s').speedSwitches.map(s => s.id), ['picture_reader'], 'Qwen3.6 reads pictures with the same reader');
217  } finally { await f.cleanup(); }
218});
219
220test('through the host: choosing llama.cpp\'s picture reader writes STRATA_VISION_TOWER=mtmd into the model\'s file, and Strata\'s own again gives back the same file', async () => {
221  const f = nativeFixture();
222  try {
223    f.setHardware({ ram_gb: 64, gpus: [RTX] });
224    const path = setConfig(f, 'iq2_xs', { backend: 'cuda' });
225    await f.control.refresh();
226    const before = readFileSync(path, 'utf8');
227    const first = f.control.settings('iq2_xs');
228    const row = first.speedSwitches.find(s => s.id === 'picture_reader');
229    assert.deepEqual([row.on, row.group, row.words.on, row.words.off], [true, 'Image reading', 'Strata\'s own (recommended)', 'llama.cpp\'s']);
230    const picked = f.control.save('iq2_xs', { values: { env: { ...first.values.env, ...ENV.picture_reader } } });
231    assert.equal(JSON.parse(readFileSync(path, 'utf8')).env.STRATA_VISION_TOWER, 'mtmd');
232    assert.equal(picked.speedSwitches.find(s => s.id === 'picture_reader').on, false);
233    const env = { ...picked.values.env };
234    delete env.STRATA_VISION_TOWER;
235    f.control.save('iq2_xs', { values: { env } });
236    assert.deepEqual(JSON.parse(readFileSync(path, 'utf8')), JSON.parse(before));
237  } finally { await f.cleanup(); }
238});
239
240test('through the host: a Qwen model on a PC the engine cannot speed up offers no switch (SYCL, a Mac, no card)', async () => {
241  const f = nativeFixture();
242  try {
243    f.setHardware({ ram_gb: 32, gpus: [{ index: 0, name: 'Intel Arc A750', vendor: 'intel', vram_gb: 8 }] });
244    setConfig(f, 'iq2_xs', { backend: 'sycl' });
245    await f.control.refresh();
246    assert.deepEqual(f.control.settings('iq2_xs').speedSwitches.map(s => s.id), ['picture_reader'], 'no speed switch; the picture reader row is there for a model that reads pictures');
247  } finally { await f.cleanup(); }
248});
249
250test('the Expert settings show the rows in the existing row layout with an On / Off choice (Off recommended for KVA), and the words are in all nine languages', () => {
251  const screen = read('../src/components/NativeSettings.tsx');
252  assert.match(screen, /<h3 className="h4">\{tr\("Speed"\)\}<\/h3>/);
253  assert.match(screen, /<label className="native-setting-row" key=\{sw\.id\}><span><strong>\{tr\(sw\.label\)\}<\/strong><small>\{tr\(sw\.hint\)\}<\/small><\/span><Select /, 'the same row, the same Select');
254  assert.match(screen, /\[\{ value: 'on', label: 'On \(recommended\)' \}, \{ value: 'off', label: 'Off' \}\] : \[\{ value: 'off', label: 'Off \(recommended\)' \}, \{ value: 'on', label: 'On' \}\]/);
255  assert.match(screen, /if \(write\) env\[name\] = value; else delete env\[name\];/, 'the default removes the entries');
256  const languages = ['en', 'zh', 'ja', 'de', 'es', 'ru', 'pt', 'ko', 'fr'];
257  const catalog = lang => JSON.parse(read(`../src/locales/fix-${lang}.json`));
258  const words = [...SPEED_SWITCHES.flatMap(s => [s.label, s.hint, ...Object.values(s.words ?? {})]), 'On (recommended)', 'Off (recommended)'];
259  const english = Object.values(catalog('en'));
260  for (const word of words) assert.ok(english.includes(word), `English catalog: ${word}`);
261  for (const lang of languages.slice(1)) {
262    const translated = Object.values(catalog(lang));
263    const en = catalog('en');
264    for (const [id, text] of Object.entries(en)) if (words.includes(text)) {
265      assert.ok(catalog(lang)[id] && catalog(lang)[id] !== text, `${lang} ${id} is translated`);
266      assert.ok(translated.includes(catalog(lang)[id]));
267      assert.ok(!/\{\d+\}/.test(catalog(lang)[id]));
268    }
269  }
270});
271
272test('the effect texts say what the feature does and what the other choice costs, in plain words', () => {
273  for (const sw of SPEED_SWITCHES) {
274    assert.ok(sw.words ? sw.hint.includes(`Choose ${sw.words.off}`) : sw.default === 'off' ? /Off by default/.test(sw.hint) : /[Tt]urn off/.test(sw.hint), sw.id);
275    assert.ok(sw.hint.length < (sw.id === 'picture_reader' ? 300 : 260), sw.id);   // the picture reader: the owner's approved help line (11-11), 275 characters
276    assert.ok(!/STRATA_|DS4_|env|--/.test(sw.hint), 'no flags or variable names for a non-technical reader');
277  }
278  assert.equal(SPEED_SWITCHES[0].hint, 'Reads very long prompts faster by approximating part of the work. Off by default: answers about long documents can miss or mix up details.');
279});