Files
neuron-tai/tests/test_llama_shard_worker_binding.py
2026-08-01 01:28:06 +03:00

47 lines
1.8 KiB
Python

"""DGR-037 structural guardrails for the standalone llama.cpp worker.
The real GGUF lane is opt-in and needs a mounted artifact; these tests keep the
default suite model-download-free while guarding the integration shape that a
later real-model harness exercises.
"""
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
WORKER = ROOT / "packages/node/native/worker"
def test_worker_uses_the_private_llama_shardengine_not_the_fixture_engine():
service_header = (WORKER / "shard_service.h").read_text(encoding="utf-8")
service = (WORKER / "shard_service.cpp").read_text(encoding="utf-8")
engine = (WORKER / "llama_shard_engine.cpp").read_text(encoding="utf-8")
assert '#include "llama_shard_engine.h"' in service_header
assert "FakeShardEngine" not in service_header
assert "engine_.Execute(" in service
assert "llama_model_load_from_file" in engine
assert "llama_model_meshnet_range_report" in engine
def test_worker_configuration_and_death_hook_are_explicit_and_opt_in():
main = (WORKER / "shard_worker_main.cpp").read_text(encoding="utf-8")
for name in (
"MESHNET_MODEL_ARTIFACT",
"MESHNET_MODEL_ARTIFACT_DIGEST",
"MESHNET_RUNTIME_RECIPE_DIGEST",
"MESHNET_SHARD_START_LAYER",
"MESHNET_SHARD_END_LAYER",
"MESHNET_INJECT_PROCESS_DEATH_AFTER_EXECUTIONS",
):
assert name in main
assert "engine->Shutdown()" in main
def test_identity_is_loaded_not_stream_supplied_and_health_reports_it():
source = (WORKER / "shard_service.cpp").read_text(encoding="utf-8")
assert "r.start_layer() == engine_.identity().start_layer" in source
assert "r.end_layer() == engine_.identity().end_layer" in source
assert "model artifact or runtime recipe digest does not match" in source
assert "resident_bytes" in source
assert '" range=["' in source