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()

target = '''    # Step 1: Execute Round 1
    print("\\n[AR-84] === EXECUTING VERIFICATION ROUND 1 ===")'''

replacement = '''    # Step 0b: AR-84 Authentic BrainHost Operational Route & Anti-Forgery Tests
    print("\\n[AR-84] Executing isolated BrainHost operational route test...")
    sys.path.insert(0, str(AR84_ROOT))
    from test_isolated_brain_route import run_isolated_brain_test
    brain_route_res = run_isolated_brain_test()
    summary["brain_operational_route"] = brain_route_res
    assert brain_route_res.get("autonomous_hook_dispatched"), "BrainHost operational route failed to dispatch autonomous hook"

    print("\\n[AR-84] Executing 9 Anti-Forgery negative gate tests...")
    import pytest
    af_test_path = str(AR84_ROOT / "tests" / "test_ar84_antiforgery_gates.py")
    af_ret = pytest.main([af_test_path, "-v"])
    summary["antiforgery_gates_returncode"] = af_ret
    assert af_ret == 0, f"Anti-forgery gate tests failed with code {af_ret}"

    # Step 1: Execute Round 1
    print("\\n[AR-84] === EXECUTING VERIFICATION ROUND 1 ===")'''

if target in content:
    content = content.replace(target, replacement, 1)
    print("Injected AR-84 authentic checks into main()")
else:
    print("Target not found")

with open(path, "w", encoding="utf-8") as f:
    f.write(content)
print("Finished updating run_ar84_verification.py")

