build(agent): new-agents-4#58ba63 iteration
This commit is contained in:
parent
2a22b95e71
commit
274887d856
|
|
@ -1,46 +1,48 @@
|
|||
"""Graph-of-Contracts (GoC) registry placeholder.
|
||||
"""Lightweight Graph-of-Contracts (GoC) registry for MVP.
|
||||
|
||||
This module provides a tiny, production-friendly scaffold for a versioned
|
||||
adapter registry and a minimal Graph-of-Contracts skeleton. It's designed as
|
||||
an extension point for future adapters (data feeds, brokers) while keeping
|
||||
the MVP lightweight and auditable.
|
||||
This module provides a minimal, production-friendly skeleton that other
|
||||
parts of the EquiCompiler can import and use. It is intentionally small
|
||||
and dependency-free, designed to be extended in future sprint cycles.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import hashlib
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
class GoCRegistry:
|
||||
"""Lightweight in-process registry of adapters/contracts."""
|
||||
"""Very small in-process registry for GoC contracts/adapters."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.adapters: Dict[str, Dict[str, Any]] = {}
|
||||
self._registry: Dict[str, Dict[str, Any]] = {}
|
||||
|
||||
def register_adapter(self, name: str, info: Dict[str, Any]) -> None:
|
||||
self.adapters[name] = info
|
||||
def register(self, name: str, contract: Dict[str, Any]) -> None:
|
||||
"""Register a contract descriptor by name."""
|
||||
self._registry[name] = contract
|
||||
|
||||
def to_digest(self) -> str:
|
||||
# Deterministic digest of the current adapters mapping
|
||||
return hashlib.sha256(json.dumps(self.adapters, sort_keys=True).encode("utf-8")).hexdigest()
|
||||
def get(self, name: str) -> Dict[str, Any]:
|
||||
"""Retrieve a registered contract descriptor by name, or empty if not found."""
|
||||
return self._registry.get(name, {})
|
||||
|
||||
def overview(self) -> Dict[str, Any]:
|
||||
return {"adapters": self.adapters, "digest": self.to_digest()}
|
||||
def list(self) -> Dict[str, Dict[str, Any]]:
|
||||
"""Return the whole registry mapping."""
|
||||
return dict(self._registry)
|
||||
|
||||
|
||||
def build_minimal_goC_skeleton(registry_digest: str, generated_at: str) -> Dict[str, Any]:
|
||||
"""Return a minimal GoC skeleton including registry digest metadata.
|
||||
def build_minimal_goC_skeleton(digest: str, timestamp: str) -> Dict[str, Any]:
|
||||
"""Return a minimal Graph-of-Contracts skeleton for the given digest.
|
||||
|
||||
The skeleton is intentionally tiny and can be extended as adapters are
|
||||
added. It provides a stable shape for downstream consumers to validate
|
||||
contract integrity and replay provenance.
|
||||
This is a tiny, replay-friendly structure that can be extended with
|
||||
actual contract metadata in later MVP iterations.
|
||||
"""
|
||||
return {
|
||||
"version": "0.1",
|
||||
"contracts": [],
|
||||
"metadata": {
|
||||
"generated_at": generated_at,
|
||||
"registry_digest": registry_digest,
|
||||
"generated_at": timestamp,
|
||||
"source_digest": digest,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
__all__ = ["GoCRegistry", "build_minimal_goC_skeleton"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue