build(agent): new-agents-4#58ba63 iteration
This commit is contained in:
parent
660826d0e7
commit
59943d9ce6
|
|
@ -1,56 +1,58 @@
|
||||||
"""Lightweight Graph-of-Contracts (GoC) scaffolding.
|
"""Lightweight Graph-of-Contracts (GoC) registry skeleton.
|
||||||
|
|
||||||
This module provides a minimal in-process registry for contracts/adapters
|
This module provides a minimal, production-friendly GoC skeleton that the
|
||||||
and a factory to produce a skeleton GoC structure embedded in the IR.
|
core.IR translator can attach to the IR for auditability and future
|
||||||
The goal is to enable the core DSL -> IR path to be testable and
|
interoperability with adapters.
|
||||||
extensible without introducing heavy dependencies.
|
|
||||||
|
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, List
|
from typing import Dict, Any
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
class GoCRegistry:
|
class GoCRegistry:
|
||||||
"""A tiny in-memory registry for Graph-of-Contracts (GoC).
|
"""Very small, in-process GoC registry placeholder.
|
||||||
|
|
||||||
This is intentionally lightweight for MVP usage. It stores contracts by
|
This class is a no-op registry designed for MVP usage. It can be expanded in
|
||||||
name and allows listing and registering new ones. It does not persist to disk
|
the future to support multi-adapter registrations, versioned contracts, and
|
||||||
in this MVP, but it provides a spot to hook in real registries later.
|
registry-backed lookups.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self._contracts: List[Dict[str, object]] = []
|
self._contracts: Dict[str, Dict[str, Any]] = {}
|
||||||
|
|
||||||
def register_contract(self, name: str, contract: Dict[str, object]) -> None:
|
def register(self, name: str, contract: Dict[str, Any]) -> None:
|
||||||
"""Register a new contract descriptor under the given name."""
|
self._contracts[name] = contract
|
||||||
entry = {"name": name, "contract": contract, "registered_at": int(time.time())}
|
|
||||||
self._contracts.append(entry)
|
|
||||||
|
|
||||||
def list_contracts(self) -> List[Dict[str, object]]:
|
def get(self, name: str) -> Dict[str, Any] | None:
|
||||||
return list(self._contracts)
|
return self._contracts.get(name)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def list(self) -> list[str]:
|
||||||
return f"GoCRegistry(contracts={len(self._contracts)})"
|
return list(self._contracts.keys())
|
||||||
|
|
||||||
|
|
||||||
def build_minimal_goC_skeleton(registry_digest: str, generated_at: str) -> Dict[str, object]:
|
def build_minimal_goC_skeleton(digest: str, generated_at: str) -> Dict[str, object]:
|
||||||
"""Produce a minimal, self-contained GoC skeleton.
|
"""Return a minimal Graph-of-Contracts skeleton.
|
||||||
|
|
||||||
The skeleton is deliberately small but structured to support extension as
|
Parameters
|
||||||
adapters are added. It includes a registry digest, a timestamp, and an empty
|
- digest: a hex digest representing the source IR or contract set digest.
|
||||||
contracts list that can be populated by future integrations.
|
- generated_at: ISO timestamp when the skeleton is generated.
|
||||||
|
|
||||||
|
Returns a small, deterministic structure containing a registry digest and
|
||||||
|
an empty contracts array for later population by adapters.
|
||||||
"""
|
"""
|
||||||
skeleton: Dict[str, object] = {
|
|
||||||
|
return {
|
||||||
"version": "0.1",
|
"version": "0.1",
|
||||||
"contracts": [],
|
"contracts": [],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"generated_at": generated_at,
|
"generated_at": generated_at,
|
||||||
"registry_digest": registry_digest,
|
"source_digest": digest,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return skeleton
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["GoCRegistry", "build_minimal_goC_skeleton"]
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue