From 604e23cd9a3995919180a5d660ba95337daef76c Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Mon, 19 Oct 2026 11:35:23 +0200 Subject: [PATCH] Engine-less app update: tauri.update.conf.json drops engine-bundle so one latest.json entry per OS fits every installer variant; tests for the overlay, for the engine-less update on an installed AMD engine, and for the release engine selection (CUDA 13/12 by driver and card, HIP by gfx, Metal) --- apps/desktop/src-tauri/tauri.update.conf.json | 7 ++ apps/host/tests/bundled-engine.test.mjs | 24 +++++ tests/terminal/test_release_config.py | 29 +++++++ tests/terminal/test_release_matrix.py | 87 +++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 apps/desktop/src-tauri/tauri.update.conf.json create mode 100644 tests/terminal/test_release_matrix.py diff --git a/apps/desktop/src-tauri/tauri.update.conf.json b/apps/desktop/src-tauri/tauri.update.conf.json new file mode 100644 index 00000000..3fd40310 --- /dev/null +++ b/apps/desktop/src-tauri/tauri.update.conf.json @@ -0,0 +1,7 @@ +{ + "bundle": { + "resources": { + "resources/engine-bundle": null + } + } +} diff --git a/apps/host/tests/bundled-engine.test.mjs b/apps/host/tests/bundled-engine.test.mjs index a6e6f93b..29a369ee 100644 --- a/apps/host/tests/bundled-engine.test.mjs +++ b/apps/host/tests/bundled-engine.test.mjs @@ -126,3 +126,27 @@ test('an older driver gets only the build it can run; a driver below both gets t assert.deepEqual(readdirSync(v.engine).sort(), [n12, n13].sort()); } finally { t.cleanup(); u.cleanup(); v.cleanup(); } }); + +// The app update (latest.json) is built without engine-bundle (tauri.update.conf.json), so one update fits every installer variant. +test('an engine-less app update (no engine-bundle folder, or one holding only .gitignore) leaves the installed engines exactly as they are', async () => { + const t = setup(); + try { + const amd = makePackage(t.engine, '0.1.45.3', { platform: 'windows-x86_64', backend: 'hip', variant: 'rx9070' }); + const before = readFileSync(join(t.engine, amd, 'engine-component.json'), 'utf8'); + assert.equal((await installBundledEngine({ bundleDir: join(t.base, 'no-such-engine-bundle'), components: t.components })).action, 'none'); + writeFileSync(join(t.bundle, '.gitignore'), '*\n!.gitignore\n'); + assert.equal((await installBundledEngine({ bundleDir: t.bundle, components: t.components, platform: 'windows-x86_64' })).action, 'none'); + assert.deepEqual(readdirSync(t.engine), [amd]); + assert.equal(readFileSync(join(t.engine, amd, 'engine-component.json'), 'utf8'), before); + } finally { t.cleanup(); } +}); + +test('why the update carries no engine: a CUDA installer on an AMD PC would copy its CUDA engine beside the AMD one (no NVIDIA driver to filter by)', async () => { + const t = setup(); + try { + const amd = makePackage(t.engine, '0.1.45.3', { platform: 'windows-x86_64', backend: 'hip', variant: 'rx9070' }); + const cuda = makePackage(t.bundle, '0.1.45.3', { platform: 'windows-x86_64', variant: 'cuda13', minDriver: '580.65' }); + assert.equal((await installBundledEngine({ bundleDir: t.bundle, components: t.components, driver: null })).action, 'installed'); + assert.deepEqual(readdirSync(t.engine).sort(), [amd, cuda].sort(), 'the AMD engine stays; a useless CUDA engine is added'); + } finally { t.cleanup(); } +}); diff --git a/tests/terminal/test_release_config.py b/tests/terminal/test_release_config.py index aaf5b25c..8e563cd8 100644 --- a/tests/terminal/test_release_config.py +++ b/tests/terminal/test_release_config.py @@ -12,6 +12,19 @@ def load(name: str) -> dict: return json.loads((TAURI / name).read_text(encoding="utf-8-sig")) +def merge_patch(base, patch): + """RFC 7396, the way `tauri build --config ` layers an overlay: a null removes the key.""" + if not isinstance(patch, dict): + return patch + out = dict(base) if isinstance(base, dict) else {} + for key, value in patch.items(): + if value is None: + out.pop(key, None) + else: + out[key] = merge_patch(out.get(key), value) + return out + + class ReleaseConfig(unittest.TestCase): def test_every_installer_bundles_the_engine(self): self.assertEqual(load("tauri.conf.json")["bundle"]["resources"]["resources/engine-bundle"], "engine-bundle") @@ -29,6 +42,22 @@ class ReleaseConfig(unittest.TestCase): self.assertEqual(up["endpoints"], ["https://github.com/Niko1221/Strata/releases/latest/download/latest.json"]) self.assertNotIn("REPLACE", up["pubkey"]) + def test_the_update_overlay_drops_only_the_engine(self): + """The app update (latest.json) is built with tauri.update.conf.json: the same app without engine-bundle, so one update + fits every installer variant (CUDA 13, CUDA 12, AMD) and downloads 0 engine bytes. Engines come per card from the feed.""" + full = load("tauri.conf.json") + update = merge_patch(full, load("tauri.update.conf.json")) + self.assertNotIn("resources/engine-bundle", update["bundle"]["resources"]) + self.assertEqual({k: v for k, v in full["bundle"]["resources"].items() if k != "resources/engine-bundle"}, update["bundle"]["resources"]) + self.assertEqual({k: v for k, v in full["bundle"].items() if k != "resources"}, {k: v for k, v in update["bundle"].items() if k != "resources"}) + self.assertEqual(full["plugins"], update["plugins"]) # same key, same endpoint: it is the same app + self.assertNotIn("endpoints", load("tauri.update.conf.json").get("plugins", {})) + + def test_one_endpoint_and_no_variant_specific_updater_config(self): + """Three platform keys in one latest.json is the whole design; a variant-specific endpoint would give an AMD or CUDA 12 PC another variant's installer.""" + for name in ("tauri.conf.json", "tauri.release.conf.json", "tauri.tester.conf.json", "tauri.update.conf.json"): + self.assertNotIn("{{", json.dumps(load(name).get("plugins", {})), name) + if __name__ == "__main__": unittest.main() diff --git a/tests/terminal/test_release_matrix.py b/tests/terminal/test_release_matrix.py new file mode 100644 index 00000000..00f2f57f --- /dev/null +++ b/tests/terminal/test_release_matrix.py @@ -0,0 +1,87 @@ +"""The 0.2.0-beta release set as a signed feed offers it: one engine package per platform/backend/variant (values copied from the +packages' engine-component.json), and what `feed.select_engine` hands each kind of PC. This is the evidence that engine updates +reach every installer variant by card, so the app update can stay engine-less (tauri.update.conf.json).""" +from __future__ import annotations + +import unittest + +from strata_control import feed as feedmod + +V = "0.1.45.3" +SM_NEW = ("sm_75", "sm_86", "sm_89", "sm_120", "compute_120") # the CUDA 13 packages +SM_OLD = ("sm_60", "sm_61", "sm_70", "sm_75", "sm_80", "sm_86", "sm_89", "compute_89") # the CUDA 12 packages (Pascal and Volta) + + +def pkg(platform, backend, variant, archs, driver=None): + return {"version": V, "platform": platform, "backend": backend, "variant": variant, "archs": list(archs), + "min_driver": {"nvidia": driver} if driver else {}, "min_runtime": None, + "build_id": f"rel-{platform}-{backend}-{variant}", "format": "tar.gz", "url": f"strata-engine-{platform}-{variant}.tar.gz", + "size": 1000, "sha256": "a" * 64, "manifest_sha256": "b" * 64, "installed_bytes": 2000, "notes": ""} + + +RELEASE = [ + pkg("windows-x86_64", "cuda", "cuda13", SM_NEW, "580.65"), + pkg("windows-x86_64", "cuda", "cuda12", SM_OLD, "576.02"), + pkg("windows-x86_64", "hip", "rx9070", ("gfx1200", "gfx1201")), + pkg("linux-x86_64", "cuda", "cuda13", SM_NEW, "580.65"), + pkg("linux-x86_64", "cuda", "cuda12", SM_OLD, "575.51"), + pkg("linux-x86_64", "hip", "rx9070", ("gfx1200", "gfx1201")), + pkg("linux-x86_64", "hip", "rx7900", ("gfx1100", "gfx1101", "gfx1102")), + pkg("macos-arm64", "metal", "", ("apple-gpu",)), +] + + +def pc(platform, backend, driver=None, sm=(), gfx=()): + return {"platform": platform, "backend": backend, "runtime": "0.2.0", "nvidia_driver": driver, "cuda_archs": list(sm), "gfx": list(gfx)} + + +class ReleaseSelection(unittest.TestCase): + def pick(self, hardware): + best, reasons = feedmod.select_engine([feedmod._engine_package(p) for p in RELEASE], hardware) + return (best.platform, best.backend, best.variant) if best else None, reasons + + def test_every_release_variant_is_chosen_by_some_pc(self): + chosen = { + self.pick(pc("windows-x86_64", "cuda", "590.10", ["sm_120"]))[0], # RTX 5070 + self.pick(pc("windows-x86_64", "cuda", "576.02", ["sm_61"]))[0], # GTX 1080 on an older driver + self.pick(pc("windows-x86_64", "hip", gfx=["gfx1201"]))[0], # RX 9070 + self.pick(pc("linux-x86_64", "cuda", "615.71", ["sm_86"]))[0], # RTX 3060 + self.pick(pc("linux-x86_64", "cuda", "575.51", ["sm_60"]))[0], # Tesla P100 + self.pick(pc("linux-x86_64", "hip", gfx=["gfx1201"]))[0], # Radeon AI PRO R9700 + self.pick(pc("linux-x86_64", "hip", gfx=["gfx1100"]))[0], # RX 7900 XTX + self.pick(pc("macos-arm64", "metal"))[0], + } + self.assertEqual(chosen, {(p["platform"], p["backend"], p["variant"]) for p in RELEASE}) + + def test_cuda_13_or_12_follows_the_driver_and_the_card(self): + win = "windows-x86_64" + self.assertEqual(self.pick(pc(win, "cuda", "580.65", ["sm_86"]))[0][2], "cuda13") + self.assertEqual(self.pick(pc(win, "cuda", "590.10", ["sm_120"]))[0][2], "cuda13") + got, why = self.pick(pc(win, "cuda", "576.02", ["sm_120"])) # a new card on an older driver: CUDA 12 reaches it by PTX + self.assertEqual(got[2], "cuda12") + self.assertTrue(any("580.65" in r for r in why)) + self.assertEqual(self.pick(pc(win, "cuda", "615.71", ["sm_70"]))[0][2], "cuda12", "Volta is only in the CUDA 12 build") + self.assertEqual(self.pick(pc("linux-x86_64", "cuda", "575.51", ["sm_75"]))[0][2], "cuda12") + self.assertEqual(self.pick(pc("linux-x86_64", "cuda", "580.65", ["sm_75"]))[0][2], "cuda13") + + def test_a_driver_that_is_too_old_gets_no_engine_and_a_reason(self): + got, why = self.pick(pc("windows-x86_64", "cuda", "551.00", ["sm_86"])) + self.assertIsNone(got) + self.assertTrue(any("576.02" in r for r in why) and any("580.65" in r for r in why)) + + def test_amd_gets_its_own_build_and_never_a_cuda_one(self): + self.assertEqual(self.pick(pc("linux-x86_64", "hip", gfx=["gfx1200"]))[0][2], "rx9070") + self.assertEqual(self.pick(pc("linux-x86_64", "hip", gfx=["gfx1102"]))[0][2], "rx7900") + got, why = self.pick(pc("windows-x86_64", "hip", gfx=["gfx1100"])) # no Windows RX 7000 build in this release + self.assertIsNone(got) + self.assertTrue(any("gfx1100" in r for r in why)) + for hw in (pc("windows-x86_64", "hip", gfx=["gfx1201"]), pc("linux-x86_64", "hip", gfx=["gfx1201"])): + self.assertEqual(self.pick(hw)[0][1], "hip") + + def test_the_platform_decides_first(self): + self.assertIsNone(self.pick(pc("macos-arm64", "cuda", "590.10", ["sm_86"]))[0]) + self.assertEqual(self.pick(pc("macos-arm64", "metal"))[0], ("macos-arm64", "metal", "")) + + +if __name__ == "__main__": + unittest.main()