Skip to content

feat: feed prior bot comments to model for conceptual dedup - #27

Merged
aliasunder merged 7 commits into
mainfrom
worktree-conceptual-dedup
Jul 23, 2026
Merged

aliasunder merged 7 commits into
mainfrom
worktree-conceptual-dedup

Conversation

@aliasunder

@aliasunder aliasunder commented Jul 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Cross-run dedup uses file:category:line keys with a ±5 line proximity window, which misses conceptual duplicates — findings with the same underlying premise but anchored at different lines (e.g. PR feat: doc-staleness context — mention-based reverse-reference scan #10: false symlink premise raised 3× at lines 183, 219, 336)
  • Feed existing bot comment bodies to the model via a new prior_bot_comments prompt section so it self-suppresses known issues at the semantic level — handles paraphrases that no lexical similarity measure would catch
  • Refactored fetchInlineAnchors → fetchInlineCommentState to preserve raw comment bodies alongside anchors; extended fetchIssueCommentState to return finding bodies (status comment excluded); strip dedup anchor HTML before prompt inclusion; cap at 30

Test plan

  • npm test — 412 tests pass (7 new)
  • npm run lint — 0 warnings
  • npm run build — compiles
  • docker build . — image builds
  • Verify prior bot comment bodies are passed through (anchor-stripped) to generateFindings
  • Verify status comment is excluded from prior bot comments
  • Verify cap at 30 most recent comments
  • Verify empty priorBotComments on first run (no prior comments)
  • Verify prompt renders the prior_bot_comments section with nonce tag and suppression note
  • Verify section ordering: diff → prior bot comments → prior findings

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved review generation across repeated runs by providing previous bot comments as context.
    • Prior comments are filtered, deduplicated, limited to the most recent entries, and clearly separated from status updates.
    • Review prompts now instruct the system not to re-report findings already covered by earlier bot comments.
  • Tests

    • Added coverage for first-run behavior, comment limits, status-comment exclusion, anchor removal, and prompt formatting.

Cross-run dedup uses file:category:line keys with a ±5 line proximity
window — this misses conceptual duplicates at distant lines (same
premise, 100+ lines apart). Feed existing bot comment bodies to the
model via a new prior_bot_comments prompt section so it self-suppresses
known issues at the semantic level.

- Refactor fetchInlineAnchors → fetchInlineCommentState to preserve
  raw comment bodies alongside anchors
- Extend fetchIssueCommentState to return finding bodies (status
  comment excluded)
- Strip dedup anchor HTML before including in prompt
- Cap at 30 most recent comments to bound token usage
- Add priorBotComments to ReviewContext, flows through to buildUserPrompt
- 7 new tests: body passthrough, anchor stripping, status exclusion,
  cap enforcement, first-run empty case, prompt rendering + ordering

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@umm-actually

umm-actually Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

umm-actually re-reviewed at a23ed30

1 new finding(s) posted (3 tracked finding(s) across all runs).


umm-actually · deepseek/deepseek-v4-pro

@aliasunder

Copy link
Copy Markdown
Owner Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Prior bot comment context

Layer / File(s) Summary
Comment state collection
src/orchestrate.ts
Prior inline and issue comment state now includes finding bodies, status classification, anchors, and anchor-stripped comment content.
Orchestration context and dedup integration
src/orchestrate.ts
Prior bot comments are combined, normalized, capped at 30 entries, passed to finding generation, and reused for cross-run anchor deduplication.
Prior comment prompt rendering
src/review/prompt.ts
Prompt generation conditionally adds prior bot comments between the diff and prior findings sections.
Orchestration and prompt coverage
src/__tests__/orchestrate.test.ts, src/review/__tests__/prompt.test.ts
Tests cover comment sourcing, normalization, status exclusion, capping, first-run behavior, rendering, ordering, and updated context fixtures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly captures the main change: sending prior bot comments to the model for conceptual deduplication.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-conceptual-dedup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/__tests__/orchestrate.test.ts`:
- Around line 1713-1715: Update the test around priorBotCommentsFrom to assert
the complete retained comments array, matching the exact sequence from “finding
10” through “finding 39” in order, rather than checking only its length and
final entry.

In `@src/orchestrate.ts`:
- Around line 429-434: Update the data retrieval used by priorBotComments so
both inline and issue comment client methods return creation timestamps
alongside bodies; merge the two collections chronologically, sort by those
timestamps, then apply PRIOR_COMMENT_CAP before stripping anchors, preserving
the 30 most recent comments regardless of source.
- Around line 429-434: Update the prior-comment assembly around priorBotComments
to enforce an explicit token budget in addition to PRIOR_COMMENT_CAP. After
stripAnchorComment, retain comments newest-first and truncate or stop before the
cumulative token count exceeds the reserved budget, ensuring the bounded content
is what gets appended after context-budget calculation.

In `@src/review/__tests__/prompt.test.ts`:
- Around line 307-313: Update the test around userPrompt to assert the complete
deterministic prior-bot-comments section as one exact rendered block, including
the opening tag with its note attribute, both comment bodies, the delimiter, and
the closing tag; replace the separate toContain assertions for these fragments
while preserving any unrelated prompt assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d031e75b-88fc-4b53-8a5d-e45868a883e9

📥 Commits

Reviewing files that changed from the base of the PR and between a1c2f49 and 88c9273.

📒 Files selected for processing (4)
  • src/__tests__/orchestrate.test.ts
  • src/orchestrate.ts
  • src/review/__tests__/prompt.test.ts
  • src/review/prompt.ts

Comment thread src/__tests__/orchestrate.test.ts Outdated
Comment thread src/orchestrate.ts
Comment thread src/review/__tests__/prompt.test.ts
aliasunder and others added 3 commits July 22, 2026 19:53
… sections

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tion

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Full-result toEqual on all selectFindings tests (was decomposed property
picks that missed droppedAsOverlapping/droppedByCap fields). Collapse
4 fragment toContain calls in the prior-bot-comments prompt test into one
full-section assertion. Add pipe-escaping coverage for renderPaths —
the only production behavior with no test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/orchestrate.ts
Comment thread src/orchestrate.ts
aliasunder and others added 3 commits July 22, 2026 20:17
…oc, outputs table

- AGENTS.md: review/ structure tree now includes filter-non-findings.ts
  (listed as "non-finding filter")
- prompt.ts: buildUserPrompt JSDoc now enumerates the prior-bot-comments
  and prior-findings sections that follow the diff
- README.md: findings_count output description now mentions the
  non-finding filter stage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aliasunder
aliasunder merged commit 62383ec into main Jul 23, 2026
8 checks passed
Comment thread src/orchestrate.ts
Comment on lines 144 to +151
anchors: extractAnchors(
comments.map((comment) => ({
findingComments.map((comment) => ({
body: comment.body,
line: null,
originalLine: null,
})),
),
findingBodies: findingComments.map((comment) => comment.body),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[low/correctness] Collect findingBodies only from anchored comments in fetchIssueCommentState (confidence: low)

findingBodies is derived from findingComments, which includes any non-status comment regardless of whether it contains a valid anchor. A bot comment that is not a status comment and lacks an anchor would still appear in priorBotComments, polluting the prompt with non-finding text.

Failure scenario: A bot posts a standalone PR comment that does not start with STATUS_ANCHOR and lacks a hidden anchor (e.g., a follow-up note or a future non-finding comment). The comment body is included in priorBotComments, wasting context and potentially confusing the model's conceptual dedup.

Suggested fix
Derive findingBodies only from comments that extractAnchors successfully parses, or filter comments to those containing the anchor pattern before mapping.

@aliasunder
aliasunder deleted the worktree-conceptual-dedup branch July 25, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant