Skip to content

fix(sdd,executing-plans): harden workspace claims, task-brief boundaries, review-package, and task-done - #2744

Open
arittr wants to merge 17 commits into
fix/wave1-worktree-finish-safetyfrom
fix/wave1-executor-helpers
Open

arittr wants to merge 17 commits into
fix/wave1-worktree-finish-safetyfrom
fix/wave1-executor-helpers

Conversation

@arittr

@arittr arittr commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #2736 (fix/wave1-worktree-finish-safety): the base branch is #2736's branch, so the diff on GitHub shows only this PR's changes.

Who is submitting this PR? (required)

Field Value
Your model + version Gemini 4 Carbon (High)
Harness + version Antigravity CLI 1.5.16 (via Paseo)
All plugins installed superpowers, dealerboard, toolsmith
Human partner who reviewed this diff Drew Ritter (@arittr)

What your human partner asked you to do, in their words:

Fix the confirmed bugs across task-brief, sdd-workspace, review-package, task-start, task-done, and .gitattributes (plan preamble without worker-blockquote leak, final-task boundary, atomic brief writes, deleted-plan resolution, directory-locked workspace claiming, commit bodies in review packages, stripped-exec-bit invocation, and explicit exit-status ledgering) with deterministic unit tests.

Human-authored summary (required, under 200 words)

Stacked on #2736, this fixes a cluster of bugs in the bash/awk helper scripts shared by subagent-driven-development and executing-plans that surfaced once people started running real multi-task plans through them. task-brief was dropping everything above Task 1 (so implementers never saw the plan's Goal or Global Constraints, while naive fixes leaked the controller's own dispatch blockquote), letting the last task swallow trailing ## Execution Handoff sections, and truncating existing briefs to 0 bytes on lookup misses. If an earlier task deleted or moved the plan file, sdd-workspace, task-brief, and review-package all broke with exit 2.

On top of that, sdd-workspace spun forever if .superpowers was blocked by a file and raced when two plans shared a basename, review-package used --oneline (hiding commit bodies from reviewers), package zip extractors stripping +x broke task-start/task-done, and task-done scraped the last stdout line instead of recording real exit status. This fixes those helper contracts together with unit tests.

What problem are you trying to solve?

Fixes #2298, fixes #2342, fixes #2493, fixes #2611, fixes #2619, fixes #2620, fixes #2630, fixes #2642.
Addresses part of #2406.

task-brief (used by both executors through task-start and the SDD dispatch):

sdd-workspace:

review-package:

executing-plans/scripts/task-start and task-done:

What does this PR change?

Is this change appropriate for the core library?

Yes — these are the bundled bash/awk helper scripts for subagent-driven-development and executing-plans, using only POSIX/bash/git/awk primitives with zero third-party dependencies.

