fix: bind recipe identity to certified artifact bytes (DGR-025)

Append +artifact.<sha256> to the llama.cpp runtime axis, computed from the
exact bytes read by attest_loaded_runtime, so a differently-built shared
object with copied lock values can no longer forge a certified runtime
identity. Node/tracker parsers require the suffix; new test proves a
byte-identical-lock but different-binary artifact produces a different
recipe fingerprint. Regenerates conformance vectors accordingly.

105 passed in tests/test_native_identity_emission.py,
tests/test_runtime_pin_identity.py, tests/test_runtime_recipe_identity.py.
This commit is contained in:
Dobromir Popov
2026-07-21 13:22:02 +03:00
parent 902ecde363
commit 03e97ca31a
10 changed files with 1277 additions and 69 deletions

View File

@@ -34,11 +34,25 @@ from meshnet_node.runtime_recipe import ( # noqa: E402
DerivativeBinding,
RuntimeRecipe,
ShardIdentity,
tokenizer_identity,
)
from meshnet_tracker.recipe import ( # noqa: E402
parse_identity,
tokenizer_identity as tracker_tokenizer_identity,
)
from meshnet_tracker.recipe import parse_identity # noqa: E402
VECTORS = _ROOT / "tests" / "data" / "recipe_fingerprint_vectors.json"
SCHEMA_VERSION = 1
SCHEMA_VERSION = 2
# The tokenizer axis is content-addressed: a digest over the tokenizer's actual
# bytes, never a repository label. These example bytes are part of the wire
# contract exactly like the digests derived from them.
_TOKENIZER_FILES = {
"tokenizer.json": b'{"version":"example","vocab":{"a":0,"b":1}}\n',
"tokenizer_config.json": b'{"model_max_length":8}\n',
}
_TOKENIZER_IDENTITY = tokenizer_identity(_TOKENIZER_FILES)
assert _TOKENIZER_IDENTITY == tracker_tokenizer_identity(_TOKENIZER_FILES)
_RECIPE = RuntimeRecipe(
weight_quantization="Q4_K_M",
@@ -46,10 +60,13 @@ _RECIPE = RuntimeRecipe(
compute_dtype="float32",
kv_dtype="q8_0",
kv_layout="paged-v1",
tokenizer_revision="0123456789abcdef",
tokenizer_revision=_TOKENIZER_IDENTITY,
architecture_adapter="llama/range-v1",
backend_id="llama.cpp",
runtime_version="llama.cpp@" + "d" * 40 + "+patchstack." + "e" * 64,
runtime_version=(
"llama.cpp@" + "d" * 40 + "+patchstack." + "e" * 64
+ "+build." + "f" * 64 + "+artifact." + "a" * 64
),
recipe_id="example-gguf",
recipe_version="1",
catalogue_version="2026.07.1",