Skip to content

feat: name a line in an allow entry - #251

Merged
webern merged 9 commits into
mainfrom
m/deslag-allowraw
Nov 2, 2026
Merged

webern merged 9 commits into
mainfrom
m/deslag-allowraw

Conversation

@webern

@webern webern commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

AI Summary

An allow entry could only name a sentence. But banned_chars also reports characters in frontmatter, in HTML blocks and in a no-break space between two sentences, and no sentence holds those. Such a finding could be neither fixed (fix rightly refuses to edit it) nor exempted. Worse, an entry that quoted the line failed with "does not hold a sentence equal to the quote", and the same report said "No sentence of a.md holds a finding", so the two messages together contradicted the finding the run had just printed.

This adds the line form of an allow entry (issue #68).

What a line entry exempts

A finding outside every sentence, matched by the whole text of its line, in any section. Only banned_chars takes it, because it is the only lint that reports outside sentences. For another lint, loading refuses the entry and says to name the sentence with quote.

[[md.allow]]
path = "README.md"
lint = "banned_chars"
line = "<p>c — d</p>"
reason = "Markup that the page needs as it is."

line takes the place of quote. An entry with both, with neither, with an empty line, or with a line holding a control character other than a tab is refused at load. The line is the whole line as findings count lines. Spaces and tabs fold and the ends are trimmed; any other character must match, so a character added anywhere on the line stales the entry. It is not a line number (an edit above would move it) and not a span (a short one would match anywhere).

A line entry drops only the occurrences of its lint on that line that no sentence holds. A finding inside a sentence on the same line is still reported, so a finding has one way to be exempted.

Stale entries

  • no_such_line: no line of the file equals the entry.
  • two_lines: two or more lines equal it. Duplicates fail, as two equal sentences do, because exempting every copy would let a line be pasted elsewhere.
  • no_finding: the line exists but holds no occurrence outside every sentence. The message is worded for a line and points at quote when the finding is in a sentence.
  • A prefix is not a match. A file line with text added after the entry's text fails as no_such_line.
  • When a quote entry fails because its text equals a line that holds a finding outside every sentence, the reason says so, says that such a line is named by line, and says to tell the human.
  • A failed entry's report lists, after the sentences, up to three closest lines that hold a finding outside every sentence. When no sentence holds a finding, the report ends "No sentence of X holds a finding of L. The findings it has are outside every sentence.", so it no longer denies a finding the file has.
  • A failed line entry ends with advice worded for a line: only a human exempts a line, leave the line as it is.

fix holds a line that a line entry names, for every lint, as it holds a quoted sentence. The notice for an entry added since the base, explain, JSON, SARIF and GitHub annotations show Line: "..." for a line entry. In JSON a line entry has line and no quote; a sentence entry's output is byte-identical to before, and FORMAT_VERSION stays 1. A four-value JSON-array entry reads as before.

Freezer and fill changes

Each release freezes a config that names every setting. A line entry is a new setting, so the freeze must produce one that holds.

  • tests/configs/fill.toml names a line entry per section. The frozen fixture repo gains the lines the fill names: <td>✔️</td> in docs/note.md, and a comment holding One.<no-break space>Two. in the Rust, C++ and TOML files. A test ties the fill's lines to the fixture's, so changing one without the other fails.
  • The fill turns on banned_chars for the no-break space in the rust, cpp and toml sections. Without it the frozen config has no finding there, so the entry could not hold.
  • overlay in tools/release/src/freeze.rs laid each item of a fill list onto the config item at the same position. Reordered, a quote entry and a line entry merged into one entry that the loader refuses. It now lays a fill item onto an item of the same kind. The kind of an item is the set of keys that tell the items of the fill's list apart (some items carry them, others lack them), so for allow it is which of quote or line the item carries. A fill item with no item of its kind left is appended when it brings a key the list lacks. A list whose items carry the same keys has one kind, which keeps the old behaviour.
  • tests/frozen.rs reads a map-valued setting as one schema leaf, not as one path per map key.

since = "next" and the page

AllowFile.line carries since = "next", with its doc comment. quote becomes optional in the on-disk type, so the schema no longer marks it required and cannot say "quote or line, not both"; loading enforces that. No schema bump: no config already written changes meaning.

src/instructions/lints/allow.md gains the sentence "A banned_chars finding outside every sentence, as in frontmatter or HTML, is named by line, its whole line, in place of quote." and stays within its 800-byte budget (787 bytes). The doc comments of path and lint now say "sentence or line", which moves the schema description of those fields; one comment is rewrapped under 100 columns with its text unchanged.

Decided on the maintainer's behalf

  • A line entry matches the whole line, not a prefix. With a prefix match an agent could grow a match by appending text to the line, and the entry would keep holding.
  • The summary line HUMANS_ONLY ("only a human writes or changes an exemption; leave the sentence as it is") keeps its "sentence" wording. It prints after every run that has a failed entry, sentence entries included, and changing it would move the output of existing cases. The per-entry advice for a line entry says "line".
  • The SARIF rule description keeps "one sentence". Changing it would move existing SARIF output. The SARIF message text for a line entry says "The line:".
  • A quote and a line of equal text are different entries.
  • A line entry in a Rust comment includes its /// markers. A finding in a comment sentence is the sentence's, so a line entry there ends no_finding; this is tested.
  • The closest lines in a failed report use the same edit distance as the closest sentences, measured against the entry's own text.
  • The report wording is "The line:" and the notice and explain wording is "Line:".
  • The sentence-only runs are byte-identical to before; the PR moves no golden and no existing case output.

Measurement

Every banned_chars group on, release build, over the .md files of the in-tree corpus (1,230) and of the big tier. Before: main at 39b804f on deslag-blobs:v6@sha256:d075cbb3 (23,100 files). After: this branch at 1e13c6f on deslag-blobs:v7@sha256:d9a3047c38e2f9e7845f15f4a4f8a66b715595879f818e4ad4cd0997077c85fb (23,100 files). "Outside" means a finding in frontmatter, in an HTML block, or a space character (U+00A0, U+202F, U+200A) between two sentences.

before, big tier (v6) after, big tier (v7) before, in-tree after, in-tree
files with a finding 8,820 8,823 532 532
of them with a finding outside every sentence 829 829 41 41
of them with one only there 155 155 4 4
findings in frontmatter (files) 1,782 (484) 1,782 (484) 39 39 (19)
findings in HTML blocks (files) 2,579 (324) 2,579 (324) 103 103 (22)
findings between sentences (files) 241 (39) 241 (35) 1 1 (1)
lines holding such a finding 2,101 2,101 not measured 99
line length, median / 90th percentile / longest 95 / 341 / 1,609 95 / 341 / 1,609 not measured 108 / 356 / 961
lines equal to another line of their file (folded) 193 193 not measured 0
lines that also hold a finding inside a sentence 44 44 not measured 0

The counts match but for two: v7 has 8,823 files with a finding, three more than v6, and 35 files with a space between two sentences where the earlier figure said 39. No count of findings moved. Besides these, 638 findings (60 files) in the big tier sit outside every sentence in a paragraph, such as box-drawing characters, check marks and em dashes; the line entry reaches them too, and the earlier figures did not count them.

Tests

New cases under tests/cases/banned_chars/:

  • allow_line: frontmatter, HTML block and between-sentence lines named by line entries: clean.
  • allow_line_stale: no_such_line, two_lines and no_finding on a line whose finding is in a sentence.
  • allow_line_quoted: a quote entry whose text equals a line with a finding outside every sentence.
  • allow_line_base: the notice for an added line entry.
  • allow_line_fix: fix leaves a between-sentence no-break space alone when a line entry names its line.

During the review of the diff the outputs of two of these moved, and each move is intended:

  • allow_line_stale (stderr and JSON): a failed line entry now ends with the line advice ("only a human exempts a line ...") instead of the sentence advice.
  • allow_line_quoted (stderr and JSON): the report gains the "No sentence of README.md holds a finding of banned_chars. The findings it has are outside every sentence." line. The entries are quote entries, so their advice is unchanged.

tests/allow.rs gains tests for the load refusals, a Rust comment line, JSON, SARIF and GitHub output, explain, --diff, and fix. Unit tests cover matching, duplicates, the closest lines and the load checks. tools/release/tests/release.rs gains a_fill_list_is_laid_by_kind_not_by_position, which lays [quote, line] onto a config holding [line, quote] and onto a config with two quote entries, and checks that no item carries both a quote and a line. It fails on the previous head of this branch, where the quote and line merged.

Mutations, each reverted after; the result is the tests that fail:

  • Drop the outside-every-sentence filter: unit tests in fix and lint::allow, two tests in tests/allow.rs, and the cases allow_line_fix and allow_line_stale.
  • Let two lines match: the unit test for a line the file does not hold or holds twice, and the case allow_line_stale.
  • Skip the line in fix's hold: the fix unit test, fix_leaves_the_whole_line_a_line_entry_names and the case allow_line_fix.
  • Drop the closest lines from the report: the lint::allow report test, a_line_with_a_character_added_fails_its_entry_and_brings_the_finding_back, and the cases allow_line_quoted and allow_line_stale.
  • Match by prefix (starts_with): a_line_with_text_added_after_the_entry_does_not_match. This mutation passed every test before that test existed. Matching the other way round, by contains and by ends_with, also fails tests.
  • Fold spaces but not tabs: the unit test for folding.
  • Overlay never appends, always lays into item 0, or always appends: each fails a test in tools/release/tests/release.rs.
  • Change a line in fill.toml or the matching constant in the frozen fixture: the test that ties them fails, and so does the frozen-config load test.

A simulated prep in a scratch clone wrote a config for the next release holding both allow entries per section, and every_frozen_config_loads_and_warns_only_for_redirects and the_newest_frozen_configs_name_every_setting passed there.

Testing

  • make ci-fast: exit 0
  • make test: exit 0
  • make test-tools: exit 0
  • cargo test -p deslag-release: exit 0
  • make check-release: exit 2, failing only nothing_arrives_in_next and the_newest_frozen_configs_name_every_setting. Both are expected on a branch that adds since = "next" and name {md,rust,cpp,toml}.allow[].line (and the possessive_own settings that are already next on main); the next release's freeze clears them.
  • check --base origin/main on this repo: exit 0

References

banned_chars also reports characters in frontmatter, in HTML blocks and
between sentences. No sentence holds those, so an entry could not name
them, and fix refused them. An entry for banned_chars may now give
`line`, the whole text of one line, in place of `quote`.

Spaces and tabs fold and the ends are trimmed; any other character must
match. The file must hold the line once. The entry drops only the
occurrences on that line that no sentence holds, never one inside a
sentence. New statuses: no_such_line and two_lines; no_finding is worded
for a line. Loading refuses an entry with both or neither, an empty
line, a control character other than a tab, and a line for any other
lint.

A failed entry lists, after the sentences, the three closest lines that
hold a finding no sentence holds. A quote that equals such a line says
so and points to `line`. Fix holds a named line whole. The notice,
explain and the json output show `Line:` or `line` for a line entry; the
output for a quote entry is unchanged.

The allow page gains one sentence and stays within its budget. The
freeze fill gains a line entry for each section.
Five cases under banned_chars: a frontmatter line and an HTML line
exempted by `line`, the stale statuses, a quote that equals such a line,
the reviewer notice under a base, and fix leaving a named line whole.
Load refusals, the json, sarif and github output, explain, a base and a
diff, fix, and a line of a Rust comment.
The fill entries that name a line held against no file, so the next
release freeze would have failed. The frozen repo now writes the line
each entry names, a no-break space between two sentences of a comment
for rust, cpp and toml, and an HTML line for md. A config with a line
entry gets those lines; an older config would report them.

The fill turns banned_chars on for rust, cpp and toml with a ban on the
no-break space, since the freeze copies lint settings into md only.
The freeze now lays each item of a list in the fill by position and
appends an item that brings a key the list lacks, so an allow entry
with a line sits beside one with a quote instead of being merged into
it, which no config loads.
listing() takes what it lists and where as two values, not one string
it splits again. compile() builds the entry's names in the match that
reads quote and line. apply() chooses between a sentence and a line
with an enum, not a boxed trait object. A comment over 100 columns is
wrapped, and the doc comments of path, lint and reason now say
sentence or line.
A failed entry that names a line ended with advice about a sentence.
It now says a human exempts a line, leave the line as it is, and
editing a line only to get past a lint is no fix. When a file has no
sentence with a finding but has lines with one, the report says the
findings are outside every sentence, not only that no sentence holds
one.
Text added to a named line stales the entry. A prefix match passed
every test before this one.
The freezer laid each item of a fill list onto the config item at the
same position. If the config listed its `allow` entries in another
order than the fill, a `quote` entry and a `line` entry merged into one
entry that the loader refuses.

`overlay` now matches by kind. The kind of an item is the set of keys
that tell the items of the fill's list apart, the keys some carry and
others lack. A fill item with no item of its kind left is appended when
it brings a key the list lacks. A test lays a quote and a line entry
onto a reordered list and onto two quote entries.
@webern webern added enhancement New feature or request ai Primarily authored by AI (whether PR, Issue, Whatever) area/config Has to do with deslag configuration (deslag.yaml, etc.) area/lint Deals with the linting algorithms themselves, how they work. labels Nov 2, 2026
@webern
webern marked this pull request as ready for review November 2, 2026 16:18
@webern webern added the approved The PR is approved for merging. label Nov 2, 2026
@webern

webern commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

CI is green on 1e13c6f (run 41479129435).

Decided on the maintainer's behalf: a line entry names the whole line, matched exactly after folding runs of whitespace, not a prefix or a substring. A prefix match would let an agent widen an exemption by appending text to a line that already matches, and a substring match would exempt every line that happens to contain the quoted text. The cost is that an entry goes stale when any character of its line changes, which the stale report names, as it does for a quote entry.

@webern
webern merged commit eb5961f into main Nov 2, 2026
7 checks passed
@webern
webern deleted the m/deslag-allowraw branch November 2, 2026 16:37
webern added a commit that referenced this pull request Nov 29, 2026
…erride (#273)

## Human Summary

This gives the user the ability to exempt a single lint case.

## Summary

Issue #68 asked for two things. The first is a way to exempt one
violation, keyed to its place and not to the whole file. The second is a
way for a narrower override to turn off a lint that a broader override
turned on.

Much of the first already exists. `[[<section>.allow]]` entries (#199,
#251) exempt one sentence, they require a reason, a tally of them prints
on every run, and a stale entry fails the check. `list_growth`, the lint
behind #67, was removed in #207, so there was no list count to rebase.
What was still missing:

- `density` could not be exempted. An `allow` entry for `density` now
quotes one whole paragraph or list item, folded the same way a sentence
quote is. Any edit to that block makes the entry stale, and the block is
judged again. So a paragraph that grows has to be re-exempted by a
human, and an entry does not last forever. A failed entry reports
`no_such_block`, `two_blocks` or `no_finding`. `deslag fix` leaves a
quoted block as it is. A `line` on a `density` entry is refused.
- An override can now say `off = ["<lint>", ...]`. This sets each named
lint back to unset for the files the override matches. A later override
that sets the lint's table turns it back on, with only the settings that
table sets. Loading the config (exit 2) refuses an unknown lint, a lint
named twice, a lint the same override both turns off and sets, and an
`off` for a lint that no table in the section turns on. `deslag explain`
shows `# <lint>: off, by override N`. The field is marked `since =
"next"` with a default of `[]`, so it needs no schema version bump.

Exemptions stay in the config, with no in-file marker. That keeps to the
existing rule that there is one way to exempt a finding.

`guide.md` and `lints/allow.md` no longer say that an override cannot
turn a lint off, or that an entry only exempts a sentence. They keep the
rule that an agent proposes an entry or an `off` and a human writes it.
The summary line, the SARIF rule text and the docs for entries now say
"text" rather than "sentence", since an entry can name a paragraph.

`.agents/deslag.toml` is unchanged. The #67 workaround was already
removed along with `list_growth`.

## Testing

- [x] `make ci-fast`: exit 0, including `check-deslag` on the repo
itself
- [x] `make test-tools`: exit 0
- [x] New `density` cases: `override_off`, `allow_applied`,
`allow_fails` (covering `no_such_block` and `no_finding`), `allow_rust`
and `allow_fix_held`
- [x] Unit tests for the `off` load errors, the merge order and
`two_blocks`, plus a new `deslag explain` test
- [x] Expected outputs regenerated with `make fix-test-output`, and the
diff checked. Existing `density` cases changed only by the added advice
sentence and the sentence-to-text wording.

## References

- Closes #68
- Related: #67, #199, #207, #251
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Primarily authored by AI (whether PR, Issue, Whatever) approved The PR is approved for merging. area/config Has to do with deslag configuration (deslag.yaml, etc.) area/lint Deals with the linting algorithms themselves, how they work. enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant