Skip to content

[T-097a] Parallel isolation: ROS_DOMAIN_ID slots, GZ_PARTITION, localhost discovery; 2 parallel episodes clean #203

Open

Description

@CodewithJha

Task T-097a · Milestone M9 — Gazebo backend · Size S · Priority P1 · Epic #9

Implements FR-SIM-004

Branch feat/t-097a-parallel-isolation-ros-domain-id — one task = one branch = one PR (doc 32 §6)

Summary

Slot allocator per worker host (domain_id_base + slot), GZ_PARTITION=rp_<worker>_<slot>, ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST; test two concurrent episodes without crosstalk.

Context / motivation

Doc 10 §9; enables max_parallel_per_host > 1.

Scope

In scope

  • Crosstalk detection test (each episode's topics only).

Implementation guidance

  • slots.py: class SlotAllocator: def acquire(self) -> Slot; def release(self, slot) -> None using fcntl.flock on <workdir_root>/slots/<n>.lock for n < max_parallel_per_host; Slot.domain_id = domain_id_base + n, Slot.partition = f"rp_{worker_id_short}_{n}".
  • Gazebo worker concurrency = min(worker.concurrency, max_parallel_per_host); the backend acquires a slot per episode and passes its env to EpisodeProcess.
  • Crosstalk test: two concurrent episodes with different pallet positions must produce different min-distance profiles, and ros2 node list in one domain must not show the other's nodes.
  • Standards: respect the layering contracts (doc 16 §2) and conventions in doc 34; no hard-coded tunables — thresholds/defaults come from typed settings (doc 27); no magic numbers (ruff PLR2004); public APIs typed (mypy strict) and documented.

Configuration keys

From the configuration reference (doc 27). Keys marked (new) must be added to the typed settings models and appear in the generated reference (T-003c).

  • backends.gazebo_nav2.domain_id_base
  • backends.gazebo_nav2.max_parallel_per_host
  • worker.concurrency

Acceptance criteria

  • Two parallel episodes complete with independent traces (sim test).
  • Slots released on exceptions (context manager).
  • Locks from a crashed container don't block (flock released by the kernel).
  • Tests listed below added and green in CI; coverage of new code meets the gate in doc 18 §3.
  • Docs, config reference and CHANGELOG Unreleased updated where behaviour, keys or interfaces changed.
  • Definition of Done (doc 32 §3) satisfied.

Tests required

  • tests/sim/test_parallel_isolation.py.

Dependencies

Blocked by: #202 (T-096b)

Blocks: #205 (T-098)

Parallelization notes

Files / paths owned by this task — avoid editing other paths; shared files (pyproject.toml entry points, cli/main.py, api/routers/__init__.py, router.tsx, docker/compose.yaml, ci.yml) are append-only:

  • backend/src/roboprobe/backends/gazebo_nav2/slots.py

Parallel with T-097b.

Definition of Done

Per doc 32 §3 and AGENTS.md §5: lint, format, mypy strict and import-linter green; tests added and passing; docs updated; PR template completed with Closes #<this issue>; Conventional Commit messages referencing T-097a (doc 16 §6); commits authored only by the repository owner identity (AGENTS.md §4); CI green; reviewer checklist (doc 32 §5.1) satisfied.

References

Design docs: doc 10 §9

Requirements: FR-SIM-004 (traceability: doc 28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:simulatorSimulator backends (kinematic2d, Gazebo adapter)milestone:M9M9 — Gazebo backendpriority:P1Required for milestone exitsize:S<= 1 daytaskChild task of a milestone epictype:featureNew functionality

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions