import gradio as gr from datetime import datetime import subprocess import sys # --- SELF-FIX HELPER (stdlib only) --- def self_fix(): """Attempt to auto-fix indentation using autopep8.""" try: subprocess.run( [sys.executable, "-m", "autopep8", "-i", __file__, "--select=E101,E111,E121"], check=True, ) print("✅ Auto-fix applied. Factory-reboot the Space now.") except Exception as e: print(f"❌ Auto-fix failed: {e}") APP_TITLE = "Sourceborn URR Control Shell" ACCEPTED_CONCEPTS = [ "Point Zero", "Source Point", "Halt Point", "Mystery", "Invention", "Point Zero with Product", ] BACKEND_SUPPORT = [ "raw source lock", "session and run tracking", "node definitions", "high-parameter memory entries", "filter results", "halt points", "loop creation", "merge proposals", "URR PASS / HOLD / REJECT reviews", "human gate decisions", "master log events", "archive/source references", ] PHASES = [ ("Phase 0", "Repo safety + Sourceborn lock", "Ready"), ("Phase 1", "Database models", "Pending"), ("Phase 2", "Master Log service", "Pending"), ("Phase 3", "Raw source lock + filter pipeline", "Pending"), ("Phase 4", "Halt Point → Loop/Sub-loop engine", "Pending"), ("Phase 5", "URR PASS / HOLD / REJECT gates", "Pending"), ("Phase 6", "Human gate decisions", "Pending"), ("Phase 7", "Memory search + merge proposal", "Pending"), ("Phase 8", "Archive/source ingestion", "Pending"), ("Phase 9", "Modern control dashboard", "Ready"), ("Phase 10", "Tests + deploy safety", "Pending"), ] LOCK_STATUS_LINES = [ ("Sourceborn Sequence", "v0.1 Review Status"), ("Concepts", "Keep"), ("Naming", "Review"), ("Core", "Not final"), ("Freeze", "Not approved"), ("Next", "Test with more examples later before freeze"), ] ACTIVE_STRUCTURE = [ "Sourceborn/", "00_TALK_AND_CONTROL", "01_SOURCEBORN_ENGINE", "02_URR", "99_ARCHIVE", ] def format_items(items): return "\n".join([f"- {item}" for item in items]) def make_lock_table(): rows = "| Area | Status |\n|---|---|\n" for area, status in LOCK_STATUS_LINES: rows += f"| {area} | {status} |\n" return rows def make_phase_table(): rows = "| Phase | Task | Status |\n|---|---|---|\n" for phase, task, status in PHASES: rows += f"| {phase} | {task} | {status} |\n" return rows def generate_review(review_input, decision): now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") return f"""# {decision} Review **Time:** {now} ## Review Input {review_input or "No review input provided."} ## Sourceborn Lock * Sourceborn Sequence = v0.1 Review Status * Concepts = Keep * Naming = Review * Core = Not final * Freeze = Not approved """ CSS = """ .gradio-container { max-width: 1220px !important; margin: auto !important; } .sb-hero { padding: 28px; border-radius: 24px; background: radial-gradient(circle at top left, rgba(99,102,241,0.35), transparent 34%), linear-gradient(135deg, rgba(15,23,42,0.98), rgba(30,41,59,0.92)); border: 1px solid rgba(148,163,184,0.22); box-shadow: 0 24px 70px rgba(2,6,23,0.35); } .sb-title { font-size: 38px; font-weight: 800; letter-spacing: -0.04em; margin-bottom: 8px; } .sb-subtitle { color: #cbd5e1; font-size: 16px; line-height: 1.6; } .sb-badge { display: inline-block; padding: 7px 13px; margin: 10px 8px 0 0; border-radius: 999px; background: rgba(99,102,241,0.18); border: 1px solid rgba(165,180,252,0.35); color: #e0e7ff; font-size: 14px; font-weight: 600; } """ with gr.Blocks(css=CSS, title=APP_TITLE) as demo: gr.HTML( """