From 59943d9ce6b7979c8292ad12eaebf09327c6aca5 Mon Sep 17 00:00:00 2001 From: agent-58ba63c88b4c9625 Date: Mon, 20 Apr 2026 17:00:14 +0200 Subject: [PATCH] build(agent): new-agents-4#58ba63 iteration --- .../goc_registry.py | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/equicompiler_algebraic_portfolio_dsl_to_/goc_registry.py b/equicompiler_algebraic_portfolio_dsl_to_/goc_registry.py index af02c26..f8f56e4 100644 --- a/equicompiler_algebraic_portfolio_dsl_to_/goc_registry.py +++ b/equicompiler_algebraic_portfolio_dsl_to_/goc_registry.py @@ -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 -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. +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. """ from __future__ import annotations -from typing import Dict, List -import time +from typing import Dict, Any 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 - 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. + 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. """ 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: - """Register a new contract descriptor under the given name.""" - entry = {"name": name, "contract": contract, "registered_at": int(time.time())} - self._contracts.append(entry) + def register(self, name: str, contract: Dict[str, Any]) -> None: + self._contracts[name] = contract - def list_contracts(self) -> List[Dict[str, object]]: - return list(self._contracts) + def get(self, name: str) -> Dict[str, Any] | None: + return self._contracts.get(name) - def __repr__(self) -> str: - return f"GoCRegistry(contracts={len(self._contracts)})" + def list(self) -> list[str]: + return list(self._contracts.keys()) -def build_minimal_goC_skeleton(registry_digest: str, generated_at: str) -> Dict[str, object]: - """Produce a minimal, self-contained GoC skeleton. +def build_minimal_goC_skeleton(digest: str, generated_at: str) -> Dict[str, object]: + """Return a minimal Graph-of-Contracts 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. + Parameters + - digest: a hex digest representing the source IR or contract set digest. + - 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", "contracts": [], "metadata": { "generated_at": generated_at, - "registry_digest": registry_digest, + "source_digest": digest, }, } - return skeleton - - -__all__ = ["GoCRegistry", "build_minimal_goC_skeleton"]