build(agent): new-agents-4#58ba63 iteration

This commit is contained in:
agent-58ba63c88b4c9625 2026-04-20 16:45:20 +02:00
parent 28782f593f
commit 1e5f4179ec
1 changed files with 23 additions and 34 deletions

View File

@ -1,48 +1,37 @@
"""Lightweight Graph-of-Contracts (GoC) registry for MVP. """Lightweight Graph-of-Contracts (GoC) registry scaffold.
Minimal, production-safe placeholder that enables import-time hooks and a
This module provides a minimal, production-friendly skeleton that other verifiable skeleton for the MVP.
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 from __future__ import annotations
from typing import Dict, Any from typing import Dict
import hashlib
import time
class GoCRegistry: class GoCRegistry:
"""Very small in-process registry for GoC contracts/adapters.""" """Very small in-process registry for adapters and contracts."""
def __init__(self):
self.adapters = {}
self.contracts = {}
def __init__(self) -> None: def register_adapter(self, name: str, details: Dict[str, object]):
self._registry: Dict[str, Dict[str, Any]] = {} self.adapters[name] = details
return name
def register(self, name: str, contract: Dict[str, Any]) -> None: def register_contract(self, contract_id: str, details: Dict[str, object]):
"""Register a contract descriptor by name.""" self.contracts[contract_id] = details
self._registry[name] = contract return contract_id
def get(self, name: str) -> Dict[str, Any]: def build_minimal_goC_skeleton(registry_digest: str, timestamp: str) -> Dict[str, object]:
"""Retrieve a registered contract descriptor by name, or empty if not found.""" """Return a minimal, reproducible GoC skeleton."""
return self._registry.get(name, {}) # Simple, deterministic hash to seed the GoC's identity
seed = hashlib.sha256(f"{registry_digest}:{timestamp}".encode("utf-8")).hexdigest()
def list(self) -> Dict[str, Dict[str, Any]]:
"""Return the whole registry mapping."""
return dict(self._registry)
def build_minimal_goC_skeleton(digest: str, timestamp: str) -> Dict[str, Any]:
"""Return a minimal Graph-of-Contracts skeleton for the given digest.
This is a tiny, replay-friendly structure that can be extended with
actual contract metadata in later MVP iterations.
"""
return { return {
"version": "0.1", "version": "0.1",
"contracts": [], "contracts": [],
"metadata": { "registry_digest": registry_digest,
"generated_at": timestamp, "generated_at": timestamp,
"source_digest": digest, "registry_seed": seed,
},
} }
__all__ = ["GoCRegistry", "build_minimal_goC_skeleton"] __all__ = ["GoCRegistry", "build_minimal_goC_skeleton"]