Skip to content

Add support for barriers#256

Merged
ppinchuk merged 72 commits intomainfrom
pp/barriers
Apr 22, 2026
Merged

Add support for barriers#256
ppinchuk merged 72 commits intomainfrom
pp/barriers

Conversation

@ppinchuk
Copy link
Copy Markdown
Collaborator

This PR adds support for both hard and soft barriers without the need to specify a high dummy cost multiplier value like 99999. Instead the algorithm simply does not show barriered cells as successors. Soft barriers have an intrinsic rank, and can be dropped iteratively until a valid routing solution is found. All of this is described in the routing layer guide that was put together a while ago.

The requirements for this PR led to a sizable refactor of dataset.rs, but hopefully that module has better separation of responsibilities now.

@ppinchuk ppinchuk self-assigned this Apr 18, 2026
@ppinchuk ppinchuk added enhancement Update to logic or general code improvements new computation Update that adds a new computation method p-high Priority: high topic-rust-routing Issues/pull requests related to rust routing code labels Apr 18, 2026
@ppinchuk ppinchuk requested a review from castelao as a code owner April 18, 2026 18:20
@ppinchuk ppinchuk added the topic-python-cli Issues/pull requests related to python CLI label Apr 18, 2026
Copilot AI review requested due to automatic review settings April 18, 2026 18:20
@ppinchuk ppinchuk linked an issue Apr 18, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for hard/soft barrier layers across the Python orchestration and Rust routing core, avoiding “dummy high cost” barrier encodings and enabling retry-by-dropping ranked soft barriers while tracking which barriers were relaxed per solution.

Changes:

  • Extend routing payloads + CLI APIs to accept barrier_layers, normalize barrier_values, and persist hard barriers into the Python-built routing raster.
  • Refactor Rust dataset handling to materialize derived cost + barrier masks in a swap store, and add retry-aware successor generation + per-solution dropped-barrier metadata.
  • Update Rust/Python bindings and tests to return/validate (path, cost, dropped_barrier_layers) results, plus docs describing barrier configuration.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/python/unit/test_skimage_validate.py Adjusts assertions for new 3-tuple route result shape.
tests/python/unit/test_rust_bindings.py Adds unit coverage for hard/soft barriers and dropped-barrier metadata.
tests/python/unit/routing/test_routing_base.py Adds Python-side normalization + routing-layer barrier behavior tests (includes a callable-vs-property issue).
tests/python/unit/routing/cli/test_routing_cli_point_to_feature.py Updates CLI converter batch tuple to include barrier layers.
tests/python/unit/routing/cli/test_routing_cli_build_costs.py Adds CLI test ensuring explicit barriers become NaN in final routing raster output.
tests/python/integration/test_rust_bindings_integration.py Adds layered-file integration coverage for hard/soft barriers and retries.
revrt/routing/cli/utilities.py Includes barrier layers in routing-layer output hashing/persistence.
revrt/routing/cli/point_to_point.py Adds barrier_layers parameter + documentation to point-to-point CLI entry.
revrt/routing/cli/point_to_feature.py Adds barrier_layers parameter + documentation to point-to-feature CLI entry.
revrt/routing/cli/build_costs.py Plumbs barrier_layers from config into routing-layer build.
revrt/routing/cli/base.py Threads barrier layers through batch generation and routing execution.
revrt/routing/base.py Normalizes barrier layers for Rust, applies hard barriers to Python routing raster, and records dropped-barrier metadata in outputs.
revrt/models/cost_layers.py Introduces BarrierLayer model + barrier_values parsing/validation.
docs/source/guides/routing_layers.md Documents barrier operators including != and usage guidance.
crates/revrt/src/solution.rs Extends Solution to store dropped barrier layer names.
crates/revrt/src/routing/scenario.rs Adds retry-aware successor filtering and dropped-barrier reporting helpers.
crates/revrt/src/routing/mod.rs Implements per-start retry loop dropping soft barrier groups and recording metadata.
crates/revrt/src/network/long_range/mod.rs Tweaks frontier update criteria to use estimated cost (aligning with PQ ordering).
crates/revrt/src/lib.rs Adds a core test ensuring explicit barriers block routing.
crates/revrt/src/ffi/mod.rs Updates Python return tuple type to include dropped barrier layers (docs currently overstate contents).
crates/revrt/src/dataset/swap.rs New swap initialization/layout inspection module for derived routing arrays.
crates/revrt/src/dataset/reader.rs New cached neighborhood reader for costs + hard/soft barrier masks.
crates/revrt/src/dataset/mod.rs Major dataset refactor to use swap+reader+derived writer and expose soft barrier grouping.
crates/revrt/src/dataset/lazy_subset.rs Expands documentation/comments and supports new derived workflow.
crates/revrt/src/dataset/derived.rs New derived-data writer to materialize costs + barrier masks chunk-wise.
crates/revrt/src/cost.rs Adds barrier layer types, grouping by importance, and barrier mask construction.
crates/revrt/Cargo.toml Adds test-integration feature gating for Rust integration tests.

Comment thread crates/revrt/src/dataset/swap.rs Outdated
Comment thread tests/python/unit/routing/test_routing_base.py Outdated
Comment thread tests/python/unit/routing/test_routing_base.py Outdated
Comment thread crates/revrt/src/ffi/mod.rs Outdated
Comment thread crates/revrt/src/dataset/swap.rs Outdated
Comment thread crates/revrt/src/dataset/swap.rs Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 18, 2026

Codecov Report

❌ Patch coverage is 71.73913% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.86%. Comparing base (fcee3dc) to head (88e5e31).

Files with missing lines Patch % Lines
revrt/routing/base.py 67.50% 7 Missing and 6 partials ⚠️

❌ Your patch status has failed because the patch coverage (71.73%) is below the target coverage (93.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #256      +/-   ##
==========================================
- Coverage   97.26%   96.86%   -0.41%     
==========================================
  Files          26       26              
  Lines        2927     2967      +40     
  Branches      340      351      +11     
==========================================
+ Hits         2847     2874      +27     
- Misses         59       66       +7     
- Partials       21       27       +6     
Flag Coverage Δ
unittests 96.86% <71.73%> (-0.41%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@castelao castelao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of code. Thanks for addressing the barriers requirements! I think we might be able to resolve the barriers in a simpler way, but we should move this PR forward to support barriers now, and try to improve it later when we have a chance. Thanks!

Comment thread crates/revrt/Cargo.toml
workspace = true

[features]
test-integration = []
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! With that we can easily choose when we can afford a heavier tests.

@ppinchuk ppinchuk merged commit f024d74 into main Apr 22, 2026
26 checks passed
@ppinchuk ppinchuk deleted the pp/barriers branch April 22, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Update to logic or general code improvements new computation Update that adds a new computation method p-high Priority: high topic-python-cli Issues/pull requests related to python CLI topic-rust-routing Issues/pull requests related to rust routing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add barrier layer functionality

4 participants