Repository navigation
Description
Bug
npx sequant run <issues> falsely reports open issues as "already merged" after a previous run on those issues was interrupted (SIGINT) before any commits were made.
Reproduction
- Run
npx sequant run 608 604 -q— sequant creates worktrees + branchesfeature/608-...andfeature/604-...frommain, starts the spec phase. - Press
^Cbefore any commit lands. - SIGINT cleanup runs
git worktree remove --forceon each worktree. The underlying branches are not deleted — their tips equal themaincommit they were forked from. - Re-run
npx sequant run 608 604 -q— both issues are skipped:Both issues are still OPEN on GitHub. State has been corrupted to! #608: already merged — skipping (use --force to re-run) ! #604: already merged — skipping (use --force to re-run)status: "merged".
Root cause
isBranchMergedIntoMain in src/lib/workflow/pr-status.ts uses git branch --merged main, which lists any branch whose tip is reachable from main — including empty branches whose tip equals an old main ancestor with zero commits added. For the orphaned branches above, git branch --merged main returns them as "merged", isIssueMergedIntoMain returns true, and reconcileStateAtStartup advances the issue from in_progress to merged.
Confirmed locally: git rev-list --count main..feature/608-investigate-metrics-... is 0, and git branch --merged main lists both branches. No real merge ever occurred — git log main --grep "(#608)" and --grep "(#604)" return empty.
This is the inverse of #592 / #606 (which fix "state thinks open but GitHub says merged"). Here state thinks merged but GitHub says open.
Acceptance criteria
-
isBranchMergedIntoMainreturnsfalsefor an empty branch whose tip is an ancestor ofmainwith zero commits added. -
isBranchMergedIntoMaincontinues to returntruefor an actually-merged branch (tip recorded as a non-first parent of a merge commit on the base branch). -
isIssueMergedIntoMaincontinues to detect squash-merged issues via the existing(#N)/Merge #Ncommit-message grep (Method 2). - After SIGINT-then-rerun on an issue list,
npx sequant run <issue>does not skip those issues as "already merged" when the branches are empty orphans with no commits. - Test: empty-branch fixture passed to
isBranchMergedIntoMainreturnsfalse. - Test: empty-branch fixture passed to
isIssueMergedIntoMain(via the branch-discoveryMethod 1path) returnsfalsewhen no(#N)commit exists. - Existing
#305tests forisBranchMergedIntoMainandisIssueMergedIntoMainupdated to mock the new merge-evidence check (git rev-parse+git rev-list --merges --parents) instead ofgit branch --merged. - CHANGELOG entry under
[Unreleased] / Fixed.
Out of scope (follow-up candidates)
- Branch-deletion hygiene in SIGINT cleanup (deleting empty orphan branches alongside
git worktree remove). The bug is fixed by the detection change alone; orphan-branch cleanup is a separate hygiene concern.
Activity
admarble commentedon May 9, 2026
QA Review for Issue #616
AC Coverage
isBranchMergedIntoMainreturnsfalsefor empty orphan whose tip is an ancestor ofmaingit rev-parseand only returnstruewhen tip appears as a non-first parent of a merge commit. Smoke-tested on a real ad-hoctest-orphan-616branch offmain: returnsfalse(old code'sgit branch --merged mainlisted it as merged — confirmed).truefor actually-merged branchesisIssueMergedIntoMain(607)returnstrue(merged via squash, picked up by Method 2).isIssueMergedIntoMainMethod 2(#N)/Merge #Ngrep unchangedpr-status.ts:140-168is byte-identical to main; squash-merge detection path is unchanged.reconcileStateAtStartupno longer advancesin_progress→mergedfor empty branches. Verified end-to-end with the smoke test above.isBranchMergedIntoMainreturnsfalsestate-utils.test.ts:928-948.isIssueMergedIntoMainMethod 1 returnsfalsewhen no(#N)existsstate-utils.test.ts:1034-1098("regression: empty feature branch from interrupted run is NOT detected as merged"), uses production issue numbers 608 in fixture.isBranchMergedIntoMain (#305)tests and thereconcileStateAtStartuptest L790-869 now mockgit rev-parse+git rev-list --merges --parents.git branch --mergedmocking removed.[Unreleased] / FixedCHANGELOG.mdline 19 — comprehensive entry naming the function, root cause, and prior #592/#606 cross-reference, with issue tag(#616).Coverage: 8/8 AC items met
Original ACs: 8/8 met
Derived ACs: N/A — no /spec quality plan in issue comments
Quality Plan Verification
N/A — no Feature Quality Planning section found in issue #616 comments.
Incremental QA Summary
N/A — first QA run.
CI Status
build (20.x)build (22.x)typecheckvalidate-pluginvalidate-skillsCI Summary: 5 passed, 0 pending, 0 failed. PR #617
mergeable=MERGEABLE,mergeStateStatus=CLEAN.Quality Metrics
any)Cache Status
N/A — caching not configured for this run.
Build Verification
N/A —
npm run buildpassed on the feature branch.Test Coverage Analysis
src/lib/workflow/pr-status.tssrc/lib/workflow/state-utils.test.ts(re-exports + testspr-statusexports; 33/33 passed)src/lib/workflow/state-utils.test.tsCHANGELOG.mdCoverage: 1/1 changed source files have corresponding tests
Critical paths without tests: None
Code Review
Strengths:
isBranchMergedIntoMainis excellent — defines "merged" precisely (non-first parent of a merge commit), names the squash-merge caveat, and points callers atisIssueMergedIntoMain's grep path for squash detection.falseon unresolved branch, malformed merge lines (parts.length > 2), and any thrown error.rev-parse+rev-list --merges --parents) matches the new implementation.test-orphan-616branch offmain— old logic (git branch --merged main) lists it as merged; new logic returnsfalse.Issues:
pr-status.ts:106doc-comment forisIssueMergedIntoMainstill says: "1. Check if branch exists and is merged viagit branch --merged <baseBranch>". Method 1 no longer usesgit branch --merged— it now delegates to the rewrittenisBranchMergedIntoMain. Stale and misleading after this PR; should read something like "1. Check viaisBranchMergedIntoMain(branch tip recorded as a non-first parent of a merge commit on the base branch)". Non-blocking but worth fixing in this PR or as a follow-up.Suggestions:
-200as the merge lookback. Sequant's main has ~29 merge commits today, so this is comfortably sufficient. If the project ever grows past ~200 merge commits and an issue's merge sits older than that window, the check could miss it — but Method 2's commit-message grep ((#N)/Merge #N) covers that case inisIssueMergedIntoMain, so this is a graceful degradation, not a hazard. Worth a one-line code comment on-200if it's revisited.falsefromisBranchMergedIntoMainwhere the old code would returntrue. This is by design per the AC-2 wording ("non-first parent of a merge commit"), andisIssueMergedIntoMainMethod 2 still picks up FF merges via the conventional-commit(#N)suffix in sequant's workflow. No action needed; flagging for future readers of the diff.Test Quality Review
Merge #N) all covered.child_process.spawnSyncis mocked — the external boundary. No internal modules mocked.mockSpawnSync.mockReset()in eachbeforeEach.Issues Found: None.
Anti-Pattern Detection
Dependency Audit
N/A —
package.jsonnot modified.Code Patterns
Critical Issues: 0
Warnings: 0
Call-Site Review
N/A — no new exported functions;
isBranchMergedIntoMainwas modified in place. Existing call sites inisIssueMergedIntoMain(pr-status.ts:133) andreconcileStateAtStartup(viastate-utilsre-export) remain unchanged and pass through correctly under the new behavior (verified by the smoke test and existing test L790-869).Execution Evidence
npx vitest run src/lib/workflow/state-utils.test.tsnpm run buildnpx tsx -ecallingisBranchMergedIntoMain("test-orphan-616")false(matches AC-1 expectation; old code would returntrue)isIssueMergedIntoMain(607)true(squash-merged via Method 2; AC-3 preserved)isIssueMergedIntoMain(616)falseEvidence status: Complete
Skill Command Verification
N/A — no
.claude/skills/**/*.mdfiles modified.CLI Registration Verification
N/A —
RunOptionsandbin/cli.tsnot modified.Smoke Test
isIssueMergedIntoMain(607)test-orphan-616branch offmain; calledisBranchMergedIntoMaingit branch --merged mainlists the branch); new code returns false.isBranchMergedIntoMain("does/not/exist")git rev-parsenon-zero status → early return.Smoke Test Status: Complete
Self-Evaluation
mainin this repo and confirmedisBranchMergedIntoMainnow returnsfalsewhere the oldgit branch --merged mainpath returned the branch as merged. Cross-checked against a real squash-merged issue (feat(#552): detect behavior-rule implementations across skill+runtime touchpoints #607) to confirm Method 2 still flipstrue.feature/608-investigate-metrics-gap) and asserts on the post-fix outcome (false). It would catch a regression togit branch --merged-style logic immediately.-200lookback ingit rev-list. In sequant's repo (~29 merges) this is far off, andisIssueMergedIntoMainMethod 2 ((#N)grep) catches squash-merges regardless. Acceptable.Verdict: AC_MET_BUT_NOT_A_PLUS
All 8 acceptance criteria are literally met, tests pass (33/33), build is clean, CI is green, and the fix has been end-to-end-verified against the actual bug repro on this repo. The single non-A+ blocker is a stale doc-comment at
pr-status.ts:106describing Method 1 as usinggit branch --merged <baseBranch>— that's no longer true after this change. Tiny, non-blocking, but should be tightened either in this PR or as a follow-up so future readers don't trust a stale description.Documentation
[Unreleased] / Fixed, with issue tag(#616))pr-status.ts:106doc-comment forisIssueMergedIntoMainMethod 1 still referencesgit branch --merged; recommend updating to reflect the new merge-evidence check.Next Steps
src/lib/workflow/pr-status.ts:106so Method 1 no longer referencesgit branch --merged. One-line edit; can be appended to this PR or filed as a follow-up./docs 616if any user-facing surface is being touched (none in this PR — fix is internal logic; CHANGELOG already covers the user-visible behavior change).mergeable=MERGEABLE,mergeStateStatus=CLEAN, all 5 CI checks green).docs(#616): correct stale Method 1 description on isIssueMergedIntoMain
admarble commentedon May 10, 2026
QA Review for Issue #616 (re-run on
263369c)Incremental re-run after the doc-comment gap from the prior
AC_MET_BUT_NOT_A_PLUSverdict was closed by263369c docs(#616): correct stale Method 1 description on isIssueMergedIntoMain.Incremental QA Summary
Last QA: prior run on
ac2be37(verdict:AC_MET_BUT_NOT_A_PLUS— sole blocker: stale doc-comment atpr-status.ts:106)Changes since last QA: 1 file (
src/lib/workflow/pr-status.ts, +1/-1 in theisIssueMergedIntoMainJSDoc)isBranchMergedIntoMainand tests unchanged sinceac2be37; verified verbatimnpx vitest run src/lib/workflow/state-utils.test.tsnpm run buildclean — JSDoc{@link}parses fine263369c(were pending at last QA)1. Find \feature/-*` branches with `git branch -a` and check via {@link isBranchMergedIntoMain}`Summary: 8 ACs cached as MET, 4 always-fresh (build + CI + tests + the gap), 0 regressions.
CI Status
build (20.x)build (22.x)typecheckvalidate-pluginvalidate-skillsCI Summary: 5 passed, 0 pending, 0 failed. PR #617
mergeable=MERGEABLE,mergeStateStatus=CLEAN.Stale Branch Check
The branch is one commit behind main —
60778b6 fix(#614): resolve npm audit cluster 1landed on main during this session. Unrelated to this PR's surface area; no rebase required.Quality Metrics (cumulative diff vs main)
any)Code Review (delta from prior QA)
Strengths:
{@link isBranchMergedIntoMain}keeps the precise definition of "merged" in one place (the docblock onisBranchMergedIntoMain, which already covers "non-first parent of a merge commit" and the squash-merge caveat) — eliminates the drift surface that produced the original gap.feedback_gap_fix_review.md(gap-fix commits need their own adversarial pass): re-grep'dgit branch --mergedacrosssrc/— only the remaining hit is atpr-status.ts:46, inside the rewritten function's own docblock, intentionally referencing "the older `git branch --merged` check" as historical context. Keep.feedback_gap_fixing_diminishing_returns.md: the two prior "Suggestions" (-200lookback rationale comment, FF-merge note) were correctly left out of scope — they were forward-looking polish, not unmet ACs.Issues: None.
Suggestions: None.
Adversarial Pass on the Gap-Fix Commit (per
feedback_gap_fix_review.md){@link isBranchMergedIntoMain}resolve correctly?tscpassed; same-file reference; no hyperlink rendering needed.pr-status.ts:119doesgit branch -a;:127-128filters withfeature/<N>-...regex;:133callsisBranchMergedIntoMain.:46(intentional historical context) and the two test-file comments atstate-utils.test.ts:931, :1038(intentional contrast with old behavior).#614touchedpackage.json/package-lock.json/audit deps; this PR touchessrc/lib/workflow/pr-status.ts,state-utils.test.ts,CHANGELOG.md. No path overlap.gh pr viewreportsMERGEABLE/CLEAN.Self-Evaluation
isBranchMergedIntoMainsmoke (empty orphan →false; merged#607→true) onac2be37in the prior QA.263369cis JSDoc-only; nothing to re-execute.-200lookback caveat is graceful degradation covered by Method 2's commit-message grep.Verdict: READY_FOR_MERGE
All 8 ACs MET (unchanged from prior QA), CI is fully green on the head SHA, the sole
AC_MET_BUT_NOT_A_PLUSblocker (stale Method 1 doc-comment) is resolved by263369c, no new gaps introduced, branch is mergeable and clean.Documentation
[Unreleased] / Fixedwith issue tag(#616).Next Steps
fix(#616)entry onmain.reconcileStateAtStartupwill no longer falsely advance empty-orphan SIGINT-aborted issues fromin_progresstomerged— the original repro condition will be resolved on the next release.-200lookback ever becomes a concern as the repo grows, file an issue to revisit; not actionable today (sequant has ~29 merge commits onmain).fix(#616): isBranchMergedIntoMain returns false for empty orphan bran…