[verified] fix: enforce canonical native runtime pin

This commit is contained in:
Dobromir Popov
2026-07-17 23:20:03 +03:00
parent ad66f7a4d8
commit db59caa8e9
9 changed files with 110 additions and 36 deletions

View File

@@ -42,7 +42,7 @@ def _recipe(**changes: object) -> RuntimeRecipe:
"tokenizer_revision": "0123456789abcdef",
"architecture_adapter": "llama/range-v1",
"backend_id": "llama.cpp",
"runtime_version": "llama.cpp@deadbeef+meshnet.1",
"runtime_version": "llama.cpp@" + "d" * 40 + "+patchstack." + "e" * 64,
"recipe_id": "example-gguf",
"recipe_version": "1",
"catalogue_version": "2026.07.1",
@@ -276,3 +276,37 @@ def test_tracker_rejects_a_moving_runtime_version():
doc.pop("fingerprint", None)
with pytest.raises(TrackerRecipeIdentityError, match="moving reference"):
parse_identity(doc)
@pytest.mark.parametrize(
"forged",
[
"llama.cpp@master+patchstack.not-a-digest",
"llama.cpp@e920c523+patchstack.forged",
"release-that-operator-typed",
],
)
def test_node_recipe_rejects_noncanonical_llama_runtime_pins(forged):
with pytest.raises(RecipeIdentityError, match="40-hex commit"):
_recipe(runtime_version=forged)
@pytest.mark.parametrize(
"forged",
[
"llama.cpp@master+patchstack.not-a-digest",
"llama.cpp@e920c523+patchstack.forged",
"release-that-operator-typed",
],
)
def test_tracker_rejects_noncanonical_llama_runtime_pins(forged):
vectors = json.loads(
(Path(__file__).parent / "data" / "recipe_fingerprint_vectors.json").read_text(
encoding="utf-8"
)
)
doc = json.loads(json.dumps(vectors["vectors"][0]["identity"]))
doc["recipe"]["runtime_version"] = forged
doc.pop("fingerprint", None)
with pytest.raises(TrackerRecipeIdentityError, match="40-hex commit"):
parse_identity(doc)