LordXido commited on
Commit
f8b59bb
·
verified ·
1 Parent(s): 75f421f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -108
app.py CHANGED
@@ -1,114 +1,53 @@
1
- """
2
- CodexFlow_TM Canonical Execution Spine
3
- Authoritative runtime entrypoint
4
- """
5
-
6
- from fastapi import FastAPI
7
- from typing import Any, Dict
8
- import traceback
9
-
10
- # ----------------------------
11
- # Safe module loading helpers
12
- # ----------------------------
13
-
14
- def safe_call(module, fn_name, *args, **kwargs):
15
- if hasattr(module, fn_name):
16
- return getattr(module, fn_name)(*args, **kwargs)
17
- raise AttributeError(f"{module.__name__}.{fn_name} not found")
18
-
19
- # ----------------------------
20
- # Import system components
21
- # ----------------------------
22
-
23
- import ingest
24
- import economic_kernel
25
- import core_engine
26
- import analytics_engine
27
- import cashflow
28
- import energy_engine
29
- import logistics_engine
30
- import byte_enforcer
31
- import proof_engine
32
- import federation
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
- # 3. CORE ENGINE (orchestration)
79
- core_state = safe_call(core_engine, "run", kernel_state)
80
-
81
- # 4. ANALYTICS
82
- analytics_state = safe_call(analytics_engine, "analyze", core_state)
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
- # 8. PROOF
95
- proof = safe_call(proof_engine, "prove", enforced_state)
96
 
97
- # 9. FEDERATION ENVELOPE
98
- response = safe_call(
99
- federation,
100
- "wrap",
101
- {
102
- "state": enforced_state,
103
- "proof": proof
104
- }
105
- )
106
 
107
- return response
 
 
 
 
108
 
109
- except Exception as e:
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()