Skip to content

fix(#1484): sequant merge --check hard-codes origin/main in four places, so a master-default repo gets empty diffs and a clean report - #1500

Merged
admarble merged 4 commits into
mainfrom
feature/1484-fix-merge-sequant-merge-check-hard-codes-origin-ma
Oct 18, 2026
Merged

admarble merged 4 commits into
mainfrom
feature/1484-fix-merge-sequant-merge-check-hard-codes-origin-ma

Conversation

@admarble

@admarble admarble commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

sequant merge --check no longer hardcodes origin/main. runMergeChecks resolves the base once per run (resolveMergeBaseRef → origin/<default> via detectDefaultBranch) and passes it to all four sites:

  • the filesModified diff;
  • the combined-branch test's temp branch and its lockfile check;
  • the overlap check's hunk ranges;
  • the residual pattern scan.

A filesModified diff that fails is now an error finding for that branch, and the batch is BLOCKED. It used to be a silent [], which every overlap check read as "no changes".

Fixes #1484

Changes (exec, 7281925aa, fa9d9945c, 4237036ad)

  • src/lib/merge-check/index.ts:
    • resolveMergeBaseRef, called once in runMergeChecks;
    • resolveBranches takes the base;
    • a branch-diff check result for failed diffs.
  • combined-branch-test.ts, overlap-detection.ts, residual-pattern-scan.ts: take the base as a parameter. BASE_REF is gone.
  • types.ts: BranchInfo.filesModifiedError. src/commands/merge.ts: passes the base through.
  • Tests: merge-check-base.integration.test.ts (new; a bare origin whose default is master, with no origin/main), the failed-diff test in merge-check.test.ts, and the existing tests moved to the new signatures.
  • docs/reference/merge-command.md, CHANGELOG.md.

Runner fixes after QA (dd4ca291f)

QA returned AC_MET_BUT_NOT_A_PLUS, 3/3. It marked two findings "document". Both were the issue's own defect class, so I fixed them here:

  • A failed diff for a branch held by a worktree still returned a silent []. That path called getGitDiffStats, which fails open by design for run logs. AC-3 covers any failed filesModified diff, so both paths now run the same git diff --name-only <base>...<head> and report a failure the same way. Added the test "base ref does not resolve: a branch held by a worktree reports the same error".
  • Cleanup fell back to git checkout main when the original branch couldn't be read. It now falls back to the resolved base branch. Added the test "restores the base branch when the original branch cannot be read, not a hardcoded main".

QA's third finding (missing mutation records) is addressed below.

Verification (runner, on dd4ca291f)

Evidence commands, run verbatim:

  • AC-1: git grep -nE "origin/main" -- 'src/lib/merge-check/*.ts' ':!*.test.ts' prints nothing.
  • AC-2: npx vitest run src/lib/merge-check/merge-check-base.integration.test.ts -t "master-default" reports 4 passed, 0 failed.
  • AC-3: npx vitest run src/lib/merge-check/merge-check.test.ts -t "base ref does not resolve" reports 2 passed, 0 failed.

Other checks:

  • src/lib/merge-check passes 133/133.
  • tsc --noEmit and eslint are clean.
  • The freeze grep prints nothing, and the branch is 0 commits behind main.

Mutation-verified: AC-2 — the remote filesModified diff uses the origin/main literal again; within -t "master-default" exactly "resolves origin/master and reports filesModified through runMergeChecks" failed (1 failed, 3 passed); restored.
Mutation-verified: AC-3 — the failed diff no longer records an error (silent [] again); both "base ref does not resolve" tests failed; restored.
Mutation-verified: AC-3 (worktree path) — a failed worktree diff is treated as success; only "a branch held by a worktree reports the same error" failed; restored.
Mutation-verified: cleanup — the restore fallback is the literal main again; only "restores the base branch when the original branch cannot be read, not a hardcoded main" failed; restored. With everything restored, 133/133 pass.

Follow-up ledger. The spec's open question 3 was a repo-wide lint against origin/main literals, recommended as a separate issue. I dropped it: after this PR, no non-test code under src/ contains an origin/main literal. The 6 remaining mentions are comments. The earlier instances were fixed in #343 and #1460, so the lint would guard nothing today.


🤖 Generated with Claude Code

…-coding origin/main

Entire-Checkpoint: 3a1ddf158716
…and cleanup restores the resolved base, not main

Entire-Checkpoint: c5413bf0dd53
@admarble
admarble merged commit 74703cb into main Oct 18, 2026
8 checks passed
@admarble
admarble deleted the feature/1484-fix-merge-sequant-merge-check-hard-codes-origin-ma branch October 18, 2026 23:49
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.

fix(merge): sequant merge --check hard-codes origin/main in four places, so a master-default repo gets empty diffs and a clean report

1 participant