build(agent): new-agents-4#58ba63 iteration

This commit is contained in:
agent-58ba63c88b4c9625 2026-04-20 16:31:21 +02:00
parent 274887d856
commit 8ef915c6b4
4 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,27 @@
"""Lightweight Broker Adapter skeleton for MVP GoC interoperability."""
from __future__ import annotations
from typing import Dict, Any
class BrokerAdapter:
"""Minimal broker adapter interface for the GoC workflow.
This is intentionally small: it exposes a connect() method and a
contract descriptor that can be registered in the Graph-of-Contracts
registry.
"""
def __init__(self, name: str = "default") -> None:
self.name = name
def connect(self) -> bool:
# In a real adapter this would establish a connection to a broker
return True
def contract(self) -> Dict[str, Any]:
return {"type": "broker", "name": self.name}
__all__ = ["BrokerAdapter"]

View File

@ -0,0 +1,27 @@
"""Lightweight Data Feed Adapter skeletons for MVP GoC interoperability."""
from __future__ import annotations
from typing import Dict, Any
class DataFeedAdapter:
"""Minimal data-feed adapter interface for the GoC workflow.
This is intentionally small: it exposes a connect() method and a
contract descriptor that can be registered in the Graph-of-Contracts
registry.
"""
def __init__(self, name: str = "default") -> None:
self.name = name
def connect(self) -> bool:
# In a real adapter this would initialize network connections, auth, etc.
return True
def contract(self) -> Dict[str, Any]:
return {"type": "data_feed", "name": self.name}
__all__ = ["DataFeedAdapter"]

View File

@ -28,6 +28,7 @@ def parse_dsl_to_ir(dsl: str) -> Dict[str, object]:
assets: List[str] = [] assets: List[str] = []
objectives: List[str] = [] objectives: List[str] = []
constraints: Dict[str, str] = {} constraints: Dict[str, str] = {}
execution_policy: List[str] = []
lines = [ln.strip() for ln in dsl.strip().splitlines() if ln.strip()] lines = [ln.strip() for ln in dsl.strip().splitlines() if ln.strip()]
for line in lines: for line in lines:
@ -46,11 +47,17 @@ def parse_dsl_to_ir(dsl: str) -> Dict[str, object]:
if "=" in p: if "=" in p:
k, v = [s.strip() for s in p.split("=", 1)] k, v = [s.strip() for s in p.split("=", 1)]
constraints[k] = v constraints[k] = v
elif lower.startswith("execution_policy:"):
# Optional execution policy descriptor for offline/online orchestration
rest = line[len("execution_policy:"):].strip()
parts = [p.strip() for p in rest.replace(";", ",").split(",") if p.strip()]
execution_policy = parts
ir = { ir = {
"assets": assets, "assets": assets,
"objectives": objectives, "objectives": objectives,
"constraints": constraints, "constraints": constraints,
"execution_policy": execution_policy,
"version": "0.1", "version": "0.1",
} }
# Attach lightweight, deterministic attestations to support auditability. # Attach lightweight, deterministic attestations to support auditability.

View File

@ -0,0 +1,23 @@
import unittest
from equicompiler_algebraic_portfolio_dsl_to_.core import parse_dsl_to_ir
class TestExecutionPolicy(unittest.TestCase):
def test_parse_execution_policy(self):
dsl = (
"assets: AAPL, MSFT\n"
"objectives: maximize_return\n"
"constraints: max_drawdown=0.2, var=0.95\n"
"execution_policy: immediate, time_slice=1ms"
)
ir = parse_dsl_to_ir(dsl)
self.assertIn("execution_policy", ir)
policies = ir["execution_policy"]
self.assertIsInstance(policies, list)
self.assertIn("immediate", policies)
self.assertIn("time_slice=1ms", policies)
if __name__ == "__main__":
unittest.main()