build(agent): new-agents-2#7e3bbc iteration
This commit is contained in:
parent
b538216c64
commit
bb51fea7eb
|
|
@ -6,9 +6,11 @@ Public API (minimal):
|
||||||
- PlanDelta
|
- PlanDelta
|
||||||
- AuditLog
|
- AuditLog
|
||||||
- FederatedCoordinator for simple cross-venue signal aggregation
|
- FederatedCoordinator for simple cross-venue signal aggregation
|
||||||
|
- GraphOfContracts Registry (minimal MVP wiring for adapters and contract schemas)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .core import MarketStateSnapshot, SharedSignals, PlanDelta, AuditLog, FederatedCoordinator
|
from .core import MarketStateSnapshot, SharedSignals, PlanDelta, AuditLog, FederatedCoordinator
|
||||||
|
from .registry import GraphOfContractsRegistry # type: ignore
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"MarketStateSnapshot",
|
"MarketStateSnapshot",
|
||||||
|
|
@ -16,4 +18,5 @@ __all__ = [
|
||||||
"PlanDelta",
|
"PlanDelta",
|
||||||
"AuditLog",
|
"AuditLog",
|
||||||
"FederatedCoordinator",
|
"FederatedCoordinator",
|
||||||
|
"GraphOfContractsRegistry",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
"""Minimal Graph-of-Contracts registry for MercuryMesh MVP.
|
||||||
|
|
||||||
|
This module provides a tiny, in-process registry to model contract mappings
|
||||||
|
and adapter schemas without exposing raw data. It is intentionally small and
|
||||||
|
extensible, suitable for MVP wiring as you add two starter adapters.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from dataclasses import dataclass, asdict
|
||||||
|
from typing import Dict, Optional, List, Any
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ContractSpec:
|
||||||
|
"""Specification for a contract primitive in MercuryMesh.
|
||||||
|
|
||||||
|
- name: canonical contract name (e.g., "MarketState", "Delta")
|
||||||
|
- version: contract version string
|
||||||
|
- schema: optional metadata describing the contract's data shape
|
||||||
|
"""
|
||||||
|
|
||||||
|
name: str
|
||||||
|
version: str
|
||||||
|
schema: Dict[str, Any] | None = None
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
return asdict(self)
|
||||||
|
|
||||||
|
|
||||||
|
class GraphOfContractsRegistry:
|
||||||
|
"""A lightweight in-process registry for contract specs and adapter schemas."""
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self._registry: Dict[str, ContractSpec] = {}
|
||||||
|
|
||||||
|
def register_contract(self, spec: ContractSpec) -> None:
|
||||||
|
"""Register or update a contract spec by its name as the key."""
|
||||||
|
self._registry[spec.name] = spec
|
||||||
|
|
||||||
|
def get_contract(self, name: str) -> Optional[ContractSpec]:
|
||||||
|
return self._registry.get(name)
|
||||||
|
|
||||||
|
def list_contracts(self) -> List[str]:
|
||||||
|
return sorted(self._registry.keys())
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Dict[str, Any]]:
|
||||||
|
return {name: spec.to_dict() for name, spec in self._registry.items()}
|
||||||
|
|
||||||
|
|
||||||
|
# Public, module-level registry instance for quick usage patterns in MVP wiring
|
||||||
|
registry = GraphOfContractsRegistry()
|
||||||
Loading…
Reference in New Issue