import os
import sys

lab = r"C:\Users\intel\AppData\Local\OptimusRuntime\Labs\AR74\12_ar88_authority_operational_closure"
candidate_ws = os.path.join(lab, "candidate_workspace")
sys.path.insert(0, candidate_ws)

target_file = os.path.join(candidate_ws, "artifacts", "brain_host", "brain_host_tls.py")
print("Target file:", target_file)

with open(target_file, "r", encoding="utf-8") as f:
    content = f.read()

target_str = """                                    logger.info("[BrainHost] Dispatched live shadow hook for task %s, result calling dispatch...", tid)
                                    # Forward direct in-process reference to OPERATIONAL_TASKS so hook updates live dictionary directly
                                    _snap["operational_tasks"] = OPERATIONAL_TASKS
                                    dispatch_live_shadow_hook(_snap, async_dispatch=True)"""

# Check if target_str exists
if target_str in content:
    print("Found target_str in brain_host_tls.py!")
else:
    print("Target string not found, searching for variant...")
    for idx, line in enumerate(content.splitlines()):
        if "dispatch_live_shadow_hook(" in line:
            print(f"Line {idx+1}: {line}")

