#!/usr/bin/env python3 """Fail when a second GeoIntel source tree reappears below the repository root.""" from __future__ import annotations import argparse from pathlib import Path CANONICAL_MARKERS = ( "backend/app/main.py", "frontend/package.json", "docs/API_CONTRACTS.md", ) def nested_mirror_markers(repo_root: Path) -> list[str]: nested = repo_root / "geointel" return [marker for marker in CANONICAL_MARKERS if (nested / marker).is_file()] def main() -> int: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument( "--repo-root", type=Path, default=Path(__file__).resolve().parents[1], ) args = parser.parse_args() repo_root = args.repo_root.resolve() missing = [marker for marker in CANONICAL_MARKERS if not (repo_root / marker).is_file()] if missing: raise SystemExit(f"Canonical GeoIntel repository markers are missing: {missing}") duplicates = nested_mirror_markers(repo_root) if duplicates: raise SystemExit( "Nested GeoIntel repository mirror detected below geointel/: " f"{duplicates}. The repository root is the only canonical source tree." ) print("Repository layout verified: one canonical GeoIntel source tree") return 0 if __name__ == "__main__": raise SystemExit(main())