Spaces:
Sleeping
Sleeping
Deploy: mxbai GGUF false-positive fix + DNA-017 scan telemetry (app.py)
Browse files16 unmodified lines171819202122229 unmodified lines25225325425525625725825926026138 unmodified lines30030130230330430516 unmodified linessys.path.insert(0, str(Path(__file__).parent))from scan import scan, inspect_gguf, KNOWN_BASES# ββ Discovery: find derivatives that may not attribute properly ββββββββββββdef find_unattributed_derivatives(base_match: str, scanned_id: str) -> list[dict]:229 unmodified linesdetails = "### What this is\n" + result.get("detected", "") + "\n\n"if src:details += f"**Resolved full-weights source:** `{src}`\n\n"details += ("**Optional deeper checks** β use the buttons below:\n""- π Inspect this GGUF's embedded metadata (architecture + chat template) β header-only, no download\n")if src:details += "- π¬ Scan the full-weights source for full Stage 1 + Stage 2\n"disc = ("### π Derivative Discovery\n\nGGUF quants inherit their source's provenance ""(and any identity scrub baked into the chat template). Inspect the metadata or ""scan the source for the full picture.")38 unmodified linesresult = scan(model_id)store_scan_result(result)# GGUF: show detection + reveal the optional follow-up buttonsif str(result.get("format", "")).startswith("GGUF"):16 unmodified lines17181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465229 unmodified lines29529629729829930030138 unmodified lines34034134234334434534616 unmodified linessys.path.insert(0, str(Path(__file__).parent))from scan import scan, inspect_gguf, KNOWN_BASES# ββ DNA-017: scan telemetry β HF dataset (fuels derivative discovery + demand-driven ingestion)# Guarded on LOG_TOKEN (a fine-grained WRITE token for RadicalNotionAI/modeldna-scan-log).# No-op if the secret isn't set, so deploying this never breaks the Space.import os as _os, json as _json, datetime as _dtfrom pathlib import Path as _Path_SCAN_LOGGER = Nonetry:_log_token = _os.environ.get("LOG_TOKEN")if _log_token:from huggingface_hub import CommitScheduler_LOG_DIR = _Path("scan_logs"); _LOG_DIR.mkdir(exist_ok=True)_LOG_FILE = _LOG_DIR / "scans.jsonl"_SCAN_LOGGER = CommitScheduler(repo_id="RadicalNotionAI/modeldna-scan-log", repo_type="dataset",folder_path=str(_LOG_DIR), every=10, token=_log_token,path_in_repo="data", squash_history=False,)except Exception:_SCAN_LOGGER = Nonedef log_scan(model_id: str, result: dict) -> None:if _SCAN_LOGGER is None:returntry:v = result.get("verdict", {})rec = {"model_id": model_id,"ts": _dt.datetime.now(_dt.timezone.utc).isoformat(),"format": result.get("format", "checkpoint"),"architecture": v.get("architecture", "") or result.get("detected", "")[:80],"confidence": v.get("confidence"),"risk_score": v.get("risk_score"),"risk_band": v.get("risk_band"),"flag_types": [f.get("type") for f in v.get("flags", [])],"resolved_source": result.get("resolved_source"),"error": result.get("error"),}with _SCAN_LOGGER.lock:with open(_LOG_FILE, "a") as fh:fh.write(_json.dumps(rec) + "\n")except Exception:pass# ββ Discovery: find derivatives that may not attribute properly ββββββββββββdef find_unattributed_derivatives(base_match: str, scanned_id: str) -> list[dict]:229 unmodified linesdetails = "### What this is\n" + result.get("detected", "") + "\n\n"if src:details += f"**Resolved full-weights source:** `{src}`\n\n"details += "_Use the buttons below to inspect the GGUF's embedded metadata or scan the full-weights source._"disc = ("### π Derivative Discovery\n\nGGUF quants inherit their source's provenance ""(and any identity scrub baked into the chat template). Inspect the metadata or ""scan the source for the full picture.")38 unmodified linesresult = scan(model_id)store_scan_result(result)log_scan(model_id, result) # DNA-017: telemetry to HF dataset (no-op without LOG_TOKEN)# GGUF: show detection + reveal the optional follow-up buttonsif str(result.get("format", "")).startswith("GGUF"):
app.py+45-4