| |
| """Validate that the public Smoke24 project boundary stays clean.""" |
|
|
| from __future__ import annotations |
|
|
| import csv |
| import json |
| from pathlib import Path |
|
|
|
|
| ROOT = Path(__file__).resolve().parents[1] |
| PUBLIC_ROOTS = [ |
| ROOT / "data/public", |
| ROOT / "reports/public", |
| ROOT / "dashboard", |
| ROOT / "scripts", |
| ROOT / "docs", |
| ] |
| BANNED_TEXT = ( |
| "BOBSHELL_" + "API_KEY", |
| "HUGGING_FACE_HUB_" + "TOKEN", |
| "HF_" + "TOKEN", |
| "OPENAI_" + "API_KEY", |
| "ANTHROPIC_" + "API_KEY", |
| "internal/" + "ibm-bob", |
| "ornith-1.0-35b-" + "nvfp4", |
| ) |
| BANNED_COLUMNS = {"api_" + "base", "client_model_" + "arg"} |
|
|
|
|
| def read_csv(path: Path) -> list[dict[str, str]]: |
| with path.open(newline="", encoding="utf-8") as handle: |
| return list(csv.DictReader(handle)) |
|
|
|
|
| def validate_text() -> list[str]: |
| errors: list[str] = [] |
| for root in PUBLIC_ROOTS: |
| for path in root.rglob("*"): |
| if "__pycache__" in path.parts: |
| continue |
| if not path.is_file() or path.suffix.lower() in {".png", ".jpg", ".jpeg", ".webp", ".pyc"}: |
| continue |
| text = path.read_text(encoding="utf-8", errors="ignore") |
| lowered = text.lower() |
| for needle in BANNED_TEXT: |
| if needle.lower() in lowered: |
| errors.append(f"{path.relative_to(ROOT)} contains banned marker {needle}") |
| return errors |
|
|
|
|
| def validate_csvs() -> list[str]: |
| errors: list[str] = [] |
| for path in (ROOT / "data/public").rglob("*.csv"): |
| rows = read_csv(path) |
| if not rows: |
| errors.append(f"{path.relative_to(ROOT)} is empty") |
| continue |
| fields = set(rows[0]) |
| leaked = sorted(fields & BANNED_COLUMNS) |
| if leaked: |
| errors.append(f"{path.relative_to(ROOT)} contains private endpoint columns: {', '.join(leaked)}") |
| for row in rows: |
| model_id = (row.get("model_id") or row.get("canonical_model_id") or "").lower() |
| if model_id.startswith("internal/") or "nvfp4" in model_id: |
| errors.append(f"{path.relative_to(ROOT)} contains non-public model id {model_id}") |
| return errors |
|
|
|
|
| def validate_dashboard_data() -> list[str]: |
| errors: list[str] = [] |
| data_path = ROOT / "site/assets/data/report-data.json" |
| if not data_path.exists(): |
| return errors |
| data = json.loads(data_path.read_text(encoding="utf-8")) |
| for row in data.get("models", []): |
| model_id = str(row.get("model_id") or "").lower() |
| if model_id.startswith("internal/") or "nvfp4" in model_id: |
| errors.append(f"site dashboard contains non-public model id {model_id}") |
| return errors |
|
|
|
|
| def main() -> None: |
| errors = validate_text() + validate_csvs() + validate_dashboard_data() |
| if errors: |
| raise SystemExit("Public validation failed:\n" + "\n".join(errors)) |
| print("public data boundary ok") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|