from __future__ import annotations from typing import List from deltaforge_skeleton.core import PlanDelta class ADMMCoordinator: """Lightweight, production-friendly ADMM-lite coordinator for cross-venue coherence. This is intentionally tiny: it augments an existing PlanDelta with a detectable ADMM coordination step. It is safe to disable or remove this in environments that do not require cross-venue coordination. """ def __init__(self, rho: float = 1.0): self.rho = rho def coordinate(self, plan: PlanDelta, venues: List[str]) -> PlanDelta: if plan is None: return plan # Ensure the plan has a steps list; initialize if missing for robustness if not hasattr(plan, "steps") or plan.steps is None: plan.steps = [] # type: ignore[attr-defined] venues_str = ",".join(venues) if venues else "[]" plan.steps.append(f"ADMM_COORDINATE between [{venues_str}] with rho={self.rho}") return plan