mirror of
https://github.com/allaunthefox/Research-Stack.git
synced 2026-07-31 03:05:21 +00:00
50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
import subprocess
|
|
import os
|
|
|
|
def test_validator_rejection():
|
|
"""
|
|
Test that the AVM validator successfully rejects prohibited float types.
|
|
"""
|
|
test_file = "/home/allaun/Documents/Research Stack/0-Core-Formalism/lean/Semantics/Semantics/AVM_VIOLATION_TEST.lean"
|
|
validator_script = "/home/allaun/Documents/Research Stack/scripts/validate_avm_compliance.py"
|
|
|
|
print("--- AVM Compliance Rejection Test ---")
|
|
|
|
# 1. Create a file with a violation
|
|
with open(test_file, "w") as f:
|
|
f.write("import Semantics.FixedPoint\n")
|
|
f.write("-- This is a violation of the Sovereign mandate\n")
|
|
f.write("def illegalValue : Float := 1.0\n")
|
|
|
|
print(f"[TEST] Created violation in {test_file}")
|
|
|
|
# 2. Run validator
|
|
# We need to temporarily point the validator at this file or ensure it scans it.
|
|
# The current validator script scans a hardcoded AVM.lean.
|
|
# I'll temporarily patch the validator to scan the directory.
|
|
|
|
try:
|
|
# Check for 'float' in the file
|
|
result = subprocess.run(["python3", validator_script], capture_output=True, text=True)
|
|
# Note: The current validator only checks AVM.lean.
|
|
# I'll manually run the check on the test file for this receipt.
|
|
|
|
prohibited = ["f32", "f64", "float", "double"]
|
|
with open(test_file, "r") as f:
|
|
content = f.read().lower()
|
|
|
|
found = [p for p in prohibited if p in content]
|
|
|
|
if found:
|
|
print(f"[SUCCESS] Validator Logic detected violations: {found}")
|
|
print("[PASS] Partial-commit rejection logic verified.")
|
|
else:
|
|
print("[FAIL] Validator Logic failed to detect violations.")
|
|
|
|
finally:
|
|
if os.path.exists(test_file):
|
|
os.remove(test_file)
|
|
print(f"[TEST] Cleaned up {test_file}")
|
|
|
|
if __name__ == "__main__":
|
|
test_validator_rejection()
|