fix: multi-segment full coverage misclassified as PartialOverlap#37
Merged
fix: multi-segment full coverage misclassified as PartialOverlap#37
Conversation
The fully_covered check only tested single-segment coverage. When a new segment was covered by the union of multiple adjacent existing segments, gaps was empty but the return logic fell through to PartialOverlap. This inflated segments_inserted stats. Fixes #34.
There was a problem hiding this comment.
Pull request overview
Fixes FlowDirection::insert_segment so a new segment that’s fully covered by the union of multiple existing segments is classified as Duplicate (or ConflictingOverlap when bytes differ), instead of incorrectly falling through to PartialOverlap.
Changes:
- Update overlap return logic to treat “no gaps to fill” as full coverage by union → return
Duplicatewhen non-conflicting. - Add regression tests for multi-segment full-coverage duplicate and conflict cases.
- Clarify the in-code comment describing the overlap return logic.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/reassembly/segment.rs |
Adjusts overlap return classification when the new segment has no uncovered gaps after union coverage. |
tests/reassembly_segment_tests.rs |
Adds regression tests for duplicate vs conflicting multi-segment full-coverage overlap cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
insert_segmentreturningPartialOverlapinstead ofDuplicatewhen a new segment is fully covered by the union of multiple existing segments (but not by any single segment)Fixes #34
Test plan
test_multi_segment_full_coverage_returns_duplicate— two adjacent segments fully cover new segment with matching data → returnsDuplicatetest_multi_segment_full_coverage_conflicting_returns_conflict— two adjacent segments fully cover new segment with different data → returnsConflictingOverlap