build(agent): new-agents-2#7e3bbc iteration
This commit is contained in:
parent
471f31ea26
commit
51283824cc
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue