mirror of
https://github.com/allaunthefox/SilverSight.git
synced 2026-07-30 17:16:16 +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
100 lines
3.3 KiB
Python
100 lines
3.3 KiB
Python
"""test_scripts.py — Anti-smuggle script tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
|
|
|
|
|
class TestSeedlock(unittest.TestCase):
|
|
"""seedlock: deterministic RNG."""
|
|
|
|
def test_seeded_rng_reproducible(self):
|
|
from seedlock import SeededRNG
|
|
a = SeededRNG(42)
|
|
b = SeededRNG(42)
|
|
self.assertEqual(a.random(), b.random())
|
|
self.assertEqual(a.randint(0, 100), b.randint(0, 100))
|
|
|
|
def test_seeded_rng_different_seeds(self):
|
|
from seedlock import SeededRNG
|
|
a = SeededRNG(1)
|
|
b = SeededRNG(2)
|
|
# Different seeds should produce different sequences
|
|
results = {(a.random(), b.random()) for _ in range(10)}
|
|
self.assertGreater(len(results), 1)
|
|
|
|
|
|
class TestCheckDeterminism(unittest.TestCase):
|
|
"""check_determinism: hash chain verification."""
|
|
|
|
def test_import(self):
|
|
import check_determinism
|
|
self.assertTrue(hasattr(check_determinism, "check_artifact_chain"))
|
|
self.assertTrue(hasattr(check_determinism, "scan_seed_violations"))
|
|
|
|
def test_compute_hash(self):
|
|
from check_determinism import compute_json_sha256
|
|
h = compute_json_sha256({"a": 1, "b": 2})
|
|
self.assertIsInstance(h, str)
|
|
self.assertEqual(len(h), 64)
|
|
|
|
|
|
class TestVerifyWithSympy(unittest.TestCase):
|
|
"""verify_with_sympy: CAS/SMT grounding."""
|
|
|
|
def test_import(self):
|
|
import verify_with_sympy
|
|
self.assertTrue(hasattr(verify_with_sympy, "extract_ofratio_values"))
|
|
self.assertTrue(hasattr(verify_with_sympy, "extract_ncderived_chains"))
|
|
|
|
|
|
class TestCrossValidate(unittest.TestCase):
|
|
"""cross_validate: multi-model comparison."""
|
|
|
|
def test_extract_theorems(self):
|
|
from cross_validate import extract_theorems
|
|
lean_code = "theorem ncDerived_mul (r : FixtureRow) : ncDerived r = ... := by rfl"
|
|
theorems = extract_theorems(lean_code)
|
|
self.assertIn("ncDerived_mul", theorems)
|
|
|
|
def test_statements_equivalent(self):
|
|
from cross_validate import statements_equivalent
|
|
self.assertTrue(statements_equivalent("a + b = c", "x + y = z"))
|
|
self.assertFalse(statements_equivalent("a + b = c", "a - b = c"))
|
|
|
|
|
|
class TestQcFlagGenerator(unittest.TestCase):
|
|
"""qc_flag.mutation_generator: mutation generation."""
|
|
|
|
def test_apply_mutation(self):
|
|
from qc_flag.mutation_generator import apply_mutation
|
|
result = apply_mutation("allOk 8 = true", "allOk 8 = true \u2192 allOk 8 = false")
|
|
self.assertEqual(result, "allOk 8 = false")
|
|
|
|
def test_load_manifest(self):
|
|
from qc_flag.mutation_generator import load_manifest
|
|
m = load_manifest()
|
|
self.assertIn("sources", m)
|
|
self.assertGreater(len(m["sources"]), 0)
|
|
|
|
|
|
class TestModelPanel(unittest.TestCase):
|
|
"""model_panel: financial decision engine."""
|
|
|
|
def test_import(self):
|
|
try:
|
|
sys.path.insert(0, str(REPO_ROOT / ".." / "Research Stack" / "4-Infrastructure" / "shim"))
|
|
import model_panel
|
|
self.assertTrue(hasattr(model_panel, "estimate_query_cost"))
|
|
except ImportError:
|
|
self.skipTest("model_panel.py not accessible (Research Stack path)")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|