Files
leleka/engine/strata/tests/terminal/test_launch_identity.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

55 lines
2.7 KiB
Python

"""An owned server attests the bytes and arguments it actually received."""
import json
import unittest
from unittest import mock
from serve.launch_identity import attestation
from strata_control import readiness
class LaunchIdentityTests(unittest.TestCase):
def test_attestation_changes_with_source_args_and_key(self):
key = bytes(range(32))
cfg = b'{"api_key":"a private setting","model_name":"fake"}'
args = ["--config", "/tmp/run.json", "--parallel", "4"]
value = attestation(key, cfg, args)
self.assertEqual(len(value), 64)
self.assertEqual(value, attestation(key, cfg, args))
self.assertNotEqual(value, attestation(key, cfg + b" ", args))
self.assertNotEqual(value, attestation(key, cfg, [*args, "--batch-telemetry"]))
self.assertNotEqual(value, attestation(bytes(reversed(key)), cfg, args))
self.assertNotIn("private", value)
def test_wrong_or_absent_server_attestation_rejects_readiness_before_generation(self):
ready = {"bound_host": "127.0.0.1", "bound_port": 1234,
"model_id": "fake", "model_state": "ready"}
cfg = json.dumps({"model_name": "fake"}).encode()
for reported in (None, "0" * 64):
with self.subTest(reported=reported), mock.patch.object(readiness, "_request") as request:
request.return_value = {"instance": {"id": "one", "launch_attestation": reported},
"model": {"id": "fake", "loaded": True}}
with self.assertRaisesRegex(readiness.ReadinessError,
"probe_launch_attestation_mismatch"):
readiness.verify(ready, cfg, expected_host="127.0.0.1",
expected_instance="one", expected_attestation="f" * 64,
timeout=1)
self.assertEqual(request.call_count, 1)
def test_attested_lazy_model_reports_unloaded_without_generation(self):
ready = {"bound_host": "127.0.0.1", "bound_port": 1234,
"model_id": "fake", "model_state": "unloaded"}
with mock.patch.object(readiness, "_request", return_value={
"instance": {"id": "one", "launch_attestation": "f" * 64},
"model": {"id": "fake", "loaded": False}}) as request:
result = readiness.verify(ready, b'{"model_name":"fake"}',
expected_host="127.0.0.1", expected_instance="one",
expected_attestation="f" * 64, timeout=1)
self.assertTrue(result["launch_attested"])
self.assertFalse(result["generation_ready"])
self.assertEqual(request.call_count, 1)
if __name__ == "__main__":
unittest.main()