Spaces:
Sleeping
Sleeping
| """core/proof_system.py — Journal des améliorations prouvées""" | |
| import json, time, os | |
| from typing import Dict | |
| from pathlib import Path | |
| class ProofSystem: | |
| def __init__(self, storage_path: str = "/tmp/vortex_data/proofs.json"): | |
| self.path = Path(storage_path) | |
| self.path.parent.mkdir(parents=True, exist_ok=True) | |
| self.proofs = [] | |
| if self.path.exists(): | |
| try: | |
| self.proofs = json.loads(self.path.read_text()) | |
| except: | |
| pass | |
| def register_improvement(self, version: str, before: float, after: float, benchmark: str) -> Dict: | |
| proof = { | |
| "version": version, "benchmark": benchmark, | |
| "before": before, "after": after, | |
| "delta": after - before, "ts": time.time() | |
| } | |
| self.proofs.append(proof) | |
| self.path.write_text(json.dumps(self.proofs, indent=2)) | |
| return proof | |
| def should_rollback(self, version: str, new_score: float, threshold: float = 0.05) -> bool: | |
| for p in reversed(self.proofs): | |
| if p["version"] == version: | |
| return (p["before"] - new_score) > threshold | |
| return False | |