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

This commit is contained in:
agent-58ba63c88b4c9625 2026-04-20 16:48:23 +02:00
parent 1e5f4179ec
commit 6ac709a18d
2 changed files with 42 additions and 23 deletions

View File

@ -1,37 +1,56 @@
"""Lightweight Graph-of-Contracts (GoC) registry scaffold.
Minimal, production-safe placeholder that enables import-time hooks and a
verifiable skeleton for the MVP.
"""Lightweight Graph-of-Contracts (GoC) scaffolding.
This module provides a minimal in-process registry for contracts/adapters
and a factory to produce a skeleton GoC structure embedded in the IR.
The goal is to enable the core DSL -> IR path to be testable and
extensible without introducing heavy dependencies.
"""
from __future__ import annotations
from typing import Dict
import hashlib
from typing import Dict, List
import time
class GoCRegistry:
"""Very small in-process registry for adapters and contracts."""
def __init__(self):
self.adapters = {}
self.contracts = {}
"""A tiny in-memory registry for Graph-of-Contracts (GoC).
def register_adapter(self, name: str, details: Dict[str, object]):
self.adapters[name] = details
return name
This is intentionally lightweight for MVP usage. It stores contracts by
name and allows listing and registering new ones. It does not persist to disk
in this MVP, but it provides a spot to hook in real registries later.
"""
def register_contract(self, contract_id: str, details: Dict[str, object]):
self.contracts[contract_id] = details
return contract_id
def __init__(self) -> None:
self._contracts: List[Dict[str, object]] = []
def build_minimal_goC_skeleton(registry_digest: str, timestamp: str) -> Dict[str, object]:
"""Return a minimal, reproducible GoC skeleton."""
# Simple, deterministic hash to seed the GoC's identity
seed = hashlib.sha256(f"{registry_digest}:{timestamp}".encode("utf-8")).hexdigest()
return {
def register_contract(self, name: str, contract: Dict[str, object]) -> None:
"""Register a new contract descriptor under the given name."""
entry = {"name": name, "contract": contract, "registered_at": int(time.time())}
self._contracts.append(entry)
def list_contracts(self) -> List[Dict[str, object]]:
return list(self._contracts)
def __repr__(self) -> str:
return f"GoCRegistry(contracts={len(self._contracts)})"
def build_minimal_goC_skeleton(registry_digest: str, generated_at: str) -> Dict[str, object]:
"""Produce a minimal, self-contained GoC skeleton.
The skeleton is deliberately small but structured to support extension as
adapters are added. It includes a registry digest, a timestamp, and an empty
contracts list that can be populated by future integrations.
"""
skeleton: Dict[str, object] = {
"version": "0.1",
"contracts": [],
"registry_digest": registry_digest,
"generated_at": timestamp,
"registry_seed": seed,
"metadata": {
"generated_at": generated_at,
"registry_digest": registry_digest,
},
}
return skeleton
__all__ = ["GoCRegistry", "build_minimal_goC_skeleton"]

0
test.sh Normal file → Executable file
View File