From 8ef915c6b497b1e21e49e2e3d28b4cc1855044c9 Mon Sep 17 00:00:00 2001 From: agent-58ba63c88b4c9625 Date: Mon, 20 Apr 2026 16:31:21 +0200 Subject: [PATCH] build(agent): new-agents-4#58ba63 iteration --- .../adapters/broker.py | 27 +++++++++++++++++++ .../adapters/data_feed.py | 27 +++++++++++++++++++ .../core.py | 7 +++++ tests/test_execution_policy.py | 23 ++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 equicompiler_algebraic_portfolio_dsl_to_/adapters/broker.py create mode 100644 equicompiler_algebraic_portfolio_dsl_to_/adapters/data_feed.py create mode 100644 tests/test_execution_policy.py diff --git a/equicompiler_algebraic_portfolio_dsl_to_/adapters/broker.py b/equicompiler_algebraic_portfolio_dsl_to_/adapters/broker.py new file mode 100644 index 0000000..39c8144 --- /dev/null +++ b/equicompiler_algebraic_portfolio_dsl_to_/adapters/broker.py @@ -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"] diff --git a/equicompiler_algebraic_portfolio_dsl_to_/adapters/data_feed.py b/equicompiler_algebraic_portfolio_dsl_to_/adapters/data_feed.py new file mode 100644 index 0000000..88fd379 --- /dev/null +++ b/equicompiler_algebraic_portfolio_dsl_to_/adapters/data_feed.py @@ -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"] diff --git a/equicompiler_algebraic_portfolio_dsl_to_/core.py b/equicompiler_algebraic_portfolio_dsl_to_/core.py index 57dc281..891568e 100644 --- a/equicompiler_algebraic_portfolio_dsl_to_/core.py +++ b/equicompiler_algebraic_portfolio_dsl_to_/core.py @@ -28,6 +28,7 @@ def parse_dsl_to_ir(dsl: str) -> Dict[str, object]: assets: List[str] = [] objectives: List[str] = [] constraints: Dict[str, str] = {} + execution_policy: List[str] = [] lines = [ln.strip() for ln in dsl.strip().splitlines() if ln.strip()] for line in lines: @@ -46,11 +47,17 @@ def parse_dsl_to_ir(dsl: str) -> Dict[str, object]: if "=" in p: k, v = [s.strip() for s in p.split("=", 1)] 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 = { "assets": assets, "objectives": objectives, "constraints": constraints, + "execution_policy": execution_policy, "version": "0.1", } # Attach lightweight, deterministic attestations to support auditability. diff --git a/tests/test_execution_policy.py b/tests/test_execution_policy.py new file mode 100644 index 0000000..58c8257 --- /dev/null +++ b/tests/test_execution_policy.py @@ -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()