What alternatives did you consider?

  1. fix(sdd): stop task-brief leaking trailing plan sections #2359's terminator for every task: not taken. fix(sdd): stop task-brief leaking trailing plan sections #2359 ends any task at an equal-or-shallower ## heading where two fence parsers both agree the line is outside a fence. On the 17 plans this repository once kept under docs/superpowers/plans/, that trims the mid-plan leaks and truncates nothing, but a non-final task with its own same-level subheading would lose that subsection. This PR bounds only the final task, and task-brief: the last task of a section absorbs the following non-Task heading and its prose #2406 stays partly open.
  2. fix(sdd): sdd-workspace fails fast on unusable workspaces, never spins #2621's noclobber marker write (a three-way owns() and a cap of 32): it would also fix sdd-workspace: owns() cannot distinguish 'unusable' from 'foreign-owned' — infinite slug loop; marker claim is check-then-create #2619 and is smaller. This PR keeps the mkdir lock its first version had.
  3. A different ledger result (a labelled last output line, or a TAP-style pass/fail summary as in fix(executing-plans): ledger the test summary, not the trailing duration #2348 and fix(executing-plans): record node --test pass/fail summary, not # duration_ms (Fixes #2342) #2679): not taken. The ledger records the exit status and the log filename, and the test counts are in the log.
  4. One plan identity across worktrees (marker relative to the deepest containing worktree, and .markdown stripped from slugs), from this PR's first version: returned to dev's rule. Neither sdd-workspace: owns() cannot distinguish 'unusable' from 'foreign-owned' — infinite slug loop; marker claim is check-then-create #2619 nor subagent-driven-development: review-package and sdd-workspace fail once a plan task deletes the plan file #2630 needs it, and it would leave in-flight workspaces whose plan sits in another worktree with no matching marker.
  5. This PR's first version's other hardening: an LF rule for skills/*/scripts/* in .gitattributes, task-ID validation in task-done, a separate task-<N>-tests.failed.log, the ledger header taken from the plan-path marker, repair of a ledger with no trailing newline, a stderr warning on a silent pass, creating OUTFILE's directory, a /dev/null OUTFILE branch, and reserving .gitignore and .plan-path slugs. No cited issue asks for any of them, so they returned to dev's text.
  6. fix(sdd): include commit bodies in review packages #2303's commit format (%h %s%n%w(0,4,4)%b): not taken. --format=medium also adds Author and Date lines and full hashes; both show commit bodies.
  7. Writing through a symlink or special-file OUTFILE, as dev does: not taken. dev's own tail reads OUTFILE's size and line count, so with a device or a pipe it reports a found task as missing (exit 3), and on Linux /dev/stdout redirected to a file hangs. task-brief refuses such an OUTFILE instead.

Does this PR contain multiple unrelated changes?

Partly. Every change is in the helper scripts the two plan executors share, or in the skill text that describes what those scripts print. Some changes depend on each other: the #2630 fix runs through sdd-workspace, task-brief, review-package and task-done; the #2493 header and the #2406 bound share task-brief's two-pass scan; and the cached-brief path for #2630 uses the #2611 staging. Others are independent and a few lines each: the commit format (#2298), the ^{commit} checks (#2620), the bash invocations (#2642) and the ledger result (#2342). It is stacked on #2736 because both change skills/executing-plans/SKILL.md and skills/subagent-driven-development/SKILL.md.

Existing PRs

This PR carries no text from another contributor's PR.

Environments tested

Harness (e.g. Claude Code, Cursor) Harness version Model Model version/ID
Antigravity CLI 1.5.16 (via Paseo) Gemini 4 Carbon Gemini 4 Carbon (High)
Claude Code 2.1.325 Claude Opus 5.5 (changes), Claude Fable 5.2 (review) claude-opus-5-5, claude-fable-5-2

New harness support (required if this PR adds a new harness)

N/A — does not add support for a new harness.

Evaluation

Rigor

  • If this is a skills change: I used superpowers:writing-skills and
    completed adversarial pressure testing (paste results below)
  • This change was tested adversarially, not just on the happy path
  • I did not modify carefully-tuned content (Red Flags table,
    rationalizations, "human partner" language) without extensive evals
    showing the change is an improvement

This PR changes skill text (executing-plans/SKILL.md, subagent-driven-development/SKILL.md, implementer-prompt.md), and no pressure testing with agents was done. The adversarial testing is of the scripts: concurrent claims, a stale lock, a blocked .superpowers, CRLF plans, nested and tilde fences, unclosed fences, deleted plans and removed parent directories, dash-prefixed, directory, FIFO and symlink OUTFILEs, tree and blob revisions, and stripped execute bits. This PR changes no Red Flags table, rationalization table or "your human partner" wording.

The original diff had an independent review by several reviewers. A hunk-by-hunk ledger then compared every hunk with dev and kept it only where a cited issue, a confirmed review finding, or a statement verified false required it; the rest returned to dev's text. A separate reviewer checked the rebuilt branch against that ledger, added one commit (d87729d, which drops an awk assignment nothing reads), and re-ran the tests there. Four commits came after that review: the merge of #2736's updated branch (dbed263, which changes none of the scripts), the return of sdd-workspace's usage check to dev's text (22a0cc0), the refusal of a symlink or special-file OUTFILE (6af681b), and the skips for its two test cases (ef91a2a); the checks listed above were run at ef91a2a. Except for the last bullet below, the new and changed tests were run at d87729d against copies of the branch with one change each:

  • All five scripts replaced by fix(worktrees): guard worktree creation, branch finishing, and executor workspace lifecycle #2736's: 26 cases fail in test-sdd-workspace.sh, and in test-executing-plans-scripts.sh 6 fail, which is every new or changed case there (the two ledger lines, the tree BASE, stripped execute bits twice, the deleted plan).
  • The plan-header patch reversed: only "chunked plan: Task 3's brief has the labelled plan header and not Chunk 1" fails.
  • The final-task stderr message put back to the first version's wording: only "final task stops before trailing ## Self-Review / ## Execution Handoff and notes heading on stderr" fails.
  • The "serving cached brief" warning deleted: the two cached-brief cases and the end-to-end case fail.
  • The .lock slug mapping deleted: only "plans named .lock.md and .LOCK.md reserve the lock name case-insensitively" fails.
  • Eight new cases in test-sdd-workspace.sh also pass against fix(worktrees): guard worktree creation, branch finishing, and executor workspace lifecycle #2736's scripts, because they guard paths those scripts already handle. Four were shown to fail under targeted changes: the worker-blockquote skip removed, the header printed with a leading blank line, and the temporary file staged in $TMPDIR. The other four were not shown to fail: "task-brief exits 2 on deleted plan when requested task was never cached", "task-brief exits 2 when plan is deleted and no cached brief exists for task", the review-package unclaimed-plan case, and "canonical candidate workspace wins over alphabetically earlier backup copy"; the last cannot fail under either candidate scheme.
  • At ef91a2a, with task-brief put back to 22a0cc0's copy (no OUTFILE refusal): only the FIFO and symlink cases fail, each with exit 0 and the FIFO or the link replaced by a regular file.

Human review

  • A human has reviewed the COMPLETE proposed diff before submission

@arittr
arittr force-pushed the fix/wave1-executor-helpers branch 4 times, most recently from 737007b to d4140de Compare November 24, 2026 22:00
@arittr
arittr force-pushed the fix/wave1-executor-helpers branch from d4140de to d321f4b Compare November 24, 2026 22:58
@arittr
arittr added this pull request to stack #2747 November 24, 2026 23:29

@danishkumar26 danishkumar26 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code review from Hermes Agent (danishkumar26). No blocking findings.

What this change does:

  • task-brief: two-pass awk scan buffers the plan preamble, strips the controller-only "> For agentic workers:" blockquote, captures only the requested task, and bounds only the final task at equal/shallower non-Task headings — intermediate tasks no longer swallow trailing plan sections (#2406), and final-task lookup misses no longer truncate briefs to 0 bytes (#2611). Plan path and task ID flow through ENVIRON, so backslashes in paths are not mangled (#2459). Unclosed fences exit 4; missing task exits 3; serves a cached brief when an earlier task deleted the plan file (#2630).
  • sdd-workspace: claims a workspace dir with an atomic mkdir(".lock") mutex, stale-PID and empty-lock recovery, worktree/submodule-aware plan_id, reserved-name slugs (.lock, .gitignore, .plan-path). A blocked or unwritable .superpowers fails fast instead of spinning (#2619); deleted plans still resolve via plan-path markers.
  • task-start/task-done/review-package: BASE/HEAD validated as commits (${X}^{commit}); review range guarded with merge-base --is-ancestor and a non-empty commit count (exit 3 for range errors, exit 2 for bad commits); git log --format=medium so commit bodies reach reviewers (#2298); test output staged atomically to task-N-tests.log, failures to task-N-tests.failed.log, ledger appended only on success; task IDs rejected if empty or containing / or ..; scripts invoked via ${BASH:-bash} so zip-stripped exec bits do not break them (#2040, #2642).
  • .gitattributes enforces LF line endings for skills//scripts/.

Verified by running (this checkout):

  • bash tests/claude-code/test-sdd-workspace.sh -> all checks PASS (20-way concurrent colliding claims, stale-PID lock recovery, CRLF plans, nested 4-backtick/tilde fences, deleted plans and removed parent dirs, reserved slugs, absorbed submodules, blocked .superpowers, directory OUTFILE rejection)
  • bash tests/claude-code/test-executing-plans-scripts.sh -> all checks PASS (stripped exec bits on sibling copies, silent commands, nonexistent/removed task IDs, failed re-runs preserving passing logs)
  • bash tests/sdd-helper-paths/test-sdd-helper-paths.sh -> PASS
  • bash -n on all five changed shell scripts -> clean
  • git diff --check -> clean

Not checked: shellcheck lint (shellcheck not installed on this box).

Verdict: Ship.

arittr and others added 15 commits November 26, 2026 01:23
… rule to dev's text where no issue requires a change

task-done keeps what its issues need: BASE is peeled to a commit
(#2620), sdd-workspace runs through bash (#2642), and the ledger
records "exit 0, log: task-<N>-tests.log", or "exit 0 (no output), ..."
when the command printed nothing, in place of a scraped last line
(#2342).

No cited issue asks for the rest, so it reads as on dev again:
- the task-id guard and the validation through task-brief (#2342 never
  mentions task ids), with its two test cases and the deleted-plan
  assertion that pinned it;
- the .failed.log staging with its EXIT trap and temp log, the stderr
  warning for a silent pass and its aside in SKILL.md, the ledger header
  read from the plan-path marker, and the repair of an unterminated
  ledger line, with the five test cases that pinned them;
- the skills/*/scripts/* LF rule in .gitattributes, with its check-attr
  case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s text where no issue requires a change

sdd-workspace keeps what #2619 and #2630 need: the writable-directory
guard, the mkdir claim lock, the bounded claim loop, an empty PLAN_FILE
refused, a missing plan resolved lexically to the workspace that
already claimed it, and a .lock slug, in any case, kept off the lock
directory. review-package keeps its deleted-plan resolution (#2630),
its ^{commit} checks (#2620) and commit bodies (#2298).

Neither issue needs a new plan identity, so dev's rule is back: the
plan-path marker is repo-relative in the repo, absolute outside it.
These read as on dev again, because no cited issue asks for them:
- the worktree-prefix plan_id loop, which merged one plan's workspaces
  across worktrees and left in-flight workspaces behind at upgrade;
- the .markdown slug, the .gitignore and .plan-path reserved slugs, and
  the "root" parent fallback; the slug comes from basename again;
- the comments the rewrite deleted ("Physical path...", "Invoke via
  bash...", "Normalize the plan path...", and the ownership rule now
  above claim_candidate), and the reordered usage check;
- review-package reusing the deleted-plan lookup's directory;
- the test fixture's git_id refactor.

The three cross-checkout identity cases go with the loop, the
absorbed-submodule case goes because it passes on dev and no issue asks
for it, and the reserved-slug case keeps .lock.md and .LOCK.md only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to dev's text where no issue requires a change

task-brief keeps what its issues need: the brief is staged in a temp
file beside OUTFILE and moved into place only after a clean scan, so a
missing task or a failed rerun never empties an existing brief (#2611);
a deleted plan serves the brief already cached in its workspace
(#2630); and the two-pass CommonMark scan bounds the final task and
carries the plan header (#2406, #2493).

No cited issue asks for the rest, so it reads as on dev again:
- the task number passed through ENVIRON; -v n is back, and so is the
  comment on why only the plan path goes through ENVIRON;
- the not-found message and exit 3 moved into awk, and the close of the
  stderr pipe at the end of awk's END; the shell check is back, on the
  staged file, and stderr prints in the same order as before;
- the line count kept in a variable; the "wrote" line counts the
  committed file again;
- creating a missing OUTFILE directory: an explicit OUTFILE in a missing
  directory fails, as on dev;
- the /dev/null OUTFILE branch, which served only the task-id check
  that left task-done, with its two test cases.

Two cases now create OUTFILE's directory before the call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd deleted-plan rules

The rewrite deleted the header that says why the workspace is per plan,
why it is not under .git/, how plan-path markers and legacy adoption
work, and why -C exists (#1799), along with the comments on the
create-only .gitignore and the Windows path print. Those choices still
hold, and nothing else in the file records them.

They read as on dev again, with two sentences added to the marker
paragraph so it describes the script as it now is: the counter stops at
100 and claims run under a mkdir lock whose dead holder is reclaimed
(#2619), and a plan file that no longer exists resolves to the
workspace whose marker already names it (#2630). Only the two lines
those sentences join are rewrapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er's rule

A brief opened with everything above the plan's first Task heading and
nothing to mark where that context ends and the task begins, yet the
task reviewer reads the whole brief as what was requested. In a plan
grouped by chunk or phase, every task also got Chunk 1's heading and
intro.

The header now sits under a label saying its Global Constraints bind
the task and the rest is context, and it ends at the header's last ---
rule, so chunk and phase intros stay out; a header with no rule gets
one. The comment above the scan describes this. The code is the
review's F1/F2 patch (#2493).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l review

The final-task bound keeps a plan's trailing Self-Review and Execution
Handoff out of the last brief (#2406). It also keeps out a closing
"Final verification" or "Done criteria" section, and no step told the
executor to read one: Final Review went straight to the review package,
and task-brief's only trace was a stderr line that read like a
truncation error.

executing-plans' Final Review now opens by telling the executor to run
the checks in those sections first, and task-brief's message says the
plan from that heading on is in no brief. Both texts are the review's
F4. The message's apostrophe is written '\'' so the single-quoted awk
program still parses; pasted as is, it is a syntax error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The brief now carries the plan header ahead of the task (#2493), but
SDD's Task brief step, the implementer prompt and task-brief's own
header comment still said it holds only the task's text. Nothing told
the implementer that part of the brief is shared context, or that its
Global Constraints bind the task; the #2493 thread asked for exactly
that in the implementer template.

All three now say so, in the review's F3 words. SDD's SKILL.md stays
under the 20,000-byte cap (19,928 bytes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…it log

review-package now lists commits with their bodies (git log
--format=medium, #2298), but the fallback for a harness without bash
still told the controller to run git log --oneline, which shows
subjects only. It now says git log, whose default format is the one
review-package uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…plan cases

Two #2630 cases ran task-brief on a deleted plan without capturing its
stderr, so every run printed "task-brief: warning: deleted-plan.md not
found; serving cached brief" twice between PASS lines. Both now send
stderr to a file and check that the warning is there, as the review's
F16 proposed, so the suite's output is clean and a lost warning fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
stderr() set used_stderr so that awk's END could close the stderr pipe
only when something had been printed. Both readers went back to dev's
text with the not-found check, so the flag is set and never read. The
stderr() helper itself stays; awk still closes its pipes at exit, and
the order of stderr lines is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The usage check had gained `|| [ -z "$1" ]` so that an empty PLAN_FILE
is refused now that the relaxed existence check lets a missing plan
through (#2630). The slug check three lines later already refuses it:
basename makes an empty or "." slug of an empty path, and both fail
that check. `sdd-workspace ""` still exits 2 ("cannot derive a
workspace name from: ") and creates nothing, with or without -C. No
cited issue needs the extra condition, so the line reads as on dev
again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2611's staging writes the brief to a temporary file beside OUTFILE and
renames it into place. The rename replaced whatever OUTFILE was: a FIFO
or a symlink became a regular file, and as root a device such as
/dev/null would be replaced too. task-brief now exits 2 unless OUTFILE
is absent or a plain regular file, as it already did for a directory.
Nothing in the skills passes such an OUTFILE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nnot make one

Git Bash copies a file for ln -s unless native symlinks are enabled,
and a shell may lack mkfifo. Each case now probes for the thing it
needs and prints a [SKIP] line when it cannot be made, so the file
still runs on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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