from __future__ import annotations from typing import Dict, List, Optional class GoCContract: """Lightweight Graph-of-Contracts (GoC) contract descriptor. This is a minimal, production-friendly stub intended to Bootstrapping versioned adapters and replayable messages without vendor lock-in. """ def __init__(self, contract_id: str, version: str, description: str, primitives: Optional[Dict] = None): self.contract_id = contract_id self.version = version self.description = description self.primitives = primitives or {} def __repr__(self) -> str: return f"GoCContract(id={self.contract_id!r}, version={self.version!r})" class GoCRegistry: """In-memory registry for GoC contracts. This is intentionally small but deterministic, suitable for MVP use-cases and unit tests. It preserves contracts and allows retrieval by id. """ def __init__(self) -> None: self._store: Dict[str, GoCContract] = {} def register_contract(self, contract: GoCContract) -> str: self._store[contract.contract_id] = contract return contract.contract_id def get_contract(self, contract_id: str) -> Optional[GoCContract]: return self._store.get(contract_id) def list_contracts(self) -> List[GoCContract]: return list(self._store.values())