Repository navigation
Description
What happens
The qa phase rebases the feature branch onto origin/main mid-review. Its own output says so:
✔ Branch rebased onto origin/main
When main has advanced since the branch was pushed, this rewrites already-pushed commits. The local branch and its remote diverge (ahead 8, behind 7), and the only way to land the rewritten history is a force-push — which this repo's hooks block and CLAUDE.md forbids.
Observed
On #1059 (2026-09-15, sequant 2.15.1, sequant_run over MCP, phases: qa). main advanced to 32118b71 (#1065) during the review. Seven pushed commits were rewritten with new SHAs; the run otherwise succeeded with verdict AC_MET_BUT_NOT_A_PLUS.
Recovery, since the rebased commits were content-identical:
git reset --hard origin/<branch>
git merge origin/main
Why it matters
A phase should not rewrite history that exists on the remote. The failure is silent — nothing in the verdict mentions it — and the next git push is what surfaces it, by which point a careless --force looks like the obvious fix. An orchestrator that does not check git status -sb after every qa run will either force-push or get stuck.
Suggested fix
Merge origin/main instead of rebasing whenever the branch has an upstream (@{u} exists), which is the rule the repo already applies everywhere else. Rebase is only safe on a branch that was never pushed.
Acceptance criteria
- AC-1: when the feature branch has an upstream (
@{u}resolves), the pre-PR step mergesorigin/maininstead of rebasing, and no pushed commit SHA changes — Verify:npx vitest run src/lib/workflow/worktree-manager.test.ts -t "1069"→ a temp repo with a pushed branch and an advanced main ends with the same SHAs for the pushed commits plus one merge commit. Mutation-verified per CLAUDE.md §Testing: restore the unconditional rebase → the case fails; restore. - AC-2: a branch with no upstream still rebases as before — Verify: same command, case
no upstream rebases. - AC-3: the phase's printed line says which happened (
merged origin/mainorrebased onto origin/main) — Verify: same command, casereports merge vs rebase. - AC-4:
npm run build && npm testgreen.
Release-graph plan — guard-2026-09 (2026-09-20)
Graph: guard-2026-09 Tier: mechanical Wave: 2
May touch: src/lib/workflow/worktree-manager.ts (rebaseBeforePR), src/lib/workflow/batch-executor.ts (the pre-PR call site at the rebase step only), their tests, CHANGELOG.md
The npm run build && npm test AC is verified by the runner from a clean shell after the PR opens (PLAN I-1); the agent runs only the test files its ACs name. Mutation markers use failedTest starting with the test file path (I-4). Wave 2 because #1070 edits batch-executor.ts in wave 1; no hard edge.
Activity
admarble commentedon Sep 20, 2026
Runner context — guard-2026-09 wave 2 launch, 2026-09-20. Base:
origin/mainatbef0ac98(all seven wave-1 PRs merged: #1086 scrub, #1104 marker docs, #1053, #1106 ownership gate, #1095 parsers, #1096 conformance suite, #1070 failing verdicts post). These rules override the exec AND qa skills' defaults for this run:npm testin the worktree — this applies to the qa phase too. Under concurrent phase agents that one call exceeds the 30-minute no-progress wall and the phase is killed (three wave-1 phases died this way). Verify each AC by its own command; run only the test files the ACs name. The runner runs the full suite once per PR from a clean shell and records it on the PR.<!-- SEQUANT_MUTATION: {"ac":"AC-N","mutation":"<what you deleted>","failedTest":"<test file path> > <describe> > <case>"} -->in the PR body.failedTestMUST start with the test file path. RunparseMutationMarkerson your body before opening the PR. Commit before mutating.timeout.git commit -m "...", noCo-Authored-By. Push the branch and open the PR yourself (one wave-1 exec forgot). Never rebase or force-push after pushing. One AC per line in the PR body, idsAC-Nonly.Issue-specific:
src/lib/workflow/batch-executor.test.tsis shared with #1087 this wave: add your cases in ONE newdescribe("#1069 …")block appended at the end of the file and touch nothing else there (#1087 appends its own block).batch-executor.ts: the pre-PR rebase call site only. Note the qa phase itself currently rebases pushed branches (this is the bug); expect the✔ Branch rebased onto origin/mainline in your own run.admarble commentedon Sep 20, 2026
Complexity: Standard (4 ACs, 1 directory)
AC Quality Check
AC-1..3 are measurable and carry a
Verify:command. Two notes:src/lib/workflow/worktree-manager.test.ts, which does not exist (onlyworktree-manager.build-pr-body.test.tsand.frozen-install.test.ts). It is created new.-t "1069"requires1069in the describe/case name.npm run build && npm test) is runner-verified from a clean shell per the graph plan; the agent runs only the named test files.Scope Assessment
Non-Goals: not stated in the issue. Inferred from "May touch": the chain-mode successor rebase (
ensureWorktree,rebaseOntoLocalBranch, ~L905/L1373) is out of scope — those rebase onto a local predecessor branch, notorigin/main.src/lib/workflow)Verdict: ✅ SCOPE_OK
Acceptance Criteria
AC-1: pushed branch → merge
origin/main, no pushed SHA changesVerification: Integration Test (real temp repos: bare remote + clone + worktree, no mocks)
Scenario: Given a branch pushed to
origin/<branch>with N commits andorigin/mainadvanced → WhenrebaseBeforePRruns → Then the N original SHAs are all still ancestors of HEAD (and HEAD~ chain unchanged) plus exactly one merge commit;git status -sbshowsahead 1, notahead N, behind M.Assumptions: hermetic git identity from
vitest.global-setup.tscovers the merge commit. Mutation: restore the unconditionalgit rebase→ this case must fail.AC-2: no upstream → still rebases
Verification: Integration Test (
no upstream rebases)Scenario: Given a never-pushed branch, main advanced → When run → Then history is linear (no merge commit), branch sits on
origin/main.Assumptions: see Open Question 1 — the fixture must also cover the fresh-worktree shape (below).
AC-3: printed line says which happened
Verification: Integration Test (
reports merge vs rebase)Scenario: Given each of the two setups → Then stdout contains
merged origin/main/rebased onto origin/mainrespectively (spyconsole.log; chalk color stripped).AC-4:
npm run build && npm testgreenVerification: runner, clean shell. Existing
rebaseBeforePRunit tests insrc/commands/run.test.ts:1382+mockspawnSyncpositionally (fetch → rebase → …); they will break when a new upstream-probe call is added and must be updated (see plan step 4).Implementation Plan
Phase 1:
rebaseBeforePR(worktree-manager.ts:1418)branchIsPushed(worktreePath, baseRef): true iff the branch has an upstream (rev-parse --abbrev-ref --symbolic-full-name @{u}succeeds) and that upstream is notbaseRef(see Open Question 1 — this is the key correctness point).git merge --no-edit <baseRef>; else existinggit rebase <baseRef>. Conflict path:merge --abort(vsrebase --abort), sameRebaseResultshape (success:false, "conflict - manual resolution required"). Keep messaging parallel.✔ Merged origin/main into branch (…)→ exactlymerged origin/main/rebased onto origin/mainper AC-3; also handle "Already up to date" (print it truthfully rather than claiming a merge). Consider addingstrategy: "merge" | "rebase"toRebaseResultso callers/tests don't parse stdout.HEADbefore the operation and pass it aspreRebaseReftoreinstallIfLockfileChanged(it defaults toORIG_HEAD, which a merge that is "already up to date" or fast-forward does not reliably set). Update the positionalspawnSyncmocks insrc/commands/run.test.tsfor the extra probe call.Phase 2: call site + tests
batch-executor.ts:2253— no logic change expected (it already just callsrebaseBeforePR); touch only ifRebaseResult.strategyshould be surfaced in the log. Add the#1069describe once, appended at the end ofbatch-executor.test.ts, only if a call-site assertion is needed (shared with bug(codex): usage-limit turn failures classified 'unknown' — quality loop re-runs into the same quota, --auto-wait can't engage #1087 — touch nothing else).src/lib/workflow/worktree-manager.test.tswith cases:#1069 pushed branch merges and keeps SHAs,no upstream rebases,reports merge vs rebase, plus (added)fresh worktree branch tracking origin/main still rebasesandmerge conflict aborts and leaves branch intact. Real git, and name it so the 5s default timeout isn't an issue (or set explicit timeouts — no.integration.in the name ⇒ 5s limit).CHANGELOG.mdentry. Record mutation-verified marker in the PR body (failedTestbeginning withsrc/lib/workflow/worktree-manager.test.ts > …).Rule Touchpoints
Rule-shaped AC ("instead of … whenever … no pushed commit") — touchpoints:
worktree-manager.ts:1418(rebaseBeforePR, the fix site) andbatch-executor.ts:2253(call site). Skill prose also describes rebasing:.claude/skills/qa/SKILL.md:327,332tells users togit rebase origin/main— advice to a human, and it contradicts the repo's merge-not-rebase rule; not in "May touch", so raised as a follow-up, not silently widened (Open Question 2).Design Review
worktree-manager.ts::rebaseBeforePR— the only place theorigin/mainsync happens; the call site stays dumb.rebaseOntoLocalBranch(fetch → op → abort on conflict → result struct); the "merge pushed branches" rule from repo practice.@{u}as the issue says?" → because of the finding below.Feature Quality Planning
Notable items:
@{u}resolves" — is wrong for fresh worktrees. Verified empirically:git worktree add -b feat <path> origin/main(whatensureWorktreedoes at L893) auto-sets upstream toorigin/main, so@{u}resolves toorigin/mainfor a never-pushed branch. A bare@{u}check would merge on every first run — silently regressing AC-2 in production while a "no upstream" fixture (branch created without tracking) still passes. Same trap the unpushed-commits probe at L300 sits next to. The check must be "upstream exists and is not the base ref" (equivalently,origin/<branch>exists). Derived AC below.merge --abort; otherwise the worktree is left mid-merge andcreatePRoperates on a dirty tree.Derived ACs
origin/<base>(freshworktree add -b … origin/main) still rebases — casefresh worktree branch tracking origin/main still rebasessuccess:falseOpen Questions
origin/<baseBranch>" (adopt AC-5). Impact if the issue's literal@{u}is used: every fresh branch merges instead of rebasing; AC-2's literal fixture still passes, so QA could miss it.qa/SKILL.md:327,332recommendsgit rebase origin/mainto users — Recommendation: file a follow-up (not in "May touch"; skill edits need all three mirror dirs). Impact if left: prose contradicts the fix.rebaseBeforePRas planned; it fires on any run, so title is loosely worded, not a scope difference.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: Single-function bug fix with
buglabel; ACs are unit/integration verified by the tests the issue names, sotestgenis skipped (targeted tests are written in exec). No UI, no security surface. Runner rules from the launch comment apply (no fullnpm testin the worktree; commit before mutating; stop at the PR).Label Review
Current: bug
Recommended: bug, planned
Quality Loop: Won't auto-enable (SCOPE_OK, simple fix)
fix(#1069): test repos set a git identity for CI; abort a merge that …
test(#1069): set the git identity before the first commit so the case…
admarble commentedon Sep 20, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/6 met
Gaps:
unitvitest project.vitest.config.ts:19-30puts**/*.test.tswithout.integration.intounit, which keeps vitest's 5s defaulttestTimeout. Each of the 5 cases spawns 10+ realgitsubprocesses. The spec explicitly said "name it so the 5s default timeout isn't an issue (or set explicit timeouts — no.integration.in the name ⇒ 5s limit)" — neither was done. Measured 2.53s for 5 cases on an idle machine; fix(test): tsx-spawning integration tests blow vitest's 5s default — phase-registry should use the prebuilt dist like its five siblings #842 measured 7.5–17.8s for subprocess tests under full-suite load.beforeEachis safe (60shookTimeout), but theit()bodies commit, push and advance main inside the 5s budget.merge --aborton non-conflict failure has zero test coverage. That branch (if (pushed) { merge --abort }) was added byfb95d910specifically socreatePRnever runs against aMERGE_HEADtree. No case exercises it:worktree-manager.test.tscovers only the conflict abort, and both updatedrun.test.tscases mock the upstream probe as status 128 → rebase path, so they never reach it.merge --abortcan discard uncommitted work on that same path.git merge --abortresets hard; unrelated dirty files would be lost. Mitigated in practice (a checkpoint commit runs atbatch-executor.ts:2216-2240before the rebase step, and git refuses to start a merge that would overwrite tracked local changes), but there's no guard or comment recording that assumption.src/commands/run.test.ts. Three cases were not updated (should successfully rebase…,should continue when fetch fails,should use custom base branch…). They still pass — the un-updatedmockReturnValueOncenow feeds the upstream probe, whose empty stdout makesbranchIsPushedreturnfalse, so the rebase path is still taken andshould use custom base branchstill meaningfully asserts["rebase", "origin/master"]. But the// Mock rebase (success)comments now describe the wrong call, which will mislead the next editor of these positional mocks.✔ Branch merged origin/mainunconditionally. Cosmetic; AC-3 is still satisfied.Suggestions:
RebaseResult.strategyhas no production consumer;batch-executor.ts:2253discards the return value entirely. It's a test-only affordance today (the spec did suggest it). Surfacing it in the run log would make the merge-vs-rebase choice visible to the operator, which is closer to the issue's "the failure is silent" complaint.qa/SKILL.mdtells usersgit rebase origin/main(stale-branch remediation) andgit pull origin main(pre-flight sync). That prose now contradicts this fix and the repo's merge-not-rebase rule. Correctly excluded from "May touch"; worth filing.fix(#1069): merge origin/main into pushed branches instead of rebasin…