Skip to content

addtional fixes - #1112

Merged
rsenden merged 4 commits into
feat/v3.x/aviator/26.4from
p/umadevis1/additional_remediation_fix
Sep 29, 2026
Merged

rsenden merged 4 commits into
feat/v3.x/aviator/26.4from
p/umadevis1/additional_remediation_fix

Conversation

@umadevis1

Copy link
Copy Markdown
Contributor

Summary

Fix coordinate-space mismatch in HunkClassifier pre-classification and
correct incomplete overlap detection logic in range comparisons.

Changes

1. Fix: HunkClassifier declared-vs-actual coordinate mismatch

Problem: HunkClassifier.classifyRange was comparing a candidate hunk's
DECLARED line numbers against AppliedChange entries storing ACTUAL (post-shift)
coordinates. When a broader remediation shifted hunks via offset projection,
narrower nested hunks would fail to be pre-classified as POSSIBLY_REMEDIATED
and instead fell through to real application, where they failed with
ANCHOR_DOES_NOT_MATCH.

Example:

  • Remediation 6E80 deletes lines 44-62 (replaces with 2 lines, delta -12)
  • Remediation DE397 targets line 53 (inside 6E80's declared range)
  • Before fix: classifyRange compared declared-53 against 6E80's actual range
    (shifted to 32-50), missed the nesting, returned APPLIED
  • After fix: classifyRange compares declared-53 against 6E80's declared 44-62,
    correctly returns POSSIBLY_REMEDIATED

Solution: Thread declared coordinates through ledger pipeline:

  • PendingAppliedChange: add declaredLineFrom/declaredLineTo fields
  • AppliedChange: add declared fields and new coversDeclaredRange() /
    overlapsDeclaredRangePartially() methods
  • HunkClassifier.classifyRange: use declared-range methods for pre-classification
  • Leave projectOffset() and actual-coordinate shifting untouched

2. Fix: Incomplete overlap detection in overlapsPartially

Problem: overlapsPartially() docstring says "without either side fully
containing the other," but implementation only checked one direction. A candidate
range fully containing the applied range would incorrectly return true.

Solution: Check both directions:

boolean overlaps = lineFrom <= originalLineTo && originalLineFrom <= lineTo;
boolean candidateContainsThis = lineFrom <= originalLineFrom && originalLineTo <= lineTo;
return overlaps && !coversFully(lineFrom, lineTo) && !candidateContainsThis;


Testing
Unit tests: 31/31 pass (includes 1 new regression test for
nested-inside-broader-delete scenario)
Impact analysis: Single caller (HunkClassifier.classifyRange) benefits
from overlap logic fix; all tests pass with no regressions
Files Changed
remediation/classifier/PendingAppliedChange.java — add declared range fields
remediation/writer/FileWriteCoordinator.java — pass declared coords when staging
remediation/classifier/AppliedChangeLedger.java — map declared coords in fromPending
remediation/model/AppliedChange.java — add declared fields/methods + fix overlap logic
remediation/classifier/HunkClassifier.java — use declared-range methods
fpr/processor/RemediationProcessorTest.java — add regression test

@rsenden
rsenden merged commit ec1f7be into feat/v3.x/aviator/26.4 Sep 29, 2026
13 checks passed
@rsenden
rsenden deleted the p/umadevis1/additional_remediation_fix branch September 29, 2026 10:27
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.

4 participants