35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
"""test_hook_parity.py — T21.3 §21.3C-2: canonical hook hash parity.
|
|
The installed hook MUST match the canonical source."""
|
|
from __future__ import annotations
|
|
import hashlib
|
|
from pathlib import Path
|
|
REPO = Path(__file__).resolve().parent.parent
|
|
CANONICAL = REPO / "config" / "mimo-hooks" / "event-wait-guard.ts"
|
|
# T21.3: the hook lives at the ACTUAL controller user's home, not the
|
|
# test runner's. Use an env override or skip when unavailable.
|
|
import os as _os
|
|
INSTALLED = Path(_os.environ.get(
|
|
"MIMOCODE_HOOK_TARGET",
|
|
str(Path(_os.environ.get("RUNE_HOOK_TARGET_HOME", "/home/nick"))
|
|
/ ".mimocode" / "hooks" / "event-wait-guard.ts")))
|
|
|
|
|
|
def _sha(p: Path) -> str:
|
|
return hashlib.sha256(p.read_bytes()).hexdigest()
|
|
|
|
|
|
def test_213c_canonical_exists():
|
|
assert CANONICAL.is_file()
|
|
|
|
|
|
def test_213c_installed_matches_canonical():
|
|
assert INSTALLED.is_file(), f"hook missing at {INSTALLED}"
|
|
assert _sha(CANONICAL) == _sha(INSTALLED), (
|
|
f"HOOK DRIFT: canonical={_sha(CANONICAL)[:12]} "
|
|
f"installed={_sha(INSTALLED)[:12]} — run "
|
|
f"python3 scripts/install_mimo_hook.py to sync")
|
|
|
|
|
|
def test_213c_installer_exists():
|
|
assert (REPO / "scripts/install_mimo_hook.py").is_file()
|