Spaces:
Sleeping
Sleeping
| # app.py | |
| # Author: Liam Grinstead | |
| # Purpose: Run agent simulations, mutations, falsifiability checks, and validation stages with automatic logging | |
| from modules.agent_spawner import spawn_agent | |
| from modules.mutation_engine import mutate_agent | |
| from modules.field_visualizer import render_fields | |
| from modules.falsifiability_bench import run_falsifiability | |
| from modules.codex_logger import log_artifact | |
| from modules.codex_viewer import load_codex | |
| import gradio as gr | |
| import stage1 # later add stage2, stage3, etc. | |
| def run_simulation(agent_id, mutation_profile): | |
| """ | |
| Run a full simulation cycle: | |
| 1. Spawn agent | |
| 2. Apply mutation profile | |
| 3. Render fields (optional) | |
| 4. Run falsifiability bench | |
| 5. Log artifact with SHA-512 seal | |
| """ | |
| agent = spawn_agent(agent_id) | |
| mutated = mutate_agent(agent, mutation_profile) | |
| try: | |
| render_fields(mutated) | |
| except Exception: | |
| pass | |
| score, hash_val = run_falsifiability(mutated) | |
| log_artifact(mutated, score, hash_val) | |
| return mutated, hash_val | |
| # ---------------- Validation Stage Wrapper ---------------- | |
| def run_stage(stage_name, mode, steps_or_epochs, batch, lr): | |
| if stage_name == "Stage 1 — CIFAR-10 Baseline": | |
| stage1.train( | |
| mode=mode, | |
| epochs=int(steps_or_epochs), | |
| batch=int(batch), | |
| lr=float(lr), | |
| log_path="stage1_cifar10_log.jsonl" | |
| ) | |
| return f"Stage 1 complete.\nMode: {mode}\nEpochs: {steps_or_epochs}\nBatch: {batch}\nLR: {lr}\nTelemetry saved to stage1_cifar10_log.jsonl" | |
| else: | |
| return "Stage not yet implemented." | |
| # ---------------- Gradio Interface ---------------- | |
| iface = gr.Interface( | |
| fn=run_stage, | |
| inputs=[ | |
| gr.Dropdown(["Stage 1 — CIFAR-10 Baseline"], label="Select Stage"), | |
| gr.Dropdown(["RFT", "BASE"], label="Mode"), | |
| gr.Number(label="Epochs", value=5), | |
| gr.Number(label="Batch Size", value=256), | |
| gr.Number(label="Learning Rate", value=5e-4), | |
| ], | |
| outputs="text", | |
| title="RFTSystems — Symbolic Mutations & Validation", | |
| description="Run agent simulations or validation stages of Rendered Frame Theory (RFT)." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |