Files
leleka/engine/strata/tools/minimal_server_smoke.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

77 lines
3.3 KiB
Python

#!/usr/bin/env python3
"""Exercise fake-engine serving from a clean runtime-only Python environment.
Create a fresh venv, install requirements.txt, then run this script with that
venv's Python. The runtime integration module exercises foreground and POSIX
owned serving; no GPU, model weights or optional terminal framework is needed.
"""
from __future__ import annotations
import argparse
import hashlib
import importlib.util
import json
import os
import platform
import re
import subprocess
import sys
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
TEST_MODULE = "tests.terminal.test_runtime"
MIN_TESTS = 32
def smoke() -> dict:
if sys.prefix == sys.base_prefix:
raise RuntimeError("run with a dedicated virtual environment")
if os.name != "posix":
raise RuntimeError("this owned-runtime check currently requires POSIX")
visible = {name: importlib.util.find_spec(name) is not None
for name in ("rich", "textual", "numpy", "jinja2", "requests")}
if visible != {"rich": False, "textual": False, "numpy": True,
"jinja2": True, "requests": True}:
raise RuntimeError(f"runtime-only dependency set was not isolated: {visible}")
started = time.monotonic()
result = subprocess.run([sys.executable, "-m", "unittest", TEST_MODULE], cwd=ROOT,
capture_output=True, text=True, timeout=240, check=False)
summary = result.stdout + result.stderr
# Windows-only tests skip on POSIX, so unittest ends "OK (skipped=N)", not a bare "OK".
count = re.search(r"Ran (\d+) tests in [0-9.]+s\s+OK(?: \(skipped=(\d+)\))?\s*$", summary)
executed = int(count[1]) - int(count[2] or 0) if count else 0
passed = result.returncode == 0 and count is not None and executed >= MIN_TESTS
return {"schema_version": 1, "scope": "source_checkout_fake_engine_runtime_only",
"platform": platform.platform(), "python": platform.python_version(),
"requirements_sha256": hashlib.sha256((ROOT / "requirements.txt").read_bytes()).hexdigest(),
"optional_packages_visible": {name: visible[name] for name in ("rich", "textual")},
"server_packages_visible": {name: visible[name] for name in ("numpy", "jinja2", "requests")},
"test_module": TEST_MODULE, "tests_run": executed if count else None,
"duration_s": round(time.monotonic() - started, 2),
"test_exit_code": result.returncode, "actual_gpu_engine": False,
"passed": bool(passed), "test_summary": summary[-1000:]}
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--report", type=Path, required=True, help="new absolute JSON report path")
args = parser.parse_args()
report = args.report.expanduser()
if not report.is_absolute() or report.exists():
parser.error("--report must be an absolute new file")
result = smoke()
report.parent.mkdir(parents=True, exist_ok=True)
descriptor = os.open(report, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
with os.fdopen(descriptor, "w", encoding="utf-8") as stream:
json.dump(result, stream, indent=2)
stream.write("\n")
print(json.dumps({"report": str(report), "passed": result["passed"]}), flush=True)
return 0 if result["passed"] else 6
if __name__ == "__main__":
raise SystemExit(main())