build(agent): new-agents-3#dd492b iteration

This commit is contained in:
agent-dd492b85242a98c5 2026-04-20 15:03:36 +02:00
parent 02f4d00ab0
commit 2d7cc3767c
2 changed files with 44 additions and 0 deletions

View File

@ -1,8 +1,14 @@
"""MercuryMesh Core Primitives """MercuryMesh Core Primitives
Public API for lightweight MVP of the privacy-preserving market data federation. Public API for lightweight MVP of the privacy-preserving market data federation.
This package also exposes a small canonical bridge utility to translate
MercuryMesh primitives to a vendor-agnostic Interoperability Registry (IR)
representation. The bridge is intentionally lightweight and intended for MVP
interop demos and testing.
""" """
from .contracts import MarketSignal, AggregatedSignal, PlanDelta, PrivacyBudget, AuditLog, ProvenanceProof from .contracts import MarketSignal, AggregatedSignal, PlanDelta, PrivacyBudget, AuditLog, ProvenanceProof
from .bridge_ir import to_ir_market_signal, to_ir_aggregated_signal
__all__ = [ __all__ = [
"MarketSignal", "MarketSignal",
"AggregatedSignal", "AggregatedSignal",
@ -10,4 +16,6 @@ __all__ = [
"PrivacyBudget", "PrivacyBudget",
"AuditLog", "AuditLog",
"ProvenanceProof", "ProvenanceProof",
"to_ir_market_signal",
"to_ir_aggregated_signal",
] ]

36
mercurymesh/bridge_ir.py Normal file
View File

@ -0,0 +1,36 @@
from __future__ import annotations
from typing import Dict
from .contracts import MarketSignal, AggregatedSignal
def to_ir_market_signal(ms: MarketSignal) -> Dict[str, object]:
"""Translate a MarketSignal to a canonical IR-like dict.
This is a lightweight representation suitable for interoperability tests
and demonstrations. It does not alter the original data model; it's a
serializable view suitable for cross-venue adapters.
"""
return {
"local_context": {
"venue": ms.venue_id,
"instrument": ms.symbol,
"timestamp": ms.timestamp.isoformat(),
"features": ms.features,
"version": ms.version,
}
}
def to_ir_aggregated_signal(agg: AggregatedSignal) -> Dict[str, object]:
"""Translate an AggregatedSignal to a canonical IR-like dict."""
return {
"aggregated": {
"venues": agg.venues,
"feature_vector": agg.feature_vector,
"privacy_budget_used": agg.privacy_budget_used,
"nonce": agg.nonce,
"merkle_proof": agg.merkle_proof,
}
}