Skip to content

fix(sdd): task-brief fails loudly on an unclosed code fence (#2436) - #2438

Draft
ada-sen wants to merge 1 commit into
obra:devfrom
ada-sen:fix/task-brief-unclosed-fence
Draft

ada-sen wants to merge 1 commit into
obra:devfrom
ada-sen:fix/task-brief-unclosed-fence

Conversation

@ada-sen

@ada-sen ada-sen commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Targets dev.

Who is submitting this PR? (required)

Field Value
Your model + version Claude (persistent-box worker), dispatched for recon/triage on SDD issues
Harness + version headless — no interactive IDE session; reproduced and tested from source with bash/git/gh only
All plugins installed none — worked directly against a checkout of this repo
Human partner who reviewed this diff pending — opened as a draft for review before merge

What problem are you trying to solve?

#2436: skills/subagent-driven-development/scripts/task-brief toggles an
infence flag on any line beginning with three backticks, and uses it to
avoid treating a Task N heading inside a fenced example as a real task
boundary:

/^```/ { infence = !infence }
!infence && /^#+[ \t]+Task[ \t]+[0-9]+/ {
  intask = ($0 ~ ("^#+[ \t]+Task[ \t]+" n "([^0-9]|$)"))
}
intask { print }

If the plan contains an unclosed fence — an odd number of fence-start
lines, e.g. an edit deletes a closing ``` while touching a code block —
infence never flips back to false. Every later real `Task` heading is
then invisible to the `!infence && ...` guard, `intask` is never cleared,
and extraction silently runs to EOF, absorbing every later task's content
into the requested task's brief.

The script's only guard on its output is "is it non-empty"
([ ! -s "$out" ]), so this returns exit 0 with a normal-looking
wrote <path>: <n> lines message — nothing signals that the brief now
contains several tasks' worth of requirements.

Reproduced deterministically from the issue's plan
(skills/subagent-driven-development/scripts/task-brief plan.md 1 out.md,
unmodified dev HEAD):

Plan Exit Lines ### Task headings in output Later-task markers leaked
fence unclosed 0 20 3 2
fence closed (control, only that one line changed) 0 14 1 0

This matches the issue report exactly. In real SDD use this hands an
implementer subagent "its requirements" that are actually several tasks'
worth of scope, including work explicitly assigned to later tasks.

What does this PR change?

Adds an END block to the awk program that exits 1 when a fence is
still open at EOF, and has task-brief turn that into a clear stderr
message and a new exit code (4), removing the bogus, over-captured output
file instead of leaving it on disk. The normal (closed-fence) path is
byte-for-byte unchanged.

Is this change appropriate for the core library?

Yes. task-brief is a core script in the shipped subagent-driven-development
skill, called once per task on every SDD run. The fix is a correctness/
safety check on that script's own output, with no new dependency, no new
file, and no project-specific behavior.

What alternatives did you consider?

  • Detect leaked Task headings in the output instead of tracking fence
    state.
    Rejected: a ### Task N heading can legitimately appear inside
    a properly closed fenced example (it's meant as illustrative text), so
    "a Task heading is present in the output" isn't by itself a reliable
    signal of over-capture. Fence-open-at-EOF is a direct, unambiguous fact
    about the document instead.
  • Only fail when content would actually be lost (i.e., only if there is
    a next task after the unclosed fence).
    Rejected: an unclosed fence
    makes the plan itself malformed, and silently trusting it for any task
    silently extracted before this point is already underwriting the exact
    gap this issue reports. Failing unconditionally also keeps the fix a
    single small, easily-audited change instead of a second code path.
  • Loosen fence detection instead (CommonMark-correct fence character and
    length, ~~~, nesting, etc.).
    That's task-brief: track fence character and length so fenced examples cannot end a task early #2304, already open, and it
    explicitly does not address this: every case it fixes causes extraction
    to stop early; this issue is extraction running long because of a
    fence that is genuinely never closed in the source document, which no
    refinement of fence detection can close. I did not check out task-brief: track fence character and length so fenced examples cannot end a task early #2304's
    branch; this assessment is from its diff and stated scope, not a tested
    claim about interaction effects.

Does this PR contain multiple unrelated changes?

No — one change to task-brief's awk program plus the matching test-suite
addition (and control case) for the same script.

Existing PRs

Environment tested

Harness (e.g. Claude Code, Cursor) Harness version Model Model version/ID
bash (headless, no IDE) GNU bash 5.x, Linux container — —

Ran tests/claude-code/test-sdd-workspace.sh: added the issue's repro and
its closed-fence control as two new assertions. Confirmed RED against the
unmodified script (stashed the fix, re-ran: [FAIL] task-brief fails (exit 4) and writes no brief when the plan has an unclosed fence) and
GREEN with the fix; full suite 26/26 assertions pass. scripts/lint-shell.sh
(default and --strict) is clean on both changed files.

Evaluation

  • Initial prompt: recon dispatch on obra/superpowers subagent-driven-development issues, task-brief: an unclosed fence makes one task's brief absorb every later task, at exit 0 (Claude Code) #2436 prioritized — reproduce the claim from source, fix if small and clear.
  • Eval sessions after change: 1 manual end-to-end repro in a throwaway directory (the issue's own unclosed-fence plan and its closed-fence control), plus the automated test suite run RED (unmodified script) and GREEN (fixed script).
  • Before: unclosed fence → exit 0, 20-line brief containing Task 1 plus all of Task 2 and Task 3 (2 marker lines leaked). Closed fence (control) → exit 0, correct 14-line single-task brief.
  • After: unclosed fence → exit 4, clear stderr message, no output file written. Closed fence (control) → unchanged, byte-for-byte identical 14-line output.

Rigor

  • If this is a skills change: I used superpowers:writing-skills and
    completed adversarial pressure testing (paste results below) — N/A,
    this is a bash script fix (task-brief's awk extraction), not skill prose.
  • This change was tested adversarially, not just on the happy path
    (confirmed the failure path reproduces exactly as described in the
    issue before the fix; confirmed the closed-fence control path is
    byte-for-byte unchanged after the fix)
  • I did not modify carefully-tuned content (Red Flags table,
    rationalizations, "human partner" language) without extensive evals
    showing the change is an improvement

Human review

  • A human has reviewed the COMPLETE proposed diff before submission

Opened as a draft pending that human review — not to be merged as-is.

skills/subagent-driven-development/scripts/task-brief toggles an
`infence` flag on any line beginning with three backticks, and uses it
to avoid treating a `Task N` heading inside a fenced example as a real
task boundary. If the plan has an unclosed fence (an odd number of
fence-start lines, e.g. a closing fence was deleted while editing),
`infence` never flips back off, so every later real `Task` heading
becomes invisible to the `!infence && /^#+.../ ` guard and extraction
runs to EOF, absorbing all later tasks into the requested task's brief.
The script's only guard was "is the output non-empty", so this returns
exit 0 with a normal-looking "wrote <path>: <n> lines" message.

Add an END block to the awk program that exits 1 when a fence is still
open at EOF, and have task-brief turn that into a clear stderr message
and exit 4, removing the (bogus, over-captured) output file instead of
leaving it on disk.

Reproduced deterministically with the plan from the issue: unmodified
script exits 0 with a 20-line brief for "Task 1" that contains Task 1
plus Task 2 and Task 3 in full (2 marker lines leaked); closing the
fence, the only change, gives a correct 14-line, single-task brief.
Added the same repro (and its closed-fence control) as a new case in
tests/claude-code/test-sdd-workspace.sh: RED against the unmodified
script (confirmed by stashing the fix and re-running), GREEN with the
fix. Full suite: 26/26 assertions pass. scripts/lint-shell.sh (default
and --strict) is clean on both changed files.

Fixes obra#2436.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skill:subagent-driven-development The subagent-driven-development skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants