From e3db872f6a285dfc5a5f609617faae6c8da2ebe7 Mon Sep 17 00:00:00 2001 From: agent-7e3bbc424e07835b Date: Mon, 20 Apr 2026 14:31:48 +0200 Subject: [PATCH] build(agent): new-agents-2#7e3bbc iteration --- .../__init__.py | 13 +++++++++-- .../adapters/canonical.py | 22 ++++++++++++++++++- .../dsl.py | 18 +++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/interplanetary_edge_orchestrator_privacy/__init__.py b/interplanetary_edge_orchestrator_privacy/__init__.py index c87941a..428ccd6 100644 --- a/interplanetary_edge_orchestrator_privacy/__init__.py +++ b/interplanetary_edge_orchestrator_privacy/__init__.py @@ -4,11 +4,20 @@ orchestrator suitable for offline-first operation in space habitats. """ from .federated import Client, Server +from .dsl import PrivacyBudget, AuditLog # export governance primitives for adapters try: # Optional: Expose registry helpers for MVP interoperability without # forcing a hard dependency in tests that only exercise federation. from .go_registry import register_contract, get_contract_schema, list_contracts # type: ignore - __all__ = ["Client", "Server", "register_contract", "get_contract_schema", "list_contracts"] + __all__ = [ + "Client", + "Server", + "PrivacyBudget", + "AuditLog", + "register_contract", + "get_contract_schema", + "list_contracts", + ] except Exception: # If registry is not available for some environments, still expose the core APIs. - __all__ = ["Client", "Server"] + __all__ = ["Client", "Server", "PrivacyBudget", "AuditLog"] diff --git a/interplanetary_edge_orchestrator_privacy/adapters/canonical.py b/interplanetary_edge_orchestrator_privacy/adapters/canonical.py index f09fdb7..d6a7f72 100644 --- a/interplanetary_edge_orchestrator_privacy/adapters/canonical.py +++ b/interplanetary_edge_orchestrator_privacy/adapters/canonical.py @@ -8,7 +8,7 @@ from __future__ import annotations from typing import Any, Dict, List -from ..dsl import LocalProblem, SharedVariables, PlanDelta +from ..dsl import LocalProblem, SharedVariables, PlanDelta, PrivacyBudget, AuditLog class CanonicalAdapter: @@ -24,3 +24,23 @@ class CanonicalAdapter: def map_plan_delta(self, version: int, delta: Dict[str, Any], insight: str | None = None) -> PlanDelta: return PlanDelta(version=version, delta=delta, insight=insight) + + def map_privacy_budget(self, budget: PrivacyBudget) -> Dict[str, Any]: + """Serialize PrivacyBudget into a contract-friendly dict.""" + return { + "type": "PrivacyBudget", + "signal": budget.signal, + "budget": budget.budget, + "expiry": budget.expiry, + } + + def map_audit_log(self, audit: AuditLog) -> Dict[str, Any]: + """Serialize AuditLog into a contract-friendly dict.""" + return { + "type": "AuditLog", + "entry": audit.entry, + "signer": audit.signer, + "timestamp": audit.timestamp, + "contract_id": audit.contract_id, + "version": audit.version, + } diff --git a/interplanetary_edge_orchestrator_privacy/dsl.py b/interplanetary_edge_orchestrator_privacy/dsl.py index a1febdb..2ce9adf 100644 --- a/interplanetary_edge_orchestrator_privacy/dsl.py +++ b/interplanetary_edge_orchestrator_privacy/dsl.py @@ -39,3 +39,21 @@ class PlanDelta: version: int delta: Dict[str, Any] = field(default_factory=dict) insight: Optional[str] = None + + +@dataclass +class PrivacyBudget: + """Governance/privacy budget block for a contract message.""" + signal: str + budget: float + expiry: Optional[float] = None + + +@dataclass +class AuditLog: + """Tamper-evident audit log entry for governance provenance.""" + entry: str + signer: str + timestamp: float + contract_id: str + version: str