Repository navigation
Description
Epic: graph-2026-10-freeze-c Tier: mechanical Execution: sequant_run
Problem
sequant merge --check hard-codes origin/main as the base in four places in src/lib/merge-check/:
| Site | Use |
|---|---|
combined-branch-test.ts:57 |
const BASE_REF = "origin/main": the combined branch is cut from it (:264), and the lockfile check compares against it (:364) |
index.ts:170 |
git diff --name-only origin/main...origin/<branch>: each batch branch's filesModified |
overlap-detection.ts:38 |
git diff --unified=0 origin/main...<branch> -- <file>: hunk ranges for overlap |
residual-pattern-scan.ts:61 |
git diff origin/main...<branch> --unified=0: residual pattern scan |
On a repo whose default branch is master (or anything other than main), origin/main doesn't exist. The combined-branch test can't create its branch. The three diffs fail, and their callers read the empty stdout as "no changes". At index.ts:170, filesModified silently becomes [], so the overlap checks, including #1454's external-PR overlap, see nothing and report clean. That's wrong output with no error.
Found by QA on #1460 (PR #1483), whose document finding named combined-branch-test.ts:57. A repo-wide git grep found the other three.
Prior fixes / producers
- This is the same class as the base-ref cluster: fix(chain): --chain successors branch from main, not predecessor's committed work (up-front worktree provisioning) #748, fix(observability): phase diff stats compare against the local base ref while worktrees branch from origin/<base> — phantom filesModified + base tip logged as the phase commit #878, fix(observability): remaining bare main...HEAD consumers after #878 — qa-cache diff hash, worktree-manager summaries, aider file-context, non-qa skill gates #890, bug(qa): the qa phase rebases an already-pushed branch onto main, forcing a force-push to land it #1069, bug(exec): sequant run worktrees never record sequantBase, so the zero-diff/uncommitted guard compares against origin/main and a --base ahead of main disables it #1234, fix(run): --base creates the worktree from the branch but opens the PR against the repo default branch #1386, ensureWorktree "recreating fresh" rebuilds a PR branch from base and drops its commits; qa re-run reviews the wrong tree #1380, fix(worktree): a non-default bare --base is cut from local <base> but counted against origin/<base> (#1380 follow-up, #1234/#1386 class) #1406 and fix(run): phase agents never get SEQUANT_BASE_BRANCH — skills fall back to main on master-default repos #1460. Every TypeScript consumer of the base outside
merge-check/now goes through one resolver (resolveDiffBase/resolveBaseRef/computeWorktreeBaseRef).merge-check/never adopted one. git log -S 'origin/main' -- src/lib/merge-check/: feat(run): Add batch-level integration QA —sequant merge --check#313 (PR feat(#313): Add batch-level integration QA — sequant merge --check #324, which introduced the literals), fix(merge-check): combined-branch-test runs npm test/build without reinstalling deps after a lockfile change → false BLOCKED #803 (PR fix(#803): reinstall deps in merge-check's combined-branch test #806) and PM_CONFIG.yarn.ciInstall uses Yarn 2+--immutable, which Yarn 1 rejects — no berry detection exists #871 (PR fix(#871): resolve yarn frozen install per yarn major in both provisioning paths #876). Neither later fix touched the base.- Since fix(run): phase agents never get SEQUANT_BASE_BRANCH — skills fall back to main on master-default repos #1460 (PR fix(#1460): phase agents never get SEQUANT_BASE_BRANCH — skills fall back to main on master-default repos #1483),
detectDefaultBranch(verbose, cwd)takes the repo to read.merge --checkruns at the repo root.
Acceptance Criteria
- AC-1: No string literal
origin/mainremains in non-test code undersrc/lib/merge-check/, and every base ref there comes from one resolver call permerge --checkrun, passed to all four former sites. Evidence:git grep -nE "origin/main" -- 'src/lib/merge-check/*.ts' ':!*.test.ts'prints nothing (comments rewritten too), and AC-2's test covers all four sites. - AC-2: On a temp repo whose default branch is
master(bare origin,origin/HEAD→master, noorigin/main) with one feature branch that changes a file, each of the four sites usesorigin/master:runMergeChecksreports that branch'sfilesModifiedas the changed file, the combined-branch test creates its temp branch fromorigin/master, the overlap check reads the branch's hunk ranges, and the residual pattern scan reads its diff. Evidence:npx vitest run src/lib/merge-check/merge-check-base.integration.test.ts -t "master-default"reports ≥ 4 passed and 0 failed (a filter that matches nothing reports all skipped and exits 0), mutation-verified by restoring theorigin/mainliteral atindex.ts'sfilesModifieddiff (exactly thefilesModifiedcase fails). - AC-3: When the
filesModifieddiff command fails,filesModifiedisn't silently[]: the report carries an error finding for that branch naming the failed git command. Evidence:npx vitest run src/lib/merge-check/merge-check.test.ts -t "base ref does not resolve"reports ≥ 1 passed and 0 failed (a filter that matches nothing reports all skipped and exits 0), mutation-verified by restoring the silent[]fallback.
May touch
src/lib/merge-check/ (combined-branch-test.ts, index.ts, overlap-detection.ts, residual-pattern-scan.ts, types.ts) and their tests, including merge-check-base.integration.test.ts (new), docs/reference/merge-command.md, CHANGELOG.md.
Non-Goals
- Base resolution outside
src/lib/merge-check/(detectDefaultBranchand the other resolvers are used as they are). - A
--baseflag formerge --check. Batches with a non-default base are a separate question. - Any edit under
plugin/,.claude/skills/ortemplates/skills/(plugin freeze).
Activity
admarble commentedon Oct 18, 2026
Complexity: Standard (3 ACs, 1 directory)
AC Quality Check
All three ACs are single-line, carry
Evidence:, and are measurable. Notes:≥ N passedclause. Good.Scope Assessment
Non-Goals: present (base resolution outside
merge-check/,--baseflag, plugin/skill dirs).src/lib/merge-check/)Verdict: ✅ SCOPE_OK
Acceptance Criteria
AC-1: No
origin/mainliteral in non-testmerge-check/; one resolver call per runVerification: Integration Test (the AC-2 test) plus the grep in Evidence
Scenario: Given the merge-check sources → When the grep runs → Then no output; and a single resolution is threaded to all four sites.
AC-2: master-default repo uses
origin/masterat all four sitesVerification: Integration Test (
merge-check-base.integration.test.ts,-t "master-default", ≥4 cases)Scenario: Given a temp repo with a bare origin,
origin/HEAD→master, noorigin/main, one feature branch changing one file → When each site runs → ThenfilesModified= [that file], the temp branch is cut fromorigin/master, overlap reads its hunks, the residual scan reads its diff.Assumptions:
combined-branch-test.integration.test.ts:201already builds a bare origin + clone fixture. Reuse it with amasterdefault.AC-3: A failed
filesModifieddiff is not silently[]Verification: Unit Test (
merge-check.test.ts,-t "base ref does not resolve")Scenario: Given the diff command exits non-zero → When
resolveBranches/runMergeChecksruns → Then the report has anerrorfinding for that branch naming the git command.Implementation Plan
Phase 1: One resolver
runMergeChecks(index.ts), resolve once:const baseRef =origin/${detectDefaultBranch(false, repoRoot)}`` (worktree-manager.ts:242, cwd-aware since fix(run): phase agents never get SEQUANT_BASE_BRANCH — skills fall back to main on master-default repos #1460). Not `resolveBaseRef(cwd)`: it prefers a per-branch recorded `sequantBase`, which is wrong for a repo-root batch check.baseRefas a required parameter intoresolveBranches,runCombinedBranchTest,runOverlapDetection(→getChangedLineRanges) andrunResidualPatternScan(→extractPatternsFromDiff). DeleteBASE_REFincombined-branch-test.ts(:57, used at:264,:364). Required, so a future caller can't silently reintroduce a default.origin/main(AC-1 greps comments too).Phase 2: Surface the failure (AC-3)
index.ts:166-176, checkdiffResult.status. On failure, record the failure onBranchInfo(new optional field intypes.ts, e.g.filesModifiedError: stringholding the command) and emit anerrorCheckFindingfor that branch fromrunMergeChecks. KeepfilesModified = []only as the payload, never as the signal.getGitDiffStats(worktreePath)atindex.ts:160uses the defaultbaseBranch = "main", andresolveDiffBasereturns it verbatim when unresolvable. That's the same silent-empty bug on amasterrepo. Pass the resolved base (branch name withoutorigin/). It sits insidemerge-check/, so it is in scope, but the AC-1 grep can't see it. See Open Question 1.Phase 3: Tests and docs
merge-check-base.integration.test.ts(4+ cases under amaster-defaultdescribe) and the AC-3 case inmerge-check.test.ts. Update the existing callers (merge-check.test.ts:158-232,combined-branch-test*.test.ts) for the new parameter, and theorigin/maincommand strings mocked atcombined-branch-test.test.ts:123,597.index.ts'sfilesModifieddiff and confirm only thefilesModifiedcase fails. Restore the silent[]fallback and confirm the AC-3 test fails. RecordMutation-verified:markers in the PR body with the file path first (src/lib/merge-check/merge-check-base.integration.test.ts > …). Updatedocs/reference/merge-command.mdandCHANGELOG.md.Design Review
runMergeChecksresolves once, and each check receives the ref. The resolvers stay where they are (Non-Goal).baseRefparameter. Rejected: a module-levelresolveBase()called in each file (four resolutions can disagree mid-run, and the AC wants one call). Rejected:resolveBaseRef(cwd), which reads a per-branch recorded base.merge-check/, which is the last unadopted consumer. Residual risk is a new hard-coded consumer. Agit greplint acrosssrc/(not onlymerge-check/) would close the class. See Open Question 3.--base?" It's a Non-Goal.git grep origin/main src/finds the four sites plus tests. Consumers ofBranchInfo.filesModifiedarerunOverlapDetection,runExternalPrOverlapandrunMirroringCheck. They all read the field populated atindex.ts, so one fix point covers all of them.detectDefaultBranchhas a single producer. Its fallback to"main"whenorigin/HEADcan't be read remains. A master repo withorigin/HEADunset still getsorigin/main, which is a Non-Goal and should be mentioned in the docs.No divergence from the prescribed lever.
Feature Quality Planning
All standard checks pass. Notable items:
getGitDiffStatsdefault"main"(Plan step 5).errorfinding should push the branch toBLOCKED, notREADY. Confirm withcomputeIssueVerdicts(report.ts:22) and assert it in the test.Derived ACs
getGitDiffStats) uses the resolved base on a master-default repoOpen Questions
getGitDiffStatsdefault? — Recommendation: yes, add as AC-4 (owner edits the AC lines). Impact: if skipped, a master repo with worktrees still reports emptyfilesModified, and AC-2'srunMergeCheckscase passes only on the remote-branch path.detectDefaultBranchis called once perrunMergeChecks. Impact: otherwise unenforced.origin/mainliterals? — Recommendation: separate follow-up issue, not this one. Impact: the class can recur.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: one directory, bug fix, mechanical.
testgenskipped: the label isbugonly. The ACs declare their own test files, and the integration fixture exists.Label Review
Current: bug, graph-2026-10-freeze-c
Recommended: no change
Reason: n/a
Quality Loop: won't auto-enable (SCOPE_OK).
admarble commentedon Oct 18, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 3/3 met
Gaps:
fix(#1484): a worktree branch's failed diff is an error finding too, …
admarble commentedon Oct 18, 2026
Runner verification (graph-2026-10-freeze-c W3, node F). I ran this after QA's AC_MET_BUT_NOT_A_PLUS (3/3) on PR #1500.
Fixed in
dd4ca291f. QA marked both findings "document", but both were this issue's own defect:[]. That path usedgetGitDiffStats, which fails open. AC-3 covers everyfilesModifieddiff, so both paths now share one checkedgit diff --name-only. New test added.main. It now falls back to the resolved base. New test added.Evidence commands, run verbatim on
dd4ca291f:src/lib/merge-checkpasses 133/133.tscand eslint are clean. The freeze grep prints nothing, and the branch is 0 commits behind main.Mutations, each failing only its target test, then restored:
origin/mainliteral is back at thefilesModifieddiff.[]is back.mainagain.The records are in the PR body.
Follow-up ledger: the spec's open question 3 (a repo-wide lint against
origin/mainliterals) is dropped. After this PR, no non-test code undersrc/contains the literal. The 6 remaining mentions are comments, and the earlier instances were fixed in #343 and #1460. Nothing else was deferred.PR #1500 waits on CI and then on the owner's merge decision.
docs(#1492): record F (#1484) merged as 74703cb