* test(#3898): a spaced-hyphen thematic break in ## Gaps is not an entry (failing first) * fix(#3898): a separator-shaped line in ## Gaps is skipped, not made an entry splitGapsEntriesCore's opener regex (/^(\s*)-\s/) matched a spaced hyphen thematic break, fabricating a gap named '- -' with result 'unknown' — surfaced by audit-uat as an outstanding finding that cannot be cleared by editing any entry, because there is no entry, only the separator the author wrote for readability. Five shapes were affected (- - -, -, and wider/indented variants); the unaffected ones (---, ----, * * *, ___) were safe only by accident — the path never matched them, not because it understood breaks. A line whose content after the opening marker is solely hyphens and whitespace (with at least one further hyphen) is now skipped entirely — neither an opener nor a continuation. Deliberately option 2 from the issue, not a full thematic-break concept: a break does not close the Gaps list, entries after it keep parsing, and the deliberately-frozen byte-for-byte Gaps behavior changes ONLY for documents carrying such a separator (which previously produced a phantom). A real entry whose truth begins with a hyphen (- truth: "-5 error budget...") is untouched — its remainder contains non-hyphen characters. * fix(#3898): review fold-ins — span-contiguous skip, property coverage The skip is narrowed to where the phantom came from: a separator-shaped line BETWEEN entries (nothing open, or it would open a top-level entry). One landing strictly inside a live entry (indent > baseIndent) folds back as a continuation line, so entry lines and the GapsEntrySpan agree byte-for-byte — the span invariant and the #3805 ack writer's identity re-verification both hold (the review traced the unconditional skip to a match_verification_failed refusal in that corner). Adds the parser- convention property test (arbitrary hyphen counts/indents/spacings) and a span-contiguity pin. * chore(#3898): changeset fragment (pr number backfilled after PR creation) * chore(#3898): backfill changeset PR number (4057) --------- Co-authored-by: sim <sim@local>
This commit is contained in:
27
src/uat.cts
27
src/uat.cts
@@ -2613,9 +2613,36 @@ function splitGapsEntriesCore(sectionBody: string): GapsEntrySpan[] {
|
||||
}
|
||||
};
|
||||
|
||||
// #3898: a spaced-hyphen thematic break (`- - -`, `- -`, `- - -`, …) is a
|
||||
// SEPARATOR, not an entry. The opener regex below matches it (hyphen +
|
||||
// whitespace), which fabricated a gap named `- -` with result 'unknown' —
|
||||
// an item that cannot be cleared by editing any entry, because there is no
|
||||
// entry, only the separator the author wrote deliberately. A line whose
|
||||
// content after the opening marker consists solely of hyphens and spaces
|
||||
// (with at least one further hyphen) is skipped entirely: it neither opens
|
||||
// an entry nor is folded into the current one. This is deliberately NOT a
|
||||
// full thematic-break concept (option 2 in the issue): a break does not
|
||||
// close the Gaps list — entries after it keep parsing.
|
||||
const isSeparatorShaped = (line: string, bulletPrefixLen: number): boolean => {
|
||||
const remainder = line.slice(bulletPrefixLen);
|
||||
return /^[-\s]*$/.test(remainder) && remainder.includes('-');
|
||||
};
|
||||
|
||||
rawLines.forEach((rawLine, idx) => {
|
||||
const line = rawLine.replace(/\r$/, '');
|
||||
const bulletMatch = line.match(/^(\s*)-\s/);
|
||||
// Narrowed skip (review disposition a): a separator-shaped line is skipped
|
||||
// only when it sits BETWEEN entries (nothing open yet, or it would open a
|
||||
// top-level entry — where the phantom came from). One landing strictly
|
||||
// INSIDE a live entry (indent > baseIndent) folds back as a continuation
|
||||
// line, so the entry's GapsEntrySpan stays byte-contiguous — the span
|
||||
// invariant below and the ack writer's identity re-verification both hold.
|
||||
if (
|
||||
bulletMatch && isSeparatorShaped(line, bulletMatch[0].length) &&
|
||||
(current === null || bulletMatch[1].length <= (baseIndent ?? 0))
|
||||
) {
|
||||
return; // separator line between entries — neither an opener nor a continuation
|
||||
}
|
||||
if (bulletMatch) {
|
||||
const indent = bulletMatch[1].length;
|
||||
if (baseIndent === null) baseIndent = indent;
|
||||
|
||||
Reference in New Issue
Block a user