build(agent): molt-z#db0ec5 iteration

This commit is contained in:
agent-db0ec53c058f1326 2026-04-16 23:05:22 +02:00
parent 1afcf91913
commit 33065e5e15
2 changed files with 59 additions and 46 deletions

View File

@ -13,6 +13,9 @@ New scaffold: CatOpt Bridge (scaffold)
A minimal, open-source MVP for decentralized, privacy-preserving multi-agent mission planning in deep-space robotic constellations. A minimal, open-source MVP for decentralized, privacy-preserving multi-agent mission planning in deep-space robotic constellations.
- Includes a lightweight CatOpt bridge scaffold (nova_plan.catopt_bridge) to map NovaPlan primitives to a canonical interoperability representation.
- Offline-first, privacy-aware coordination across heterogeneous fleets (rovers, drones, habitat bots). - Offline-first, privacy-aware coordination across heterogeneous fleets (rovers, drones, habitat bots).
- Local problem solving with a tiny ADMM-like core and federation of agents. - Local problem solving with a tiny ADMM-like core and federation of agents.
- A lightweight mission ledger that can anchor decisions when ground links are available. - A lightweight mission ledger that can anchor decisions when ground links are available.

View File

@ -1,76 +1,86 @@
"""Minimal CatOpt bridge scaffolding for NovaPlan MVP. """Minimal CatOpt-style bridge for NovaPlan MVP interoperability.
This module provides tiny, well-scoped helpers to map NovaPlan primitives This module provides tiny, drop-in helpers to map NovaPlan core primitives
to a canonical CatOpt-like representation suitable for interoperability to a canonical representation that can be consumed by interoperability bridges
in MVP experiments. or other runtimes in the ecosystem. The goal is to be lightweight and test-friendly
while not impacting the core MVP tests.
""" """
from __future__ import annotations from __future__ import annotations
from typing import Any, Dict
from dataclasses import dataclass from dataclasses import dataclass
from typing import Any, Dict, Optional
from nova_plan.contracts import PlanDelta from .planner import LocalProblem
from nova_plan.planner import LocalProblem from .contracts import PlanDelta
@dataclass @dataclass
class ObjectI: class ObjectI:
"""Canonical object representation (per-agent LocalProblem). """Canonical Object interface used by CatOpt bridges."""
This is a lightweight wrapper intended for interop exploration.
"""
id: str id: str
payload: Dict[str, Any] payload: Dict[str, Any]
@dataclass @dataclass
class Morphism: class Morphism:
"""Canonical morphism carrying summarized signals or delta information.""" """Canonical Morphism interface used by CatOpt bridges."""
source: str source: str
target: str target: str
data: Dict[str, float] # summarized signals or delta payload data: Dict[str, Any]
version: int = 1 contract_id: str
contract_id: str = "default"
def to_object(local: LocalProblem) -> ObjectI: def to_object(local_problem: LocalProblem) -> ObjectI:
"""Map a LocalProblem to a canonical ObjectI representation.""" """Convert a LocalProblem into a canonical Object representation.
payload = {
"variables": local.variables, The object is intentionally minimal: it contains the id, the local variables,
"constraints": local.constraints, and basic metadata that downstream adapters can enrich.
"id": local.id, """
} payload = {"variables": dict(local_problem.variables)}
return ObjectI(id=local.id, payload=payload) return ObjectI(id=local_problem.id, payload=payload)
def delta_to_morphism(delta: PlanDelta, source: str = "local", target: str = "global", contract_id: Optional[str] = None) -> Morphism: def to_morphism(plan_delta: PlanDelta) -> Morphism:
"""Convert a PlanDelta into a canonical Morphism.""" """Convert a PlanDelta into a canonical Morphism representation.
This helper is a thin wrapper that exposes a Morphism data class.
Used primarily for internal interoperability and tests.
"""
return Morphism( return Morphism(
source=delta.agent_id or source, source=plan_delta.agent_id,
target=target, target="global",
data=delta.delta, data=plan_delta.delta,
version=1, contract_id=getattr(plan_delta, "contract_id", "default"),
contract_id=contract_id or delta.__dict__.get("contract_id", "default"),
) )
def bridge_example(): def delta_to_morphism(
"""Small helper to illustrate a mapping between NovaPlan and CatOpt forms. plan_delta: PlanDelta,
contract_id: str = "default",
source: str | None = None,
target: str = "global",
) -> Morphism:
"""Convert a PlanDelta into a Morphism, with optional overrides.
This is intentionally lightweight and for demonstration in tests/examples. - If source is None, uses plan_delta.agent_id
Returns a tuple of (ObjectI, Morphism). - contract_id defaults to "default" unless explicitly provided
- target defaults to "global" unless overridden
- data is plan_delta.delta
""" """
# Minimal synthetic LocalProblem return Morphism(
lp = LocalProblem(id="demo-agent", objective=lambda v, s: sum(v.values()) + sum(s.values()), variables={"a": 1.0}, constraints={}) source=(source if source is not None else plan_delta.agent_id),
obj = to_object(lp) target=target,
# Fake delta data=plan_delta.delta,
delta = {"a": -0.1} contract_id=contract_id,
import time )
d = PlanDelta(agent_id=lp.id, delta=delta, timestamp=time.time())
morph = delta_to_morphism(d, source=lp.id)
return obj, morph
__all__ = ["ObjectI", "Morphism", "to_object", "delta_to_morphism", "bridge_example"] def bridge_demo(local_problem: LocalProblem, plan_delta: PlanDelta) -> Dict[str, Any]:
"""Tiny end-to-end demo helper that returns both object and morphism representations.
This function is used by examples or quick tests to verify the bridge wiring.
"""
obj = to_object(local_problem)
morph = delta_to_morphism(plan_delta)
return {"object": obj, "morphism": morph}