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