Skip to content

symfonic.services.switching.static_source

static_source

DMC-3 — the hermetic in-process static-generation backend (library mode).

This is also the reference implementation of BindingSource (CON-S-4). It performs no I/O, opens no socket, and reads no environment variable: the only inputs are the release profile compiled into the package and the override the adopter passed explicitly to the constructor. That is what "hermetic" has to mean for a library that gets embedded in someone else's process.

StaticBindingSource

StaticBindingSource(profile: ReleaseProfile, *, overrides: Mapping[str, GenerationVector] | None = None)

Resolve bindings from the release's static vector plus local overrides.

Source code in src/symfonic/services/switching/static_source.py
def __init__(
    self,
    profile: ReleaseProfile,
    *,
    overrides: Mapping[str, GenerationVector] | None = None,
) -> None:
    self._profile = profile
    self._vectors: dict[str, GenerationVector] = dict(profile.static_vectors)
    self._sources: dict[str, str] = dict.fromkeys(self._vectors, "release-static")
    self._freeze = self._package_freeze(profile)
    for bundle_id, override in (overrides or {}).items():
        self._apply_override(bundle_id, override)

describe

describe() -> str

The startup log line: vector hash and where it came from, never keys.

Source code in src/symfonic/services/switching/static_source.py
def describe(self) -> str:
    """The startup log line: vector hash and where it came from, never keys."""
    parts = [
        f"{bundle_id} vector={vector.vector_hash} source={self._sources[bundle_id]}"
        for bundle_id, vector in sorted(self._vectors.items())
    ]
    return f"binding[static,{self._profile.package_version}] " + "; ".join(parts)

resolve_epoch async

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

A library release has exactly one epoch: the one it compiled in.

Source code in src/symfonic/services/switching/static_source.py
async def resolve_epoch(self, bundle_id: str, epoch: int) -> BundleBinding:
    """A library release has exactly one epoch: the one it compiled in."""
    binding = await self.resolve(bundle_id)
    if epoch != binding.epoch:
        raise BindingUnavailableError(
            f"this release binds bundle {bundle_id!r} at epoch {binding.epoch}; "
            f"there is no epoch {epoch} to resume onto. A pin from another "
            "deployment mode is not portable into library mode."
        )
    return binding