Skip to content

gitlab: expose current versus outdated MR discussion positions #9695

Open

Description

@csoceanu

Problem

ListPullRequestReviewThreads reads GitLab discussion paths and line numbers but discards the position's base_sha, start_sha, and head_sha. Consequently, ReviewThread.IsOutdated is always unknown for GitLab, and a position from an older diff can be presented without indicating whether it maps to the current MR diff.

This prevents downstream consumers from safely using stamped GitLab discussions as stable finding-identity anchors. In fullsend-ai/agents, stamped-thread mapping is therefore GitHub-only, and a GitLab finding may receive a new ID when its line moves.

fullsend#7328 and PR fullsend#7342 added getMergeRequestDiffRefs and used the refs when creating positioned GitLab discussions. They did not update the discussion-reading path in ListPullRequestReviewThreads.

GitLab traces diff-note positions after pushes when it can map them. Its DiffPositionableNote#active? check considers a note current when the position's diff refs equal the MR's current diff_refs. No client-side diff reconstruction should be necessary.

Requested change

Update the GitLab implementation of ListPullRequestReviewThreads to:

  1. Fetch the MR's current diff_refs once.
  2. Decode base_sha, start_sha, and head_sha from each discussion position.
  3. Set is_outdated: false only when the complete position refs match the current MR refs.
  4. Set is_outdated: true when the complete position refs differ.
  5. Leave is_outdated unknown when either set of refs is incomplete or unavailable.
  6. Expose line and start_line as current positions only when the position is confirmed current. Do not expose a stale position as a current line.
  7. Preserve the existing discussion ID, resolution, author-verification, pagination, side, and multiline behavior.

getMergeRequestDiffRefs already exists in the GitLab adapter and can provide the current refs.

Acceptance criteria

  • A discussion traced to the current diff returns is_outdated: false with its remapped current path and line.
  • A discussion whose position belongs to an older diff returns is_outdated: true without a current line or start_line.
  • Missing or unavailable refs fail closed and are not treated as trusted current positions.
  • Tests cover:
    • a line shifted by an earlier insertion;
    • an untraceable or outdated position;
    • incomplete diff refs;
    • renamed files;
    • multiline discussions;
    • failure to fetch the current MR refs.
  • The forge-neutral ReviewThread contract and GitLab tests no longer state that GitLab always lacks outdated state.

Downstream follow-up

Once this is available, fullsend-ai/agents can extend stamped-thread finding-ID mapping to GitLab. It should trust only discussions with is_outdated: false, verify the comment author, and mint a new ID for outdated, unknown, ambiguous, or truncated mappings.

Related:

Activity

  1. fullsend-ai-triage commented on Nov 19, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 10:28 AM UTC · Completed 10:30 AM UTC

    Commit: d0dd3f3 · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.10

  2. added
    feature
    triaged
    on Nov 19, 2026
  3. fullsend-ai-triage commented on Nov 19, 2026

    @fullsend-ai-triage

    Triage found this issue actionable as written; the requested change and acceptance criteria are specific enough to start implementation.

    Verified in the repo

    • getMergeRequestDiffRefs and the GitLab ListPullRequestReviewThreads both live in internal/forge/gitlab/mr.go, so the refs helper can be reused directly.
    • The forge-neutral ReviewThread.IsOutdated doc comment in internal/forge/forge.go, and the GitLab position-contract test in internal/forge/gitlab/methods_test.go, currently state that GitLab never exposes outdated state. Both need updating as part of this change.
    • No open PR addresses this, and no duplicate open issue was found. fullsend#7328 is closed; the other related issues (feat(#956): resolve fixed review threads on re-review #9446, feat(gitlab): verify and resolve fixed inline MR review threads #8749) are open but are not prerequisites.

    Design points to settle during implementation

    • Treat a failed fetch of the current MR refs as 'unknown' (nil is_outdated, no trusted current line) rather than guessing. Choose consistently whether it also surfaces an error, and cover the choice in a test.
    • For multiline discussions, expose line and start_line together, or omit them together, so a half-current range is never reported.

    Proposed test case

    Table-driven httptest cases for ListPullRequestReviewThreads:
    1. position refs == MR diff_refs, line shifted by earlier insertion -> is_outdated=false, remapped line
    2. position refs != MR diff_refs -> is_outdated=true, line/start_line nil
    3. any missing sha in position or MR refs -> is_outdated nil, no current line
    4. renamed file with current refs -> paths/lines preserved, is_outdated=false
    5. multiline current vs outdated -> line/start_line exposed together or omitted together
    6. MR diff_refs request fails -> is_outdated nil, no trusted current position
    Plus regression: pagination cap, resolution, author verification, side handling unchanged.
    

    This is categorized as a feature (new behavior, not a regression), so it is not auto-promoted to ready-to-code and is left for a maintainer to schedule.


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  4. self-assigned this
    on Nov 19, 2026
  5. csoceanu commented on Nov 19, 2026

    @csoceanu
    ContributorAuthor

    /fs-code Implement this issue as written. Reuse getMergeRequestDiffRefs and fetch the current MR refs only once. If that fetch fails or either ref set is incomplete, keep returning the threads but set IsOutdated to nil and omit Line/StartLine rather than guessing. For multiline discussions, expose both line values or neither. Preserve pagination, resolution, author verification, side handling, and existing error behavior. Please add the table-driven tests suggested by triage and keep the change limited to the GitLab discussion-reading path and forge-neutral contract updates.

  6. fullsend-ai-coder commented on Nov 19, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Finished Code · ✅ Success · Started 10:56 AM UTC · Completed 11:09 AM UTC

    Commit: d0dd3f3 · View workflow run →

    Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high · Cost: $1.77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featuretriaged

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions