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

This commit is contained in:
agent-58ba63c88b4c9625 2026-04-20 17:11:07 +02:00
parent 22c492a570
commit da98879a87
1 changed files with 30 additions and 32 deletions

View File

@ -1,58 +1,56 @@
"""Lightweight Graph-of-Contracts (GoC) registry skeleton. """Lightweight Graph-of-Contracts (GoC) registry skeleton.
This module provides a minimal, production-friendly GoC skeleton that the This module provides a minimal in-process GoC registry and a helper to
core.IR translator can attach to the IR for auditability and future generate a basic GoC skeleton for a given IR digest. It is intentionally
interoperability with adapters. small to avoid pulling in heavy dependencies while offering a deterministic
structure that downstream adapters can attach to.
The implementation is intentionally small and dependency-free to avoid
introducing external runtime requirements in MVP environments. It exposes:
- GoCRegistry: a tiny in-process registry interface (minimal feature-set).
- build_minimal_goC_skeleton(digest, generated_at): a function that returns a
deterministic skeleton structure embedding the given digest and timestamp.
""" """
from __future__ import annotations from __future__ import annotations
from typing import Dict, Any from typing import Dict, List, Optional
from datetime import datetime
class GoCRegistry: class GoCRegistry:
"""Very small, in-process GoC registry placeholder. """A tiny in-process registry for GoC contracts/adapters.
This class is a no-op registry designed for MVP usage. It can be expanded in This is intentionally lightweight and primarily serves as a discovery
the future to support multi-adapter registrations, versioned contracts, and surface for adapters. It stores contracts by name and associates a digest
registry-backed lookups. with each registered contract set for replay-auditable provenance.
""" """
def __init__(self) -> None: def __init__(self) -> None:
self._contracts: Dict[str, Dict[str, Any]] = {} self._contracts: Dict[str, Dict[str, str]] = {}
def register(self, name: str, contract: Dict[str, Any]) -> None: def register(self, name: str, contract_digest: str, metadata: Optional[Dict[str, str]] = None) -> None:
self._contracts[name] = contract """Register a contract by name with its digest and optional metadata."""
meta = dict(metadata or {})
self._contracts[name] = {
"digest": contract_digest,
**meta,
}
def get(self, name: str) -> Dict[str, Any] | None: def list_contracts(self) -> List[str]:
return self._contracts.get(name)
def list(self) -> list[str]:
return list(self._contracts.keys()) 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(digest: str, generated_at: str) -> Dict[str, object]:
"""Return a minimal Graph-of-Contracts skeleton.
Parameters def build_minimal_goC_skeleton(registry_digest: str, timestamp_iso: str) -> Dict[str, object]:
- digest: a hex digest representing the source IR or contract set digest. """Return a minimal GoC skeleton dict suitable for embedding in IR.
- generated_at: ISO timestamp when the skeleton is generated.
Returns a small, deterministic structure containing a registry digest and The skeleton is intentionally small but deterministic, allowing consumer
an empty contracts array for later population by adapters. code to rely on a stable structure for replay and auditing.
""" """
return { return {
"version": "0.1", "version": "0.1",
"contracts": [], "contracts": [],
"metadata": { "metadata": {
"generated_at": generated_at, "generated_at": timestamp_iso,
"source_digest": digest, "registry_digest": registry_digest,
}, },
} }
__all__ = ["GoCRegistry", "build_minimal_goC_skeleton"]