diff --git a/interplanetary_edge_orchestrator_privacy/__init__.py b/interplanetary_edge_orchestrator_privacy/__init__.py index c06511d..c87941a 100644 --- a/interplanetary_edge_orchestrator_privacy/__init__.py +++ b/interplanetary_edge_orchestrator_privacy/__init__.py @@ -4,5 +4,11 @@ orchestrator suitable for offline-first operation in space habitats. """ from .federated import Client, Server - -__all__ = ["Client", "Server"] +try: + # Optional: Expose registry helpers for MVP interoperability without + # forcing a hard dependency in tests that only exercise federation. + from .go_registry import register_contract, get_contract_schema, list_contracts # type: ignore + __all__ = ["Client", "Server", "register_contract", "get_contract_schema", "list_contracts"] +except Exception: + # If registry is not available for some environments, still expose the core APIs. + __all__ = ["Client", "Server"] diff --git a/interplanetary_edge_orchestrator_privacy/go_registry.py b/interplanetary_edge_orchestrator_privacy/go_registry.py new file mode 100644 index 0000000..ee1c660 --- /dev/null +++ b/interplanetary_edge_orchestrator_privacy/go_registry.py @@ -0,0 +1,36 @@ +"""Graph-of-Contracts registry (MVP). + +This module provides a tiny, in-memory registry for contract schemas that adapters +can publish and query. It is intentionally minimal and side-effect free so tests +and MVP clients can import it without pulling in additional dependencies. +""" + +from __future__ import annotations + +from typing import Any, Dict, Optional + +_registry: Dict[str, Dict[str, Dict[str, Any]]] = {} + + +def register_contract(name: str, version: str, schema: Dict[str, Any]) -> None: + """Register or update a contract schema for a given name and version. + + - name: canonical contract name (e.g., "NovaPlan", "CatOpt"). + - version: semantic version string. + - schema: a serializable dictionary describing the contract surface. + """ + global _registry + _registry.setdefault(name, {})[version] = schema + + +def get_contract_schema(name: str, version: str) -> Optional[Dict[str, Any]]: + """Return the registered schema for a name/version, if present.""" + return _registry.get(name, {}).get(version) + + +def list_contracts() -> Dict[str, Dict[str, Dict[str, Any]]]: + """Return the full in-memory registry mapping. + + Structure: { name: { version: schema_dict, ... }, ... } + """ + return _registry