"""task-2736 — harness test path pinning.

`scripts/__init__.py` makes `scripts` a *regular* package, so Python binds the
first `scripts/` found on sys.path. Under pytest the canonical checkout
(/home/jay/workspace) can precede this worktree on sys.path, which would shadow
the restored `scripts/harness/v36/guard.py` with the canonical copy that does
not yet contain it. Pin this worktree's root to the front and evict any
pre-imported `scripts*` modules so the harness tests exercise the restored
files in THIS worktree.

(Production is unaffected: the hook inserts ANU_WORKSPACE_ROOT=/home/jay/workspace
 at sys.path[0], where guard.py lands after merge.)
"""
import sys
from pathlib import Path

_REPO_ROOT = str(Path(__file__).resolve().parents[2])

if sys.path[:1] != [_REPO_ROOT]:
    sys.path.insert(0, _REPO_ROOT)

for _mod in [m for m in list(sys.modules) if m == "scripts" or m.startswith("scripts.")]:
    del sys.modules[_mod]
