Repository navigation
Description
Goal
Every issue body and comment body the tracker reads has CRLF normalised to LF once at the package boundary, so the line-anchored scans read a web-editor body as they read an LF one (table test per scanner, no regexp changes); and the task new tests assert the created issue carries exactly the cc:task label. Adopts #296 and #297.
Requirements
M15-R4
Adopts
- Backlog capture: the tracker's line-anchored regexps miss CRLF bodies #296 — Backlog capture: the tracker's line-anchored regexps miss CRLF bodies
- Backlog capture: nothing asserts that task new applies cc:task #297 — Backlog capture: nothing asserts that task new applies cc:task
Plan
Requirement covered: M15-R4 (adopts #296, #297).
The helper. tracker.NormalizeLineEndings(string) string — one \r\n → \n strings.ReplaceAll, exported so the GitHub reader, the scanners, the tests and a fake tracker all share one implementation. No regexp changes.
Where it is applied — two layers, and why both. The boundary alone does not give the guarantee R4 asks for, because Tracker is an interface: IssueBody and Comments are the seam, and a string crossing it carries no promise about its line endings. So the normalisation goes in both places.
- The GitHub-backed readers, where a body actually enters the package:
IssueBody's return, andComment.BodyinComments— the only two methods that return an issue or comment body (Taskcarries labels and state, no body;FileContentreturns a file, not a record, and is out of scope). - Each exported scanner's entry, so a scanner called with a body from anywhere — another backend, a fake tracker, a caller holding a body it did not read through the tracker — cannot see CRLF:
PlanPresent,AdoptedRefs,RequirementIDs(andMismatchedRequirementIDsthrough it),ExtractRecords,UnresolvedGates,ParseVerdicts,StartedBy. It is free when there is nothing to replace —strings.Replacereturns the input unchanged when it finds no match — so the second layer costs a scan, not an allocation.
The ad-hoc one goes. paragraphs (tracker.go ~701) does its own strings.ReplaceAll before splitting; its only callers are ExtractRecords and UnresolvedGates, which now normalise at their entry, so it is deleted and its doc comment says the body reaches it already normalised. Three layers of the same rule is noise; two is the seam.
task new: no behaviour change. taskNewFake.CreateIssue records the labels it is handed and a test asserts the created issue carries exactly [cc:task] — the constant, not a literal — and not cc:milestone (#297).
SPEC §4: one sentence added at the end of the record-grammar reading rules — line endings are not part of the grammar, a CRLF body reads as the LF one. It is a protocol-visible guarantee for anyone who writes a record in the web editor, and it sits beside the sibling rule that code is content.
Tests. A table test in internal/tracker driving every scanner twice, LF and CRLF, through the boundary — the fixture is served by the fakeGH helper as the issue/comment JSON and read back with GitHub{}.IssueBody / GitHub{}.Comments, so the test walks the path a GitHub body takes — asserting the two results are equal and the LF result is the expected one. Plus the task new label assertion in internal/cli. go test ./..., go vet, gofmt -l clean; CHANGELOG entry (#309).
Coordination. #308 paginates Comments, SubIssues and listIssues in the same file; this PR touches only the body line in each reader and rebases onto origin/main before opening.
Ask-the-human points
None.
Activity
radiusred-cody commentedon Sep 6, 2026
Started by @radiusred-cody[bot].
radiusred-cody commentedon Sep 7, 2026
Decision: the CRLF normalisation lives in two layers, not one:
NormalizeLineEndingsis called in the GitHub-backed readers that return a body (IssueBody,Comments) and again at the entry of every exported scanner (PlanPresent,AdoptedRefs,RequirementIDs,ExtractRecords,UnresolvedGates,ParseVerdicts,StartedBy). The ad-hocstrings.ReplaceAllinsideparagraphsis deleted, and nothing below those two layers repeats the rule.Trade-off: R4 asks for two guarantees that no single site gives.
Trackeris an interface, so the reader is the boundary a real body crosses but not the only way a body reaches a scanner: astringcrossing that seam carries no promise about its line endings, andmilestone close,task finishandstatusall call the scanners with whatever their tracker handed them. Normalising only ingithub.goleaves a second backend, a fake tracker, or a caller holding a body it read some other way able to feed CRLF straight into a(?m)…$scan. Normalising only in the scanners leavesComment.Bodyitself carrying CRLF intointernal/cli, where the citation walk reads the same text. So both: the reader makes the data one shape, and the scanner makes the reading unconditional. The second pass is free where there is nothing to replace —strings.Replacereturns its input unchanged when it finds no match — so it costs a scan, not an allocation.Rejected: normalising inside the unexported helpers instead (
section,adoptsSection,paragraphs,StripCode). It is the same work spread over more sites, it puts the rule below the level a reader looks for it, and it would have had to be repeated on each new helper. Keeping the ad-hoc call inparagraphsas a third layer was also rejected: its only two callers are exported scanners that now normalise at their entry, and three copies of one rule is noise — its doc comment states the precondition instead.Decision: the table test drives each scanner through
GitHub{}.IssueBodyandGitHub{}.Comments— the fixture is served as the issue and comment JSON by the existingfakeGHhelper — rather than calling the scanners with hand-made strings.Trade-off: it needs a few lines in
TestHelperGH(which now answers an issue read and a comment listing from the environment, finding the REST path by itsrepos/prefix so a paginating reader's extra flags cannot hide it), but it proves the path a GitHub body actually takes instead of the path the test invented. It also means the test would still catch a regression if the boundary layer were removed and only the scanner layer left, and the other way round.Deviation: none from the plan; this is the plan as written, recorded here as the contract asks.
Measured against the code with the normalisation removed everywhere, three of the eight rows fail:
AdoptedRefs(the## Adoptsheading is matched by a(?m)…$line, so a CRLF body yields no adoptions at all),ExtractRecordsandUnresolvedGates(the paragraph split collapses the whole comment into one paragraph, so a**Decision:**swallows the**Gate raised:**after it). The rest —PlanPresent,RequirementIDs,MismatchedRequirementIDs,ParseVerdicts,StartedBy— read a CRLF body correctly already, by not being anchored to a line's end; their rows are the guard that keeps it that way, which is what R4 asks for.radiusred-cody commentedon Sep 7, 2026
Decision: SPEC §4 gets the sentence. At the end of the record-grammar reading rules, beside the rule that code is content: "Line endings are not part of the grammar: a body saved with CRLF — what a web editor writes — is read exactly as the same body written with LF, in the record scans and the
## Adoptssection alike."Trade-off: R4 leaves the call to the implementer, and the argument for silence is that this is an implementation correction, not a protocol change — the grammar was always meant to be read this way, and §4 does not otherwise describe how bytes reach the scanner. The argument that won is that a human writing a record does so in GitHub's web editor, which is exactly the thing that produces CRLF: the reader who needs the guarantee is the reader §4 is written for, and until now nothing told them whether a Decision typed in the browser would be found. One sentence, no new grammar, and it sits with the sibling rule about code rather than opening a section of its own.
Rejected: describing the normalisation itself (where it happens, that it is
\r\n→\n). That is implementation, it belongs in the code and the changelog, and SPEC §4 states what a record is, not how the tracker reads bytes.Decision:
Comment.Bodyis normalised, butUnresolvedGatesstill returns theCommentvalues it was given rather than normalised copies.Trade-off: the comments it returns already carry LF when they came through
Comments, which is every caller; making the scanner rewrite them as well would change what it returns for a caller that built its own, for no gain —task finishreads.URLand the count. Scanning is the scanner's job; rewriting its input is not.fix: the tracker reads a CRLF body exactly as it reads the LF one (#309)
test: task new applies cc:task, asserted where the issue is created (#…
docs: line endings are not part of the record grammar (#309)
docs: the changelog entry for the CRLF normalisation and the label te…
fix: the tracker reads a CRLF body exactly as it reads the LF one (#309)
test: task new applies cc:task, asserted where the issue is created (#…
docs: line endings are not part of the record grammar (#309)
docs: the changelog entry for the CRLF normalisation and the label te…
test: each CRLF row is read straight into the scanner too, pinning bo…
4 remaining items
docs: the changelog entry for the CRLF normalisation and the label te…
test: each CRLF row is read straight into the scanner too, pinning bo…
fix: the tracker reads a CRLF body exactly as it reads the LF one (#309)
test: task new applies cc:task, asserted where the issue is created (#…
docs: line endings are not part of the record grammar (#309)
docs: the changelog entry for the CRLF normalisation and the label te…
test: each CRLF row is read straight into the scanner too, pinning bo…
test: the header says what the through-reader rows pin, and what pins…
fix: the tracker reads a CRLF body exactly as it reads the LF one (#309)
test: task new applies cc:task, asserted where the issue is created (#…
docs: line endings are not part of the record grammar (#309)
docs: the changelog entry for the CRLF normalisation and the label te…
test: each CRLF row is read straight into the scanner too, pinning bo…
test: the header says what the through-reader rows pin, and what pins…