build(agent): new-agents-4#58ba63 iteration
This commit is contained in:
parent
22c492a570
commit
da98879a87
|
|
@ -1,58 +1,56 @@
|
|||
"""Lightweight Graph-of-Contracts (GoC) registry skeleton.
|
||||
|
||||
This module provides a minimal, production-friendly GoC skeleton that the
|
||||
core.IR translator can attach to the IR for auditability and future
|
||||
interoperability with adapters.
|
||||
|
||||
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.
|
||||
This module provides a minimal in-process GoC registry and a helper to
|
||||
generate a basic GoC skeleton for a given IR digest. It is intentionally
|
||||
small to avoid pulling in heavy dependencies while offering a deterministic
|
||||
structure that downstream adapters can attach to.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, Any
|
||||
from typing import Dict, List, Optional
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
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
|
||||
the future to support multi-adapter registrations, versioned contracts, and
|
||||
registry-backed lookups.
|
||||
This is intentionally lightweight and primarily serves as a discovery
|
||||
surface for adapters. It stores contracts by name and associates a digest
|
||||
with each registered contract set for replay-auditable provenance.
|
||||
"""
|
||||
|
||||
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:
|
||||
self._contracts[name] = contract
|
||||
def register(self, name: str, contract_digest: str, metadata: Optional[Dict[str, str]] = None) -> None:
|
||||
"""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:
|
||||
return self._contracts.get(name)
|
||||
|
||||
def list(self) -> list[str]:
|
||||
def list_contracts(self) -> List[str]:
|
||||
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
|
||||
- digest: a hex digest representing the source IR or contract set digest.
|
||||
- generated_at: ISO timestamp when the skeleton is generated.
|
||||
def build_minimal_goC_skeleton(registry_digest: str, timestamp_iso: str) -> Dict[str, object]:
|
||||
"""Return a minimal GoC skeleton dict suitable for embedding in IR.
|
||||
|
||||
Returns a small, deterministic structure containing a registry digest and
|
||||
an empty contracts array for later population by adapters.
|
||||
The skeleton is intentionally small but deterministic, allowing consumer
|
||||
code to rely on a stable structure for replay and auditing.
|
||||
"""
|
||||
|
||||
return {
|
||||
"version": "0.1",
|
||||
"contracts": [],
|
||||
"metadata": {
|
||||
"generated_at": generated_at,
|
||||
"source_digest": digest,
|
||||
"generated_at": timestamp_iso,
|
||||
"registry_digest": registry_digest,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
__all__ = ["GoCRegistry", "build_minimal_goC_skeleton"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue