28 lines
1.4 KiB
Python
28 lines
1.4 KiB
Python
from __future__ import annotations
|
|
from .core import LocalProblem, SharedVariables, PlanDelta, Policy, AttestationHint, AuditLog, PrivacyBudget
|
|
|
|
"""Tiny DSL-like helpers for HopeMesh primitives.
|
|
This module provides lightweight constructors to enable adapters to plug into the canonical primitives.
|
|
"""
|
|
|
|
def make_local_problem(name: str, region: str | None = None, **kwargs) -> LocalProblem:
|
|
return LocalProblem(name=name, region=region, metadata=kwargs)
|
|
|
|
def make_shared_variables(description: str = "", data: dict | None = None, aggregate_type: str = "sum") -> SharedVariables:
|
|
return SharedVariables(description=description, data=data or {}, aggregate_type=aggregate_type)
|
|
|
|
def make_plan_delta(delta_id: str, actions: list[dict], **kwargs) -> PlanDelta:
|
|
return PlanDelta(delta_id=delta_id, actions=actions, annotations=kwargs)
|
|
|
|
def make_policy(policy_id: str, **rules) -> Policy:
|
|
return Policy(policy_id=policy_id, rules=rules)
|
|
|
|
def make_attestation_hint(hint_id: str, scheme: str = "dummy", payload: dict | None = None) -> AttestationHint:
|
|
return AttestationHint(hint_id=hint_id, scheme=scheme, payload=payload or {})
|
|
|
|
def make_audit_log(entry_id: str, message: str, signature: str | None = None) -> AuditLog:
|
|
return AuditLog(entry_id=entry_id, message=message, signature=signature)
|
|
|
|
def make_privacy_budget(budget_id: str, limit: float) -> PrivacyBudget:
|
|
return PrivacyBudget(budget_id=budget_id, limit=limit)
|