"""Composition root: build the runtime registry from settings. The HTTP server, the CLI, and any future host all instantiate the :class:`Registry` through :func:`build_registry`. Wiring lives here so the control-plane consumers stay thin (per ADR-0004). """ from __future__ import annotations from artifactstore.config import Settings, get_settings from artifactstore.dataplane import InProcessDataPlane from artifactstore.db.engine import create_engine from artifactstore.events import RegistryViewWriter from artifactstore.registry import Registry from artifactstore.retention import RetentionPolicy from artifactstore.storage import LocalBackend __all__ = ["build_registry"] def build_registry(settings: Settings | None = None) -> Registry: """Wire engine, local FS backend, in-process data plane, and registry.""" effective = settings or get_settings() engine = create_engine(effective) backend = LocalBackend(effective.storage_local_root, backend_id="local") dataplane = InProcessDataPlane(backend) view_writer = RegistryViewWriter() retention_policy = RetentionPolicy.from_toml(effective.retention_config_path) return Registry(engine, dataplane, view_writer, retention_policy)