Commit ·
fe76d3d
1
Parent(s): a81c92f
chore: auto-sync update 2026-04-12 07:20:00
Browse files- models.py +1 -2
- server/app.py +37 -1
- server/fin_auditor_environment.py +1 -1
models.py
CHANGED
|
@@ -5,7 +5,6 @@
|
|
| 5 |
# LICENSE file in the root directory of this source tree.
|
| 6 |
|
| 7 |
from typing import List
|
| 8 |
-
from pydantic import StrictFloat
|
| 9 |
|
| 10 |
# FIX: Import the OpenEnv base classes instead of BaseModel
|
| 11 |
from openenv.core.env_server import Action, Observation
|
|
@@ -17,5 +16,5 @@ class AuditorAction(Action):
|
|
| 17 |
class AuditorObservation(Observation):
|
| 18 |
# This is the (batch_size, 4) matrix Samarth will send
|
| 19 |
# Features: [time_elapsed, price_delta, missing_freq, risk_score]
|
| 20 |
-
features: List[List[
|
| 21 |
message: str = "Batch processed"
|
|
|
|
| 5 |
# LICENSE file in the root directory of this source tree.
|
| 6 |
|
| 7 |
from typing import List
|
|
|
|
| 8 |
|
| 9 |
# FIX: Import the OpenEnv base classes instead of BaseModel
|
| 10 |
from openenv.core.env_server import Action, Observation
|
|
|
|
| 16 |
class AuditorObservation(Observation):
|
| 17 |
# This is the (batch_size, 4) matrix Samarth will send
|
| 18 |
# Features: [time_elapsed, price_delta, missing_freq, risk_score]
|
| 19 |
+
features: List[List[float]]
|
| 20 |
message: str = "Batch processed"
|
server/app.py
CHANGED
|
@@ -77,16 +77,52 @@ if HAS_ENV and NATIVE_VERIFIED:
|
|
| 77 |
env_factory,
|
| 78 |
AuditorAction,
|
| 79 |
AuditorObservation,
|
|
|
|
| 80 |
)
|
| 81 |
|
| 82 |
else:
|
| 83 |
# Fallback for local development without the C++ binary
|
| 84 |
app = FastAPI(title="PayGorn (MOCK MODE)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
@app.post("/reset")
|
| 86 |
-
async def mock_reset(): return {"reward":
|
|
|
|
| 87 |
@app.post("/step")
|
| 88 |
async def mock_step(action: dict): return {"reward": 0.5, "done": False, "step_count": 0}
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
# Initialize metrics for the dashboard latency middleware
|
| 91 |
app_metrics = {"last_step_latency_us": 0.0}
|
| 92 |
|
|
|
|
| 77 |
env_factory,
|
| 78 |
AuditorAction,
|
| 79 |
AuditorObservation,
|
| 80 |
+
max_concurrent_envs=4, # 3 tasks + 1 buffer for probes
|
| 81 |
)
|
| 82 |
|
| 83 |
else:
|
| 84 |
# Fallback for local development without the C++ binary
|
| 85 |
app = FastAPI(title="PayGorn (MOCK MODE)")
|
| 86 |
+
|
| 87 |
+
@app.get("/health")
|
| 88 |
+
async def mock_health():
|
| 89 |
+
return {"status": "healthy"}
|
| 90 |
+
|
| 91 |
@app.post("/reset")
|
| 92 |
+
async def mock_reset(): return {"reward": None}
|
| 93 |
+
|
| 94 |
@app.post("/step")
|
| 95 |
async def mock_step(action: dict): return {"reward": 0.5, "done": False, "step_count": 0}
|
| 96 |
|
| 97 |
+
@app.websocket("/ws")
|
| 98 |
+
async def mock_ws(websocket: WebSocket):
|
| 99 |
+
"""Bare-minimum WS so Phase 2 gets a valid response, not connection refused."""
|
| 100 |
+
await websocket.accept()
|
| 101 |
+
try:
|
| 102 |
+
while True:
|
| 103 |
+
raw = await websocket.receive_text()
|
| 104 |
+
msg = json.loads(raw)
|
| 105 |
+
msg_type = msg.get("type", "")
|
| 106 |
+
if msg_type == "reset":
|
| 107 |
+
await websocket.send_text(json.dumps({
|
| 108 |
+
"type": "observation",
|
| 109 |
+
"data": {"observation": {"features": [], "message": "mock"}, "reward": None, "done": False}
|
| 110 |
+
}))
|
| 111 |
+
elif msg_type == "step":
|
| 112 |
+
await websocket.send_text(json.dumps({
|
| 113 |
+
"type": "observation",
|
| 114 |
+
"data": {"observation": {"features": [], "message": "mock"}, "reward": 0.5, "done": True}
|
| 115 |
+
}))
|
| 116 |
+
elif msg_type == "close":
|
| 117 |
+
break
|
| 118 |
+
except WebSocketDisconnect:
|
| 119 |
+
pass
|
| 120 |
+
finally:
|
| 121 |
+
try:
|
| 122 |
+
await websocket.close()
|
| 123 |
+
except RuntimeError:
|
| 124 |
+
pass
|
| 125 |
+
|
| 126 |
# Initialize metrics for the dashboard latency middleware
|
| 127 |
app_metrics = {"last_step_latency_us": 0.0}
|
| 128 |
|
server/fin_auditor_environment.py
CHANGED
|
@@ -137,7 +137,7 @@ class FinAuditorEnvironment(Environment):
|
|
| 137 |
return FinAuditorObservation(
|
| 138 |
features=anomalies,
|
| 139 |
message=f"Fin Auditor engine ready. {len(anomalies)} trades loaded.",
|
| 140 |
-
reward=
|
| 141 |
done=False
|
| 142 |
)
|
| 143 |
|
|
|
|
| 137 |
return FinAuditorObservation(
|
| 138 |
features=anomalies,
|
| 139 |
message=f"Fin Auditor engine ready. {len(anomalies)} trades loaded.",
|
| 140 |
+
reward=None,
|
| 141 |
done=False
|
| 142 |
)
|
| 143 |
|