Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
Updates never cross GPU makes: Windows display adapters decide the backend, an installed engine of another make is not replaced (#3688)
Niko122198a139c3c72d
diff --git a/apps/host/server/bundled-engine.mjs b/apps/host/server/bundled-engine.mjsindex 43aab1daf..8ae24287d 100644--- a/apps/host/server/bundled-engine.mjs+++ b/apps/host/server/bundled-engine.mjs@@ -67,13 +67,29 @@ export function nvidiaDriverVersion() {/** Where the builds are published; the wrong-make sentence points here. */export const RELEASES_URL = 'https://github.com/Niko1221/Strata/releases';+/** The PCI vendor ids (`10de`, `1002`, `8086`) of the Windows display adapters; empty off Windows or when the registry cannot be read. */+export function windowsDisplayVendors({ platform = process.platform, run = execFileSync } = {}) {+ const found = new Set();+ if (platform !== 'win32') return found;+ try {+ const out = run('reg', ['query', 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}', '/s', '/v', 'MatchingDeviceId'], { encoding: 'utf8', timeout: 8000, windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'] });+ for (const match of String(out).matchAll(/VEN_([0-9A-F]{4})/gi)) found.add(match[1].toLowerCase());+ } catch { /* no registry access: the tools decide */ }+ return found;+}+/*** The engine family this PC's graphics card needs ('cuda', 'hip', 'sycl'), or null when it cannot be told. The same order as Control* (NVIDIA first, then AMD, then Intel); STRATA_ENGINE_BACKEND wins. Reads only the driver and (Linux) the PCI vendor of the display adapters.*/-export function gpuBackendHere(env = process.env) {+export function gpuBackendHere(env = process.env, { vendors = windowsDisplayVendors() } = {}) {const forced = String(env.STRATA_ENGINE_BACKEND ?? '').trim().toLowerCase();if (forced) return ['cuda', 'hip', 'sycl'].includes(forced) ? forced : null;+ // Windows: the display adapters are the machine's own statement of which cards it has; a leftover nvidia-smi from a card that was+ // taken out must not outvote them (#3688). Same order as Control: NVIDIA, then AMD, then Intel.+ if (vendors.size) {+ for (const [vendor, backend] of [['10de', 'cuda'], ['1002', 'hip'], ['8086', 'sycl']]) if (vendors.has(vendor)) return backend;+ }if (nvidiaDriverVersion()) return 'cuda';try {const base = '/sys/class/drm';diff --git a/apps/host/server/updates.mjs b/apps/host/server/updates.mjsindex e87ddfafb..36ac65425 100644--- a/apps/host/server/updates.mjs+++ b/apps/host/server/updates.mjs@@ -67,6 +67,7 @@ export async function checkComponentUpdates({ control, appUpdater = null, appVerif (engine.status === 'available') Object.assign(engineView, { status: 'available', message: `A new engine is available (${mib(engine.download_bytes)}).` });else if (engine.status === 'install') Object.assign(engineView, { status: 'available', message: `This PC needs an engine to run models. Press Update engine to download it (${mib(engine.download_bytes)}).` });else if (engine.status === 'current' || engine.status === 'failed-before' || engine.status === 'skipped') Object.assign(engineView, { status: 'current', message: 'The engine is up to date.', details: engine.note });+ else if (engine.status === 'wrong-make') Object.assign(engineView, { status: 'unavailable', message: engine.note ?? 'Nothing was changed: the update was for another make of graphics card.', details: (engine.reasons ?? []).join('\n') || undefined });else if (engine.status === 'not-in-feed') Object.assign(engineView, { status: 'current', message: 'No engine update is listed right now.' });else Object.assign(engineView, { status: 'unavailable', message: "There isn't an engine for this PC's graphics card yet.", details: (engine.reasons ?? []).join('\n') || undefined });const control_ = report.control ?? {};diff --git a/apps/host/tests/bundled-engine.test.mjs b/apps/host/tests/bundled-engine.test.mjsindex 726556267..2bfdec3c3 100644--- a/apps/host/tests/bundled-engine.test.mjs+++ b/apps/host/tests/bundled-engine.test.mjs@@ -173,3 +173,15 @@ test('an AMD build on an NVIDIA PC is not unpacked and the sentence names the ritest('wrongMakeNotice names the make, not a list of reasons', () => {assert.equal(wrongMakeNotice({ backend: 'cuda', archs: ['sm_86'] }, 'hip'), 'This Strata is for NVIDIA cards. Your PC has an AMD card: download the AMD version from https://github.com/Niko1221/Strata/releases');});++test('Windows: the display adapters decide the make, and a leftover nvidia-smi does not outvote them (#3688)', async () => {+ const { gpuBackendHere, windowsDisplayVendors } = await import('../server/bundled-engine.mjs');+ assert.equal(gpuBackendHere({}, { vendors: new Set(['1002']) }), 'hip');+ assert.equal(gpuBackendHere({}, { vendors: new Set(['10de', '1002']) }), 'cuda');+ assert.equal(gpuBackendHere({}, { vendors: new Set(['8086']) }), 'sycl');+ assert.equal(gpuBackendHere({ STRATA_ENGINE_BACKEND: 'cuda' }, { vendors: new Set(['1002']) }), 'cuda', 'an explicit choice wins');+ const out = 'MatchingDeviceId REG_SZ PCI/VEN_1002&DEV_7551&SUBSYS_0' + String.fromCharCode(10) + 'MatchingDeviceId REG_SZ PCI/VEN_8086&DEV_46A6';+ assert.deepEqual([...windowsDisplayVendors({ platform: 'win32', run: () => out })].sort(), ['1002', '8086']);+ assert.equal(windowsDisplayVendors({ platform: 'linux', run: () => { throw new Error('must not run'); } }).size, 0);+ assert.equal(windowsDisplayVendors({ platform: 'win32', run: () => { throw new Error('no registry'); } }).size, 0);+});diff --git a/apps/host/tests/component-updates.test.mjs b/apps/host/tests/component-updates.test.mjsindex 8a74ec91c..6a2ed9e52 100644--- a/apps/host/tests/component-updates.test.mjs+++ b/apps/host/tests/component-updates.test.mjs@@ -122,6 +122,11 @@ test('the Settings update check maps the feed to the existing result shape', asyassert.equal(result.engine.status, 'unavailable');assert.doesNotMatch(result.engine.message, /windows-x86_64/);assert.match(result.engine.details, /windows-x86_64/, 'the technical reason is kept for the Details disclosure');+ result = await checkComponentUpdates({ control: make(report({ engine: { installed: { version: '0.1.46', backend: 'hip' }, offered: null, status: 'wrong-make', note: 'The engine installed here is for AMD cards, but this update would give your PC NVIDIA one. Nothing was changed.', reasons: ['x'] } })) });+ assert.equal(result.engine.status, 'unavailable');+ assert.equal(result.engine.canInstall, false);+ assert.match(result.engine.message, /Nothing was changed/, 'the app says why in plain words, not that no engine exists for the card');+ assert.doesNotMatch(result.engine.message, /isn't an engine for this PC/);result = await checkComponentUpdates({ control: make(new Error('this build trusts no update key')) });assert.equal(result.strata.status, 'error');assert.equal(result.engine.status, 'error');diff --git a/strata_cli/update_cmd.py b/strata_cli/update_cmd.pyindex 397fc5c38..613ec3025 100644--- a/strata_cli/update_cmd.py+++ b/strata_cli/update_cmd.py@@ -136,7 +136,7 @@ def _print_check(report: dict) -> None:offered = (eng["offered"] or {}).get("version")text = {"available": f"update available: {installed} -> {offered} ({_mib(eng['download_bytes'])})","install": f"no engine installed yet; {offered} is the one for this PC ({_mib(eng['download_bytes'])})",- "current": f"{installed} is up to date", "none-for-this-pc": eng.get("note") or "the feed has no engine for this PC",+ "current": f"{installed} is up to date", "none-for-this-pc": eng.get("note") or "the feed has no engine for this PC", "wrong-make": eng.get("note") or "nothing was changed","not-in-feed": "the feed lists no engines"}.get(eng["status"], eng.get("note") or eng["status"])print(f" Engine {text}")pick = eng.get("offered")@@ -176,6 +176,7 @@ def run(a) -> int:hardware = updater.detect_hardware()if a.backend:hardware["backend"] = a.backend+ hardware["backend_source"] = "requested" # the person's own decision: the make guard lets it throughlines: list = []cancel = threading.Event()ctx = updater.Context(components=root, source="", trusted={}, hardware=hardware, emit=_emit_factory(a, lines), cancel=cancel,diff --git a/strata_control/engine_component.py b/strata_control/engine_component.pyindex 0cddbf4fb..bb4abcb80 100644--- a/strata_control/engine_component.py+++ b/strata_control/engine_component.py@@ -447,10 +447,21 @@ def detect_backend(environ=None) -> tuple[str | None, str]:return forced, "environment"if host_platform().startswith("macos"):return "metal", "platform"+ # Windows: the display adapters are the machine's own statement about which cards it has, so they decide first. A leftover+ # nvidia-smi from a card that was taken out, or a toolkit installed for another card, must never outvote them: that is how an+ # AMD PC was given a CUDA engine (#3688). A tool is only asked about a make that has an adapter here.+ adapters = windows_display_adapters() if host_platform().startswith("windows") else []+ present = adapter_makes(adapters)+ if present:+ return _first_make(present), "display adapters"probes = (("cuda", ("nvidia-smi", "--query-gpu=name", "--format=csv,noheader")),("hip", ("rocminfo",) if os.name != "nt" else ("hipInfo",)),("sycl", ("sycl-ls",)))+ vendors_here = {a.get("vendor") for a in adapters}+ vendor_of = {"cuda": "10de", "hip": "1002", "sycl": "8086"}for backend, command in probes:+ if vendors_here and vendor_of[backend] not in vendors_here:+ continue # the adapters list no card of this make: a tool that answers is a leftovertool = shutil.which(command[0])if not tool:continue@@ -471,6 +482,48 @@ def detect_backend(environ=None) -> tuple[str | None, str]:return None, "no GPU tool answered"+def _first_make(makes) -> str:+ """The make Strata uses when a PC has cards of several: NVIDIA, then AMD, then Intel (the order of every probe)."""+ return next(m for m in ("cuda", "hip", "sycl") if m in makes)+++def adapter_makes(adapters: list[dict] | None) -> set[str]:+ """The engine families the Windows display adapters call for: cuda (an NVIDIA adapter), hip (an AMD card, not an integrated+ Radeon), sycl (an Intel adapter). Empty when the list is empty. Read-only, nothing is run."""+ makes = set()+ for adapter in adapters or []:+ vendor = adapter.get("vendor")+ if vendor == "10de":+ makes.add("cuda")+ elif vendor == "8086":+ makes.add("sycl")+ if windows_amd_cards(adapters or []):+ makes.add("hip")+ return makes+++def gpu_makes_present() -> set[str]:+ """The engine families this PC has a graphics card for, from the display adapters (Windows) or the PCI vendors (Linux); empty+ when that cannot be read. Used to keep an update on the make the installation was built for (#3688)."""+ if os.name == "nt":+ return adapter_makes(windows_display_adapters())+ return _drm_vendor_makes()+++def _drm_vendor_makes(root: str = "/sys/class/drm") -> set[str]:+ vendors = set()+ try:+ for card in sorted(Path(root).glob("card[0-9]*")):+ if "-" not in card.name:+ try:+ vendors.add((card / "device" / "vendor").read_text().strip().lower())+ except OSError:+ continue+ except OSError:+ return set()+ return {backend for vendor, backend in (("0x10de", "cuda"), ("0x1002", "hip"), ("0x8086", "sycl")) if vendor in vendors}++def _drm_vendor_backend(root: str = "/sys/class/drm") -> str | None:"""Linux without the vendor tools on PATH (a HIP box that runs ROCm from Python wheels has no rocminfo): the PCIvendor of the display adapters decides. NVIDIA 0x10de -> cuda, AMD 0x1002 -> hip, Intel 0x8086 -> sycl, in thatdiff --git a/strata_control/updater.py b/strata_control/updater.pyindex 7f4d719e9..2b9723fac 100644--- a/strata_control/updater.py+++ b/strata_control/updater.py@@ -224,7 +224,8 @@ def detect_hardware(environ=None) -> dict:environ = {**environ, ec.ENV_BACKEND: "hip"}backend, how = ec.detect_backend(environ)hw = {"platform": host_platform(), "backend": backend, "backend_source": how, "runtime": ec.runtime_version(),- "nvidia_driver": None, "cuda_archs": [], "gfx": [], "gpu_names": [], "variant_wanted": prefer}+ "nvidia_driver": None, "cuda_archs": [], "gfx": [], "gpu_names": [], "variant_wanted": prefer,+ "makes": sorted(ec.gpu_makes_present())}if backend == "cuda":hw["nvidia_driver"] = ec.nvidia_driver_version()hw["cuda_archs"] = ec.cuda_archs_present()@@ -477,7 +478,52 @@ def decide_engine(feed: feedmod.Feed, ctx: Context, state: State) -> dict:return _choose_engine(feed, ctx, state)[0]+GPU_MAKES = ("cuda", "hip", "sycl")+++def installed_gpu_makes(root: Path, platform: str | None) -> set[str]:+ """The GPU makes (cuda / hip / sycl) of the engines installed for this platform, whatever their state."""+ try:+ found, _ = ec.scan(root)+ except OSError:+ return set()+ return {item.backend for item in found if item.platform == platform and item.backend in GPU_MAKES}+++def make_guard(ctx: Context) -> str | None:+ """Never cross GPU makes (#3688). An update replaces the engine; it does not convert the PC from one make of card to another,+ and a package for the wrong make can only fail its test start. When the engine already installed is for a different make+ than the one detected:+ - if this PC really has a card of the installed make too (the display adapters / PCI vendors say so), the update stays+ on the installed make (a PC with an NVIDIA card and an AMD card keeps the engine it was set up with);+ - otherwise nothing is chosen and the returned sentence says why.+ An explicit ask (``--backend``, ``STRATA_ENGINE_BACKEND``) is the person's decision and passes. Returns None when the update+ may go on."""+ hw = ctx.hardware+ want = hw.get("backend")+ if want not in GPU_MAKES or hw.get("backend_source") in ("environment", "requested", "installed engine"):+ return None+ have = installed_gpu_makes(ctx.components, hw.get("platform"))+ if not have or want in have:+ return None+ here = set(hw.get("makes") or [])+ keep = [make for make in GPU_MAKES if make in have and make in here]+ if keep:+ ctx.hardware = {**detect_hardware({**ctx.environ, ec.ENV_BACKEND: keep[0]}), "backend_source": "installed engine"}+ return None+ mine = " and ".join(ec.MAKE_NAMES[m] for m in GPU_MAKES if m in have)+ return (f"The engine installed here is for {mine} cards, but this update would give your PC {ec.MAKE_NAMES[want]} one. "+ f"Nothing was changed. If you really changed your graphics card, download the {ec.MAKE_NAMES[want]} version "+ f"from {ec.RELEASES_URL}.")++def _choose_engine(feed: feedmod.Feed, ctx: Context, state: State) -> tuple[dict, feedmod.EnginePackage | None]:+ refusal = make_guard(ctx)+ if refusal:+ installed, _ = installed_engine(ctx.components, {**ctx.hardware, "backend": next(iter(sorted(installed_gpu_makes(ctx.components, ctx.hardware.get("platform")))), None)})+ return {"installed": _engine_view(installed), "offered": None, "reasons": [refusal], "status": "wrong-make", "note": refusal,+ "download_bytes": 0, "previous": state.section("engine").get("previous"), "pinned": state.section("engine").get("pinned"),+ "problem": None}, Noneinstalled, missing_reason = installed_engine(ctx.components, ctx.hardware)sticky = {**ctx.hardware, "installed_variant": installed.variant if installed is not None and installed.backend == "hip" else ""}offered, reasons = feedmod.select_engine([p for p in feed.engine], sticky)@@ -844,6 +890,9 @@ def update_engine(ctx: Context, feed: feedmod.Feed, state: State) -> dict:result["reasons"] = decision["reasons"]return resultroot = ctx.components+ have_makes = installed_gpu_makes(root, pkg.platform)+ if pkg.backend in GPU_MAKES and have_makes and pkg.backend not in have_makes and ctx.hardware.get("backend_source") not in ("environment", "requested"):+ raise UpdateError(f"the {pkg.label} engine is for another make of graphics card than the installed one; nothing was staged", 5)_warn_if_deep(ctx, ec.engine_dir(root) / folder_name(pkg), longpath.LONGEST_IN_PACKAGE.get(pkg.backend, longpath.LONGEST_IN_PACKAGE_DEFAULT) + 1)_free_space_check(root, pkg.size + pkg.installed_bytes, ctx, pkg.sha256, "engine")archive = _download(ctx, "engine", pkg.url, pkg.size, pkg.sha256, f"engine {pkg.label}", feed)diff --git a/tests/terminal/test_make_guard.py b/tests/terminal/test_make_guard.pynew file mode 100644index 000000000..0337f7464--- /dev/null+++ b/tests/terminal/test_make_guard.py@@ -0,0 +1,157 @@+"""#3688: the update path never crosses GPU makes. An AMD R9700 PC (hip rx9070 installed) was given the cuda13 engine because a leftover+nvidia-smi made detection say cuda. Three guards, all tested here with faked hardware:+ 1. detection: on Windows the display adapters decide first, and a tool for a make with no adapter is ignored;+ 2. the update decision: an installed engine of another make is never replaced by one of the detected make (unless the person asks);+ 3. the stage step refuses a package of another make even if a decision slipped it through."""+from __future__ import annotations++import subprocess+import sys+import tempfile+import unittest+from pathlib import Path+from types import SimpleNamespace+from unittest import mock++from strata_control import engine_component as ec, feed as feedmod, updater++WIN = "windows-x86_64"++R9700_ONLY = [{"vendor": "1002", "device": 0x7551, "name": "AMD Radeon AI PRO R9700", "vram_gb": 32.0}]+R9700_AND_NVIDIA = R9700_ONLY + [{"vendor": "10de", "device": 0x2504, "name": "NVIDIA GeForce RTX 3060", "vram_gb": 12.0}]+AMD_IGPU_ONLY = [{"vendor": "1002", "device": 0x164E, "name": "AMD Radeon(TM) Graphics", "vram_gb": 0.5}]+NVIDIA_ONLY = [{"vendor": "10de", "device": 0x2504, "name": "NVIDIA GeForce RTX 3060", "vram_gb": 12.0}]+++def package(backend, variant, archs, version="0.1.47"):+ return feedmod._engine_package({+ "version": version, "platform": WIN, "backend": backend, "variant": variant, "archs": list(archs),+ "min_driver": {"nvidia": "580.65"} if backend == "cuda" else {}, "min_runtime": None, "build_id": f"b-{variant}",+ "format": "zip", "url": f"e-{variant}.zip", "size": 10, "sha256": "a" * 64, "manifest_sha256": "b" * 64,+ "installed_bytes": 20, "notes": ""})+++FEED = SimpleNamespace(engine=[package("cuda", "cuda13", ("sm_75", "sm_86", "sm_120")),+ package("hip", "rdna3", ("gfx1100", "gfx1151")),+ package("hip", "rx9070", ("gfx1200", "gfx1201"))])+++class Detection(unittest.TestCase):+ def detect(self, adapters, tools=("nvidia-smi",)):+ def fake_run(command, **kw):+ return subprocess.CompletedProcess(command, 0, stdout="NVIDIA GeForce RTX 3060\n", stderr="")+ with mock.patch.object(ec.os, "name", "nt"), mock.patch.object(ec, "host_platform", return_value=WIN), \+ mock.patch.object(ec.shutil, "which", lambda name: name if name in tools else None), \+ mock.patch.object(ec.subprocess, "run", fake_run), mock.patch.object(ec, "windows_display_adapters", return_value=adapters):+ return ec.detect_backend({})++ def test_a_leftover_nvidia_smi_does_not_make_an_amd_pc_cuda(self):+ self.assertEqual(self.detect(R9700_ONLY), ("hip", "display adapters"))++ def test_a_leftover_nvidia_smi_beside_only_an_integrated_radeon_is_not_believed_either(self):+ self.assertEqual(self.detect(AMD_IGPU_ONLY), (None, "no GPU tool answered"))++ def test_an_nvidia_pc_is_still_cuda(self):+ self.assertEqual(self.detect(NVIDIA_ONLY), ("cuda", "display adapters"))++ def test_both_makes_keep_the_usual_order(self):+ self.assertEqual(self.detect(R9700_AND_NVIDIA)[0], "cuda")+ self.assertEqual(ec.adapter_makes(R9700_AND_NVIDIA), {"cuda", "hip"})++ def test_adapters_that_cannot_be_read_leave_the_tools_in_charge(self):+ self.assertEqual(self.detect([]), ("cuda", "nvidia-smi"))++ def test_the_environment_override_still_wins(self):+ with mock.patch.object(ec, "windows_display_adapters", return_value=R9700_ONLY):+ self.assertEqual(ec.detect_backend({"STRATA_ENGINE_BACKEND": "cuda"}), ("cuda", "environment"))+++class Decision(unittest.TestCase):+ """Faked hardware and a faked installed engine (a HIP package cannot be built on a machine without the HIP tuning files)."""++ def setUp(self):+ self.temp = tempfile.TemporaryDirectory(prefix="strata-makeguard-")+ self.addCleanup(self.temp.cleanup)+ self.components = Path(self.temp.name) / "components"+ self.state = updater.State(self.components)++ def installed(self, backend, variant, version="0.1.46"):+ """Pretend this engine is installed: what the folder scan and the start path would report."""+ engine = SimpleNamespace(version=version, platform=WIN, backend=backend, variant=variant, build_id="b", root=Path("x") / f"{version}-{backend}", signature="s")+ for patch in (mock.patch.object(ec, "scan", return_value=([engine], [])),+ mock.patch.object(updater, "installed_engine", lambda root, hardware: (engine if hardware.get("backend") == backend else None, None))):+ patch.start()+ self.addCleanup(patch.stop)++ def hardware(self, backend, makes, source="nvidia-smi", **extra):+ return {"platform": WIN, "backend": backend, "backend_source": source, "runtime": None, "nvidia_driver": "610.47",+ "cuda_archs": ["sm_86"] if backend == "cuda" else [], "gfx": ["gfx1201"] if backend == "hip" else [], "gpu_names": [],+ "makes": list(makes), **extra}++ def ctx(self, hardware):+ return updater.Context(components=self.components, source="", trusted={}, hardware=hardware, environ={})++ def test_the_r9700_case_detection_says_cuda_but_the_adapters_list_only_the_amd_card_so_the_update_stays_hip(self):+ self.installed("hip", "rx9070")+ ctx = self.ctx(self.hardware("cuda", ["hip"])) # what a leftover nvidia-smi said+ with mock.patch.object(updater, "detect_hardware", return_value=self.hardware("hip", ["hip"])):+ report, pkg = updater._choose_engine(FEED, ctx, self.state)+ self.assertEqual(ctx.hardware["backend"], "hip")+ self.assertEqual(ctx.hardware["backend_source"], "installed engine")+ self.assertEqual((pkg.backend, pkg.variant), ("hip", "rx9070"))+ self.assertEqual(report["status"], "available")++ def test_with_no_card_of_the_installed_make_the_update_is_refused_in_plain_words(self):+ self.installed("hip", "rx9070")+ report, pkg = updater._choose_engine(FEED, self.ctx(self.hardware("cuda", ["cuda"])), self.state)+ self.assertIsNone(pkg)+ self.assertEqual(report["status"], "wrong-make")+ for word in ("AMD", "NVIDIA", "Nothing was changed"):+ self.assertIn(word, report["note"])+ self.assertIsNone(report["offered"])+ self.assertEqual(report["installed"]["backend"], "hip")++ def test_cards_unreadable_and_a_different_make_installed_also_refuses(self):+ self.installed("hip", "rx9070")+ report, pkg = updater._choose_engine(FEED, self.ctx(self.hardware("cuda", [])), self.state)+ self.assertEqual((report["status"], pkg), ("wrong-make", None))++ def test_nothing_installed_yet_is_not_blocked(self):+ with mock.patch.object(ec, "scan", return_value=([], [])):+ report, pkg = updater._choose_engine(FEED, self.ctx(self.hardware("cuda", ["cuda"])), self.state)+ self.assertEqual((report["status"], pkg.backend), ("install", "cuda"))++ def test_the_same_make_updates_as_before(self):+ self.installed("cuda", "cuda13", version="0.1.46")+ report, pkg = updater._choose_engine(FEED, self.ctx(self.hardware("cuda", ["cuda"])), self.state)+ self.assertEqual((report["status"], pkg.backend, pkg.variant), ("available", "cuda", "cuda13"))++ def test_the_cuda_pc_with_an_nvidia_engine_does_not_flip_to_amd(self):+ self.installed("cuda", "cuda13")+ ctx = self.ctx(self.hardware("cuda", ["cuda", "hip"]))+ report, pkg = updater._choose_engine(FEED, ctx, self.state)+ self.assertEqual(pkg.backend, "cuda")++ def test_an_explicit_backend_is_the_persons_decision_and_passes(self):+ self.installed("hip", "rx9070")+ for source in ("requested", "environment"):+ self.assertIsNone(updater.make_guard(self.ctx(self.hardware("cuda", ["cuda"], source=source))), source)++ def test_the_stage_step_refuses_a_package_of_another_make_even_if_a_decision_slipped_it_through(self):+ self.installed("hip", "rx9070")+ ctx = self.ctx(self.hardware("cuda", ["cuda"]))+ cuda = package("cuda", "cuda13", ("sm_86",))+ with mock.patch.object(updater, "_choose_engine", return_value=({"status": "available", "installed": None}, cuda)), mock.patch.object(updater, "_download", side_effect=AssertionError("downloaded")):+ with self.assertRaises(updater.UpdateError) as caught:+ updater.update_engine(ctx, FEED, self.state)+ self.assertIn("another make", str(caught.exception))+++class Host(unittest.TestCase):+ def test_the_app_shows_the_sentence_not_the_no_engine_for_this_card_text(self):+ text = (Path(__file__).resolve().parents[2] / "apps" / "host" / "server" / "updates.mjs").read_text(encoding="utf-8")+ self.assertIn("engine.status === 'wrong-make'", text)+++if __name__ == "__main__":+ unittest.main()diff --git a/tests/terminal/test_sycl_package.py b/tests/terminal/test_sycl_package.pyindex be9ac3147..80d6f904a 100644--- a/tests/terminal/test_sycl_package.py+++ b/tests/terminal/test_sycl_package.py@@ -56,7 +56,7 @@ class ArcChoice(unittest.TestCase):mock.patch.object(ec, "host_platform", return_value=platform), \mock.patch.object(updater, "host_platform", return_value=platform), \mock.patch.object(ec, "_drm_vendor_backend", lambda: real(drm)), \- mock.patch.object(ec, "_windows_vendor_backend", lambda: real(drm)): # the test PC may be Windows: either probe answers+ mock.patch.object(ec, "windows_display_adapters", return_value=[]), mock.patch.object(ec, "_windows_vendor_backend", lambda: real(drm)): # the test PC may be Windows: either probe answersreturn updater.detect_hardware(environ or {})def pick(self, hardware):