44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""Lightweight cross-venue execution router (experimental)."""
|
|
from __future__ import annotations
|
|
|
|
from typing import List, Optional
|
|
|
|
from deltaforge_mvp.core import PlanDelta
|
|
|
|
|
|
class ExecutionRouter:
|
|
"""Simple round-robin routing of a PlanDelta to available venues.
|
|
|
|
This is a tiny, self-contained shim that demonstrates how a real executor
|
|
would dispatch plan deltas to venue adapters with latency/fees metadata.
|
|
"""
|
|
|
|
def __init__(self, venues: Optional[List[str]] = None):
|
|
self.venues = venues or []
|
|
self._idx = 0
|
|
|
|
def route(self, plan: PlanDelta) -> dict:
|
|
"""Route the given plan to a venue (or no venue if unknown).
|
|
|
|
Returns a dict with routing metadata that downstream systems can consume.
|
|
"""
|
|
if not self.venues:
|
|
return {"routed": False, "reason": "no_venues_configured"}
|
|
|
|
venue = self.venues[self._idx % len(self.venues)]
|
|
self._idx += 1
|
|
# Attach simple routing metadata to the plan (clone-like behavior)
|
|
routed = PlanDelta(
|
|
deltas=plan.deltas,
|
|
confidence=plan.confidence if hasattr(plan, "confidence") else 1.0,
|
|
venue=venue,
|
|
author=plan.author,
|
|
timestamp=plan.timestamp,
|
|
signature=plan.signature,
|
|
)
|
|
return {
|
|
"routed": True,
|
|
"venue": venue,
|
|
"plan": routed,
|
|
}
|