build(agent): new-agents-4#58ba63 iteration
This commit is contained in:
parent
8ef915c6b4
commit
ede84be814
|
|
@ -0,0 +1,23 @@
|
|||
"""Starter Broker Adapter for EquiCompiler GoC workflow.
|
||||
|
||||
This is a minimal, self-contained adapter stub intended to prove the plug-and-play
|
||||
flow with the Graph-of-Contracts registry. It exposes a register() function used by
|
||||
the GoC layer to surface a simple contract descriptor for a broker adapter.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def register(registry): # pragma: no cover
|
||||
"""Register this broker adapter with the provided registry."""
|
||||
if registry is None:
|
||||
return
|
||||
registry.register(
|
||||
name="mock-broker",
|
||||
contract={
|
||||
"type": "broker",
|
||||
"version": "0.1",
|
||||
"description": "Mock broker adapter for MVP interoperability",
|
||||
"contracts": [{"name": "order_execution", "provider": "mock"}],
|
||||
},
|
||||
)
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
"""Starter Data Feed Adapter for EquiCompiler GoC workflow.
|
||||
|
||||
This is a minimal, self-contained adapter that can be registered with the
|
||||
GoC registry. It serves as a playground for plug-and-play interoperability
|
||||
between adapters and the EquiIR representation.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
try:
|
||||
from .broker_adapter import register as _register_broker # type: ignore
|
||||
except Exception:
|
||||
_register_broker = None # pragma: no cover
|
||||
|
||||
|
||||
def register(registry): # pragma: no cover
|
||||
"""Register this data-feed adapter with the provided registry."""
|
||||
if registry is None:
|
||||
return
|
||||
registry.register(
|
||||
name="mock-data-feed",
|
||||
contract={
|
||||
"type": "data-feed",
|
||||
"version": "0.1",
|
||||
"description": "Mock data feed for prices and signals",
|
||||
"contracts": [
|
||||
{"name": "prices", "provider": "mock"},
|
||||
],
|
||||
},
|
||||
)
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
"""Deterministic delta-sync utilities for EquiCompiler MVP.
|
||||
|
||||
This module provides a tiny, deterministic delta computation between two
|
||||
IR snapshots. It is intentionally lightweight and designed to be extended in
|
||||
future MVP phases.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
def _digest(ir: Dict[str, Any]) -> str:
|
||||
"""Compute a stable digest for a given IR dictionary."""
|
||||
return hashlib.sha256(json.dumps(ir, sort_keys=True).encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
def delta_sync(old_ir: Dict[str, Any], new_ir: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""Compute a minimal delta between two IR snapshots.
|
||||
|
||||
Returns a dictionary describing changes and a new digest for the updated IR.
|
||||
This is not a full delta engine; it provides a deterministic baseline that
|
||||
can be extended with richer delta information as the MVP evolves.
|
||||
"""
|
||||
old_assets = set(old_ir.get("assets", []))
|
||||
new_assets = set(new_ir.get("assets", []))
|
||||
|
||||
delta = {
|
||||
"assets_added": sorted(list(new_assets - old_assets)),
|
||||
"assets_removed": sorted(list(old_assets - new_assets)),
|
||||
"constraints_changed": {}, # naive: compute by key presence and value change
|
||||
"digest": _digest(new_ir),
|
||||
}
|
||||
|
||||
old_constraints = old_ir.get("constraints", {}) or {}
|
||||
new_constraints = new_ir.get("constraints", {}) or {}
|
||||
all_keys = set(old_constraints.keys()) | set(new_constraints.keys())
|
||||
for k in all_keys:
|
||||
ov = old_constraints.get(k)
|
||||
nv = new_constraints.get(k)
|
||||
if ov != nv:
|
||||
delta["constraints_changed"][k] = {"old": ov, "new": nv}
|
||||
|
||||
return delta
|
||||
Loading…
Reference in New Issue