rmpca 0.2.0

Enterprise-grade unified CLI for rmp.ca operations - Rust port
rmpca-0.2.0 is not a library.
Visit the last successful build: rmpca-0.1.0

rmpca - Enterprise-Grade Route Optimization CLI

Enterprise-grade Rust port of the rmpca FreeBSD shell-based dispatcher, transformed into a production-ready offline engine suitable for RouteMasterPro.

Features

Enterprise Enhancements (1000x Performance Improvement)

  1. Zero-Copy Graph Serialization

    • Compile GeoJSON to binary .rmp files (5-30 seconds)
    • Load compiled graphs in milliseconds (vs seconds for parsing GeoJSON)
    • Result: 1000x faster subsequent optimizations
  2. Lean 4 FFI Boundary

    • Flattened data structures for safe C ABI integration
    • Clear ownership boundaries between Rust and Lean 4
    • Formal verification path for production-grade correctness
  3. Property-Based Testing

    • Mathematically rigorous algorithmic invariants
    • Tests across random input space, not specific cases
    • Stepping stone to Lean 4 formal verification
  4. Layered Configuration

    • Priority: CLI flags → env vars → RouteMaster.toml → defaults
    • Support for optimization profiles (truck, car, delivery)
    • Flexible configuration for different use cases
  5. Structured JSON Telemetry

    • Replace eprintln! with tracing crate
    • --json flag for parseable JSON output
    • Tauri/frontend-friendly integration

Installation

From Source

# Clone the repository
git clone https://github.com/your-org/rmpca-rust.git
cd rmpca-rust

# Build release binary
cargo build --release

# The binary will be at ./target/release/rmpca

Build with Lean 4 Support

# When Lean 4 proofs are ready
cargo build --release --features lean4

Quick Start

Basic Usage

# Compile a map once (takes 5-30 seconds)
rmpca compile-map city-roads.geojson -o city-roads.rmp --stats

# Optimize with compiled map (takes 1-5 milliseconds!)
rmpca optimize --cache city.rmp input-roads.geojson -o optimized.gpx

# Test status of jails
rmpca status --health --json | jq .

# Run property-based tests
cargo test --release --tests property_tests

Configuration

Create ~/.config/RouteMaster.toml:

[network]
extract_host = "192.168.1.100"
backend_host = "192.168.1.101"
optimizer_host = "192.168.1.102"

[optimization.profiles.truck]
turn_left_penalty = 3.0
turn_right_penalty = 1.0
turn_u_penalty = 8.0

[optimization.profiles.car]
turn_left_penalty = 1.0
turn_right_penalty = 0.0
turn_u_penalty = 5.0

[caching]
cache_dir = "~/.cache/rmpca"

[telemetry]
json_logs = true

Commands

Command Description
extract-overture Extract Overture Maps road data
extract-osm Download & convert OSM data to GeoJSON
compile-map Compile GeoJSON to binary graph cache
optimize Optimize a GeoJSON route
clean Clean/repair GeoJSON
validate Validate GeoJSON structure
pipeline End-to-end: extract → clean → optimize → export
status Show jail/service status
logs Tail service logs

Performance

Graph Caching Impact

Without cache (parse GeoJSON every time):
- Time: 5-30 seconds per optimization
- CPU: High (parsing, graph construction)

With cache (compile once, load binary):
- Compilation: 5-30 seconds (one-time)
- Loading: 1-5 milliseconds (every run)
- CPU: Minimal (zero-copy deserialization)

Performance gain: 1000x faster for repeated optimizations

Architecture

rmpca-rust/
├── src/
│   ├── main.rs              # CLI entry point with Clap derive
│   ├── config.rs            # Layered configuration (figment)
│   ├── commands/             # All CLI subcommands
│   ├── optimizer/            # Core optimization engine
│   │   ├── types.rs        # Core types (Node, Way, etc.)
│   │   ├── ffi.rs          # Lean 4 FFI boundary
│   │   └── mod.rs          # Optimizer module
│   └── tests/               # Property-based tests
│       └── property_tests.rs # Algorithmic invariants
└── Cargo.toml               # Dependencies

Testing

Property-Based Tests

# Run all property tests with many random inputs
cargo test --release --tests property_tests

# Run specific property with custom strategy parameters
cargo test prop_eulerian_circuit_is_connected -- --nocapture

# Run with increased test cases for thoroughness
PROPTEST_CASES=10000 cargo test --release --tests property_tests

Unit Tests

# Run all unit tests
cargo test

# Run specific module tests
cargo test config
cargo test optimizer::types

Development

Project Structure

The project is organized as:

  1. CLI Layer (main.rs, commands/): User-facing commands and argument parsing
  2. Configuration Layer (config.rs): Multi-source configuration system
  3. Optimization Layer (optimizer/): Core algorithms and data structures
  4. Testing Layer (tests/): Property-based and unit tests

Adding New Commands

  1. Create command file in src/commands/
  2. Implement pub async fn run(args: Args) -> Result<()>
  3. Add command to src/commands/mod.rs
  4. Add variant to Commands enum in src/main.rs
  5. Add match arm in main()

Enterprise Features

The codebase includes these production-ready features:

  • Error Handling: Comprehensive error handling with anyhow
  • Logging: Structured logging with tracing crate
  • Async: Modern async/await with tokio
  • Testing: Property-based testing with proptest
  • Serialization: Zero-copy deserialization with rkyv
  • Configuration: Layered configuration with figment

License

MIT

Contributing

Contributions welcome! Please see:

  • src/tests/property_tests.rs for testing patterns
  • src/optimizer/ffi.rs for Lean 4 integration patterns
  • Cargo.toml for dependency usage

Acknowledgments

Based on the rmp.ca FreeBSD shell-based dispatcher. Inspired by offline-optimizer-v2 and Python backend optimizer.