Repository navigation
fix(sdd): stop task-brief leaking trailing plan sections - #2359
akalongman wants to merge 2 commits into
Conversation
The trailing-section leak this fixes is real and worth fixing — the corpus numbers check out (I reproduced 13 of the 13 repo-plan cases). But the new terminator also cuts a task at a same-level heading that is genuinely part of the task, and it does so silently, with exit 0. Blocker — ### Task 1: Build the widget
### Requirements
Must support A, B, C.
### Steps
1. Do AOn Related: same-name/ambig is not the only escape. The Minor — the CRLF close-check is narrower than #2304's. Line 54 uses |
|
Checked both points against the branch. The same-level heading case. The constructed example ( I also measured the pattern over the 123 plans on this machine, 969 To make the behaviour explicit rather than silent, the branch now carries two test cases: a fenced same-level heading stays in its task (the cited plan's shape), and an unfenced one ends it. If you have a real plan where an unfenced same-level heading is part of the task, I would like to see it; the corpus here has none. CRLF. Agreed, aligned the close check with #2304's |
A task ended only at the next Task heading, so sections after the last task (Self-review, Done when, Notes) rode into that task's brief. A task now also ends at the next heading of the same or a shallower level, when two fence parses agree the heading sits outside a code fence. Task IDs keep the whole-ID match of obra#2604, and sub-task headings stay in their parent's brief. Three assertions added to tests/claude-code/test-sdd-workspace.sh.
The strict fence parser's close check now allows a trailing carriage return, the form obra#2304 landed. Two test cases make the same-level heading rule explicit: a fenced same-level heading stays in its task (the shape real plans use to quote text for insertion), an unfenced one ends it (a sibling section such as Self-review or Done when).
e3136cf to
d270494
Compare
danishkumar26
left a comment
There was a problem hiding this comment.
What this change does: Rewrites the task-brief ending rule in skills/subagent-driven-development/scripts/task-brief so a task stops at the next same-or-shallower heading (level 2+) instead of leaking trailing plan sections (Self-review, Done when) into the last task's brief. Adds a second, stricter fence parser (cfence) alongside the existing one; a heading ends a task only when both parsers agree it is outside a fence, otherwise the old behavior stands. Adds five test scenarios covering trailing sections, deeper sub-headings, ambiguous fencing, fenced same-level headings, and unfenced same-level headings.
- (Nothing to fix.) The rule is confined to one awk block with the in-code contract documented; deeper headings (e.g.
#### Notes) still belong to the task. Verified locally: all task-brief assertions pass, exit 0, including the 5 new scenarios.
Verdict: Ship.
Not checked: none — script-level change, test suite runs locally.
Who is submitting this PR? (required)
claude-fable-5-1) ran the session; Claude Opus 5, 1M context (claude-opus-5[1m]) subagents measured the transcripts, drafted this diff and ran the testsWhat problem are you trying to solve?
scripts/task-briefstarts a task at itsTask Nheading and ends it onlyat the next
Task <digits>heading, so the last task of a plan absorbs everysection that follows it. Plans written by
writing-plansroutinely end with## Self-review notes,## Done when,## Final verificationor a## Verification checklist, and those land in the brief that is handed to animplementer as its requirements.
It happened in a real run. In a 14-task plan executed with SDD on
2026-09-19, the brief for the last task
(
task-16-brief.mdin that run's workspace) is31 lines, and line 27 is
## Self-review notes, the plan author's ownchecklist. The implementer for that task received it as part of its
requirements, and the task reviewer received the same file as What Was
Requested.
It happens in this repository's plans too. Extracting every task of every
plan under
docs/superpowers/plans/with the shipped script, 13 taskextractions across 10 plans carry a trailing section:
## Self-Review Checklistinto the last task of the visual-companion plans,## Amendment 1through
## Amendment 4into four tasks of2026-07-30-codex-efficiency-fixes.md,## Verification checklist (run after Task 15)into task 15 of2026-05-06-lift-drill-into-evals.md,## Chunk 2and
## Chunk 3group headers into the tasks that precede them.Across 93 real plans on this machine (732 task extractions), 78 extractions
carry 847 lines of text that belongs to no task.
What does this PR change?
A task now also ends at the next heading of level 2 or deeper that is not
deeper than the task's own heading, and only where two independent fence
parses agree the heading is outside a fenced example.
Rebased on 2026-11-12 onto
devat df2e996, after #2604, #2605 and #2606reworked
task-brief. The terminator is now a rule of its own afterdev'sTask-heading rule, and
dev's whole-ID match, sub-task rule andunclosed-fence refusal stay as they are. The terminator never fires inside
dev's fence, so a fence that never closes still refuses (exit 4) or warnsexactly as before.
Is this change appropriate for the core library?
Yes. It is a correctness fix to a shipped core script that every SDD run
calls once per task. No new dependency, no new file, no project-specific
behaviour.
What alternatives did you consider?
End the task at any
##heading that is not a Task heading. Rejectedafter measuring it: plans embed whole markdown documents inside a task (this
repository's
2026-04-06-worktree-rototill.mdpastes a full SKILL.md, and2026-08-27-diagnosing-superpowers.mdpastes prompt files), and their innerheadings then cut the task short. On the repository's own plans that variant
truncated task 2 of the rototill plan from 261 lines to 60 and task 4 of the
diagnosing plan from 305 to 43. Losing requirements is a much worse failure
than carrying a checklist, so the terminator is gated instead.
Fix the fence tracking and rely on it alone. The existing every-fence-line
toggle mistracks tilde fences, nested fences and indented fences, which is
what #2304 fixes. But the embedded documents above are genuinely ambiguous
markdown: a bare
inside amarkdown block closes it under CommonMark,however the author meant it, so a single correct parser still cuts those
tasks short. Requiring two parsers to agree is what makes the new terminator
safe on plans that already exist.
Name the trailing sections (
Self-review,Done when, ...). A word listcannot cover
## Amendment 2or## Chunk 3, and it would have to grow withevery plan template.
Leave it to the plan author. The plans that leak were written by
writing-plansand are well formed; nothing in the plan format says a taskowns everything below it until the next task.
Does this PR contain multiple unrelated changes?
No. One script, one behaviour, plus its tests.
Existing PRs
(searched on 2026-09-21, open and closed, for task-brief, fence, Task 6b,
subagent-driven-development, and the same terms across issues)
#2176 (open, issue #2175) fixes the neighbouring half of the terminator:
Task 6bmatching a request forTask 6. #2604 has since fixed the same ondevwith a whole-ID match, which this PR keeps as it is, so the two halvescompose on
devitself: the ID match stops a letter-suffixed sibling taskfrom merging in, this PR stops a non-task section from merging in.
#2304 (open) rewrites the fence rule to follow CommonMark, for a different
symptom: a fenced example containing
### Task 99ends the real task early.This PR leaves the existing fence line untouched and adds its stricter parse
under a separate name, so the two do not conflict textually. If #2304 lands
first, the
cfenceparse here becomes partly redundant and the terminatorcan be gated on the corrected
infencealone, at the cost of the ambiguousembedded-document case; I would rather keep both parses and say why.
#1949, #1938 and #1858 touch where the brief is written, not what it
contains.
Environment tested
New harness support (required if this PR adds a new harness)
Not applicable. No harness is added.
Clean-session transcript for "Let's make a react todo list"
Evaluation
work through
subagent-driven-development, using the transcripts of fivereal runs. The leaked
## Self-review notesin a real task brief came outof reading the workspace those runs left behind.
files rather than sessions: every task of 93 real plans (732 extractions)
and of this repository's 16 plans was extracted with the shipped script and
with the fixed one, and every difference was read.
gains a line, and the first line dropped is a plan-level heading in every
case (
## Self-review notes7 times,## Self-Review6,## Self-review5,
## Done when5,## Final verification3, then## Spec coverage check,## Notes for the reviewer,## Out of scope for this plan,## Execution handoff,## Chunk 2, and so on).dev's script: 2092 extractionsfrom 260 plans, of which 167 lose 2902 lines in total. No extraction gains
a line or changes its exit status, every change only drops lines from the
end, and the first line dropped is a plan-level heading in every case.
Rigor
superpowers:writing-skillsandcompleted adversarial pressure testing (paste results below)
rationalizations, "human partner" language) without extensive evals
showing the change is an improvement
No skill prose changes, so the writing-skills box does not apply. The
adversarial cases are in the new fixtures and in the corpus run: a task with
deeper sub-headings of its own (kept), a plan-level section after the last
task (cut), a task containing an embedded markdown document with a bare
closing fence (not cut, because the parses disagree), and the 93-plan corpus
where the rule had to produce no new truncation anywhere.
bash tests/claude-code/test-sdd-workspace.shpasses on the rebased branch,72 assertions, five of them new:
Against
dev's script the two that expect a section cut off (the first andthe last) fail, and the three guards pass.
scripts/lint-shell.sh(ShellCheck 0.11.0) passes on bothchanged files.
Human review