"""Free-tier Hugging Face interface for Project RxV. The Space is intentionally a control plane: it receives public repository URLs and renders reports, while the private Runner executes every package in a fresh sandbox. Never enable an embedded runner in this public process. """ from __future__ import annotations import html import json import os import re import time from typing import Any from urllib.parse import urlparse import gradio as gr import httpx API_URL = os.getenv("RXV_API_URL", "").rstrip("/") GITHUB_RE = re.compile(r"^https://github\.com/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+/?$") CSS = """ :root{--rxv:#9b7bff;--aqua:#4de0cd;--ink:#070a12;--panel:#101725;--line:#263450} body,.gradio-container{background:radial-gradient(950px 480px at 83% -5%,#382473 0%,transparent 58%),var(--ink)!important;color:#f4f7ff!important;font-family:Inter,ui-sans-serif,system-ui} .gradio-container{max-width:1240px!important}.hero{padding:55px 0 23px}.eyebrow{color:var(--aqua);font-size:11px;font-weight:800;letter-spacing:.18em}.hero h1{font-size:clamp(42px,6vw,76px);line-height:.95;letter-spacing:-.065em;margin:13px 0}.hero h1 span{display:block;color:#ad93ff}.hero p{color:#afbbd1;max-width:760px;font-size:17px;line-height:1.6}.metric{border-left:1px solid #33425e;padding-left:15px;margin-right:26px;display:inline-flex;flex-direction:column}.metric b{font-size:22px}.metric small{color:#95a2bb;text-transform:uppercase;font-size:10px;letter-spacing:.08em}.card{background:linear-gradient(145deg,rgba(21,30,48,.97),rgba(11,16,28,.97));border:1px solid var(--line);border-radius:16px;padding:20px!important}.section-title{font-weight:800;font-size:16px}.hint{color:#9ba9c1;font-size:13px}.primary button{background:linear-gradient(90deg,#8561f6,#aa80ff)!important;border:0!important;font-weight:800!important;height:48px!important}.status{border:1px solid #30415e;border-radius:10px;padding:14px 16px;background:#0b101b}.suite{display:grid;grid-template-columns:13px 1fr auto;gap:10px;padding:12px 0;border-bottom:1px solid #253149}.suite:last-child{border:0}.dot-pass{color:#4de0cd}.dot-warning{color:#ffc668}.dot-fail{color:#ff7286}.tag{font-size:10px;letter-spacing:.1em;color:#aab7d0}.empty{color:#98a6c0;padding:22px 0}.notice{margin:16px 0;padding:12px 14px;border:1px solid #4a397d;border-radius:10px;color:#d4c8ff;background:rgba(141,105,255,.09)} """ def validate_repo_url(value: str) -> str: value = value.strip().rstrip("/") parsed = urlparse(value) if parsed.hostname != "github.com" or parsed.username or parsed.password or parsed.query or parsed.fragment or not GITHUB_RE.fullmatch(value): raise gr.Error("Enter a public GitHub repository URL, for example https://github.com/org/package.") return value def suite_html(report: dict[str, Any] | None) -> str: if not report: return '
Weighted across correctness, security, test confidence, reproducibility, and release risk.
' def findings_html(report: dict[str, Any] | None) -> str: if not report or not report.get("findings"): return 'Paste a public GitHub repository. Project RxV runs a deep, isolated validation across package integrity, AST risk, security, tests, coverage, documentation, visual snapshots, reproducibility, and release readiness.
RXV_API_URL in Space Variables to enable real test runs.Only public GitHub owner/repository URLs are accepted.
") repo = gr.Textbox(label="Public GitHub repository", placeholder="https://github.com/organisation/package") profile = gr.Radio([("Rapid · static, structure, install", "rapid"), ("Standard · full package confidence", "standard"), ("Release · visual, portability, release gate", "release")], value="standard", label="Validation depth") submit = gr.Button("Start isolated validation →", variant="primary", elem_classes=["primary"]) with gr.Column(scale=5, elem_classes=["card"]): gr.HTML("Package layout · metadata · license · AST · secrets · dependencies · build · CRAN check · tests · coverage · lint · docs · vignettes · visual/UI · reproducibility · release gate