Spaces:
Paused
Paused
File size: 2,575 Bytes
8c1b9fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | #!/usr/bin/env python3
"""Repository-wide naming audit (ADR-0001).
Fails if forbidden/legacy product names appear, or if the canonical strings are
missing from key files. PathRAG is allowed (algorithm name).
"""
from __future__ import annotations
import re
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
# Legacy / off-brand product names that must never appear.
FORBIDDEN = [
r"\bVoiceRAG\b",
r"\bAuralynx\b",
r"\bAuraLynq\b", # wrong casing
r"\bAurLynq\b",
r"\bTalkRAG\b",
]
# Directories/files to skip.
SKIP_DIRS = {
".git",
".venv",
"venv",
"node_modules",
".next",
"__pycache__",
".mypy_cache",
".ruff_cache",
".pytest_cache",
"data",
"models",
"reports",
}
TEXT_EXT = {
".py",
".md",
".toml",
".yml",
".yaml",
".sh",
".ts",
".tsx",
".js",
".json",
".txt",
".cfg",
".ini",
".env",
".example",
".Dockerfile",
}
def iter_files():
for p in ROOT.rglob("*"):
if any(part in SKIP_DIRS for part in p.parts):
continue
if p.is_file() and (p.suffix in TEXT_EXT or p.name.endswith("Dockerfile")):
yield p
def main() -> int:
violations: list[str] = []
patterns = [re.compile(p) for p in FORBIDDEN]
for path in iter_files():
if path.name == "name_audit.py":
continue
try:
text = path.read_text(encoding="utf-8")
except (UnicodeDecodeError, OSError):
continue
for pat in patterns:
for m in pat.finditer(text):
line = text[: m.start()].count("\n") + 1
violations.append(f"{path.relative_to(ROOT)}:{line}: forbidden name '{m.group()}'")
# Canonical presence checks.
required = {
"pyproject.toml": ['name = "auralynq"'],
"README.md": ["Auralynq", "Talk to Your Data"],
}
for rel, needles in required.items():
fp = ROOT / rel
if not fp.exists():
violations.append(f"{rel}: missing (expected canonical naming)")
continue
content = fp.read_text(encoding="utf-8")
for n in needles:
if n not in content:
violations.append(f"{rel}: missing required string {n!r}")
if violations:
print("✗ Name audit FAILED:")
for v in violations:
print(f" - {v}")
return 1
print("✓ Name audit passed: Auralynq naming is consistent.")
return 0
if __name__ == "__main__":
sys.exit(main())
|