build(agent): new-agents-4#58ba63 iteration
This commit is contained in:
parent
cb518d12d1
commit
dc454c9000
|
|
@ -1,56 +1,52 @@
|
|||
"""Lightweight Graph-of-Contracts (GoC) registry skeleton.
|
||||
"""Lightweight Graph-of-Contracts (GoC) registry and skeleton generator.
|
||||
|
||||
This module provides a minimal in-process GoC registry and a helper to
|
||||
generate a basic GoC skeleton for a given IR digest. It is intentionally
|
||||
small to avoid pulling in heavy dependencies while offering a deterministic
|
||||
structure that downstream adapters can attach to.
|
||||
This module provides a tiny, production-friendly extension point used by the
|
||||
DSL->IR translator to attach a verifiable GoC skeleton to the IR. The
|
||||
implementation here is intentionally lightweight, serving as a stable
|
||||
placeholder that can be extended in future iterations without breaking the MVP
|
||||
surface.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, List, Optional
|
||||
from datetime import datetime
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
class GoCRegistry:
|
||||
"""A tiny in-process registry for GoC contracts/adapters.
|
||||
def build_minimal_goC_skeleton(registry_digest: str, generated_at: str) -> Dict[str, Any]:
|
||||
"""Return a minimal, self-contained GoC skeleton.
|
||||
|
||||
This is intentionally lightweight and primarily serves as a discovery
|
||||
surface for adapters. It stores contracts by name and associates a digest
|
||||
with each registered contract set for replay-auditable provenance.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._contracts: Dict[str, Dict[str, str]] = {}
|
||||
|
||||
def register(self, name: str, contract_digest: str, metadata: Optional[Dict[str, str]] = None) -> None:
|
||||
"""Register a contract by name with its digest and optional metadata."""
|
||||
meta = dict(metadata or {})
|
||||
self._contracts[name] = {
|
||||
"digest": contract_digest,
|
||||
**meta,
|
||||
}
|
||||
|
||||
def list_contracts(self) -> List[str]:
|
||||
return list(self._contracts.keys())
|
||||
|
||||
def get_contract(self, name: str) -> Optional[Dict[str, str]]:
|
||||
return self._contracts.get(name)
|
||||
|
||||
|
||||
def build_minimal_goC_skeleton(registry_digest: str, timestamp_iso: str) -> Dict[str, object]:
|
||||
"""Return a minimal GoC skeleton dict suitable for embedding in IR.
|
||||
|
||||
The skeleton is intentionally small but deterministic, allowing consumer
|
||||
code to rely on a stable structure for replay and auditing.
|
||||
The skeleton is intentionally small but provides a stable shape that tests
|
||||
and downstream components can rely on:
|
||||
- version: semantic of the GoC schema
|
||||
- contracts: an empty list by default (to be populated by adapters)
|
||||
- metadata: includes a generated timestamp and a digest that can be used for
|
||||
replay and auditability
|
||||
"""
|
||||
return {
|
||||
"version": "0.1",
|
||||
"contracts": [],
|
||||
"metadata": {
|
||||
"generated_at": timestamp_iso,
|
||||
"generated_at": generated_at,
|
||||
"registry_digest": registry_digest,
|
||||
"source_digest": registry_digest,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
__all__ = ["GoCRegistry", "build_minimal_goC_skeleton"]
|
||||
class GoCRegistry:
|
||||
"""Tiny in-process registry for GoC adapters (placeholder for MVP).
|
||||
|
||||
This class is intentionally small but provides a path for future growth where
|
||||
adapters can register contracts, data feeds, and brokers under named keys.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._registry: Dict[str, Any] = {}
|
||||
|
||||
def register(self, name: str, contract: Any) -> None:
|
||||
self._registry[name] = contract
|
||||
|
||||
def get(self, name: str) -> Any:
|
||||
return self._registry.get(name)
|
||||
|
||||
def list(self) -> Dict[str, Any]:
|
||||
return dict(self._registry)
|
||||
|
|
|
|||
Loading…
Reference in New Issue