Skip to content

Commit 769d38a

Browse files
committed
refactor: split review postprocess dedup helpers
Made-with: Cursor
1 parent c21fb96 commit 769d38a

4 files changed

Lines changed: 38 additions & 17 deletions

File tree

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
- [x] `src/review/pipeline/services.rs`: separate service wiring from optional feature initialization.
106106
- [x] `src/review/pipeline/file_context/sources.rs`: split repo sources, symbol sources, and supplemental context sources.
107107
- [x] `src/review/pipeline/comments.rs`: separate comment assembly, filtering, and metadata stamping.
108-
- [ ] `src/review/pipeline/postprocess/dedup.rs`: split duplicate detection, scoring, and merge/rewrite behavior.
108+
- [x] `src/review/pipeline/postprocess/dedup.rs`: split duplicate detection, scoring, and merge/rewrite behavior.
109109
- [ ] `src/review/pipeline/postprocess/feedback.rs`: separate store lookups from suppression/annotation decisions.
110110
- [ ] `src/review/pipeline/execution/dispatcher.rs`: carve request scheduling, concurrency control, and result collection.
111111
- [ ] `src/review/pipeline.rs`: keep trimming top-level orchestration as helpers mature.

src/review/pipeline/postprocess/dedup.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
#[path = "dedup/matching.rs"]
2+
mod matching;
3+
#[path = "dedup/merge.rs"]
4+
mod merge;
5+
16
use crate::core;
27

8+
use matching::find_dominated_comment_index;
9+
use merge::merge_specialized_comment;
10+
311
pub(super) fn deduplicate_specialized_comments(
412
mut comments: Vec<core::Comment>,
513
) -> Vec<core::Comment> {
@@ -15,22 +23,8 @@ pub(super) fn deduplicate_specialized_comments(
1523

1624
let mut deduped: Vec<core::Comment> = Vec::with_capacity(comments.len());
1725
for comment in comments {
18-
let dominated = deduped.iter_mut().find(|existing| {
19-
existing.file_path == comment.file_path
20-
&& existing.line_number == comment.line_number
21-
&& core::multi_pass::content_similarity(&existing.content, &comment.content) > 0.6
22-
});
23-
if let Some(existing) = dominated {
24-
if comment.confidence > existing.confidence {
25-
existing.content = comment.content;
26-
existing.confidence = comment.confidence;
27-
existing.severity = comment.severity;
28-
}
29-
for tag in &comment.tags {
30-
if !existing.tags.contains(tag) {
31-
existing.tags.push(tag.clone());
32-
}
33-
}
26+
if let Some(index) = find_dominated_comment_index(&deduped, &comment) {
27+
merge_specialized_comment(&mut deduped[index], comment);
3428
} else {
3529
deduped.push(comment);
3630
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use crate::core;
2+
3+
pub(super) fn find_dominated_comment_index(
4+
deduped: &[core::Comment],
5+
comment: &core::Comment,
6+
) -> Option<usize> {
7+
deduped.iter().position(|existing| {
8+
existing.file_path == comment.file_path
9+
&& existing.line_number == comment.line_number
10+
&& core::multi_pass::content_similarity(&existing.content, &comment.content) > 0.6
11+
})
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use crate::core;
2+
3+
pub(super) fn merge_specialized_comment(existing: &mut core::Comment, comment: core::Comment) {
4+
if comment.confidence > existing.confidence {
5+
existing.content = comment.content;
6+
existing.confidence = comment.confidence;
7+
existing.severity = comment.severity;
8+
}
9+
10+
for tag in &comment.tags {
11+
if !existing.tags.contains(tag) {
12+
existing.tags.push(tag.clone());
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)