Skip to content

fix: relax comment drift detection for in-place edits#466

Merged
tomasz-tomczyk merged 2 commits intomainfrom
drift-similarity-threshold
May 5, 2026
Merged

fix: relax comment drift detection for in-place edits#466
tomasz-tomczyk merged 2 commits intomainfrom
drift-similarity-threshold

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

  • Carry-forward marked comments as "Drifted" whenever the anchor line text changed at all, even when the original anchor was still a clean prefix of the edited line (e.g. text appended in place).
  • Now treats edited-but-recognizable lines as anchored at the LCS-remapped position: substring match (gated to anchors ≥8 chars to avoid spurious hits on } / return) covers append/trim, Levenshtein ratio ≥ 0.7 covers minor rewordings.
  • File-wide search remains exact-match to avoid jumping to look-alike lines elsewhere in the file.

Review

  • Code review: passed (short-anchor gate added in fixup)
  • Parity audit: N/A (backend carry-forward; no review-page surface)
  • Intent audit: clean

Test plan

  • go test ./... — all green
  • gofmt -l . clean, golangci-lint run ./... clean
  • New TestCarryForward_AnchorEditedInPlaceNotDrifted — reproduces the real-world scenario where text was appended to a list item.
  • New TestAnchorSimilar table — identical, trim, append, minor edit, short-anchor (gated), unrelated, heavy rewrite, multi-line.

🤖 Generated with Claude Code

tomasz-tomczyk and others added 2 commits May 5, 2026 20:59
Comments were marked as drifted whenever the anchor line changed at all,
even when the original text was still a clean prefix of the edited line.
Now treats edited-but-recognizable lines as anchored: substring match
covers append/trim, Levenshtein ratio (>= 0.7) covers minor rewordings.

File-wide search remains exact-match to avoid jumping to look-alike lines
elsewhere in the file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without a length gate, a 1-2 char anchor like `}` or `return` would
trivially anchor to any longer line containing those characters at the
LCS row. Gate substring on min(len(a), len(b)) >= 8 so trivial anchors
fall through to Levenshtein, which scales correctly with length.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 92.15686% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.25%. Comparing base (32d8c6e) to head (77a831e).

Files with missing lines Patch % Lines
watch.go 92.15% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #466      +/-   ##
==========================================
+ Coverage   69.04%   69.25%   +0.21%     
==========================================
  Files          36       36              
  Lines       10698    10749      +51     
==========================================
+ Hits         7386     7444      +58     
+ Misses       2748     2743       -5     
+ Partials      564      562       -2     
Flag Coverage Δ
e2e 32.38% <0.00%> (-0.16%) ⬇️
unit 66.77% <92.15%> (+0.22%) ⬆️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tomasz-tomczyk tomasz-tomczyk merged commit 299e08e into main May 5, 2026
8 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the drift-similarity-threshold branch May 5, 2026 20:19
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