Skip to content

fix(loop): refuse to cut a feature branch from a base that lacks the feature - #3604

Merged
clabonte merged 2 commits into
mainfrom
fix/issue-3601-missing-branch-feature-folder
Nov 26, 2026
Merged

clabonte merged 2 commits into
mainfrom
fix/issue-3601-missing-branch-feature-folder

Conversation

@clabonte

Copy link
Copy Markdown
Contributor

Closes #3601.

Root cause

When the branch named in PLAN.md did not exist, ensure_feature_branch cut it from the declared base with git checkout -B. A feature folder committed only on the current branch is absent from that base, so the new branch held no PLAN.md: the next read raised a bare FileNotFoundError, with the operator already moved onto the new branch.

Fix

Before switching, ensure_feature_branch checks whether the feature's PLAN.md is committed at HEAD but missing from the base (git cat-file -e). If so it raises FeatureBranchError naming the path and the base, with two ways forward (create the branch from the current checkout, or merge the feature into the base first). Nothing is switched.

Unchanged: a base that holds the feature, and an untracked feature folder (the --prepare path, which checkout -B carries along). The guard returns "no refusal" whenever it cannot resolve the path, so it only ever adds a refusal.

The normal specfuse run path now catches FeatureBranchError, prints it and exits 1, as --prepare already did, so this and the existing dirty-tree refusal no longer surface as tracebacks.

Tests

  • tests/test_feature_branch_missing_on_base.py: the refusal (red on unchanged code: the branch was created from main with no error), plus two controls, a base that holds the feature and an untracked folder riding along.

Verification

  • scripts/smoke-test.sh: 5104 tests OK, smoke test OK.

🤖 Generated with Claude Code

Test and others added 2 commits November 25, 2026 18:22
…feature

Closes #3601. When PLAN.md's `branch` did not exist, ensure_feature_branch
cut it from the declared `base` with `git checkout -B`. A feature folder
committed only on the current branch is absent from that base, so the new
branch had no PLAN.md: the next read raised a bare FileNotFoundError and the
operator was left on the new branch.

ensure_feature_branch now checks, before switching, whether the feature's
PLAN.md is committed at HEAD but missing from the base, and raises
FeatureBranchError naming the path, the base and the two ways forward. The
operator stays on their branch. An untracked folder (the --prepare path) and
a base that holds the feature behave as before. The normal `specfuse run`
path now prints a FeatureBranchError and exits 1 instead of a traceback, as
--prepare already did.

Tests:
- tests/test_feature_branch_missing_on_base.py:TestFeatureMissingOnBase —
  refusal before switching (red on unchanged code), plus two controls: base
  holding the feature, and an untracked folder riding along.

Verification:
- scripts/smoke-test.sh: 5104 tests OK, smoke test OK

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clabonte
clabonte merged commit 6afce21 into main Nov 26, 2026
6 checks passed
@clabonte
clabonte deleted the fix/issue-3601-missing-branch-feature-folder branch November 26, 2026 12:44
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.

specfuse run cuts a missing feature branch from a base that lacks the feature folder, then crashes

1 participant