fix(code-review): base local branch/file diff on origin/<default>, not frozen local ref - #171
Closed
parkerbyrd-ux wants to merge 1 commit into
Closed
parkerbyrd-ux wants to merge 1 commit into
parkerbyrd-ux wants to merge 1 commit into
Conversation
…t frozen local ref Local `/code-review:start`/`:deep` with no PR computed its changeset against the bare local default branch via a 3-dot diff (`main...HEAD`). In a linked git worktree (e.g. Conductor) the local `main` ref is frozen at workspace-creation time, so the merge-base became the workspace's creation point and the "diff" silently ballooned to include every PR merged to main since — flagging findings in unrelated, already-merged code and tripping spurious coverage-gap HIGHs. resolve-scope now: - detects the repo default branch via `origin/HEAD` (no longer hardcodes `main`), - bases local branch/file scope on the live remote-tracking ref `origin/<default>` (best-effort fetch; falls back to the local ref when offline / no remote), - warns on stderr when the local default branch has drifted behind origin. base_ref stays the plain branch name (preserving the <BASE_REF> token and STATE_KEY). The PR path, `--base` override, staged (`--cached`), and GitHub mode are unchanged — base resolution runs only when the diff is actually based on the local default (never on the PR-detected or staged paths). Adds unit coverage (origin-based default, offline fallback, non-main default, file-paths pathspec, drift warning) and bumps the plugin version to 3.1.1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Local
/code-review:start/:deepwith no PR (the default branch-scope path) computed its changeset against the bare local default branch via a 3-dot diff (main...HEAD).In a linked git worktree (e.g. Conductor workspaces) the local
mainref is frozen at workspace-creation time and never auto-updates — the live base is the remote-tracking reforigin/main. With 3-dot semantics the merge-base becomes the workspace's creation point, so the "diff" silently balloons to include every PR merged tomainsince the workspace was created. Observed in the wild: localmain198 commits behindorigin/main→git diff main...HEAD= 633 files (operator's ~57 + 198 unrelated merged PRs) vsgit diff origin/main...HEAD= ~57 files. The oversized diff flagged findings in unrelated already-merged code and tripped a spurious HIGH coverage-gap.resolve-scopenow, for local branch/file scope:origin/HEAD(no longer hardcodesmain, fixing a latentmaster/developmis-base),origin/<default>(best-effortgit fetch; falls back to the local ref when offline / no remote),⚠️ local '<branch>' is N commits behind origin/<branch>warning when the local default has drifted.base_refstays the plain branch name, preserving the<BASE_REF>token andSTATE_KEY = "<review_branch>:<base_ref>". Base resolution runs only when the diff is actually based on the local default — never on the PR-detected or staged paths, so neither a needless fetch nor a misleading drift warning occurs there.Feature Flags
None.
Breaking changes
None. The PR path,
--base <ref>override,staged(--cached), and GitHub mode are unchanged. Local branch/file reviews now diff againstorigin/<default>...HEADinstead of<default>...HEAD— this is the intended fix (a stale local default branch no longer inflates the diff).Test plan
uv run pytest plugins/→ 1994 passed, 3 skippeduv run ruff check .→ cleanuv run pyright→ 0 errorsTestResolveScopecases (now assertorigin/main...HEAD; made the local-path tests hermetic) and added coverage: offline fallback to local ref, non-maindefault branch, file-paths pathspec preservation, and the drift-warning helper (fires when behind, silent at 0). PR-path /--baseoverride / worktree-isolation tests unchanged.3.1.0 → 3.1.1;commands/start.mdusage comment and resolve-scope section updated.🤖 Generated with Claude Code