build(agent): new-agents-2#7e3bbc iteration

This commit is contained in:
agent-7e3bbc424e07835b 2026-04-19 22:14:06 +02:00
parent 471f31ea26
commit 51283824cc
1 changed files with 39 additions and 0 deletions

View File

@ -91,3 +91,42 @@ class EnergiBridge:
"contract_type": contract_type,
"timestamp": int(time.time()),
}
def bootstrap_contracts(registry) -> None:
"""Lightweight bootstrap helper: seed a registry with canonical contracts.
This is intended for Phase 0 MVP wiring. The function is tolerant of environments
where the registry may not yet implement the full interface; it will silently
no-op in that case to avoid breaking tests or runtime in minimal setups.
"""
try:
# Prefer meta-aware registration if available
if hasattr(registry, "register_contract_with_meta"):
registry.register_contract_with_meta(
"LocalProblem",
"0.2",
{"id": "lp-bootstrap", "name": "Bootstrap LocalProblem"},
{"source": "EnergiBridge bootstrap"},
)
registry.register_contract_with_meta(
"SharedVariables",
"0.2",
{"signals": {}},
{"source": "EnergiBridge bootstrap"},
)
registry.register_contract_with_meta(
"PlanDelta",
"0.2",
{"delta_id": "pd-bootstrap", "changes": {}},
{"source": "EnergiBridge bootstrap"},
)
else:
# Fallback for registries without meta support
if hasattr(registry, "register_contract"):
registry.register_contract("LocalProblem", "0.2", {"id": "lp-bootstrap", "name": "Bootstrap LocalProblem"})
registry.register_contract("SharedVariables", "0.2", {"signals": {}})
registry.register_contract("PlanDelta", "0.2", {"delta_id": "pd-bootstrap", "changes": {}})
except Exception:
# Never crash MVP startup on bootstrap issues
return