Conversation
A comment matched on a deleted line reported an old-file line number with no side, and every consumer -- JSON, SARIF, the GitHub Action, the VS Code extension -- read it as a new-file line (issue alibaba#1486). resolveFromHunk resolved the old-side pass with extractSideLines(hunk, false), which carries old-file numbers only, and LlmComment has no side field to tell the two apart. Rather than add a schema field, this follows the approach suggested in the issue thread: - a deleted-line match no longer publishes an old-file number; it stays 0, the documented "unanchored" signal, so the file-content fallback gets another try - a context-line match publishes the line's own new-file number indexedLine gained newLineNum (0 for deleted lines), matchConsecutive was split so the matched index is available, and newSideSpan() decides whether a whole span exists on the new side; the old-side pass now continues to later hunks when a match cannot be anchored.
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
|
Thanks for exploring the schema-compatible approach. I agree that resetting deleted-line coordinates to The resolver has already found a real location in the old file. Converting it to An optional For #1486, I would prefer retaining the precise deleted-line location and carrying its side rather than making the finding unanchored. The current approach is a safe fallback, but it changes the behavior from “precisely located on the old side” to “location discarded.” |
|
Thanks — and you are right that Making an anchored finding indistinguishable from one that could not be resolved at all is a real Your So I would rather not compete with #1519 on #1486. Two clean outcomes — your call:
I will not push on this until you answer. |
|
Thanks for the clear steer — and I agree with it. My reasoning was that an anchor on a deleted line is worse than no anchor, because it places the comment somewhere the code no longer is. But you are right that So #1518 is superseded, and I have closed it rather than leave a competing approach open. Since its three files are a subset of #1519's coverage there is nothing in it worth porting, but if any of the resolver tests or the One thing worth pinning whichever way it lands: after the change, a finding whose old-side location is genuinely unknown should still be distinguishable from one anchored on a deleted line. |
Fixes #1486
The problem
A comment matched on a deleted line reported an old-file line number with no side, and every consumer — JSON, SARIF, the GitHub Action, the VS Code extension — reads that number as a new-file line.
resolveFromHunkresolved the old-side pass throughextractSideLines(hunk, false), which carries old-file numbers only, andLlmCommenthas nosidefield to tell them apart.Approach
This follows the schema-compatible route suggested in the issue thread (thanks @chaojixinren) rather than adding a
sidefield:0— the documented "unanchored" signal — which lets the file-content fallback try again.Implementation:
indexedLinegainednewLineNum(0for deleted lines);matchConsecutivewas split so the matched index is available;newSideSpan()decides whether a whole span exists on the new side; and the old-side pass nowcontinues to later hunks when a match cannot be anchored.pages/src/content/docs/en/tools.mddocuments the resulting contract (only theencopy has that section).Two judgement calls worth your review
first_new..last_new. Across insertions this spans the inserted lines too: a 10-line insertion above a matched context block yields5..7rather than just5. The anchor is correct; the range is wider than strictly necessary. If you'd rather emit a single line for context-only matches, that's a small change.MultiLineHunkMatch,OldPathMapping,WhitespaceTolerant,TestResolveLineNumbers_SingleLineHunkMatch→ renamed_DeletedLineIsNotAnchored) referenced deleted lines; I re-pointed them at added/replaced lines to preserve each test's original intent rather than flipping them to assert0. You may prefer them to assert0directly — that's a defensible reading and I'm happy to switch.Verification
New tests include
TestResolveLineNumbers_DeletedCodeBelowInsertions, which reproduces the issue's exact scenario (10 insertions above a deletedlegacyCall()) and asserts0on both the hunk-only andNewFileContentpaths, plusTestNewSideSpan_*.Not run here:
make testas written hardcodes-race, and this box hasCGO_ENABLED=0with no gcc (go: -race requires cgo). I ran the identical package set without-race. CI will run the real target. The committed code does not touch-race.AI assistance (required disclosure)
Per CONTRIBUTING: this change was written with AI assistance. Tool used: DeepSeek Harness (
dsh), an AI coding agent drivingghand a local checkout. It located the resolver path, implemented the fix, updated the tests and docs, and ran the commands above. The diff and every test expectation were reviewed before opening this PR.No commits, messages, or trailers attribute this work to an AI: there is no
Assisted-byorCo-developed-by, consistent with the project's policy.