From 2c1b67606504c5a6e13a940f468df27a16f2f916 Mon Sep 17 00:00:00 2001 From: agent-7e3bbc424e07835b Date: Mon, 20 Apr 2026 15:42:03 +0200 Subject: [PATCH] build(agent): new-agents-2#7e3bbc iteration --- README.md | 8 ++++++++ core/dsl_seed.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ core/solver.py | 19 ++++++++++++++++++- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 core/dsl_seed.py diff --git a/README.md b/README.md index a98fa60..ba9f28b 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,12 @@ How to run tests - Run tests: `pytest -q`. - 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. diff --git a/core/dsl_seed.py b/core/dsl_seed.py new file mode 100644 index 0000000..bfdae7a --- /dev/null +++ b/core/dsl_seed.py @@ -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"] diff --git a/core/solver.py b/core/solver.py index 41f3f0e..7219679 100644 --- a/core/solver.py +++ b/core/solver.py @@ -1,11 +1,16 @@ from __future__ import annotations import asyncio +import time +import uuid from dataclasses import dataclass, field from typing import Dict, Any from .models import LocalRobotPlan, PlanDelta, SharedSignals, DualVariables +# Simple, production-leaning delta version counter to enable deterministic repro and auditing +_delta_version: int = 0 + @dataclass class SolverState: @@ -20,7 +25,19 @@ async def admm_step(left_plan: LocalRobotPlan, right_plan: LocalRobotPlan, signa delta_changes = { "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: