#!/usr/bin/env python3 """Reject oncology vocabulary on UI import lines, and require the MIT notice.""" from __future__ import annotations import re import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] UI = ROOT / "ui" IMPORT_LINE = re.compile(r"""^\s*(import|export)\b.*\bfrom\b|^\s*import\s*\(""") FORBIDDEN = re.compile(r"oncology|cancers?|drugs?|targets?", re.IGNORECASE) SOURCE_SUFFIXES = {".ts", ".tsx", ".css", ".mjs"} def import_lines(path: Path) -> list[str]: hits: list[str] = [] for number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), start=1): if IMPORT_LINE.search(line) and FORBIDDEN.search(line): hits.append(f"{path.relative_to(ROOT)}:{number}: {line.strip()}") return hits def main() -> int: problems: list[str] = [] for path in sorted(UI.rglob("*")): if not path.is_file() or "node_modules" in path.parts or ".next" in path.parts: continue if path.suffix in SOURCE_SUFFIXES: problems.extend(import_lines(path)) notice = (UI / "NOTICE").read_text(encoding="utf-8") if "Copyright (c) 2026 OnCo" not in notice or "MIT License" not in notice: problems.append("ui/NOTICE is missing the OnCo MIT copyright and permission notice") if problems: print("\n".join(problems)) return 1 print("ui boundary: no oncology imports; NOTICE retains the OnCo MIT text") return 0 if __name__ == "__main__": sys.exit(main())