Skip to content

fix(sdd): reject empty or non-descendant BASE..HEAD ranges in review-package - #2136

Merged
arittr merged 1 commit into
devfrom
fix/review-package-range-guards
Sep 17, 2026
Merged

arittr merged 1 commit into
devfrom
fix/review-package-range-guards

Conversation

@obra

@obra obra commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Problem

review-package builds a review package from whatever BASE/HEAD range it's handed. When an SDD subagent commits to the wrong branch (#2050's reported failure: an implementer committed to main instead of its worktree), the range is either empty — the reviewer sees nothing and approves 'clean' work — or contains commits that aren't descendants of the expected base. Both silently corrupt the review chain SDD's correctness depends on.

Fix

Five lines after the existing BASE/HEAD validation, in the script's own style:

  • git merge-base --is-ancestor "$base" "$head" — reject with 'HEAD is not a descendant of BASE', exit 3
  • git rev-list --count — reject an empty range, exit 3

Exit 3 distinguishes range corruption from usage errors (exit 2). This is the mechanical-enforcement shape requested on #1588; prompt-side wording changes are deliberately out of scope (they need evals).

TDD evidence

Two new assertions in tests/claude-code/test-sdd-workspace.sh (divergent BASE built via commit-tree, and BASE==HEAD). RED against the unmodified script (both cases: exit 0, no stderr), GREEN with the guards; all 15 suite assertions pass.

Note: this touches review-package near PR #2134's hunk — whichever lands second gets a trivial rebase.

Reported by @conradstorz in #2050; guard shape credited to closed PR #2082 (@stantheman0128). Fixes #2050.

Who is submitting

Claude Fable 5 on Claude Code 2.1.228 (implementation subagent + controller review), working the triage build queue directed by @obra, who reviews the diff.

@arittr @ada-sen — review requested.

…package

When an SDD implementer commits to the wrong branch (#2050), the
BASE..HEAD range handed to review-package is either empty or not rooted
at BASE. Both cases previously produced a review package silently —
an empty one lets the reviewer approve "clean" work that isn't there.

Add two mechanical guards after BASE/HEAD validation, exiting 3 (vs 2
for usage errors) so callers can distinguish range problems:

- git merge-base --is-ancestor BASE HEAD, else "HEAD is not a
  descendant of BASE"
- git rev-list --count BASE..HEAD > 0, else "empty commit range"

Guard shape credits the analysis in closed PR #2082 by @stantheman0128.

Fixes #2050

@arittr arittr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arittr
arittr merged commit b61242d into dev Sep 17, 2026
jmbruzos pushed a commit to jmbruzos/superpowers that referenced this pull request Oct 19, 2026
…kspace keeps a repo's own .kdd/sdd/.gitignore

review-package exits 3 on a HEAD that does not descend from BASE or an empty
range (upstream obra#2136), and calls sdd-workspace through bash. sdd-workspace
writes .kdd/sdd/.gitignore only when missing (upstream obra#2399). Upstream's
two range-guard cases ported, plus a create-only case; all three failed
before. Items 5, 6; AC3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
filipjurcicek-filevine added a commit to filipjurcicek-filevine/superpowers that referenced this pull request Nov 5, 2026
The fork's sdd-workspace, task-brief, and review-package were identical
to v6.3.0, so the upstream versions apply as they are:

- sdd-repo (new): the helpers act on the git repository of the current
  directory, as git does, and stop with exit 2 outside one. All take
  -C DIR for another working tree (obra#2429, obra#1799).
- sdd-workspace: a plan-path marker gives plans with the same basename
  separate workspaces (obra#2138), and a committed .superpowers/sdd/.gitignore
  is no longer overwritten (obra#2161).
- task-brief: finds task IDs such as A1, 6b, and 2.1, and Task 6 no
  longer matches Task 6b (obra#2459). It refuses a brief that an unclosed
  code fence would run to the end of the plan (obra#2436).
- review-package: an empty or non-descendant BASE..HEAD exits 3 (obra#2136).

The skills now say to run each helper by its absolute path from the
working tree, not "from this skill's directory", which made agents run
the helpers against the plugin cache (obra#2525).

Tests: upstream test-sdd-workspace.sh and test-sdd-helper-paths.sh. The
path test failed on 5 skill lines before the wording change and passes
after it. All nine offline suites pass; shellcheck is clean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants