feat: DGR-004-CHAIN - Execute chained DGR-004/005/003-emission with anchor
This commit is contained in:
68
tests/test_llama_cpp_dependency.py
Normal file
68
tests/test_llama_cpp_dependency.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""Offline guards for DGR-004's pinned llama.cpp dependency boundary."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
LLAMA_DIR = ROOT / "packages/node/native/llama"
|
||||
SCRIPT = ROOT / "scripts/llama_cpp_dependency.py"
|
||||
|
||||
|
||||
def _sha256(path: pathlib.Path) -> str:
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def test_lock_and_patch_manifest_are_self_consistent_and_exact() -> None:
|
||||
lock = json.loads((LLAMA_DIR / "UPSTREAM_LOCK.json").read_text())
|
||||
commit = (LLAMA_DIR / "UPSTREAM_COMMIT").read_text().strip()
|
||||
patches = (LLAMA_DIR / "patches/series").read_text().splitlines()
|
||||
sums = {
|
||||
name: digest
|
||||
for digest, name in (
|
||||
line.split(maxsplit=1)
|
||||
for line in (LLAMA_DIR / "patches/SHA256SUMS").read_text().splitlines()
|
||||
if line and not line.startswith("#")
|
||||
)
|
||||
}
|
||||
|
||||
assert commit == lock["commit"]
|
||||
assert len(commit) == 40
|
||||
assert patches == lock["patch_series"]
|
||||
assert patches == sorted(patches)
|
||||
assert patches
|
||||
for patch_name in patches:
|
||||
patch = LLAMA_DIR / "patches" / patch_name
|
||||
assert sums[patch_name] == _sha256(patch)
|
||||
assert "Subject: [PATCH" in patch.read_text()
|
||||
|
||||
|
||||
def test_dependency_script_reports_the_locked_boundary_without_network() -> None:
|
||||
completed = subprocess.run(
|
||||
[sys.executable, str(SCRIPT), "inspect"],
|
||||
cwd=ROOT,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
report = json.loads(completed.stdout)
|
||||
|
||||
assert report["commit"] == (LLAMA_DIR / "UPSTREAM_COMMIT").read_text().strip()
|
||||
assert report["patch_count"] == 1
|
||||
assert report["model_downloads"] is False
|
||||
assert report["semantic_certification"] is False
|
||||
assert "dense" in report["glm_stock_limitations"].lower()
|
||||
|
||||
|
||||
def test_patch_stack_does_not_contain_meshnet_control_plane_code() -> None:
|
||||
forbidden = ("tracker", "route session", "grpc", "http", "billing", "wallet")
|
||||
patch_text = "\n".join(
|
||||
(LLAMA_DIR / "patches" / name).read_text().lower()
|
||||
for name in (LLAMA_DIR / "patches/series").read_text().splitlines()
|
||||
)
|
||||
assert not any(term in patch_text for term in forbidden)
|
||||
Reference in New Issue
Block a user