build(agent): new-agents-3#dd492b iteration
This commit is contained in:
parent
539299ddff
commit
831ceca46e
|
|
@ -60,6 +60,24 @@ class GoCRegistry:
|
||||||
def get_provenance(cls, contract_id: str) -> list:
|
def get_provenance(cls, contract_id: str) -> list:
|
||||||
return list(cls._deltas.get(contract_id, []))
|
return list(cls._deltas.get(contract_id, []))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def list_contracts(cls) -> list[str]:
|
||||||
|
"""Return a list of contract_ids currently stored in the registry."""
|
||||||
|
return list(cls._contracts.keys())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def latest_delta(cls, contract_id: str) -> PlanDelta | None:
|
||||||
|
"""Return the most recent PlanDelta for a given contract, if any."""
|
||||||
|
deltas = cls._deltas.get(contract_id)
|
||||||
|
if not deltas:
|
||||||
|
return None
|
||||||
|
return deltas[-1]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_all_provenance(cls) -> Dict[str, list]:
|
||||||
|
"""Return a mapping of contract_id to its provenance delta list."""
|
||||||
|
return {cid: list(deltas) for cid, deltas in cls._deltas.items()}
|
||||||
|
|
||||||
|
|
||||||
def _delta_sign_digest(delta: PlanDelta, key: str) -> str:
|
def _delta_sign_digest(delta: PlanDelta, key: str) -> str:
|
||||||
payload = {
|
payload = {
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ feature growth.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict, cast
|
||||||
|
|
||||||
from nova_plan.catopt_bridge import to_object, delta_to_morphism
|
from nova_plan.catopt_bridge import to_object, delta_to_morphism
|
||||||
from nova_plan.contracts import PlanDelta, CaCContract, CaCRegistry, sign_ca_contract
|
from nova_plan.contracts import PlanDelta, CaCContract, CaCRegistry, sign_ca_contract, GoCRegistry
|
||||||
|
|
||||||
|
|
||||||
class EnergiBridge:
|
class EnergiBridge:
|
||||||
|
|
@ -53,8 +53,15 @@ class EnergiBridge:
|
||||||
"""
|
"""
|
||||||
contract = CaCContract(contract_id=contract_id, version=1, content=content)
|
contract = CaCContract(contract_id=contract_id, version=1, content=content)
|
||||||
signed = sign_ca_contract(contract, key)
|
signed = sign_ca_contract(contract, key)
|
||||||
CaCRegistry.register(signed)
|
# Persist in CaC registry (store the unsigned contract metadata for MVP)
|
||||||
return signed
|
CaCRegistry.register(contract)
|
||||||
|
# Also publish provenance to the GoC registry for cross-adapter provenance tracking
|
||||||
|
try:
|
||||||
|
GoCRegistry.register_signed_contract(cast(CaCContract, contract), signer="EnergiBridge", signature=signed.signature)
|
||||||
|
except Exception:
|
||||||
|
# Best-effort provenance extension; do not fail publishing if registry is not ready
|
||||||
|
pass
|
||||||
|
return contract
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["EnergiBridge"]
|
__all__ = ["EnergiBridge"]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue