diff options
| author | Jesse Vincent <jesse@fsck.com> | 2026-10-22 22:31:14 +0000 |
|---|---|---|
| committer | Jesse Vincent <jesse@fsck.com> | 2026-10-23 03:38:19 +0000 |
| commit | f75c01fd9b320060c301e2c6591dfc74a8436f15 (patch) | |
| tree | 56f1e02460ebe2aa835f36582521cd6e80adf564 /tests/claude-code | |
| parent | b58deb3b948d4c305feeac122700100419ee2777 (diff) | |
fix(sdd): task-brief recognizes alphanumeric task IDs and matches them whole
task-brief only treated `Task` followed by digits as a task heading, and
found the requested task by splicing TASK_NUMBER into a regex followed
by `([^0-9]|$)`. Plans that number tasks by lane (`### Task A1`,
`### Task B2`) could not be extracted at all: `task-brief plan.md A1`
exits 3 "task A1 not found" (#2459). Among 1,288 distinct plans in Jesse's
own repositories, 19 plans have such headings (262 headings, IDs like A1,
M3a, F.2, W0), and none of those tasks could be briefed.
The same splice made the match a prefix match: Task 6 also took a sibling
Task 6b (#2175), Task 1 took Task 1.1 and 1.2, Task 2.1 took Task 201
because `.` is any character, and an ID like `6(` crashed awk (#2405).
A task heading is now `Task` followed by an ID made of letters and digits,
optionally dot-separated, that contains at least one digit. The digit is
what keeps `## Task Overview` or `#### Task notes` from becoming a task
boundary. awk extracts the heading's ID and compares it to TASK_NUMBER as
a whole string, so TASK_NUMBER never reaches awk as a regex.
A deeper Task heading whose ID extends the requested one with a letter or
dot is a sub-task and stays in the parent's brief, as the prefix match
happened to do before: plans in that corpus nest `#### Task 1a` under
`### Task 1`, and a Task 1 brief without its sub-tasks would lose most of
its requirements. A sub-task's own brief ends at its next sibling. Depth
alone is not the test, because plans also drift from `## Task 1` to
`### Task 2`, and those are siblings.
The heading word stays the English literal `Task`, which is what
writing-plans' template uses. Widening it to any word would turn the
`Phase 1`, `Chunk 2` and `Step 1` headings that plans commonly carry
(308, 182 and 56 of them in the same corpus) into tasks.
Claude-Session: https://claude.ai/code/session_01SHANcr4A71nzuU9et4Fnba
Diffstat (limited to 'tests/claude-code')
| -rwxr-xr-x | tests/claude-code/test-sdd-workspace.sh | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/tests/claude-code/test-sdd-workspace.sh b/tests/claude-code/test-sdd-workspace.sh index 16cf50d..667e5a0 100755 --- a/tests/claude-code/test-sdd-workspace.sh +++ b/tests/claude-code/test-sdd-workspace.sh @@ -140,6 +140,118 @@ PLAN echo " got: $brief_path" fi + # --- Task IDs: alphanumeric (#2459), matched whole, never as a prefix --- + cat > "$repo/plan-ids.md" <<'PLAN' +# Lanes Plan + +## Task Overview + +Shared context; not a task. + +### Task A1: First lane + +BODY-A1 + +#### Task notes + +Still part of A1. + +### Task A10: Same lane, later + +BODY-A10 + +### Task 6: Numbered + +BODY-6 + +### Task 6b: Sub-task + +BODY-6B + +### Task 2.1: Dotted + +BODY-2.1 + +### Task 201: Decoy + +BODY-201 +PLAN + local id want got id_out="$TEST_ROOT/id-brief.md" + for id in A1 A10 6 6b 2.1 201; do + want="BODY-$(printf '%s' "$id" | tr '[:lower:]' '[:upper:]')" + rc=0 + (cd "$repo" && "$SDD_SCRIPTS/task-brief" plan-ids.md "$id" "$id_out" >/dev/null 2>&1) || rc=$? + got="$(grep '^BODY-' "$id_out" 2>/dev/null | tr '\n' ' ')" || true + if [[ "$rc" -eq 0 && "$got" == "$want " ]]; then + pass "task-brief extracts Task $id and nothing else" + else + fail "task-brief extracts Task $id and nothing else" + echo " exit: $rc, bodies: $got" + fi + : > "$id_out" + done + (cd "$repo" && "$SDD_SCRIPTS/task-brief" plan-ids.md A1 "$id_out" >/dev/null 2>&1) || true + if grep -q 'Still part of A1.' "$id_out"; then + pass "a Task heading with no digit in its ID is not a task boundary" + else + fail "a Task heading with no digit in its ID is not a task boundary" + echo " brief: $(cat "$id_out" 2>/dev/null)" + fi + # A deeper heading whose ID extends the task's (7 -> 7a) is a sub-task and + # stays in the parent's brief; a deeper heading for another task (a plan + # that drifts from ## Task 9 to ### Task 10) is still a boundary. + cat > "$repo/plan-nested.md" <<'PLAN' +### Task 7: Parent + +BODY-7 + +#### Task 7a: First part + +BODY-7A + +#### Task 7b: Second part + +BODY-7B + +### Task 8: Next + +BODY-8 + +## Task 9: Shallower heading + +BODY-9 + +### Task 10: Deeper, but not a sub-task + +BODY-10 +PLAN + for id in 7 7a 7b 8 9 10; do + case "$id" in + 7) want="BODY-7 BODY-7A BODY-7B " ;; + *) want="BODY-$(printf '%s' "$id" | tr '[:lower:]' '[:upper:]') " ;; + esac + rc=0 + (cd "$repo" && "$SDD_SCRIPTS/task-brief" plan-nested.md "$id" "$id_out" >/dev/null 2>&1) || rc=$? + got="$(grep '^BODY-' "$id_out" 2>/dev/null | tr '\n' ' ')" || true + if [[ "$rc" -eq 0 && "$got" == "$want" ]]; then + pass "nested plan: Task $id brief holds exactly its own section" + else + fail "nested plan: Task $id brief holds exactly its own section" + echo " exit: $rc, bodies: $got (want: $want)" + fi + done + + for id in 2 '2|6' '6(' Overview; do + rc=0 + (cd "$repo" && "$SDD_SCRIPTS/task-brief" plan-ids.md "$id" "$id_out" >/dev/null 2>&1) || rc=$? + if [[ "$rc" -eq 3 ]]; then + pass "task-brief '$id' matches no task (exit 3)" + else + fail "task-brief '$id' matches no task (exit 3)" + echo " exit: $rc, brief: $(cat "$id_out" 2>/dev/null)" + fi + done + # --- review-package takes the plan first and lands in its directory --- local git_id=(-c user.email=t@example.com -c user.name=t -c commit.gpgsign=false) ( cd "$repo" \ |
