Repository navigation
Conversation
`todo close` found `## Acceptance criteria` and `## Evidence` by the first line containing that text, so a quote of the heading in prose or inside a code fence was read as the section and a task closed with its real criterion unticked or its real evidence empty. textutil.Section now matches the heading as a whole line outside fences, and the spec reader and the section-presence checks go through the same rule. Fixes azrtydxb#336 docs: none — internal parsing fix, the documented heading format is unchanged
This branch has not been deployed
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.
What
procoder todo closenow finds## Acceptance criteriaand## Evidenceonly when the heading is a line of its own, outside a fenced code block. If the heading is quoted in prose, after>or-, or inside a fence, it no longer counts as the section. The same applies to every other reader that takes a section from a Markdown document.Why
Fixes #336.
textutil.Sectionfound the heading withstrings.Index(text, "## "+name), so it took the first line that contained the heading text. In repro 1, prose quoting`## Acceptance criteria`above the real section was read as the criteria, and the task closed with its real criterion still- [ ]. In repro 2, a fenced## Evidenceexample above an empty real## Evidencewas read as the evidence, and the task closed with no evidence.How
The fix goes in
textutil.Section, becausetodo close,backlog close story, spec, plan, analysis, adr and sprint all read sections through it:textutil.SectionSpanwalks the text line by line. A heading matches only when the line is exactly## <name>, with trailing whitespace allowed (so a CRLF\rstill matches). Backtick and tilde fences (three or more characters, indented by up to three spaces) are tracked. A heading inside a fence does not start a section, and a##line inside a fence does not end one.Sectionand the newHasSectionboth useSectionSpan.spec/truth.gohad its own copy (sectionOf/lineOf, which searched for"## name\n"), so it had the same problem. It now usesSectionSpanon the EOL-normalised text. Line numbers are unchanged.strings.Contains(text, "## "+s):backlogmissingSections, and thesection missingchecks in spec, plan and analysis. They now usetextutil.HasSection, so a quoted heading can't count as a real one there either.Behaviour change to question: a heading with extra text on the same line (e.g.
## Evidence (draft)) used to be accepted as a prefix match and no longer is. The issue asks for exact whole-line matching, and the templatesprocoderwrites always produce the bare heading.Testing
go test ./...: all packages pass.internal/todotestTestCloseReadsTheRealHeadingNotAQuoteOfItcovers both repros from the issue. Both tasks must be refused (exit 1) with "unchecked" / "Evidence is empty".internal/textutiltestTestSectionIgnoresQuotedAndFencedHeadingscovers headings quoted in backticks, after>and-, and inside a fence; a fenced##line in the body; a CRLF heading; andHasSection.// proved by:lines and saw the tests fail:line == headingtostrings.Contains(line, heading): the backtick repro closes with exit 0, and the textutil test reads the quoted copy.go run ./cmd/procoder check: formatting, lint (golangci-lint 2.15.0) and Go complexity are clean. The docs obligation for the new exportedSectionSpan/HasSectionis acknowledged with adocs: noneline in the commit message. gitleaks, semgrep and ruff are not installed locally, so those checks did not run.go run ./cmd/procoder git: no findings beyond the existing info notes.Notes for the reviewer
Start at
SectionSpanininternal/textutil/textutil.go. The other source changes are one-line switches over to it. There are nodist/, version or CHANGELOG changes.