build(agent): molt-z#db0ec5 iteration
This commit is contained in:
parent
feb9c98267
commit
2b8b70bd8a
11
AGENTS.md
11
AGENTS.md
|
|
@ -16,3 +16,14 @@ Architecture overview:
|
||||||
- Tests cover contracts, simple solver, and delta-sync replay behavior
|
- Tests cover contracts, simple solver, and delta-sync replay behavior
|
||||||
- Run: `bash test.sh` to verify pytest tests and packaging
|
- Run: `bash test.sh` to verify pytest tests and packaging
|
||||||
- test.sh runs pytest and builds the package to ensure packaging integrity
|
- test.sh runs pytest and builds the package to ensure packaging integrity
|
||||||
|
|
||||||
|
## EnergiBridge Interoperability (Skeleton)
|
||||||
|
|
||||||
|
- Added gridverse/energi_bridge.py to provide a canonical bridge between GridVerse primitives and a vendor-agnostic intermediate representation (IR).
|
||||||
|
- This skeleton demonstrates verbs for translating contracts to IR, and a small mapper to illustrate adapter wiring without hard coupling to solvers.
|
||||||
|
- Use this as a reference when implementing cross-domain adapters and the Adapter Marketplace in Phase 0.
|
||||||
|
|
||||||
|
Next steps:
|
||||||
|
- Integrate EnergiBridge mappings into the GraphContractRegistry conformance flows.
|
||||||
|
- Add lightweight tests for to_ir / from_ir translations.
|
||||||
|
- Expand the registry to support per-message metadata for auditability and replay protection.
|
||||||
|
|
|
||||||
|
|
@ -13,3 +13,4 @@ Usage
|
||||||
- Explore the package under `gridverse/` and `gridverse/adapter_marketplace/`
|
- Explore the package under `gridverse/` and `gridverse/adapter_marketplace/`
|
||||||
|
|
||||||
This MVP is intentionally small but production-oriented: small, well-tested units with clear APIs designed to be composed into a larger cross-domain orchestration stack.
|
This MVP is intentionally small but production-oriented: small, well-tested units with clear APIs designed to be composed into a larger cross-domain orchestration stack.
|
||||||
|
- EnergiBridge Skeleton: A canonical bridge for mapping GridVerse primitives to a CatOpt-inspired IR, enabling cross-domain adapters and registries to interoperate. See gridverse/energi_bridge.py for details.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
"""
|
||||||
|
EnergiBridge Skeleton: canonical bridge between GridVerse primitives and a
|
||||||
|
vendor-agnostic intermediate representation (IR) inspired by CatOpt-like
|
||||||
|
intermediates.
|
||||||
|
|
||||||
|
This module provides a small, production-friendly helper set that a future
|
||||||
|
implementation can plug into the GraphContractRegistry and Adapter Marketplace
|
||||||
|
to enable cross-domain interoperability without rewriting solvers.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Any, Dict, Tuple
|
||||||
|
|
||||||
|
|
||||||
|
class EnergiBridge:
|
||||||
|
"""Minimal bridge helpers to translate between GridVerse primitives and a
|
||||||
|
vendor-agnostic IR (CatOpt-like).
|
||||||
|
|
||||||
|
The goal is not full implementation here, but a clean, well-documented
|
||||||
|
surface that downstream components can rely on when wiring adapters.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def to_ir(contract_type: str, payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
"""Convert a GridVerse contract into a canonical IR payload.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
contract_type: The name of the contract (e.g., "LocalProblem").
|
||||||
|
payload: The contract payload data.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A dict representing the IR contract, suitable for transport or
|
||||||
|
storage in the registry. This is intentionally lightweight.
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"ir_type": contract_type,
|
||||||
|
"ir_payload": payload,
|
||||||
|
"metadata": {
|
||||||
|
"source": "gridverse",
|
||||||
|
"version": "0.1",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_ir(ir: Dict[str, Any]) -> Tuple[str, Dict[str, Any]]:
|
||||||
|
"""Reverse translation from IR to a GridVerse contract tuple."""
|
||||||
|
contract_type = ir.get("ir_type")
|
||||||
|
payload = ir.get("ir_payload", {})
|
||||||
|
return contract_type, payload
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def map_gridverse_to_catopt(gridverse_contract: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
"""A tiny, deterministic mapper from GridVerse contract to a canonical IR
|
||||||
|
representation. This is a convenience to illustrate how adapters would
|
||||||
|
plug into a broader ecosystem.
|
||||||
|
"""
|
||||||
|
ct = gridverse_contract.get("type") or gridverse_contract.get("contract_type")
|
||||||
|
payload = gridverse_contract.get("payload") or gridverse_contract
|
||||||
|
return EnergiBridge.to_ir(ct or "UnknownContract", payload)
|
||||||
Loading…
Reference in New Issue