okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
aff3a132f
main
1"""The 0.2.7 speed features and their switches: the contract names, the defaults (Faster long prompts OFF, the other two ON), where each applies, and how the Terminal carries them. 2 3The app (apps/host/server/native-settings.mjs SPEED_SWITCHES) and Control (strata_control/speed_switches.py) say the same thing; the last test reads the 4app's table with node and fails when the two differ. `strata launch` shows the environment entries as rows of its Advanced table and writes them into 5the run config's "env" (`--set STRATA_KVA=1` turns Faster long prompts on); a default launch has none of them. 6""" 7from __future__import annotations 8 9import json 10import shutil 11import subprocess 12import unittest 13from pathlib import Path 14 15from strata_cli .launch import params as P 16from strata_cli .launch import settings as S 17from strata_cli .launch .runner import derive_config 18from strata_control import speed_switches as W 19 20ROOT = Path (__file__ ).resolve ().parents [2 ] 21 22ENV = {# what each switch writes outside its default 23"faster_long_prompts" : {"STRATA_KVA" :"1" }, 24"faster_12gb_nvidia" : {"STRATA_ROUTE_PRIOR" :"1.5" }, 25"faster_radeon_9000" : {"STRATA_PCIE_FRAC_DEFAULT" :"old" }, 26"picture_reader" : {"STRATA_VISION_TOWER" :"mtmd" },# llama.cpp's picture reader instead of Strata's own (owner 11-11) 27"qwen_defaults_026" : {"STRATA_DEFAULTS" :"026" },# the Terminal's troubleshooting switch: not in the app 28} 29DEFAULT = {"faster_long_prompts" :"off" ,"faster_12gb_nvidia" :"off" ,"faster_radeon_9000" :"on" ,"picture_reader" :"on" , 30"qwen_defaults_026" :"off" } 31RTX3060 = {"name" :"NVIDIA GeForce RTX 3060" ,"vendor" :"nvidia" ,"arch" :"86" ,"vram_gb" :12.0 } 32RTX4070S = {"name" :"NVIDIA GeForce RTX 4070 SUPER" ,"vendor" :"nvidia" ,"arch" :"89" ,"vram_gb" :12.0 } 33RTX4060TI16 = {"name" :"NVIDIA GeForce RTX 4060 Ti 16GB" ,"vendor" :"nvidia" ,"arch" :"89" ,"vram_gb" :16.0 } 34R9700 = {"name" :"AMD Radeon AI PRO R9700" ,"vendor" :"amd" ,"arch" :"gfx1201" } 35RX7900 = {"name" :"AMD Radeon RX 7900 XTX" ,"vendor" :"amd" ,"arch" :"gfx1100" } 36STRIX = {"name" :"AMD Radeon 8060S" ,"vendor" :"amd" ,"arch" :"gfx1151" ,"uma" :True } 37RTX = {"name" :"NVIDIA GeForce RTX 4090" ,"vendor" :"nvidia" ,"arch" :"89" } 38# A Qwen3.8-Flash-Next run config (the original, Swift, Coder, Unsloth, Gyro, NVFP4): setup writes no "arch" for it. Qwen3.6-35B-A3B has an engine path of its own: "arch". 39QWEN = {"model_name" :"qwen3.8-flash-next-iq3_s" ,"backend" :"cuda" ,"args" : ["--native" ,"m.gguf" ],"env" : {"PATH" :"/bin" }} 40QWEN36 = {"arch" :"qwen35moe" ,"model_name" :"qwen3.6-35b-a3b-ud-q4_k_xl" ,"backend" :"cuda" ,"args" : ["--native" ,"m.gguf" ],"env" : {"PATH" :"/bin" }} 41DEEPSEEK = {"arch" :"deepseek41" ,"exe" :"C:/s/engine-dsv41/0.1.52-win/strata-dsv41.exe" ,"args" : ["--pack" ,"p" ],"env" : {"DS4_ASYNC_T" :"4" }} 42 43 44def ids (cfg ,gpus ,backend = None ): 45"""The switches the app would show (the Terminal-only one is tested apart).""" 46return [s .id for s in W .applicable (cfg ,gpus ,backend )if not s .terminal_only ] 47 48 49class Contract (unittest .TestCase ): 50def test_five_switches_with_the_contract_names_and_their_defaults (self ): 51self .assertEqual ([s .id for s in W .SWITCHES ],list (ENV )) 52for s in W .SWITCHES : 53self .assertEqual (dict (s .env ),ENV [s .id ],s .id ) 54self .assertEqual (s .default ,DEFAULT [s .id ],s .id ) 55 56def test_an_effect_text_says_what_the_feature_does_in_plain_words (self ): 57for s in W .SWITCHES : 58if s .words :# a choice between two named options: the text names the other one 59self .assertIn ("Choose " + dict (s .words )["off" ],s .effect ,s .id ) 60elif not s .terminal_only : 61self .assertRegex (s .effect ,r"Off by default" if s .default == "off" else r"[Tt]urn off" ,s .id ) 62self .assertNotRegex (s .effect ,r"STRATA_|DS4_|--|env" ,s .id ) 63self .assertEqual (W .SWITCHES [0 ].effect ,"Reads very long prompts faster by approximating part of the work. Off by default: answers about long documents can miss or mix up details." ) 64 65def test_where_each_switch_applies (self ): 66self .assertEqual (ids (QWEN , [RTX ]), ["faster_long_prompts" ]) 67self .assertEqual (ids ({** QWEN ,"backend" :"hip" }, [RX7900 ]), ["faster_long_prompts" ]) 68self .assertEqual (ids ({** QWEN ,"backend" :"hip" }, [STRIX ]), ["faster_long_prompts" ],"Strix Halo is gfx1151, not gfx12" ) 69self .assertEqual (ids ({** QWEN ,"backend" :"hip" }, [R9700 ]), ["faster_long_prompts" ,"faster_radeon_9000" ]) 70self .assertEqual (ids ({"model_name" :"qwen3.8-flash-next-iq3_s" }, [R9700 ],"hip" ), ["faster_long_prompts" ,"faster_radeon_9000" ],"the installed engine's backend when the config has none" ) 71self .assertEqual (ids ({** QWEN ,"backend" :"hip" }, [{"name" :"AMD Radeon RX 9070 XT" ,"vendor" :"amd" }]), ["faster_long_prompts" ,"faster_radeon_9000" ]) 72self .assertEqual (ids ({** QWEN ,"backend" :"cuda" }, [RTX ,R9700 ]), ["faster_long_prompts" ],"the Radeon switch needs the HIP engine" ) 73for backend in ("sycl" ,"metal" ,"cpu" ,None ): 74self .assertEqual (ids ({** QWEN ,"backend" :backend }, [R9700 ]), [],backend ) 75self .assertEqual (ids (DEEPSEEK , [R9700 ]), [],"a DeepSeek config (no longer run): no switch" ) 76self .assertEqual (ids ({"exe" :"C:/x/strata-dsv41.exe" }, [RTX ]), [],"found by the engine's name too" ) 77 78def test_faster_answers_on_12gb_nvidia_cards_only_where_the_engine_routing_default_applies (self ): 79"""The engine turns residency-biased routing on by default on a DISCRETE NVIDIA card of 13 GiB or less in a CUDA build (the Flash-Next shape).""" 80self .assertEqual (ids (QWEN , [RTX3060 ]), ["faster_long_prompts" ,"faster_12gb_nvidia" ]) 81self .assertEqual (ids (QWEN , [RTX4070S ]), ["faster_long_prompts" ,"faster_12gb_nvidia" ]) 82self .assertEqual (ids (QWEN , [{** RTX3060 ,"vram_gb" :13.0 }]), ["faster_long_prompts" ,"faster_12gb_nvidia" ],"13 GiB counts" ) 83self .assertEqual (ids (QWEN , [{** RTX3060 ,"vram_gb" :13.5 }]), ["faster_long_prompts" ]) 84self .assertEqual (ids (QWEN , [RTX4060TI16 ]), ["faster_long_prompts" ],"16 GB is not a 12 GB card" ) 85self .assertEqual (ids (QWEN , [RTX ]), ["faster_long_prompts" ]) 86self .assertEqual (ids (QWEN , [RTX3060 ,RTX ]), ["faster_long_prompts" ,"faster_12gb_nvidia" ],"one small card among others" ) 87self .assertEqual (ids (QWEN , [{** RTX3060 ,"uma" :True }]), ["faster_long_prompts" ],"not a chip that shares system memory" ) 88self .assertEqual (ids (QWEN , [{** RTX3060 ,"integrated" :True }]), ["faster_long_prompts" ]) 89self .assertEqual (ids (QWEN , [{** RTX3060 ,"usable" :False }]), ["faster_long_prompts" ]) 90self .assertEqual (ids ({** QWEN ,"backend" :"hip" }, [{"name" :"AMD Radeon RX 7700 XT" ,"vendor" :"amd" ,"arch" :"gfx1101" ,"vram_gb" :12.0 }]), ["faster_long_prompts" ],"not a Radeon" ) 91self .assertEqual (ids ({** QWEN ,"backend" :"sycl" }, [RTX3060 ]), [],"not a CUDA build" ) 92self .assertEqual (ids (QWEN36 , [RTX3060 ]), [],"Qwen3.6-35B-A3B: the routing needs 512 experts" ) 93self .assertEqual (ids (QWEN , [{"name" :"GeForce RTX 3060" ,"vram_gb" :12.0 }]), ["faster_long_prompts" ,"faster_12gb_nvidia" ],"no vendor reported: the name decides" ) 94self .assertEqual (ids (QWEN , [{"name" :"Mystery card" ,"vram_gb" :12.0 }]), ["faster_long_prompts" ]) 95 96def test_the_12gb_switch_is_off_by_default_and_on_writes_route_prior_1_5 (self ): 97# 0.2.8 (owner, 2026-10-29, #4402): off by default; a default launch carries nothing, so the engine runs as 0.2.6 did 98env = {"PATH" :"/bin" } 99self .assertFalse (W .is_on ({},"faster_12gb_nvidia" )) 100self .assertEqual (W .set_switch (env ,"faster_12gb_nvidia" ,False ),env ,"Off is the default: it writes nothing" ) 101on = W .set_switch (env ,"faster_12gb_nvidia" ,True ) 102self .assertEqual (on , {"PATH" :"/bin" ,"STRATA_ROUTE_PRIOR" :"1.5" }) 103self .assertTrue (W .is_on (on ,"faster_12gb_nvidia" )) 104self .assertEqual (W .set_switch (on ,"faster_12gb_nvidia" ,False ),env ,"back to Off removes the entry" ) 105# 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 106self .assertFalse (W .is_on ({"STRATA_ROUTE_PRIOR" :"0" },"faster_12gb_nvidia" )) 107self .assertEqual (W .set_switch ({"STRATA_ROUTE_PRIOR" :"0" },"faster_12gb_nvidia" ,True ), {"STRATA_ROUTE_PRIOR" :"1.5" }) 108self .assertEqual (W .set_switch ({"STRATA_ROUTE_PRIOR" :"0" },"faster_12gb_nvidia" ,False ), {}) 109sw = W .BY_ID ["faster_12gb_nvidia" ] 110self .assertEqual (sw .default ,"off" ) 111self .assertIn ("faster on 12 GB cards" ,sw .effect ) 112self .assertIn ("Off by default" ,sw .effect ) 113self .assertIn ("long agent sessions it can repeat itself" ,sw .effect ) 114 115def test_the_terminal_only_switch_is_for_qwen_and_never_in_the_app (self ): 116sw = W .BY_ID ["qwen_defaults_026" ] 117self .assertTrue (sw .terminal_only ) 118self .assertEqual (dict (sw .env ), {"STRATA_DEFAULTS" :"026" }) 119self .assertNotIn ("qwen_defaults_026" , [s .id for s in W .app_switches ()]) 120for cfg ,gpus in ((QWEN , [RTX ]), (QWEN36 , [RTX ]), ({** QWEN ,"backend" :"sycl" }, []), ({** QWEN ,"backend" :"cpu" }, [])): 121self .assertIn ("qwen_defaults_026" , [s .id for s in W .applicable (cfg ,gpus )]) 122self .assertNotIn ("qwen_defaults_026" , [s .id for s in W .applicable (DEEPSEEK , [RTX ])],"a DeepSeek config gets no switch" ) 123self .assertEqual (W .set_switch ({"PATH" :"/bin" },sw ,True ), {"PATH" :"/bin" ,"STRATA_DEFAULTS" :"026" }) 124self .assertFalse (W .is_on ({},sw )) 125self .assertEqual (W .set_switch ({"STRATA_DEFAULTS" :"026" },sw ,False ), {}) 126 127def test_faster_long_prompts_is_for_qwen38_flash_next_only (self ): 128"""KVA was measured on the 48-layer / 512-expert Flash-Next shape and the engine declines other shapes: no row for Qwen3.6-35B-A3B (arch qwen35moe) or DeepSeek.""" 129self .assertEqual (ids (QWEN36 , [RTX ]), [],"Qwen3.6-35B-A3B on CUDA: no KVA row" ) 130self .assertEqual (ids ({** QWEN36 ,"backend" :"hip" }, [RX7900 ]), [],"on HIP too" ) 131self .assertEqual (ids ({** QWEN36 ,"backend" :"hip" }, [R9700 ]), ["faster_radeon_9000" ],"the Radeon switch is not tied to the model's shape" ) 132for family in ("qwen3.8-flash-next-iq3_s" ,"swift-1.5-iq3_s" ,"qwen3.8-flash-next-coder-iq3_s" ,"qwen3.8-flash-next-unsloth-ud-q4_k_xl" , 133"qwen3.8-flash-next-gyro-gyro-s" ,"qwen3.8-flash-next-nvfp4-nvfp4" ): 134self .assertEqual (ids ({** QWEN ,"model_name" :family }, [RTX ]), ["faster_long_prompts" ],family ) 135self .assertEqual (ids (DEEPSEEK , [RTX ]), []) 136 137def test_outside_the_default_and_back_is_the_identical_environment (self ): 138env = {"PATH" :"/bin" ,"STRATA_PREFILL" :"2" } 139for s in W .SWITCHES : 140other = W .set_switch (env ,s ,s .default != "on" )# KVA on, the other two off 141self .assertEqual (other , {** env ,** ENV [s .id ]}) 142self .assertTrue (W .is_set (other ,s )) 143self .assertEqual (W .is_on (other ,s ),s .default != "on" ) 144back = W .set_switch (other ,s ,s .default == "on" ) 145self .assertEqual (json .dumps (back ),json .dumps (env ),s .id ) 146 147def test_kva_is_off_by_default_and_an_earlier_builds_zero_shows_as_off (self ): 148self .assertFalse (W .is_on ({},"faster_long_prompts" )) 149self .assertTrue (W .is_on ({"STRATA_KVA" :"1" },"faster_long_prompts" )) 150self .assertFalse (W .is_on ({"STRATA_KVA" :"0" },"faster_long_prompts" ),"stored by the old off switch: harmless, and Off is what it is now" ) 151self .assertFalse (W .is_on ({"STRATA_KVA" :"yes" },"faster_long_prompts" ),"only 1 turns it on" ) 152self .assertEqual (W .set_switch ({"PATH" :"/bin" ,"STRATA_KVA" :"0" },"faster_long_prompts" ,False ), {"PATH" :"/bin" },"choosing Off cleans it up" ) 153 154 155class Terminal (unittest .TestCase ): 156"""`strata launch`: the run config a launch writes.""" 157 158def config (self ,base ,extra = None ): 159return derive_config (base ,S .LaunchSettings (extra = extra or {}),bool_flags = frozenset ()) 160 161def test_a_default_launch_has_none_of_the_new_entries (self ): 162for base in (QWEN ,): 163env = self .config (base ).get ("env" )or {} 164for name in W .env_names (): 165self .assertNotIn (name ,env ,name ) 166self .assertEqual (env ,base ["env" ],"the environment is exactly the installed one" ) 167self .assertEqual (json .dumps (self .config (base ),sort_keys = True ),json .dumps (self .config (base , {}),sort_keys = True )) 168 169def test_each_switch_outside_its_default_by_set_gives_exactly_its_entries (self ): 170for sid ,entries in ENV .items ():# --set STRATA_KVA=1 turns KVA on; the other two are turned off by their entries 171base = QWEN 172cfg = self .config (base ,S .settings_from_pairs ([f" { k } = { v } " for k ,v in entries .items ()])) 173self .assertEqual (cfg ["env" ], {** base ["env" ],** entries },sid ) 174self .assertEqual (cfg ["args" ],base ["args" ],"no engine flag changes" ) 175 176def test_off_again_puts_the_default_back (self ): 177cfg = self .config (QWEN ,S .settings_from_pairs (["STRATA_KVA=off" ])) 178self .assertEqual (cfg ["env" ],QWEN ["env" ]) 179turned_on = {** QWEN ,"env" : {** QWEN ["env" ],"STRATA_KVA" :"1" }} 180self .assertEqual (self .config (turned_on ,S .settings_from_pairs (["STRATA_KVA=off" ]))["env" ],QWEN ["env" ]) 181old = {** QWEN ,"env" : {** QWEN ["env" ],"STRATA_KVA" :"0" }} 182self .assertEqual (self .config (old ,S .settings_from_pairs (["STRATA_KVA=off" ]))["env" ],QWEN ["env" ]) 183 184def test_the_advanced_table_lists_only_the_switches_that_apply (self ): 185def names (cfg ,gpus ,extra = None ): 186rows = P .build_rows (None ,cfg ["args" ],None ,cfg ["env" ],None ,extra or {},P .switch_params (W .applicable (cfg ,gpus ))) 187return [r .name for r in rows if r .name in W .env_names ()] 188# (STRATA_DEFAULTS, the Qwen "0.2.6 behaviour" row, closes every Qwen table) 189self .assertEqual (names (QWEN , [RTX ]), ["STRATA_KVA" ,"STRATA_DEFAULTS" ]) 190self .assertEqual (names (QWEN , [RTX3060 ]), ["STRATA_KVA" ,"STRATA_ROUTE_PRIOR" ,"STRATA_DEFAULTS" ]) 191self .assertEqual (names ({** QWEN ,"backend" :"hip" }, [R9700 ]), ["STRATA_KVA" ,"STRATA_PCIE_FRAC_DEFAULT" ,"STRATA_DEFAULTS" ]) 192self .assertEqual (names ({** QWEN ,"backend" :"sycl" }, [R9700 ]), ["STRATA_DEFAULTS" ]) 193self .assertEqual (names (QWEN36 , [RTX ]), ["STRATA_DEFAULTS" ]) 194 195def test_the_qwen_0_2_6_row_in_the_advanced_table (self ): 196rows = P .build_rows (None ,QWEN ["args" ],None ,QWEN ["env" ],None , {},P .switch_params (W .applicable (QWEN , [RTX ]))) 197row = next (r for r in rows if r .name == "STRATA_DEFAULTS" ) 198self .assertEqual ((row .default ,row .yours ,row .known ), ("off" ,"" ,True )) 199self .assertIn ("Qwen: 0.2.6 behaviour" ,row .description ) 200self .assertIn ("off by default; set 026 to turn on" ,row .description ) 201cfg = derive_config (QWEN ,S .LaunchSettings (extra = S .settings_from_pairs (["STRATA_DEFAULTS=026" ])),bool_flags = frozenset ()) 202self .assertEqual (cfg ["env" ], {** QWEN ["env" ],"STRATA_DEFAULTS" :"026" }) 203self .assertEqual (derive_config (QWEN ,S .LaunchSettings (),bool_flags = frozenset ())["env" ],QWEN ["env" ],"a default launch carries nothing" ) 204 205def test_a_row_shows_its_default_until_it_is_changed_and_explains_itself (self ): 206rows = P .build_rows (None ,QWEN ["args" ],None ,QWEN ["env" ],None , {},P .switch_params (W .applicable (QWEN , [RTX ]))) 207row = next (r for r in rows if r .name == "STRATA_KVA" ) 208self .assertEqual ((row .name ,row .default ,row .tuned ,row .yours ,row .known ), ("STRATA_KVA" ,"off" ,"off" ,"" ,True )) 209self .assertIn ("Faster long prompts" ,row .description ) 210self .assertIn ("off by default; set 1 to turn on" ,row .description ) 211self .assertIn ("answers about long documents can miss or mix up details" ,row .description ) 212on = P .build_rows (None ,QWEN ["args" ],None ,QWEN ["env" ],None , {"STRATA_KVA" :"1" },P .switch_params (W .applicable (QWEN , [RTX ]))) 213self .assertEqual (next (r for r in on if r .name == "STRATA_KVA" ).yours ,"1" ) 214hip = {** QWEN ,"backend" :"hip" } 215radeon = next (r for r in P .build_rows (None ,hip ["args" ],None ,hip ["env" ],None , {},P .switch_params (W .applicable (hip , [R9700 ])))if r .name == "STRATA_PCIE_FRAC_DEFAULT" ) 216self .assertEqual (radeon .default ,"on" ) 217self .assertIn ("on by default; set old to turn off" ,radeon .description ) 218 219 220class PictureReader (unittest .TestCase ): 221"""The picture reader (owner 11-11: "Our tower, the other selectable"): Strata's own by default, llama.cpp's chosen in the settings. The choice is the run 222config's env entry STRATA_VISION_TOWER=mtmd, which the server hands to strata-vision (an older reader ignores it); a default file carries nothing.""" 223PICS = {** QWEN ,"vision" : {"exe" :"strata-vision" ,"mmproj" :"mm.gguf" ,"model" :"m.gguf" ,"gpu" :True }} 224 225def test_it_is_offered_for_every_qwen_model_that_reads_pictures_and_only_there (self ): 226for backend ,gpus in (("cuda" , [RTX ]), ("hip" , [R9700 ]), ("hip" , [STRIX ]), ("sycl" , []), ("metal" , []), ("cpu" , []), (None , [])): 227self .assertIn ("picture_reader" ,ids ({** self .PICS ,"backend" :backend },gpus ),backend ) 228self .assertIn ("picture_reader" ,ids ({** QWEN36 ,"vision" :self .PICS ["vision" ]}, [RTX ]),"Qwen3.6 reads pictures with the same reader" ) 229self .assertNotIn ("picture_reader" ,ids (QWEN , [RTX ]),"pictures off: no reader to choose" ) 230self .assertNotIn ("picture_reader" ,ids ({** DEEPSEEK ,"vision" :self .PICS ["vision" ]}, [RTX ]),"a DeepSeek config gets no switch" ) 231 232def test_the_app_shows_it_in_image_reading_with_two_named_options (self ): 233sw = W .BY_ID ["picture_reader" ] 234self .assertEqual ((sw .label ,sw .group ,sw .default ,dict (sw .words )), ("Picture reader" ,"Image reading" ,"on" , 235 {"on" :"Strata's own (recommended)" ,"off" :"llama.cpp's" })) 236self .assertTrue (all (s .group == "Speed" for s in W .SWITCHES if s .id != "picture_reader" )) 237self .assertLess (len (sw .effect ),300 )# the owner's approved help line (11-11) is 275 characters; the other switches keep 260 238 239def test_llama_cpps_reader_writes_one_entry_and_the_default_writes_none (self ): 240self .assertEqual (W .set_switch ({"PATH" :"/bin" },"picture_reader" ,False ), {"PATH" :"/bin" ,"STRATA_VISION_TOWER" :"mtmd" }) 241self .assertEqual (W .set_switch ({"PATH" :"/bin" ,"STRATA_VISION_TOWER" :"mtmd" },"picture_reader" ,True ), {"PATH" :"/bin" }) 242self .assertTrue (W .is_on ({},"picture_reader" )) 243self .assertFalse (W .is_on ({"STRATA_VISION_TOWER" :"mtmd" },"picture_reader" )) 244cfg = derive_config (self .PICS ,S .LaunchSettings (extra = S .settings_from_pairs (["STRATA_VISION_TOWER=mtmd" ])),bool_flags = frozenset ()) 245self .assertEqual (cfg ["env" ], {** QWEN ["env" ],"STRATA_VISION_TOWER" :"mtmd" }) 246back = derive_config (cfg ,S .LaunchSettings (extra = S .settings_from_pairs (["STRATA_VISION_TOWER=off" ])),bool_flags = frozenset ()) 247self .assertEqual (back ["env" ],QWEN ["env" ],"off puts the default back" ) 248self .assertEqual (derive_config (self .PICS ,S .LaunchSettings (),bool_flags = frozenset ())["env" ],QWEN ["env" ],"a default launch carries nothing" ) 249 250def test_the_terminal_row_names_both_readers_and_its_default (self ): 251rows = P .build_rows (None ,self .PICS ["args" ],None ,self .PICS ["env" ],None , {},P .switch_params (W .applicable (self .PICS , [RTX ]))) 252row = next (r for r in rows if r .name == "STRATA_VISION_TOWER" ) 253self .assertEqual ((row .default ,row .yours ,row .known ), ("auto" ,"" ,True )) 254self .assertIn ("Picture reader (Strata's own by default; set mtmd to use llama.cpp's)." ,row .description ) 255self .assertIn ("Choose llama.cpp's if pictures look misread." ,row .description ) 256 257 258class SameAsTheApp (unittest .TestCase ): 259@ unittest . skipUnless ( shutil . which ( "node" ), "node is not installed" ) 260def test_the_apps_table_has_the_same_names_and_words (self ): 261script = ("import {SPEED_SWITCHES} from './apps/host/server/native-settings.mjs';" 262"console.log(JSON.stringify(SPEED_SWITCHES.map(s=>({id:s.id,label:s.label,hint:s.hint,default:s.default,env:s.env,legacy:s.legacy??{},group:s.group,words:s.words??{}}))))" ) 263out = subprocess .run (["node" ,"--input-type=module" ,"-e" ,script ],cwd = ROOT ,capture_output = True ,text = True ,timeout = 60 ,check = True ).stdout 264app = json .loads (out ) 265self .assertEqual ([a ["id" ]for a in app ], [s .id for s in W .app_switches ()],"the Terminal-only switch is not in the app's table" ) 266for a ,s in zip (app ,W .app_switches ()): 267self .assertEqual (a ["label" ],s .label ) 268self .assertEqual (a ["hint" ],s .effect ,s .id ) 269self .assertEqual (a ["env" ],dict (s .env ),s .id ) 270self .assertEqual (a ["default" ],s .default ,s .id ) 271self .assertEqual (a ["legacy" ],dict (s .legacy ),s .id ) 272self .assertEqual (a ["group" ],s .group ,s .id ) 273self .assertEqual (a ["words" ],dict (s .words ),s .id ) 274 275 276if __name__ == "__main__" : 277unittest .main ()