Skip to content

tend-review reviews main-merge changes as the PR's own work #3246

Closed

Description

@max-sixty

Summary

When a PR merges main mid-review, tend-review appears to include the merge-brought-in changes in the diff it reviews, so it critiques code the PR never authored. The review reads as if those changes are the PR's own work.

Example

PR #3232 (migrate logging to native tracing::) merged main to resolve a conflict, which pulled in #3229's statusline rate-limit "lockout" feature (expected_lockout, colorize_pace, lockout_cost, and the Gauss–Hermite quadrature). #3232 authored none of that.

The worktrunk-bot review on head ada0e9156 (submitted 2026-06-25T06:41:40Z) opened with a full paragraph reviewing exactly that lockout math:

The new severity axis (expected_lockout + colorize_pace/lockout_cost) is a clean addition. Splitting the one Bayes update into posterior_lambda so p_over (the show gate) and expected_lockout (the colour axis) can't drift is the right factoring, and the Gauss–Hermite quadrature is sound ...

Only the remaining two paragraphs (the record_i64 coverage gap and the codecov/patch reasoning) were about #3232's actual diff.

Likely cause

A PR's true diff is main...HEAD (three-dot), which excludes anything already on main. #3229 is on main, so it should never appear in #3232's review. Reviewing #3229's content suggests tend-review instead diffs something that includes merge-pulled changes: a two-dot main..HEAD, the merge commit's own diff, or the set of commits in the latest push (which included the merge commit). Worth checking how the review step computes the diff it feeds the model.

Impact

Any PR that merges main during review (common for longer-lived branches) gets reviewed for unrelated code: wasted review budget, misleading feedback, and the risk of flagging or holding on issues in code the PR author can't act on.

This was written by Claude Code on behalf of max

Activity

  1. added
    claude-behavior
    on Jun 25, 2026
  2. worktrunk-bot commented on Jun 25, 2026

    @worktrunk-bot
    Collaborator

    Reproduced — and the root cause is the incremental-review path, not the full-review diff.

    The review skill takes two different diffs depending on whether the bot already reviewed an earlier commit:

    • Full review (step 3) reads gh pr diff <number> — GitHub's three-dot main...HEAD. On Add trace.jsonl structured-event sink and migrate logging to native tracing #3232 this correctly shows only the logging migration's touch to statusline.rs (tracing::debug! lines); the lockout feature is not in it.
    • Incremental review (step 1, when LAST_REVIEW_SHA exists and differs from HEAD_SHA) reads gh api repos/$REPO/compare/$LAST_REVIEW_SHA...$HEAD_SHA to decide what changed since the last review — and reviews that.

    On #3232 the bot reviewed 599700c7 first (06:05Z), then a Merge branch 'main' commit (6eee3f15) landed, then it re-reviewed ada0e915 (06:41Z). The incremental compare 599700c7...ada0e915 spans that merge, so it pulls in everything main brought in — including #3229's lockout feature. That's the diff the bot anchored its review on, which is why the lockout paragraph appeared while the clean gh pr diff would never have surfaced it.

    Evidence — counting expected_lockout/colorize_pace/lockout_cost in each diff's statusline.rs patch:

    Diff the skill computes lockout-term hits verdict
    gh pr diff 3232 (three-dot main...HEAD) 1 (incidental context line) clean — migration only
    compare/599700c7...ada0e915 (incremental) 30 (posterior_lambda, Gauss–Hermite, expected_lockout) leaks #3229

    So your three-dot hypothesis is right about the correct diff, but the leak is specifically that the incremental compare uses a two-endpoint A...B that spans a base-merge, not that the full review uses two-dot.

    This lives in the bundled tend-ci-runner review skill (step 1), so it'd fire for any tend consumer whose PRs merge the default branch mid-review — the fix belongs in the tend review skill, not in worktrunk's code (there's nothing to change here). A conservative fix: when computing incremental changes, exclude anything already on the base — restrict the incremental file/hunk set to files that also appear in the PR's three-dot gh pr diff, or equivalently diff the PR's three-dot surface at the two review points rather than LAST_REVIEW_SHA...HEAD_SHA directly. That keeps "what's new since I last looked" while dropping merge-pulled base changes.

    Happy to open this against the tend repo if you'd like it tracked there — just say the word.

    Repro commands
    REPO=$(gh repo view --json nameWithOwner --jq '.nameWithOwner')
    
    # full review path — clean
    gh pr diff 3232 | grep -cE "expected_lockout|colorize_pace|lockout_cost"        # -> 1
    
    # incremental path — leaks #3229
    gh api "repos/$REPO/compare/599700c7...ada0e915" \
      --jq '.files[] | select(.filename=="src/commands/statusline.rs") | .patch' \
      | grep -cE "expected_lockout|colorize_pace|lockout_cost"                       # -> 30

    Bot reviews on #3232: 599700c7 COMMENTED 06:05:54Z, then ada0e915 COMMENTED 06:41:40Z (the one in this report). Intervening commit: 6eee3f15 Merge branch 'main' into subprocess-log-format.

  3. worktrunk-bot commented on Jun 26, 2026

    @worktrunk-bot
    Collaborator

    Filed upstream so it's tracked against the bundled review skill where the fix lives: max-sixty/tend#734. It carries the reproduction, the three-dot-vs-incremental term-count table, and the proposed filter (restrict the compare/$LAST_REVIEW_SHA...$HEAD_SHA file set to files that also appear in gh pr diff). Nothing to change in worktrunk itself.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    claude-behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions