Spaces:
Configuration error
Configuration error
| import json | |
| from pathlib import Path | |
| import gradio as gr | |
| import pandas as pd | |
| DATA_PATH = Path(__file__).parent / "proof_data.json" | |
| def load_data(): | |
| with open(DATA_PATH, "r", encoding="utf-8") as f: | |
| return json.load(f) | |
| DATA = load_data() | |
| def format_module_table(): | |
| rows = [] | |
| for item in DATA["public_proof"]["dataset_modules"]: | |
| rows.append({ | |
| "module": item["module"], | |
| "decision": item["decision"], | |
| "status": item["status"], | |
| "omega": item["omega"] if item["omega"] is not None else "—", | |
| "note": item["note"], | |
| }) | |
| return pd.DataFrame(rows) | |
| def format_failed_apps(): | |
| rows = [] | |
| for item in DATA["deploy_dashboard"]["failed_apps"]: | |
| rows.append({ | |
| "app": item["name"], | |
| "status": item["status"], | |
| "recommended_action": item["recommended_action"], | |
| }) | |
| return pd.DataFrame(rows) | |
| def format_healthy_apps(): | |
| return pd.DataFrame({"healthy_apps": DATA["deploy_dashboard"]["healthy_apps"]}) | |
| def compute_status_badges(): | |
| summary = DATA["deploy_dashboard"]["summary"] | |
| thresholds = DATA["public_proof"]["thresholds"] | |
| ledger = DATA["public_proof"]["ledger"] | |
| md = f""" | |
| ### Estado público do sistema | |
| - **Apps monitorados:** {summary["total_apps"]} | |
| - **Deploys saudáveis:** {summary["deployed"]} | |
| - **Deploys falhos:** {summary["failed"]} | |
| - **Ψ mínimo:** {thresholds["psi_min"]} | |
| - **CVaR máximo:** {thresholds["cvar_max"]} | |
| - **Ω para PASS:** {thresholds["omega_pass"]} | |
| - **Ledger:** {ledger["type"]} | |
| - **Replay:** {ledger["replay"]} | |
| - **Receipt:** {ledger["receipt"]} | |
| """ | |
| return md | |
| def verify_sample(psi, theta_ms, cvar, pole): | |
| theta_hat = 1.0 / (1.0 + theta_ms / 100.0) | |
| omega = 0.4 * psi + 0.3 * theta_hat + 0.2 * (1.0 - cvar) + 0.1 * pole | |
| reasons = [] | |
| if psi < DATA["public_proof"]["thresholds"]["psi_min"]: | |
| reasons.append("psi_below_threshold") | |
| if cvar > DATA["public_proof"]["thresholds"]["cvar_max"]: | |
| reasons.append("cvar_above_threshold") | |
| status = "PASS" | |
| if reasons: | |
| status = "BLOCK" | |
| elif omega < DATA["public_proof"]["thresholds"]["omega_pass"]: | |
| status = "CONDITIONAL" | |
| return { | |
| "psi": round(psi, 6), | |
| "theta_ms": round(theta_ms, 6), | |
| "theta_hat": round(theta_hat, 6), | |
| "cvar": round(cvar, 6), | |
| "pole": int(pole), | |
| "omega": round(omega, 6), | |
| "decision": status, | |
| "reasons": reasons or ["admissible"], | |
| } | |
| CUSTOM_CSS = """ | |
| :root { | |
| --mv-bg: #0a0f1f; | |
| --mv-card: #11172a; | |
| --mv-card-2: #151d35; | |
| --mv-text: #f4f7ff; | |
| --mv-muted: #b7c3e0; | |
| --mv-accent: #7c5cff; | |
| --mv-accent-2: #00d0ff; | |
| --mv-ok: #16c784; | |
| --mv-warn: #ffb020; | |
| --mv-bad: #ff5d7a; | |
| } | |
| .gradio-container { | |
| background: | |
| radial-gradient(circle at top left, rgba(124,92,255,0.18), transparent 22%), | |
| radial-gradient(circle at top right, rgba(0,208,255,0.12), transparent 24%), | |
| linear-gradient(180deg, #070b16 0%, #0a0f1f 100%); | |
| color: var(--mv-text); | |
| } | |
| .mv-hero { | |
| padding: 24px 8px 8px 8px; | |
| } | |
| .mv-hero h1 { | |
| font-size: 46px; | |
| margin: 0 0 8px 0; | |
| line-height: 1.05; | |
| } | |
| .mv-sub { | |
| color: var(--mv-muted); | |
| font-size: 17px; | |
| max-width: 900px; | |
| } | |
| .mv-grid { | |
| display: grid; | |
| grid-template-columns: repeat(4, minmax(0, 1fr)); | |
| gap: 14px; | |
| margin-top: 18px; | |
| } | |
| .mv-card { | |
| background: linear-gradient(180deg, var(--mv-card), var(--mv-card-2)); | |
| border: 1px solid rgba(255,255,255,0.08); | |
| border-radius: 18px; | |
| padding: 16px; | |
| box-shadow: 0 10px 30px rgba(0,0,0,0.24); | |
| } | |
| .mv-label { | |
| color: var(--mv-muted); | |
| font-size: 13px; | |
| margin-bottom: 6px; | |
| } | |
| .mv-value { | |
| font-size: 28px; | |
| font-weight: 700; | |
| } | |
| .mv-chip { | |
| display: inline-block; | |
| padding: 6px 10px; | |
| border-radius: 999px; | |
| margin-right: 8px; | |
| font-size: 12px; | |
| font-weight: 600; | |
| } | |
| .mv-ok { background: rgba(22,199,132,0.12); color: #7bf0b9; } | |
| .mv-warn { background: rgba(255,176,32,0.12); color: #ffd073; } | |
| .mv-bad { background: rgba(255,93,122,0.12); color: #ff9fb1; } | |
| @media (max-width: 960px) { | |
| .mv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } | |
| } | |
| @media (max-width: 640px) { | |
| .mv-grid { grid-template-columns: 1fr; } | |
| .mv-hero h1 { font-size: 34px; } | |
| } | |
| """ | |
| summary = DATA["deploy_dashboard"]["summary"] | |
| hero_html = f""" | |
| <div class="mv-hero"> | |
| <div class="mv-chip mv-ok">landing oficial</div> | |
| <div class="mv-chip mv-warn">prova pública</div> | |
| <div class="mv-chip mv-bad">fail-closed explícito</div> | |
| <h1>MatVerse Memory Registry</h1> | |
| <div class="mv-sub"> | |
| Infraestrutura pública para apresentar, medir e verificar artefatos soberanos do ecossistema MatVerse. | |
| Esta página unifica narrativa institucional, prova pública baseada em Ω/MNB/Ledger e o dashboard resumido dos deploys soberanos. | |
| </div> | |
| <div class="mv-grid"> | |
| <div class="mv-card"> | |
| <div class="mv-label">Apps monitorados</div> | |
| <div class="mv-value">{summary["total_apps"]}</div> | |
| </div> | |
| <div class="mv-card"> | |
| <div class="mv-label">Deploys saudáveis</div> | |
| <div class="mv-value">{summary["deployed"]}</div> | |
| </div> | |
| <div class="mv-card"> | |
| <div class="mv-label">Deploys falhos</div> | |
| <div class="mv-value">{summary["failed"]}</div> | |
| </div> | |
| <div class="mv-card"> | |
| <div class="mv-label">Merkle root</div> | |
| <div class="mv-value" style="font-size:16px">STABLE_ROOT_PLACEHOLDER</div> | |
| </div> | |
| </div> | |
| </div> | |
| """ | |
| with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Base(), title="MatVerse Memory Registry") as demo: | |
| gr.HTML(hero_html) | |
| with gr.Tabs(): | |
| with gr.Tab("Landing"): | |
| gr.Markdown(""" | |
| ## O que é | |
| O **MatVerse Memory Registry** é a superfície pública do stack de memória verificável. | |
| Ele expõe narrativa institucional, critérios de admissibilidade, prova pública, deploy status e um verificador local do operador Ω. | |
| ## O que a página resolve | |
| - substitui o estado de erro de configuração do Space por uma homepage funcional | |
| - concentra landing page e dashboard no mesmo endereço oficial | |
| - apresenta prova pública em formato legível para revisão externa | |
| - mantém o regime **fail-closed** visível: módulos não admissíveis aparecem como bloqueados, não como sucesso cosmético | |
| """) | |
| gr.Markdown(compute_status_badges()) | |
| with gr.Row(): | |
| gr.Markdown(f""" | |
| ### Links institucionais | |
| - ORCID: {DATA["public_proof"]["institutional_links"]["orcid"]} | |
| - Space: {DATA["public_proof"]["institutional_links"]["space"]} | |
| """) | |
| gr.JSON(DATA["public_proof"]["thresholds"], label="Thresholds públicos") | |
| with gr.Tab("Prova Pública"): | |
| gr.Markdown(""" | |
| ## Operador público de governança | |
| O dashboard usa a forma pública do operador: | |
| **Ω = 0.4·Ψ + 0.3·Θ̂ + 0.2·(1−CVaR) + 0.1·PoLE** | |
| com hard constraints: | |
| - Ψ ≥ 0.85 | |
| - CVaR ≤ 0.05 | |
| - Ω ≥ 0.85 para PASS | |
| """) | |
| gr.Dataframe(value=format_module_table(), interactive=False, wrap=True, label="Módulos públicos") | |
| gr.JSON(DATA["public_proof"]["ledger"], label="Ledger / replay / receipt") | |
| with gr.Tab("Dashboard de Deploys"): | |
| gr.Markdown(""" | |
| ## Artefatos soberanos em produção | |
| Este quadro resume a frota KiloApps que alimenta o ecossistema e destaca os dois deploys falhos reportados no corpus. | |
| """) | |
| with gr.Row(): | |
| gr.Dataframe(value=format_failed_apps(), interactive=False, wrap=True, label="Falhas priorizadas") | |
| gr.Dataframe(value=format_healthy_apps(), interactive=False, wrap=True, label="Apps saudáveis amostrados") | |
| with gr.Tab("Verificador Ω"): | |
| gr.Markdown(""" | |
| ## Verificação local | |
| Insira métricas e confira a decisão canônica do operador público. | |
| """) | |
| with gr.Row(): | |
| psi = gr.Number(value=0.90, label="Ψ") | |
| theta_ms = gr.Number(value=50.0, label="Θ em ms") | |
| cvar = gr.Number(value=0.02, label="CVaR") | |
| pole = gr.Slider(0, 1, value=1, step=1, label="PoLE") | |
| verify_btn = gr.Button("Verificar") | |
| verify_out = gr.JSON(label="Resultado") | |
| verify_btn.click(fn=verify_sample, inputs=[psi, theta_ms, cvar, pole], outputs=verify_out) | |
| with gr.Tab("Raw JSON"): | |
| gr.JSON(DATA, label="proof_data.json") | |
| demo.launch() | |