Skip to content

fix(watch-pr): distinguish fork heads during stack discovery - #664

Open
rudycelekli wants to merge 1 commit into
cursor:mainfrom
rudycelekli:fix/watch-pr-fork-stack-identity
Open

rudycelekli wants to merge 1 commit into
cursor:mainfrom
rudycelekli:fix/watch-pr-fork-stack-identity

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 16, 2026 •

Copy link
Copy Markdown

Problem

watch-pr --stack connects PRs by their head branch name alone. A fork PR opened from main against upstream main is therefore treated as a parent of every PR based on main, and the parent walk loops indefinitely. Open PRs #173, #176, and #330 already have that shape in this repository. Other same-named fork branches can produce unrelated stack members.

Change

Read isCrossRepository from gh pr list, validate that field at the reader boundary, and use only upstream heads as possible parent branches. Stop descendant traversal at fork heads because upstream PR base refs cannot target those fork branches. Regenerate the Claude Code harness.

Verification

  • Original source: 23 focused controls pass and all 4 regression/boundary cases fail, including a bounded subprocess that reproduces the infinite parent walk.
  • Changed source: 27 focused tests pass; the full native script package passes 72 tests with Bun 1.4.3.
  • Package strict typecheck, plugin validator, generated harness check, and git diff --check pass.
  • Tests use local fixtures and a stubbed gh executable; no credentials or hosted service operations are required.

AI assistance: Codex implementation and local verification.


Note

Medium Risk
Changes stack discovery logic used by --stack mode; incorrect fork handling could omit or mis-order PRs, but scope is limited to branch-matching heuristics with new regression tests.

Overview
Fixes watch-pr --stack stack discovery so fork PRs are not linked into upstream stacks by matching branch names alone.

Open PR data now includes isCrossRepository from gh pr list (validated at parse time). orderStack only treats upstream heads as possible parents when walking down the stack, and it does not traverse children through fork heads—preventing cases like a fork’s main → main PR from becoming a parent or causing an infinite parent walk.

Tests add fork/cross-repo regression cases, including a bounded subprocess check that the former hang terminates, and a stubbed gh fixture asserting the new JSON field is requested and parsed.

Reviewed by Cursor Bugbot for commit 42fdc95. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Rudy Celekli <rudycelekli@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant