build(agent): new-agents-4#58ba63 iteration
This commit is contained in:
parent
204901b7d5
commit
32b8b4d6cd
|
|
@ -8,10 +8,32 @@ single utility function used by the test suite.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from .dsl import LocalProblem, SharedVariables, PlanDelta
|
||||
from .dsl import (
|
||||
LocalProblem,
|
||||
SharedVariables,
|
||||
PlanDelta,
|
||||
DualVariables,
|
||||
PrivacyBudget,
|
||||
AuditLog,
|
||||
PolicyBlock,
|
||||
GraphOfContracts,
|
||||
GraphOfContractsEntry,
|
||||
)
|
||||
from .solver import admm_update
|
||||
|
||||
__all__ = ["add", "LocalProblem", "SharedVariables", "PlanDelta", "admm_update"]
|
||||
__all__ = [
|
||||
"add",
|
||||
"LocalProblem",
|
||||
"SharedVariables",
|
||||
"PlanDelta",
|
||||
"DualVariables",
|
||||
"PrivacyBudget",
|
||||
"AuditLog",
|
||||
"PolicyBlock",
|
||||
"GraphOfContracts",
|
||||
"GraphOfContractsEntry",
|
||||
"admm_update",
|
||||
]
|
||||
|
||||
|
||||
def add(a: int, b: int) -> int:
|
||||
|
|
|
|||
|
|
@ -66,4 +66,52 @@ class PlanDelta:
|
|||
return cls(delta=data["delta"], timestamp=data["timestamp"], author=data["author"], contract_id=data.get("contract_id"))
|
||||
|
||||
|
||||
__all__ = ["LocalProblem", "SharedVariables", "PlanDelta"]
|
||||
@dataclass
|
||||
class DualVariables:
|
||||
multipliers: Dict[str, float] = field(default_factory=dict)
|
||||
|
||||
|
||||
@dataclass
|
||||
class PrivacyBudget:
|
||||
signal: float
|
||||
budget: float
|
||||
expiry: str # ISO timestamp or similar
|
||||
|
||||
|
||||
@dataclass
|
||||
class AuditLog:
|
||||
entry: str
|
||||
signer: str
|
||||
timestamp: str
|
||||
contract_id: Optional[str] = None
|
||||
version: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class PolicyBlock:
|
||||
safety: str
|
||||
exposure_rules: List[str] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass
|
||||
class GraphOfContractsEntry:
|
||||
adapter_id: str
|
||||
supported_domains: List[str]
|
||||
contract_version: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class GraphOfContracts:
|
||||
registry: Dict[str, GraphOfContractsEntry] = field(default_factory=dict)
|
||||
|
||||
def to_json(self) -> str:
|
||||
return json.dumps({k: asdict(v) for k, v in self.registry.items()})
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, payload: str) -> "GraphOfContracts":
|
||||
data = json.loads(payload)
|
||||
reg = {k: GraphOfContractsEntry(**v) for k, v in data.items()}
|
||||
return cls(registry=reg)
|
||||
|
||||
|
||||
__all__ = ["LocalProblem", "SharedVariables", "PlanDelta", "DualVariables", "PrivacyBudget", "AuditLog", "PolicyBlock", "GraphOfContracts", "GraphOfContractsEntry"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue