mirror of
https://github.com/allaunthefox/SilverSight.git
synced 2026-07-31 01:25:21 +00:00
Includes: - n-dimensional generic modules (BraidStateN, MatrixN, SpectralN, ClassifyN, FisherRigidityN, FixedPointBridge) - Feasible Set Theorem proofs + QUBO relaxation - Anti-smuggle protocol (seedlock, mutation testing, cross_validate, qc_flag, symbol verification) - Q16_16 bridge with quad matrix representation - Infrastructure scripts (entry gate, determinism checks) - Test suites for Lean modules, scripts, and QUBO pipeline - FixedPoint migration and HachimojiN8 updates - Documentation updates (ARCHITECTURE, GLOSSARY, DOCUMENT_SETS) - QUBO conflict sweep and FSR validation - GitHub Actions anti-smuggle workflow Build: 3307 jobs, 0 errors
70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
import json, shutil, subprocess, time, sys
|
|
from pathlib import Path
|
|
|
|
REPO = Path(__file__).resolve().parents[2]
|
|
BACKUP_DIR = REPO / "scripts" / "qc_flag" / ".backups"
|
|
RECEIPTS_DIR = REPO / "scripts" / "qc_flag" / "receipts"
|
|
|
|
|
|
def run_single(src_path, mut_path, target="SilverSightRRC", timeout=60):
|
|
"""Backup → apply mutation → build → restore. Returns dict with result."""
|
|
BACKUP_DIR.mkdir(parents=True, exist_ok=True)
|
|
backup = BACKUP_DIR / src_path.name
|
|
if not backup.exists():
|
|
shutil.copy2(src_path, backup)
|
|
|
|
orig = src_path.read_text()
|
|
src_path.write_bytes(mut_path.read_bytes())
|
|
|
|
t0 = time.perf_counter()
|
|
try:
|
|
r = subprocess.run(
|
|
["lake", "build", target],
|
|
cwd=REPO, capture_output=True, text=True, timeout=timeout
|
|
)
|
|
exit_code = r.returncode
|
|
output = (r.stdout + r.stderr)[-500:]
|
|
except subprocess.TimeoutExpired:
|
|
exit_code = -1
|
|
output = "TIMEOUT"
|
|
except FileNotFoundError:
|
|
exit_code = -2
|
|
output = "lake not found"
|
|
|
|
src_path.write_text(orig)
|
|
elapsed = round(time.perf_counter() - t0, 2)
|
|
|
|
mut_id = mut_path.stem.split("_")[0]
|
|
actual = "FAIL" if exit_code != 0 else "PASS"
|
|
return {
|
|
"mutation_id": mut_id,
|
|
"source": str(src_path),
|
|
"expected": "FAIL",
|
|
"actual": actual,
|
|
"exit_code": exit_code,
|
|
"elapsed_s": elapsed,
|
|
"build_log_snippet": output,
|
|
}
|
|
|
|
|
|
def compute_coverage(results):
|
|
total = len(results)
|
|
failed = sum(1 for r in results if r["actual"] == "FAIL")
|
|
return {
|
|
"total": total, "failed_expected": failed,
|
|
"passed_unexpectedly": total - failed,
|
|
"coverage_ratio": round(failed / total, 4) if total else 0,
|
|
"verdict": "PASS" if total > 0 and failed == total else "FAIL",
|
|
}
|
|
|
|
|
|
def emit_receipt(results, coverage):
|
|
RECEIPTS_DIR.mkdir(parents=True, exist_ok=True)
|
|
path = RECEIPTS_DIR / f"coverage_{int(time.time())}.json"
|
|
path.write_text(json.dumps({
|
|
"schema": "mutation_coverage_receipt_v1",
|
|
"generated_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
|
"coverage": coverage,
|
|
"entries": results,
|
|
}, indent=2))
|
|
return path
|