feat(code-review, test-planning): detect the diff base across multiple remotes and git-flow - #151
Open
taminomara wants to merge 4 commits into
Conversation
taminomara
force-pushed
the
sync/multi-remote-detect-context
branch
from
July 28, 2026 00:42
9614338 to
a24a802
Compare
taminomara
force-pushed
the
sync/multi-remote-detect-context
branch
from
July 28, 2026 00:48
a24a802 to
80244a8
Compare
taminomara
marked this pull request as ready for review
July 28, 2026 13:32
Contributor
Author
|
Merging needs coordination with #132, one of them should move added |
Collaborator
|
👋🏻 @taminomara i opened the Discussions tab for the repo just now, and posted #152 - i'm really far behind in getting your PRs merged in, and i want to get that resolved. thought it would be easiest to coordinate all of this in that discussion, instead of trying to do it in PRs |
…e remotes and git-flow The code-review and test-planning git-context detectors chose the branch to diff changes against from origin/HEAD alone. On a fork whose origin default is stale, on a git-flow branch cut from an integration branch, or on a branch that merged another branch in, that base was wrong, so the review or test plan was scoped to an inflated, empty, or mis-attributed diff. Port review-skill-or-agent's base selection to both detectors: the base is now the candidate whose fork point is nearest the current commit, measured along the branch's own first-parent line, chosen across a multi-remote candidate pool. - Candidate pool: every remote's declared default branch plus well-known trunk/integration names (main, master, trunk, mainline, next, develop, devel, development, default, dev), looked up as local and per-remote branches; nearest own-line coincidence wins, declared defaults break ties. - A candidate the branch merely merged in cannot win on its absorbed commits. - Output contract shape unchanged; fail-open to `default-branch: none` preserved. - Adds test/detect-review-context.bats and test/detect-test-context.bats (16 tests each) under test/, which these detectors previously lacked. Completes the OI-1 follow-up flagged in review-skill-or-agent (PR testdouble#119), which intentionally ran ahead of these copies. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NfTexc8iv7XAqt3ksH9zNP
…base detection Replace the per-own-line-commit `git merge-base --is-ancestor` probe in base-branch selection with a single `git rev-list --count --first-parent HEAD ^candidate` per candidate. This cuts subprocess spawns across the candidate pool from O(C*H) to O(C), so a long first-parent history no longer forces a subprocess per own-line commit. Behavior-preserving: the base chosen and the changed-files listing are unchanged, and the detector test suites pass untouched. Verified equivalent across topologies including a candidate reachable only via a merge's second parent and off-spine-only shared history in a multi-root repo. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NfTexc8iv7XAqt3ksH9zNP
…5 rename The v5 line split test-planning into automated-test-planning, so the moved detect-test-context.sh and its Bats test now live under han-coding/skills/automated-test-planning/. Update the test's SRC path and the detector sync-note comments to match the new location. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017NEQjJUi7ZHVXGfVGXKUVJ
taminomara
force-pushed
the
sync/multi-remote-detect-context
branch
from
July 28, 2026 14:42
6a3bd79 to
37afaaa
Compare
…nd-parent base detection Address code-review findings on the base-branch detectors: - Freeze HEAD to a commit up front (HEAD_SHA) so every candidate and the changed-files diff measure against the same point, not a live ref re-read per candidate (SUGG-002). - Expand the selection comment with the reasoning the count rests on: first-parent monotonicity, and that "^candidate" excludes by the candidate's full reachability while "--first-parent" limits only the walk from HEAD (SUGG-001). - Add a regression test for a candidate that reaches an own-line commit only through its own merge second parent, the topology that distinguishes full-reachability exclusion from a first-parent-limited one (WARN-001). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NfTexc8iv7XAqt3ksH9zNP
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
The
code-reviewandtest-planninggit-context detectors pick the base branch to diff against fromorigin/HEADalone. On a fork whoseorigindefault is stale, on a git-flow branch cut from an integration branch, or on a branch that merged another candidate in, that base is wrong, so the review or test plan is scoped to an inflated, empty, or mis-attributed diff.This ports
review-skill-or-agent's base detection to both detectors. The base is now the branch's own line of work: the candidate whose fork point is nearest the current commit, measured along first-parent history, chosen across a multi-remote candidate pool.What changed
detect-review-context.sh,detect-test-context.sh. Replace the singleorigin/HEADlookup with a candidate pool: every remote's declared default branch, plus well-known trunk and integration names (main,master,trunk,mainline,next,develop,devel,development,default,dev), looked up as local branches and as each remote's tracking branch. The nearest own-line coincidence wins; a declared default breaks an equal-distance tie; refs are deduplicated. A candidate the branch merely merged in cannot win on its absorbed commits, because those commits are not on the branch's first-parent line.key: valuekeys, still fail open todefault-branch: none, and always exit 0. No consuming skill prose or long-form docs change.test/detect-review-context.batsandtest/detect-test-context.bats(16 cases each), which these detectors previously lacked: stale-origin-vs-fresh-remote, git-flow integration branch, local trunk, merged-in demotion, unrelated-candidate exclusion, none / unborn / detached fallbacks, and the declared-default tie-break priority.Scope
The
build-target-diff.shchange-scope helper and theSKILL.mdPR-base override arereview-skill-or-agent-specific and stay on #119. This PR is the shared detector plus its tests only.Testing
npm test(bats --recursive test/): 33 passing (16 + 16 + the existing sanity check).npm run lint(prek run --all-files): every hook passes.Related
Completes the OI-1 follow-up flagged in #119, whose
detect-git-context.shintentionally ran ahead of these copies. Once both land, all three detectors match, and #119's "intentionally ahead" header note gets reconciled to name all three.🤖 Generated with Claude Code
https://claude.ai/code/session_01NfTexc8iv7XAqt3ksH9zNP