Skip to content

Settle the Fence Scanner's Comments, Which Eight Rounds of Correcting Did Not Converge #1620

Closed

Description

@ptr727

scripts/tests/test_release_guards.py's fence scanner is verified: four adversarial passes over more than two million documents differentially compared against a CommonMark reference, plus 68 mutants all killed, found no way to silently drop a labelled block or hand back a body that changes what bash -n decides. The code is right. Its comments are not, and eight rounds of correcting them did not converge.

The pattern, which is the point of this issue

Each round found false sentences, each round corrected them, and each round's corrections introduced more. The last round diagnosed why and still did it: the comments explain a renderer's reasoning, which is a wider claim than the code supports, so every rephrasing is a fresh assertion about CommonMark rather than a description of a scan. A sentence saying what the scan does can be checked against the scan. A sentence saying why a renderer behaves some way has to be checked against a renderer, and it was not.

The refusals are the worst affected, because the honest reason for most of them is "this scan's rule is deliberately narrower than CommonMark", and successive rounds kept reaching for a more satisfying explanation in terms of containers.

What is false now

  1. # This would take it for blank and slice it away. and the sentence after it, on the blank-line refusals. False of the scan, which tests line.strip(" ") and therefore treats a no-break space as content and raises. The subject meant is a scan using a bare predicate, which the neighbouring comment names explicitly.

  2. # Inside a container it ends that container on a line carrying less than that, and its unedited twin in fenced_blocks. A renderer ends a container on a line carrying less than the container's content column, not less than the opener's indent. For a fence at indent 3 inside an item whose content column is 2, a body line at indent 2 stays in the block where this scan refuses. The refusal is still right, because a three-character slice of that line would drop a character; the stated reason is not.

  3. # A fence sharing a line with anything else needs the container to read. False for the mid-line case it heads: a line carrying anything before a fence run can never be a fence, so no container is involved. This is verbatim the defect the previous round's commit message diagnoses, left standing one comment above the one that was fixed.

  4. Everything else is refused ... because a scan that guesses at the container a fence sits in is the silent miss this scan exists to prevent. The because makes every refusal container-motivated. No container appears in the closer refusals, the unterminated block, the backtick in an info string, the mixed run, or the no-break space after a closer.

  5. Legal Markdown is among what this refuses ... and the refused cases below are the list. No refused case is a second-list-level document, which is one of the two examples the sentence gives, so the case list is not the list for it.

  6. Five silent defects in this scanner were one bare predicate each, two written with the scanner and the rest while fixing something else in it. Two problems: one of the five, a newline-only split, names its character and so is not a bare predicate and could not be caught by the guard; and of the three later ones, one did replace an earlier one of the five, which is what that commit's own message says and what this sentence still does not.

  7. # Left to surface as an unterminated block, it would name a line carrying no fence. No such outcome exists: the unterminated message names the opener, which by construction matched the fence-line pattern.

  8. Three lower-confidence ones. never miss one it does has a counterexample in an info string of a single no-break space. Whitespace after a closing fence is not text after it is contradicted by the file's own no-break-space refusal, where two other comments correctly say "only a space or a tab". And A run of three or more backticks or tildes opens or closes a code block is not true of a mid-line run.

What would settle it

Not another round of rewriting. The rule that would have prevented all of these is that a comment in this file states what the scan does, and cites a renderer only where a case pins the difference. Applying that is a pass over the file with deletion as the default, which is its own change and wants a reviewer who has not spent eight rounds writing the sentences.

Activity

  1. added
    prose
    on Sep 14, 2026
  2. ptr727 commented on Nov 13, 2026

    @ptr727
    OwnerAuthor

    Backlog burndown claim (round 8, group 4, away mode): branch burndown/fence-scanner-comments.

    Issues: #1620.

    Predicted file set:

    • tests/test_release_guards.py (comments and docstrings only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    prose

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions