Skip to content

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

Closed

Description

@admarble

Tier: judgment

Problem

The exec zero-diff/uncommitted guard (classifyExecChanges, phase-executor.ts) compares resolveBaseRef(cwd)..HEAD. resolveBaseRef reads branch.<branch>.sequantBase and falls back to origin/main. That config key is written only by the legacy templates/scripts/new-feature.sh:203. The TypeScript worktree path sequant run uses (worktree-manager.ts) never writes it:

grep -rn sequantBase src --include='*.ts' | grep -v test   # reader only, no writer

So for every sequant run worktree, the guard compares against origin/main, whatever --base says. When the base branch is ahead of main, the base's own commits count as "commits ahead", and the guard returns commits. The none (no work) and uncommitted (#879 fail + #1032 WIP rescue) branches never fire.

Observed 2026-09-30 in the #1138 Phase 0 bench. Each run used --base bench-arm, a local branch one commit ahead of main. In 3 of 18 runs, exec backgrounded the test suite, waited for a notification, and ended with all its work uncommitted. That's the #1032 stranding mode; the fixture skills predate #1032. The guard should have failed the phase and committed the files as WIP. Instead exec reported success, the files stayed uncommitted, and qa reviewed the dirty tree and returned READY_FOR_MERGE twice and AC_MET_BUT_NOT_A_PLUS once.

Expected by the same mechanism, not reproduced: chain mode bases each successor on its predecessor's branch, so a successor exec that commits nothing sees the predecessor's commits and passes.

Secondary, same flag: the post-phase rebase in worktree-manager.ts always fetches and rebases onto origin/<base>. For a local --base it prints Could not fetch origin/bench-arm … Rebase failed: invalid upstream 'origin/bench-arm' after every phase. It's harmless but noisy.

Acceptance criteria

  • AC-1: Worktrees created by sequant run record the exact base ref the worktree was cut from (the baseRef string worktree-manager.ts computes: origin/main, origin/x, or a local feature/x) under branch.<branch>.sequantBaseRef. Evidence: npx vitest run src/lib/workflow/worktree-manager.test.ts asserts the recorded value for no --base, --base origin/x and a local --base feature/x
  • AC-2: resolveBaseRef uses sequantBaseRef verbatim when it resolves (git rev-parse --verify). Otherwise it keeps today's behavior: legacy sequantBase (written by new-feature.sh) gets origin/ prepended, and with neither key it falls back to origin/main. A local branch is never inferred from a bare name, so a stale local main is never used. Evidence: npx vitest run src/lib/workflow/phase-executor.test.ts
  • AC-3: An exec that leaves only uncommitted work on a worktree whose base is a branch ahead of main fails the phase and WIP-commits the paths (fix(exec): phase agent that backgrounds the test suite and waits for a notification strands uncommitted work — block Monitor/run_in_background under the orchestrator, WIP-commit on the no-commit guard #1032). Evidence: npx vitest run src/lib/workflow/phase-executor.test.ts with a temp repo whose base branch is one commit ahead of main
  • AC-4: The post-phase rebase uses the local base ref when --base names a local branch, and prints no fetch or rebase warning. Evidence: npx vitest run src/lib/workflow/worktree-manager.test.ts

Non-goals

  • Changing qa to refuse a dirty tree. With the guard working, exec fails before qa runs. File that separately if it's still wanted.

Relates to #537, #879, #1032, #1138.

AC-1/AC-2 revised 2026-09-30 before implementation: the original AC-2 ("return a local branch unchanged when one exists") would have compared against a stale local main in most checkouts. The exact ref is now recorded under a new key and read verbatim, and the legacy key keeps its meaning.

Activity

  1. added
    bug
    on Sep 30, 2026
  2. added a commit that references this issue on Sep 30, 2026
  3. added a commit that references this issue on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions