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

This commit is contained in:
agent-7e3bbc424e07835b 2026-04-20 15:42:03 +02:00
parent 415ea0533b
commit 2c1b676065
3 changed files with 72 additions and 1 deletions

View File

@ -17,4 +17,12 @@ How to run tests
- Run tests: `pytest -q`. - Run tests: `pytest -q`.
- Run packaging check: `python3 -m build`. - Run packaging check: `python3 -m build`.
Extending and publishing
- This repo is designed to be extended in a production-ready manner. See READY_TO_PUBLISH for publishing flag.
- A minimal DSL seed (core/dsl_seed.py) and an MVP contract seed (core/dsl.py) help bootstrap interoperability with adapters.
- The two adapters (adapters/ros2_adapter.py and adapters/gazebo_adapter.py) are placeholders to be wired to real ROS 2 and Gazebo integrations.
Contributing
- Follow the architecture described in AGENTS.md and keep changes cohesive and well-tested.
Architecture overview and how to contribute are described in AGENTS.md. Architecture overview and how to contribute are described in AGENTS.md.

46
core/dsl_seed.py Normal file
View File

@ -0,0 +1,46 @@
from __future__ import annotations
"""Seed DSL generator for FleetOpt MVP interoperability.
This module provides a tiny helper to generate a canonical seed structure
consisting of LocalRobotPlanDSL, SharedSignalsDSL and PlanDeltaDSL instances
that can be used to bootstrap interoperability between adapters and tests.
"""
from core.dsl import LocalRobotPlanDSL, SharedSignalsDSL, PlanDeltaDSL
def generate_seed() -> dict:
# Simple, deterministic seed for two robots across two fleets
plan1 = LocalRobotPlanDSL(
fleet_id="fleet-A",
robot_id="robot-1",
tasks=["pickup", "deliver"],
path=[{"x": 0.0, "y": 0.0}, {"x": 1.0, "y": 1.0}],
objectives={"energy": 0.5},
)
plan2 = LocalRobotPlanDSL(
fleet_id="fleet-B",
robot_id="robot-2",
tasks=["inspect"],
path=[{"x": 0.0, "y": 0.0}, {"x": -1.0, "y": 2.0}],
objectives={"energy": 0.3},
)
signals = SharedSignalsDSL(signals={"energy": 0.4})
delta = PlanDeltaDSL(
delta_id="delta-sample",
fleet_id="fleet-A",
changes={"cost_improvement": 0.2},
version=1,
)
return {
"plan1": plan1.to_model().__dict__,
"plan2": plan2.to_model().__dict__,
"signals": signals.to_model().__dict__,
"delta": delta.to_model().__dict__,
}
__all__ = ["generate_seed"]

View File

@ -1,11 +1,16 @@
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
import time
import uuid
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Dict, Any from typing import Dict, Any
from .models import LocalRobotPlan, PlanDelta, SharedSignals, DualVariables from .models import LocalRobotPlan, PlanDelta, SharedSignals, DualVariables
# Simple, production-leaning delta version counter to enable deterministic repro and auditing
_delta_version: int = 0
@dataclass @dataclass
class SolverState: class SolverState:
@ -20,7 +25,19 @@ async def admm_step(left_plan: LocalRobotPlan, right_plan: LocalRobotPlan, signa
delta_changes = { delta_changes = {
"cost_improvement": max(0.0, 1.0 - signals.signals.get("energy", 0.0)) "cost_improvement": max(0.0, 1.0 - signals.signals.get("energy", 0.0))
} }
return PlanDelta(delta_id=f"delta-{left_plan.robot_id}-{right_plan.robot_id}", fleet_id=left_plan.fleet_id, changes=delta_changes) # Increment a global delta version for deterministic reconciliation/auditing
global _delta_version
_delta_version += 1
nonce = uuid.uuid4().hex
timestamp = time.time()
return PlanDelta(
delta_id=f"delta-{left_plan.robot_id}-{right_plan.robot_id}",
fleet_id=left_plan.fleet_id,
changes=delta_changes,
version=_delta_version,
nonce=nonce,
timestamp=timestamp,
)
async def coordinate_fleets(left_plan: LocalRobotPlan, right_plan: LocalRobotPlan, registry_signals: SharedSignals) -> PlanDelta: async def coordinate_fleets(left_plan: LocalRobotPlan, right_plan: LocalRobotPlan, registry_signals: SharedSignals) -> PlanDelta: