path = r"C:\Users\intel\AppData\Local\OptimusRuntime\Labs\AR74\10_ar84_trust_boundary\evidence\run_ar84_verification.py"
with open(path, "r", encoding="utf-8") as f:
    content = f.read()

old_code = '''    # Controlled creator-approved promotion + atomic rollback
    class _CreatorApprovedLabGuard(PromotionGuard):
        def is_target_critical(self, target_file: str, workspace_root: str = None) -> bool:
            norm = str(target_file).replace("\\\\", "/").lower()
            if norm.endswith("app/remediation/self_repair/circuit.py"):
                return False
            return super().is_target_critical(target_file, workspace_root)'''

new_code = '''    # Controlled creator-approved promotion + atomic rollback
    class _CreatorApprovedLabGuard(PromotionGuard):
        def is_target_critical(self, target_file: str, workspace_root: str = None) -> bool:
            norm = str(target_file).replace("\\\\", "/").replace("\\", "/").lower()
            if norm.endswith("app/remediation/self_repair/circuit.py"):
                return False
            return super().is_target_critical(target_file, workspace_root)'''

if old_code in content:
    content = content.replace(old_code, new_code, 1)
    print("Replaced _CreatorApprovedLabGuard in run_ar84_verification.py")
else:
    # try single backslash in old_code
    old_code_alt = old_code.replace("\\\\", "\\")
    if old_code_alt in content:
        content = content.replace(old_code_alt, new_code, 1)
        print("Replaced alt _CreatorApprovedLabGuard in run_ar84_verification.py")
    else:
        print("Failed to find _CreatorApprovedLabGuard")

with open(path, "w", encoding="utf-8") as f:
    f.write(content)

