Files
leleka/engine/strata/tests/terminal/test_release_keys.py
T
Pavlo RatushnyiandClaude Sonnet 5.5 87e2633afe engine/strata: bring the Strata subtree to upstream 41cf05a0 (engine 0.1.50) with the local patches re-applied
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>
2026-10-25 12:49:15 +01:00

50 lines
2.6 KiB
Python

"""The keys shipped with a release build (strata_control/update_keys.json): the release feed key and the Tauri app key are there,
the tester / local-test keys are not (they come with STRATA_UPDATE_TRUSTED_KEYS), and a feed is verified against them."""
from __future__ import annotations
import json
import os
import tempfile
import unittest
from pathlib import Path
from unittest import mock
from strata_control import feed as feedmod, signing
from tests.terminal import update_fixture as fx
ROOT = Path(__file__).resolve().parents[2]
RELEASE_KEY_ID = "5d1bc23abbeffd0d"
TAURI_CONF = ROOT / "apps" / "desktop" / "src-tauri" / "tauri.conf.json"
class ShippedKeys(unittest.TestCase):
def test_the_release_feed_key_is_shipped_and_valid(self):
with mock.patch.dict(os.environ, {signing.ENV_EXTRA_KEYS: ""}):
keys = signing.load_trusted_keys()
self.assertEqual(list(keys), [RELEASE_KEY_ID]) # only the release key: no tester or local-test key in a release build
self.assertEqual(signing.key_id_of(keys[RELEASE_KEY_ID]), RELEASE_KEY_ID)
def test_the_app_key_is_the_one_in_the_tauri_config(self):
shipped = json.loads((ROOT / "strata_control" / "update_keys.json").read_text(encoding="utf-8-sig"))["app_minisign_public"]
conf = json.loads(TAURI_CONF.read_text(encoding="utf-8-sig"))["plugins"]["updater"]["pubkey"]
self.assertEqual(shipped, conf)
key_id, public = signing.minisign_public(shipped) # parses as a real Ed25519 minisign key, not the placeholder
self.assertEqual(len(public), 32)
self.assertEqual(signing.app_public_key if False else shipped, conf)
def test_a_feed_signed_by_another_key_is_refused_and_a_tester_key_works_through_the_override(self):
other = fx.make_key()
with tempfile.TemporaryDirectory() as t:
extra = Path(t) / "tester-keys.json"
extra.write_text(json.dumps({"keys": [signing.public_part(other)]}))
with mock.patch.dict(os.environ, {signing.ENV_EXTRA_KEYS: ""}):
self.assertNotIn(other["key_id"], signing.load_trusted_keys()) # a tester key is not part of a release build
with mock.patch.dict(os.environ, {signing.ENV_EXTRA_KEYS: str(extra)}):
keys = signing.load_trusted_keys()
self.assertIn(other["key_id"], keys) # private tester builds: their key via the override
self.assertIn(RELEASE_KEY_ID, keys) # ... beside the release key
if __name__ == "__main__":
unittest.main()