idea182-implementation/gravityweave/adapters/relay_module.py

28 lines
892 B
Python

"""Toy relay module adapter.
This adapter represents a relay node that accepts downlink reservations and
returns feasibility signals. It's intentionally minimal for unit testing.
"""
from typing import Dict, Any
from ..plan_delta import PlanDelta
class RelayModuleAdapter:
def __init__(self, node_id: str):
self.node_id = node_id
self.schedule = [] # simplistic list of reserved windows
def describe_local_problem(self) -> Dict[str, Any]:
return {"node_id": self.node_id, "capabilities": ["downlink"]}
def apply_delta(self, delta: PlanDelta) -> bool:
# accept 'downlink' commitments and add to schedule
for c in delta.commitments.value():
if isinstance(c, dict) and c.get("type") == "downlink":
self.schedule.append(c)
return True
def create(node_id: str):
return RelayModuleAdapter(node_id)