Skip to content

fix(orch): resolve stack branches by full ref when tags share names - #828

Open
rudycelekli wants to merge 1 commit into
cursor:mainfrom
rudycelekli:fix/orch-branch-sha-20261023
Open

rudycelekli wants to merge 1 commit into
cursor:mainfrom
rudycelekli:fix/orch-branch-sha-20261023

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

orch frontier set resolves stack branches with abbreviated git names, which goes wrong when a tag shares a branch's name. git symbolic-ref --short HEAD then reports the current branch as heads/<branch>, so the forge lookup asks for PRs on a branch that does not exist and the frontier fails with "branch heads/ has no pull request". For other branches in the chain, git rev-parse <branch> prefers refs/tags/<name> over refs/heads/<name>. The frontier then records the tag's commit as the PR head without any error, and orch ledger check gets compared against the wrong SHA.

currentBranch now reads the full refs/heads/... symbolic ref and strips the prefix, and branchSha resolves refs/heads/<branch>^{commit} with --verify. Branches without a tag of the same name resolve exactly as before. The Claude Code harness copy is regenerated.

Validation: added "resolves {gh,origin} branches when tags share their names" to orch/orch.test.ts. It tags stack/open (the current branch) and stack/closed at main and checks every recorded SHA. On origin/main the new tests fail with the heads/stack/open forge lookup error. With only the currentBranch change they fail because stack/closed records main's SHA. With the full fix, bun test --timeout 900000 orch gives 23 pass and 0 fail (the long timeout is only needed because git was slow on a loaded machine). Also ran npm install --no-save ajv ajv-formats && node scripts/validate-plugins.mjs && node scripts/generate-pstack-harness-trees.mjs --check && node --test pstack/skills/*/scripts/test/*.test.mjs (57 pass, 0 fail, 93 skipped without TLC) and git diff --check.


Note

Low Risk
Narrow git ref-resolution change in orch frontier setup with regression tests; behavior unchanged when no name collision exists.

Overview
Fixes orch frontier set when git tags share stack branch names. Abbreviated ref resolution could treat the current branch as heads/<name> (breaking forge PR lookup) or resolve rev-parse <branch> to the tag commit instead of the branch tip (wrong frontier SHAs and ledger checks).

currentBranch now reads the full refs/heads/... symbolic ref and strips the prefix; branchSha resolves refs/heads/<branch>^{commit} with --verify. A new orch test tags stack/open and stack/closed and asserts each frontier row keeps the correct branch SHA for both gh and origin.

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

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