feat(phase-1): implement warehouse domain models, topological graph builder, connectivity validation, and export

This commit is contained in:
Warehouse Twin Dev
2026-10-19 15:12:38 +05:30
parent 7ef65ce65d
commit 88b922a3e1
13 changed files with 1535 additions and 50 deletions
+27 -4
View File
@@ -49,6 +49,25 @@ warehouse-digital-twin/
### 2.3 CLI Interface (`warehouse_twin.cli`)
- **`check_environment() -> int`**: Tests Python version (>=3.10), checks disk space on `/` (warns if < 10 GB, fails if < 2 GB), checks core imports (`simpy`, `networkx`, `pytest`), verifies log directory writability, and detects Kit executable.
- **`validate_config(config_dir: Optional[str]) -> int`**: Invokes `ConfigLoader` and prints validation summaries.
- **`validate_graph(config_dir: Optional[str]) -> int`**: Builds the `networkx.DiGraph`, validates strong connectivity, tests robot class reachability, and prints a comprehensive topology report.
- **`export_graph(config_dir: Optional[str], output_path: Optional[str]) -> int`**: Builds and exports the serialized graph topology to JSON.
### 2.4 Warehouse Domain Subsystem (`warehouse_twin.domain.warehouse`)
- **`Position3D`**: Immutable 3D Cartesian coordinates `(x, y, z)` in meters with Euclidean metric calculation (`distance_to`).
- **`WarehouseDimensions`**: Physical warehouse bounding box in meters (`width=60m, depth=40m, height=8m`).
- **`ZoneArea` & `ZoneDefinition`**: Rectangular bounds and physical constraints (aisle width, maximum speed limit) for Zones A, B, and C.
- **`Station` & `ChargingStation`**: Fixed operational stations (inbound docks, outbound dock, picking stations, production drop-off) and fast/heavy charging bays.
- **`StorageLocation`**: Inventory rack locations with zone and aisle bindings.
- **`WarehouseModel`**: Comprehensive physical facility model instantiated from configuration data.
### 2.5 Routing & Topological Graph Builder (`warehouse_twin.routing.graph_builder`)
- **`WarehouseGraphBuilder`**:
- `build_graph() -> nx.DiGraph`: Constructs a directed navigation network with 540 nodes and 1,730 edges.
- Coordinate hashing: Waypoint node IDs are derived from discretized coordinates `(round(x, 1), round(y, 1))` to guarantee unified intersection nodes.
- Edge weights: Euclidean distance, speed limit, traversal time (`dist / speed`), and `allowed_robot_types`.
- Zone B restrictions: Edge attributes enforce `allowed_robot_types = {"heavy_amr"}` for Zone B aisles.
- **`ConnectivityReport`**: Structured metrics detailing strong connectivity, reachable stations, chargers, racks, lane length, and robot type accessibility.
- **`WarehouseGraphError`, `DisconnectedGraphError`, `UnreachableStationError`**: Fail-fast exceptions raised upon topological violations.
---
@@ -97,7 +116,11 @@ The testing architecture adheres to the following principles:
---
## 6. Current Limitations & Next Phase
- **Current Limitations**: Phase 0 provides the foundational architecture, configuration validation, logging, CLI, and test runner. Domain classes (`Robot`, `Task`, `WarehouseGraph`) will be instantiated in Phases 1 and 2.
- **Phase 1 Target**: Implement the warehouse topological graph in `warehouse_twin.domain.warehouse` and `warehouse_twin.routing.graph_builder`, populate Zones A, B, and C nodes, validate station accessibility, and export graph connectivity metrics.
## 6. Current Status & Next Phase
- **Completed**: Phase 0 (Environment and Foundation) and Phase 1 (Warehouse Model). The 540-node topological navigation graph is implemented, verified for strong connectivity and robot type restrictions, tested with 26 unit tests, and serializable to JSON.
- **Phase 2 Target**: Implement Robot and Task Domain Models (`warehouse_twin.domain.robot`, `warehouse_twin.domain.task`, `warehouse_twin.domain.inventory`):
- Robot state machine (`IDLE`, `DISPATCHED`, `PICKING`, `LOADED_TRANSIT`, `DROPPING`, `TRANSIT_TO_CHARGE`, `CHARGING`).
- Task state machine and priority models (`ORDER_PICK`, `REPLENISHMENT`, `PRODUCTION_LINE_FEED`, `CHARGING`).
- Payload capacity and robot type compatibility checks.
- Deterministic test fixtures.