5252 build_context_object_from_ark_config ,
5353 build_context_object_from_lock ,
5454 engine_config_from_lock ,
55+ cache_rebuild_lock ,
56+ compare_lock_payloads ,
5557)
5658
5759# ============================================================================
@@ -191,6 +193,7 @@ def _t(fr: str, en: str) -> str:
191193 # 1. Reset state for a new build
192194 try :
193195 self ._cancel_requested_during_precompile = False
196+ self ._is_rebuild = False
194197 get_main_process ().reset ()
195198 except Exception :
196199 pass
@@ -230,7 +233,7 @@ def _t(fr: str, en: str) -> str:
230233 # 4. Preparation (Resolve context and engine config)
231234 try :
232235 # Resolve Python version for locking (will be used in background thread)
233- python_version = None
236+ self . _python_version = None
234237 try :
235238 from Core .Compiler .utils import get_interpreter_version_str
236239 from Core .Venv_Manager .Manager import VenvManager
@@ -239,9 +242,9 @@ def _t(fr: str, en: str) -> str:
239242 vpython = vm .resolve_project_venv ()
240243 if vpython :
241244 vpath = vm .python_path (vpython )
242- python_version = get_interpreter_version_str (vpath )
245+ self . _python_version = get_interpreter_version_str (vpath )
243246 else :
244- python_version = get_interpreter_version_str ()
247+ self . _python_version = get_interpreter_version_str ()
245248 except Exception :
246249 pass
247250
@@ -363,7 +366,7 @@ def _after_bcasl(_report=None) -> None:
363366 self .workspace_dir ,
364367 validated .config ,
365368 engine_id = engine_id ,
366- python_version = python_version ,
369+ python_version = self . _python_version ,
367370 resolved_command = resolved_command ,
368371 )
369372 write_lock_files (self .workspace_dir , lock_payload )
@@ -452,10 +455,59 @@ def rebuild_from_lock(self, lock_path: Path) -> None:
452455 if not engine_id :
453456 raise ValueError ("Invalid lock file: missing engine name" )
454457
458+ entry_file = str (((lock_payload .get ("project" ) or {}).get ("entry" )) or "" ).strip ()
459+ if not entry_file :
460+ raise ValueError ("Invalid lock file: missing project.entry" )
461+
462+ entry_path = Path (self .workspace_dir ) / Path (entry_file )
463+ if not entry_path .is_file ():
464+ # Show a nice dialog as this is a GUI
465+ _prompt_for_required_entrypoint (self , missing_path = str (entry_path ))
466+ return
467+
455468 # Context and Config from lock (Aligned with CLI)
456469 context = build_context_object_from_lock (lock_payload )
470+ self ._is_rebuild = True
471+ self ._rebuild_lock_payload = lock_payload
472+
473+ # Alignement Git (Exact CLI Logic)
474+ try :
475+ from Ui .Cli .helpers import ensure_correct_git_commit
476+
477+ if not ensure_correct_git_commit (Path (self .workspace_dir ), lock_payload ):
478+ log_i18n_level (
479+ self ,
480+ "warning" ,
481+ "Compilation annulée: Mismatch Git non résolu." ,
482+ "Compilation cancelled: Git mismatch not resolved." ,
483+ )
484+ return
485+ except Exception as e :
486+ log_i18n_level (
487+ self ,
488+ "warning" ,
489+ f"Échec vérification Git: { e } " ,
490+ f"Git verification failed: { e } " ,
491+ )
492+
457493 engine_config = engine_config_from_lock (lock_payload )
458494
495+ # Shared Python version resolution for locking/comparison (Aligned with CLI)
496+ self ._python_version = None
497+ try :
498+ from Core .Compiler .utils import get_interpreter_version_str
499+ from Core .Venv_Manager .Manager import VenvManager
500+
501+ vm = VenvManager (self )
502+ vpython = vm .resolve_project_venv ()
503+ if vpython :
504+ vpath = vm .python_path (vpython )
505+ self ._python_version = get_interpreter_version_str (vpath )
506+ else :
507+ self ._python_version = get_interpreter_version_str ()
508+ except Exception :
509+ pass
510+
459511 # Retrieve engine instance for display name
460512 engine = None
461513 try :
@@ -555,6 +607,7 @@ def start_compilation_process(self, engine_id: str, file_path: str) -> bool:
555607 # 0. Reset state for a new build
556608 try :
557609 self ._cancel_requested_during_precompile = False
610+ self ._is_rebuild = False
558611 get_main_process ().reset ()
559612 except Exception :
560613 pass
@@ -585,7 +638,7 @@ def start_compilation_process(self, engine_id: str, file_path: str) -> bool:
585638 )
586639
587640 # Shared Python version resolution for locking/comparison (Aligned with CLI)
588- python_version = None
641+ self . _python_version = None
589642 try :
590643 from Core .Compiler .utils import get_interpreter_version_str
591644 from Core .Venv_Manager .Manager import VenvManager
@@ -594,9 +647,9 @@ def start_compilation_process(self, engine_id: str, file_path: str) -> bool:
594647 vpython = vm .resolve_project_venv ()
595648 if vpython :
596649 vpath = vm .python_path (vpython )
597- python_version = get_interpreter_version_str (vpath )
650+ self . _python_version = get_interpreter_version_str (vpath )
598651 else :
599- python_version = get_interpreter_version_str ()
652+ self . _python_version = get_interpreter_version_str ()
600653 except Exception :
601654 pass
602655
@@ -640,7 +693,7 @@ def start_compilation_process(self, engine_id: str, file_path: str) -> bool:
640693 Path (self .workspace_dir ),
641694 validated .config ,
642695 engine_id = engine_id ,
643- python_version = python_version ,
696+ python_version = self . _python_version ,
644697 resolved_command = resolved_command ,
645698 )
646699 write_lock_files (Path (self .workspace_dir ), lock_payload )
@@ -754,7 +807,7 @@ def _after_bcasl(_report=None) -> None:
754807 engine_id = engine_id ,
755808 context = context ,
756809 engine_config = engine_config ,
757- is_rebuild = True ,
810+ is_rebuild = False ,
758811 )
759812
760813 if not success :
@@ -1029,6 +1082,56 @@ def handle_finished(self, return_code: int, info: dict) -> None:
10291082 "Compilation completed successfully!" ,
10301083 )
10311084
1085+ # Integrity Check (Aligned with CLI)
1086+ if getattr (self , "_is_rebuild" , False ) and getattr (self , "_rebuild_lock_payload" , None ):
1087+ try :
1088+ log_i18n_level (
1089+ self ,
1090+ "info" ,
1091+ "Vérification de l'intégrité du verrou après compilation..." ,
1092+ "Performing lock integrity check after compilation..." ,
1093+ )
1094+ current_config = load_ark_config (Path (self .workspace_dir ))
1095+ validated = validate_ark_config (Path (self .workspace_dir ), current_config )
1096+ regenerated = build_lock_payload (
1097+ Path (self .workspace_dir ),
1098+ validated .config ,
1099+ engine_id = info .get ("engine" , "" ),
1100+ python_version = getattr (self , "_python_version" , None ),
1101+ )
1102+
1103+ rebuild_cache = cache_rebuild_lock (Path (self .workspace_dir ), regenerated )
1104+ comparison_ok = compare_lock_payloads (self ._rebuild_lock_payload , regenerated )
1105+
1106+ if not comparison_ok :
1107+ log_i18n_level (
1108+ self ,
1109+ "warning" ,
1110+ "⚠️ Mismatch détecté : le verrou actuel diffère de celui utilisé pour le rebuild." ,
1111+ "⚠️ Lock mismatch detected: the current configuration differs from the one in the lock file." ,
1112+ )
1113+ if rebuild_cache :
1114+ log_i18n_level (
1115+ self ,
1116+ "info" ,
1117+ f"Verrou de comparaison généré : { rebuild_cache } " ,
1118+ f"Comparison lock generated: { rebuild_cache } " ,
1119+ )
1120+ else :
1121+ log_i18n_level (
1122+ self ,
1123+ "success" ,
1124+ "✅ Intégrité du verrou confirmée (Strict Alignment)." ,
1125+ "✅ Lock integrity confirmed (Strict Alignment)." ,
1126+ )
1127+ except Exception as exc :
1128+ log_i18n_level (
1129+ self ,
1130+ "warning" ,
1131+ f"Impossible de regénérer le verrou de comparaison: { exc } " ,
1132+ f"Unable to regenerate comparison lock: { exc } " ,
1133+ )
1134+
10321135 engine_id = info .get ("engine" )
10331136 if engine_id :
10341137 try :
0 commit comments