Files
troupe-standup/wizard-work/spark/final_verification.py
T

60 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""Final verification: validate real files using json_validator.py"""
import json
import subprocess
from pathlib import Path
VALIDATOR = "/root/.hermes/wizard-outputs/spark/json_validator.py"
def validate_and_record(files, desc):
"""Validate files and return results."""
cmd = ["python3", VALIDATOR] + files
result = subprocess.run(cmd, capture_output=True, text=True)
return {"desc": desc, "files": files, "exit_code": result.returncode, "stdout": result.stdout}
results = {
"tests": [],
"summary": {}
}
# Test 1: Hermes snap file (shell script - should be INVALID as JSON)
hermes_file = "/root/.hermes/profiles/spark/cache/scratch/hermes-snap-82499c7d6a2e.sh"
test1 = validate_and_record([hermes_file], "Hermes snap shell script (not JSON)")
test1["expected"] = "invalid"
test1["correct"] = test1["exit_code"] != 0 # Should fail for non-JSON
results["tests"].append(test1)
# Test 2: Valid JSON created on the fly
import tempfile
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
f.write('{"verification": "passed", "timestamp": "2026-10-19", "test_data": [1,2,3]}')
valid_json = f.name
test2 = validate_and_record([valid_json], "Valid JSON file")
test2["expected"] = "valid"
test2["correct"] = test2["exit_code"] == 0 # Should pass for valid JSON
results["tests"].append(test2)
# Test 3: Multiple files at once
test3 = validate_and_record([hermes_file, valid_json], "Multiple files (mixed validity)")
test3["expected"] = "mixed"
test3["correct"] = test3["exit_code"] != 0 # Should fail due to hermes_file
results["tests"].append(test3)
# Summary
passed = sum(1 for t in results["tests"] if t["correct"])
total = len(results["tests"])
results["summary"] = {
"passed": passed,
"total": total,
"all_correct": passed == total
}
Path("/root/.hermes/wizard-outputs/spark/final_verification.json").write_text(json.dumps(results, indent=2))
print(f"FINAL VERIFICATION: {passed}/{total} tests correct")
print(f"All tests passed: {passed == total}")
print(f"Results: /root/.hermes/wizard-outputs/spark/final_verification.json")
exit(0 if passed == total else 1)