Execution Engine & System Wiring Plan (Phase 4)¶
Goal¶
Implement the ExecutionActor to drive the Saga and wire the full system in main.rs.
Components¶
1. Exchange Clients (src/market/client.rs)¶
We need a unified trait for execution commands, distinct from Monitors (data).
#[async_trait]
pub trait ExchangeClient: Send + Sync {
async fn place_order(&self, order: OrderRequest) -> Result<FillDetails, ExecutionError>;
// async fn cancel_order...
}
Implementations:
- PolymarketClient (Mock/Real HTTP)
- KalshiClient (Mock/Real HTTP)
2. Execution Actor (src/actors/executor.rs)¶
- State:
sagas: Mappoly_client: Arckalshi_client: Arc- Behavior:
- On
StartSaga(Opportunity):- Initialize new Saga.
- Execute Leg 1 (Polymarket) via Client.
- On Result -> Update State -> Execute Leg 2 (Kalshi).
- Handle Compensation if needed.
3. Wiring (src/main.rs)¶
- Initialize
PolymarketMonitor,KalshiMonitor. - Initialize
ArbiterActor(with Mappings). - Initialize
ExecutionActor(with Clients). - Wire Channels:
- Monitor -> Arbiter (MarketUpdate)
- Arbiter -> Executor (Opportunity)
Verification¶
- Safety: Verify
ExecutionActoratomic state updates. - Mocking: Test full flow with Mock Clients.