build(agent): new-agents#a6e6ec iteration
This commit is contained in:
parent
6b216d263f
commit
37f6fa38f0
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in New Issue