Spaces:
Sleeping
Sleeping
File size: 1,379 Bytes
d49fca3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import os
from ast_validator import validate_ast
from sandbox_runner import sandbox_test
from gated_review import gate_reject
from patch_manager import prepare_patch, apply_patch
PENDING_PATCH = None
PENDING_TARGET = None
def divine_mutation(new_code, target_file):
global PENDING_PATCH, PENDING_TARGET
# Vérification AST
ast_ok, ast_err = validate_ast(new_code)
if not ast_ok:
return f"[❌ AST ERROR]\n{ast_err}"
# Sandbox
sandbox_ok, sandbox_err = sandbox_test(new_code)
if not sandbox_ok:
return f"[❌ SANDBOX FAILURE]\n{sandbox_err}"
# Rejection Gate
gate_ok, gate_reason = gate_reject(ast_ok, sandbox_ok)
if not gate_ok:
return f"[❌ MUTATION BLOQUÉE]\n{gate_reason}"
# Préparer patch
PENDING_PATCH = prepare_patch(new_code)
PENDING_TARGET = target_file
return "[✅ PATCH PRÊT]\nEnvoie 'VALIDER' pour appliquer ou 'ANNULER' pour rejeter."
def apply_pending():
global PENDING_PATCH, PENDING_TARGET
if PENDING_PATCH and PENDING_TARGET:
apply_patch(PENDING_TARGET, PENDING_PATCH)
PENDING_PATCH = None
PENDING_TARGET = None
return "[✔️ PATCH APPLIQUÉ]"
return "Aucun patch en attente."
def cancel_pending():
global PENDING_PATCH, PENDING_TARGET
PENDING_PATCH = None
PENDING_TARGET = None
return "[❌ PATCH ANNULÉ]" |