Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,114 +1,53 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
# ----------------------------
|
| 35 |
-
# FastAPI app
|
| 36 |
-
# ----------------------------
|
| 37 |
-
|
| 38 |
-
app = FastAPI(
|
| 39 |
-
title="CodexFlow ΩΞ",
|
| 40 |
-
description="Autonomous Economic Reflex Operating System",
|
| 41 |
-
version="ΩΞ-Execution-Spine-1.0"
|
| 42 |
-
)
|
| 43 |
-
|
| 44 |
-
# ----------------------------
|
| 45 |
-
# Root / health
|
| 46 |
-
# ----------------------------
|
| 47 |
-
|
| 48 |
-
@app.get("/")
|
| 49 |
-
def status():
|
| 50 |
-
return {
|
| 51 |
-
"status": "online",
|
| 52 |
-
"engine": "CodexFlow_TM",
|
| 53 |
-
"role": "Economic Web Services Runtime"
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
# ----------------------------
|
| 57 |
-
# Canonical execution pipeline
|
| 58 |
-
# ----------------------------
|
| 59 |
-
|
| 60 |
-
@app.post("/execute")
|
| 61 |
-
def execute(payload: Dict[str, Any] = None):
|
| 62 |
-
"""
|
| 63 |
-
Single authoritative execution path:
|
| 64 |
-
Ingest → Kernel → Core → Analytics → Enforcement → Proof → Federation
|
| 65 |
-
"""
|
| 66 |
-
|
| 67 |
-
try:
|
| 68 |
-
# 1. INGEST
|
| 69 |
-
raw_state = safe_call(ingest, "ingest")
|
| 70 |
-
|
| 71 |
-
# 2. ECONOMIC KERNEL (physics)
|
| 72 |
-
kernel_state = safe_call(
|
| 73 |
-
economic_kernel,
|
| 74 |
-
"evaluate",
|
| 75 |
-
raw_state if payload is None else {**raw_state, **payload}
|
| 76 |
)
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
# 5. CASHFLOW DYNAMICS
|
| 85 |
-
flow_state = safe_call(cashflow, "propagate", analytics_state)
|
| 86 |
-
|
| 87 |
-
# 6. ENERGY & LOGISTICS (real-world modifiers)
|
| 88 |
-
energy_state = safe_call(energy_engine, "apply", flow_state)
|
| 89 |
-
logistics_state = safe_call(logistics_engine, "apply", energy_state)
|
| 90 |
-
|
| 91 |
-
# 7. BYTE-LEVEL ENFORCEMENT
|
| 92 |
-
enforced_state = safe_call(byte_enforcer, "enforce", logistics_state)
|
| 93 |
|
| 94 |
-
|
| 95 |
-
proof = safe_call(proof_engine, "prove", enforced_state)
|
| 96 |
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
federation,
|
| 100 |
-
"wrap",
|
| 101 |
-
{
|
| 102 |
-
"state": enforced_state,
|
| 103 |
-
"proof": proof
|
| 104 |
-
}
|
| 105 |
-
)
|
| 106 |
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
-
|
| 110 |
-
return {
|
| 111 |
-
"status": "error",
|
| 112 |
-
"error": str(e),
|
| 113 |
-
"trace": traceback.format_exc()
|
| 114 |
-
}
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from core_engine import run_engine
|
| 3 |
+
from proof_engine import generate_proof
|
| 4 |
+
|
| 5 |
+
def execute_simulation(
|
| 6 |
+
commodity,
|
| 7 |
+
physical_anchor,
|
| 8 |
+
reporting_lag
|
| 9 |
+
):
|
| 10 |
+
state = run_engine(
|
| 11 |
+
commodity=commodity,
|
| 12 |
+
anchor=physical_anchor,
|
| 13 |
+
lag_days=reporting_lag
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
proof = generate_proof(state)
|
| 17 |
+
|
| 18 |
+
return state, proof
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
with gr.Blocks(title="CodexFlow ΩΞ") as demo:
|
| 22 |
+
gr.Markdown("## CodexFlow ΩΞ — Autonomous Economic World Engine")
|
| 23 |
+
|
| 24 |
+
with gr.Row():
|
| 25 |
+
commodity = gr.Dropdown(
|
| 26 |
+
["Gold", "Oil", "Wheat", "Electricity"],
|
| 27 |
+
label="Commodity",
|
| 28 |
+
value="Gold"
|
| 29 |
+
)
|
| 30 |
+
anchor = gr.Number(
|
| 31 |
+
value=950,
|
| 32 |
+
label="Physical Anchor (Base Units)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
)
|
| 34 |
|
| 35 |
+
lag = gr.Slider(
|
| 36 |
+
1, 30,
|
| 37 |
+
value=7,
|
| 38 |
+
step=1,
|
| 39 |
+
label="Reporting Lag (days)"
|
| 40 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
run = gr.Button("Run Simulation")
|
|
|
|
| 43 |
|
| 44 |
+
output = gr.JSON(label="World State")
|
| 45 |
+
proof = gr.JSON(label="Ω-State Proof")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
+
run.click(
|
| 48 |
+
execute_simulation,
|
| 49 |
+
inputs=[commodity, anchor, lag],
|
| 50 |
+
outputs=[output, proof]
|
| 51 |
+
)
|
| 52 |
|
| 53 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|