fix(sdd): guard worktree commits in prompts and review-package (#2050) - #2082
Open
stantheman0128 wants to merge 1 commit into
Open
fix(sdd): guard worktree commits in prompts and review-package (#2050)#2082stantheman0128 wants to merge 1 commit into
stantheman0128 wants to merge 1 commit into
Conversation
A dispatched implementer whose cwd resolves to the parent checkout commits onto whatever branch is checked out there. The shared .git makes that commit resolvable from the worktree, so review-package built a package for BASE..strayHEAD that rendered the earlier tasks as deletions and still read as a plausible review; the reporter of obra#2050 caught it only because a purely additive task showed deletions. When the controller passes a literal HEAD instead, the range was empty and the package was written anyway: 0 commits, no complaint. review-package now requires HEAD to be reachable from the branch checked out here and the range to hold at least one commit, exiting 3 with the git branch --contains command to run. A FIX_BASE orphaned by an amend still builds a package, so fix rounds are unaffected. The implementer template carries the expected toplevel and branch so the subagent can check both before it commits, which is the mitigation the reporter verified across the remaining tasks of their run. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Who is submitting this PR? (required)
AI-assisted contribution. Evidence and eval notes below are from a real Windows 11 session.
What problem are you trying to solve?
Issue #2050: during subagent-driven-development (SDD), a dispatched implementer ran
git add/git commitfrom the main repository checkout instead of the isolated worktree branch. The worktree was meant to isolate the work, but the subagent cwd was not enforced, somainreceived an out-of-context commit and the review package still looked plausible.Failure mode: implementer reports a commit SHA;
review-packagebuilds a diff from BASE..HEAD even when HEAD lives on another branch or working tree, so the controller reviews unrelated history as if it were the task.What does this PR change?
implementer-prompt.md: require verifyinggit rev-parse --show-toplevelandgit branch --show-currentbefore everygit add/git commit; STOP with BLOCKED if they do not match the dispatched worktree.review-package: exit 3 when HEAD is not reachable from the checked-out branch, or when BASE..HEAD is empty (commit landed elsewhere).test-sdd-workspace.sh: four regression cases for stray-tree HEAD, empty range, happy path, and amend orphaning FIX_BASE.Deliberately not changing
SKILL.mdprose (#1588 was closed for blast radius on that file; obra asked for the smallest surface, likelyimplementer-prompt.mdonly). The mechanical guard lives inreview-package, which every task review already calls.Is this change appropriate for the core library?
Yes. Any SDD user with multiple working trees of the same repo hits this; it is not project-specific.
What alternatives did you consider?
SKILL.mdguardrails (rejected: fix: keep SDD writes inside active worktree #1588 closed for touching behavior-shaping prose without evals).review-packageenforcement (insufficient: prompts alone did not stop the reported failure).Does this PR contain multiple unrelated changes?
No. All three files serve the same worktree isolation failure mode.
Existing PRs
#1588/#1589 addressed adjacent git-worktree hazards. This PR targets the SDD implementer dispatch path described in #2050: subagent commits on the wrong branch/tree and review-package still packages plausible output.
Environment tested
Evaluation
git branch --containsguidance; in-worktree commits and amend orphan case still exit 0.Rigor
superpowers:writing-skillsand completed adversarial pressure testing (paste results below)Human review
Verification / Evidence
Linked-worktree live repro: commit on branch A while review runs in worktree B -> exit 3 before writing a misleading package.
What was not tested
EnterWorktreedispatch on macOS/Linux (mechanism is plain git ancestry checks; platform-agnostic).Fixes #2050