feat(routes): add per-route max_path_length cap - #321
Merged
Conversation
Adds a new nullable per-route knob that caps the total number of hops in a candidate packet's path. Packets whose path exceeds the cap are dropped from matching consideration entirely (before the subsequence matcher runs), so over-long paths never count toward packet_count_threshold. Complements the existing max_hop_span, which only constrains the gap between the first and last matched configured node. - Route model + migration (additive, nullable, default null = unlimited) - Threaded through matcher chain (_subsequence_indices early-return) - All 5 evaluate/preview/recent_matches call sites updated - API serializer/create/update/preview passthrough - CLI seed YAML import (update + create paths) - Frontend: distinct icons for span (<-o->) vs path-length (|<->|), always-rendered badges with infinity fallback, hover tooltips on every stats row item, i18n keys (en + nl) - Tests: matcher unit tests (within/exceeds cap), API round-trip, CLI seed import
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new nullable per-route knob
max_path_lengththat caps the total number of hops in a candidate packet's path. Packets whose path exceeds the cap are dropped from matching consideration entirely (before the subsequence matcher runs), so over-long paths never count towardpacket_count_threshold.Complements the existing
max_hop_span, which only constrains the gap between the first and last matched configured node. The new knob constrains the total packet path size and drops over-long packets up front.Semantics
max_path_lengthOptional[int](null = unlimited)null(backwards-compatible — existing routes unchanged)len(hops) > max_path_length→ reject, before running the subsequence matchChanges
Data layer
Routemodel: newmax_path_lengthcolumn (nullable Integer, default null)d307ee761a34(additive, no backfill, zero-downtime)Matcher (
collector/routes.py)_subsequence_indices; threaded throughis_subsequence,_matched_subpath,_matched_subpath_with_indices,_match_hopsevaluate_route,evaluate_route_day,evaluate_route_history,recent_matches,preview_routeAPI + CLI
RouteCreate,RouteUpdate,RouteRead,RouteDetail,RoutePreviewRequestFrontend
iconHopSpan(<-o->) formax_hop_span,iconPathLength(|⟷|) formax_path_length— distinct from each other and from the genericiconPath∞fallback when null (mirrors observer-count pattern)Tests
test_path_length_cap_within,test_path_length_cap_exceeds,test_path_length_cap_zero_ignoredtest_update_all_scalar_fieldsextended to PUTmax_path_length: 6and assert round-tripmax_path_length: 12Verification
Out of scope
invalidate_routesalready covers all route mutations)configuration.mdchange (per-route DB field, not env var)