Deterministic Governance Mechanism
Verhash LLC | Precision Substrate Computing
Development Build: FastAPI + Streamlit implementation for rapid prototyping
#!/usr/bin/env python3 """ Deterministic Exclusion Demo GUI (Development Build) FastAPI + Streamlit implementation for rapid prototyping Usage: streamlit run demo_gui_dev.py """ try: import streamlit as st import plotly.graph_objects as go import plotly.express as px except ModuleNotFoundError as exc: missing = str(exc).split("No module named ", 1)[-1].strip("'\"") print(f"Missing optional GUI dependency: {missing}") print("Install GUI deps: python -m pip install -r requirements-gui.txt") print("Run the GUI via: streamlit run demo_gui_dev.py") raise SystemExit(2) try: from streamlit.runtime.scriptrunner.script_run_context import get_script_run_ctx except Exception: get_script_run_ctx = None if get_script_run_ctx is not None and get_script_run_ctx() is None: print("This file is a Streamlit app and must be run with Streamlit:") print(" streamlit run demo_gui_dev.py") raise SystemExit(2) import time import hashlib import json from pathlib import Path from collections import deque from typing import List, Dict, Optional, Any, Tuple import os # Hugging Face Spaces detection IS_SPACES = os.getenv("SPACE_ID") is not None # Page Config MUST be the first Streamlit command st.set_page_config( page_title="Deterministic Exclusion Demo", layout="wide", initial_sidebar_state="expanded", menu_items={ 'Get Help': 'https://github.com/Rymley/Deterministic-Governance-Mechanism', 'Report a bug': 'https://github.com/Rymley/Deterministic-Governance-Mechanism/issues', 'About': """Deterministic Exclusion Demo GUI (Development Build) FastAPI + Streamlit implementation for rapid prototyping Usage: streamlit run demo_gui_dev.py""" } ) # Import engine components import sys sys.path.insert(0, str(Path(__file__).parent)) from material_field_engine import ( VerifiedSubstrate, Vector2D, MaterialFieldEngine, fp_from_float, fp_to_float, load_config ) from exclusion_demo import run_deterministic_exclusion_demo @st.cache_data def compute_substrate_embeddings_2d(substrate_list: List[str]) -> List[List[float]]: """Cached 2D embedding for material field visualization.""" from llm_adapter import DeterministicHashEmbedderND embedder = DeterministicHashEmbedderND(dim=2) return [embedder.embed(t) for t in substrate_list] @st.cache_data def compute_substrate_embeddings_highd(substrate_list: List[str]) -> List[List[float]]: """Cached 16D embedding for physics engine logic.""" from llm_adapter import DeterministicHashEmbedderND embedder = DeterministicHashEmbedderND(dim=16) return [embedder.embed(t) for t in substrate_list] # Custom CSS for monospace hash display st.markdown(""" """, unsafe_allow_html=True) # ============================================================================ # Session State Initialization # ============================================================================ if 'results' not in st.session_state: st.session_state.results = None if 'config' not in st.session_state: st.session_state.config = { 'elastic_modulus_mode': 'multiplicative', 'elastic_modulus_sigma': 0.4, 'lambda_min': 0.35, 'lambda_max': 1.20, 'inference_steps': 8 } if 'audit_log' not in st.session_state: st.session_state.audit_log = deque(maxlen=100) # ============================================================================ # Header with Branding # ============================================================================ st.markdown("""
Verhash LLC | Precision Substrate Computing
Development Build: FastAPI + Streamlit implementation for rapid prototyping