Skip to content

symfonic.services.switching.control_plane_source

control_plane_source

DMC-4 / CUT-BR — the cache-first operated-platform binding client.

The store is a control-plane dependency, not a data-plane one. Reads come from a local cache refreshed by a watcher; the hot path never blocks on the network. What the availability rules add is the part that is easy to get wrong: how long a stale binding may keep admitting work, and when it must stop.

ControlPlaneBindingSource

ControlPlaneBindingSource(store: InMemorySwitchStore, constraints: ConstraintSet, *, t_stale: float = DEFAULT_T_STALE, t_outage: float = DEFAULT_T_OUTAGE, cutover_window: float = DEFAULT_T_CUTOVER_WINDOW, clock: Callable[[], float] = time.monotonic)

Cache-first BindingSource implementing CUT-BR-1..6.

Source code in src/symfonic/services/switching/control_plane_source.py
def __init__(
    self,
    store: InMemorySwitchStore,
    constraints: ConstraintSet,
    *,
    t_stale: float = DEFAULT_T_STALE,
    t_outage: float = DEFAULT_T_OUTAGE,
    cutover_window: float = DEFAULT_T_CUTOVER_WINDOW,
    clock: Callable[[], float] = time.monotonic,
) -> None:
    self._store = store
    self._constraints = constraints
    self._t_stale = t_stale
    self._t_outage = t_outage
    self._cutover_window = cutover_window
    self._clock = clock
    self._cache: dict[str, _CacheEntry] = {}

refresh async

refresh(bundle_id: str) -> BundleRecord

The watcher/poller write point. Never called from the hot path.

Source code in src/symfonic/services/switching/control_plane_source.py
async def refresh(self, bundle_id: str) -> BundleRecord:
    """The watcher/poller write point. Never called from the hot path."""
    record = await self._store.read(bundle_id)
    self._cache[bundle_id] = _CacheEntry(record=record, fetched_at=self._clock())
    return record

resolve_epoch async

resolve_epoch(bundle_id: str, epoch: int) -> BundleBinding

CUT-SS-7 — reconstruct the binding an earlier admission ran under.

Source code in src/symfonic/services/switching/control_plane_source.py
async def resolve_epoch(self, bundle_id: str, epoch: int) -> BundleBinding:
    """CUT-SS-7 — reconstruct the binding an earlier admission ran under."""
    for record in await self._store.history(bundle_id):
        if record.epoch == epoch:
            return self._binding(record, stale=False)
    raise BindingUnavailableError(
        f"the switch store retains no epoch {epoch} for bundle {bundle_id!r}; a "
        "pinned resume denies rather than falling forward onto the current epoch."
    )