build(agent): new-agents-4#58ba63 iteration
This commit is contained in:
parent
0ae09d1e15
commit
b153c49ff1
|
|
@ -2,7 +2,14 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from edge_latency_aware_cross_venue_execution.models import LocalProblem, SharedVariables, PlanDelta, DualVariables, AuditLog
|
from edge_latency_aware_cross_venue_execution.models import LocalProblem, SharedVariables, PlanDelta, DualVariables, AuditLog # type: ignore
|
||||||
|
from .energi_bridge import (
|
||||||
|
to_ir_object,
|
||||||
|
to_ir_morphisms,
|
||||||
|
to_ir_plan_delta,
|
||||||
|
to_ir_dual,
|
||||||
|
to_ir_audit,
|
||||||
|
)
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,3 +57,20 @@ def to_dsl_dual(dual: DualVariables) -> SimpleNamespace:
|
||||||
version=dual.version,
|
version=dual.version,
|
||||||
shadow_prices=dual.shadow_prices,
|
shadow_prices=dual.shadow_prices,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Convenience wrappers for EnergiBridge IR translation (bootstrap for interoperability)
|
||||||
|
def to_ir_object_simple(obj: LocalProblem): # pragma: no cover
|
||||||
|
return to_ir_object(obj)
|
||||||
|
|
||||||
|
def to_ir_morphisms_simple(sig: SharedVariables): # pragma: no cover
|
||||||
|
return to_ir_morphisms(sig)
|
||||||
|
|
||||||
|
def to_ir_plan_delta_simple(plan: PlanDelta): # pragma: no cover
|
||||||
|
return to_ir_plan_delta(plan)
|
||||||
|
|
||||||
|
def to_ir_dual_simple(dual: DualVariables): # pragma: no cover
|
||||||
|
return to_ir_dual(dual)
|
||||||
|
|
||||||
|
def to_ir_audit_simple(audit: AuditLog): # pragma: no cover
|
||||||
|
return to_ir_audit(audit)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
"""EnergiBridge-style canonical IR mapper (minimal MVP).
|
||||||
|
|
||||||
|
Provides a lightweight translation from ELAC-Plan primitives to a
|
||||||
|
vendor-agnostic Core IR surface (Object / Morphisms / PlanDelta / DualVariables / AuditLog).
|
||||||
|
This is intentionally small but structured to bootstrap cross-adapter
|
||||||
|
interoperability in Phase 0 MVP.
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any, Dict
|
||||||
|
from edge_latency_aware_cross_venue_execution.models import LocalProblem, SharedVariables, PlanDelta, DualVariables, AuditLog # type: ignore
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"to_ir_object",
|
||||||
|
"to_ir_morphisms",
|
||||||
|
"to_ir_plan_delta",
|
||||||
|
"to_ir_dual",
|
||||||
|
"to_ir_audit",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def to_ir_object(obj: LocalProblem) -> Dict[str, Any]:
|
||||||
|
# Canonical Object: per-asset-venue planning task
|
||||||
|
return {
|
||||||
|
"type": "Object",
|
||||||
|
"id": obj.id,
|
||||||
|
"asset": obj.asset,
|
||||||
|
"venue": obj.venue,
|
||||||
|
"objective": obj.objective,
|
||||||
|
"parameters": obj.parameters,
|
||||||
|
"price_target": obj.price_target,
|
||||||
|
"tolerance": obj.tolerance,
|
||||||
|
"constraints": obj.constraints,
|
||||||
|
"created_at": obj.created_at.isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def to_ir_morphisms(sig: SharedVariables) -> Dict[str, Any]:
|
||||||
|
signals = sig.signals if getattr(sig, "signals", None) is not None else sig.variables
|
||||||
|
return {
|
||||||
|
"type": "Morphisms",
|
||||||
|
"contract_id": sig.contract_id,
|
||||||
|
"version": sig.version,
|
||||||
|
"signals": signals,
|
||||||
|
"privacy_budget": sig.privacy_budget,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def to_ir_plan_delta(plan: PlanDelta) -> Dict[str, Any]:
|
||||||
|
return {
|
||||||
|
"type": "PlanDelta",
|
||||||
|
"contract_id": plan.contract_id,
|
||||||
|
"delta": plan.delta,
|
||||||
|
"timestamp": plan.timestamp.isoformat(),
|
||||||
|
"author_signature": plan.author_signature,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def to_ir_dual(dual: DualVariables) -> Dict[str, Any]:
|
||||||
|
return {
|
||||||
|
"type": "DualVariables",
|
||||||
|
"contract_id": dual.contract_id,
|
||||||
|
"version": dual.version,
|
||||||
|
"shadow_prices": dual.shadow_prices,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def to_ir_audit(audit: AuditLog) -> Dict[str, Any]:
|
||||||
|
return {
|
||||||
|
"type": "AuditLog",
|
||||||
|
"contract_id": audit.contract_id,
|
||||||
|
"entry": audit.entry,
|
||||||
|
"timestamp": audit.timestamp.isoformat(),
|
||||||
|
"signature": audit.signature,
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue