Skip to content

feat: ban phrases the config lists - #41

Merged
webern merged 4 commits into
mainfrom
m/banned-phrases
Sep 26, 2026
Merged

webern merged 4 commits into
mainfrom
m/banned-phrases

Conversation

@webern

@webern webern commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Human Summary

Seems like a pretty good feature that could go a long way toward solving pet peeves.

Summary

Adds banned_phrases, a lint that fails a Markdown file whose prose holds a phrase the config lists. ban maps each phrase to the advice its report shows, and allow exempts a longer phrase that holds a banned one. deslag ships no phrases: with nothing in ban, the lint checks nothing. .agents/deslag.toml is unchanged.

This config and report are the broken case in tests/cases/banned_phrases/:

[md.lints.banned_phrases.ban]
"it's worth noting" = ""
"delve into" = "say what you found instead"
"in today's fast-paced world" = ""
"leverage" = "write `use`"
ERROR: deslag detected banned phrases!

README.md has 6 banned phrases.

This repo keeps these phrases out of its Markdown. Do what the advice with each one says, or reword the sentence; it often reads better with the phrase simply gone.

Do not hide a phrase in a code span or HTML, and do not change the config to get past this check. Only a human can tell you to do that, and I am a linter, not a human.

The phrases, and what to do about each:
  line 1: "Delve Into"; say what you found instead
  line 3: "In today's fast-paced world"; delete it
  line 3: "It's worth noting"; delete it
  line 4: "it's worth noting"; delete it
  line 6: "leverage"; write `use`
  line 11: "Leverage"; write `use`

deslag: 1 of 1 Markdown files with banned phrases.

The second match on line 3 runs onto line 4, and the one on line 4 is written **it's worth** noting.

How it matches

There are no regular expressions. A new Token::split in src/document/tokens.rs splits a phrase with the same code that splits a stretch of prose, so the config and the document agree on what a word is. The phrase then matches the same tokens in one block, compared by Token::folded: lower case, with a curly apostrophe made straight. Whitespace, line breaks and formatting between tokens don't count. A code span, HTML, an image, a URL or a footnote reference is a token no phrase can hold, so it breaks a match. Phrases are indexed by their first token, so each token of a file costs one lookup.

Choices the issue left open

  • A phrase is plain text, not Markdown. Token::split runs the tokenizer on the raw string instead of parsing it with Document::markdown. So # or * in a phrase stays a token instead of turning into a heading or emphasis, and the phrase is compared with what the file renders: AT&T rocks in a file matches AT&T rocks in the config.
  • Symbols match like words and marks. The issue names word, number and punctuation tokens. Without symbols (+, >, emoji), C++ rules would pass validation and never match.
  • "No words" means no word and no number, so 110% is a valid phrase.
  • Overlap is leftmost, then longest. Scanning left to right, the first match wins, and of matches that start at one token, the longest. With worth noting and noting that banned, "Worth noting that" reports Worth noting only.
  • allow is applied before overlap is settled. A match inside an allowed match is discarded first, so an allowed phrase hides only what lies inside it. With worth noting and noting that banned and well worth noting allowed, "well worth noting that" reports noting that.
  • A phrase in both ban and allow is an error within one table only, because invalid() runs per table. That lets an override allow a phrase the section bans, and after the merge allow wins; the allow case pins this. The check compares folded tokens, so It's worth noting and it's worth NOTING count as one phrase.
  • An override replaces ban and allow whole, as with banned_chars.
  • The quote is each matched token as written, with a space where whitespace parts two of them and the markup between them left out. Quoting the raw byte range gave "it's** worth noting", and "It's worth > noting" inside a block quote.
  • The advice is printed as written, and an empty one prints delete it. It is advice, not a replacement, so the report does not put it in a write ... the way banned_chars does.
  • The guide's example config turns the lint on with an empty table, because its test requires every lint. The bullet tells the agent to ask the human which phrases to ban.

Corpus numbers

These are 22 phrases widely cited as LLM tells, run through the library over tests/corpus/{human,llm,mixed} by a throwaway test that is not committed:

delve into, delves into, it's worth noting, it is worth noting, it's important to note, in today's fast-paced world, in the realm of, a testament to, tapestry, navigate the complexities, plays a crucial role, seamlessly, harness the power of, unlock the power of, game-changer, cutting-edge, ever-evolving, in conclusion, embark on, let's dive in, deep dive, whether you're

label files flagged rate matches
human 400 1 0.25% 1
llm 400 5 1.25% 7
mixed 400 13 3.25% 20

The list barely fires on any label, so it does not separate them in any useful way. Only 7 of the 22 phrases matched at all, mostly seamlessly (7 files) and whether you're (5 files, one of them human). 19 flagged files out of 1,200 is too few to tell the labels apart. The chatbot phrases people cite are rare in the Markdown that agents write in repositories.

For comparison, 12 single words that are also often cited (comprehensive, robust, seamless, leverage, crucial, essential, ensure, enhance, streamline, utilize, powerful, effortlessly) flag human 55 (13.8%), llm 67 (16.8%) and mixed 142 (35.5%). They fire far more but hardly separate human from llm: ensure alone flags 33 human files and 34 llm ones. comprehensive (4 / 14 / 25 files) and leverage (2 / 9 / 14) lean llm. Under both lists mixed files are flagged most, and I did not correct for file length. None of this makes a case for shipping a default list.

Also in this PR

Fixes found while checking the README, in three commits of their own:

  • The README holds only what stays true. It listed the lints, spelled out each one's rules and quoted corpus counts, so it went stale with every lint PR; one count was already wrong (the density defaults fail 92 of the 400 agent-written files, not 84). It now says what deslag is, how to install, set up and run it, and the config's general shape, and points to deslag instructions config-schema, deslag instructions, deslag explain and the as-built doc for the details. This is also why the PR adds no README section for banned_phrases.
  • Install. cargo install deslag fails: the crate is not on crates.io. The README installs from a checkout, and the setup guide tells the agent to ask the human how CI should install deslag instead of writing cargo install deslag --locked. deslag --help and the crate description said deslag only checks the byte budget; they now describe the linter.
  • deslag explain on a file check skips. check never reads a git-ignored file or one inside .git, but explain printed its settings as if check used them. It now prints # ignored: yes, so deslag check never reads it and stops, as it does for a file [md] does not select.
  • every_lint_has_a_failing_case counted any case with a non-empty .stderr file, so a case where deslag cannot run (exit 2) passed for a case where the lint fails a file. It now counts only cases that exit 1.

Testing

  • make ci: exit 0
  • tests/phrases.rs: case, curly apostrophes, soft and hard line breaks, formatting, code spans, HTML, images, URLs, footnotes, two blocks, blocks that are not read, allow, overlap, merging, each validation error, and Token::split agreeing with Document::markdown on sample text
  • tests/cases/banned_phrases/: clean, broken, allow (with an override that allows a phrase the section bans), custom_message, and ban_and_allow (an invalid config)
  • deslag instructions config-schema shows BannedPhrases
  • A throwaway corpus probe, not committed: every run of three prose tokens in the corpus's prose blocks (319,722 of them), joined into a phrase, split back into the same tokens and was found by the lint. No tokenizer bug turned up.
  • tests/explain.rs: a file under a git-ignored directory, and one inside .git, each say # ignored: yes and nothing more; without the fix they print full settings
  • tests/cases.rs: a case with a .exit file holding 2 does not count as failing a file; with the old rule it did
  • The README's example config, run with deslag check and deslag explain in a scratch repo, and cargo install --locked --path . into a scratch directory
  • docs/design/deslag.asbuilt.md is 16,379 bytes of its 16,384, from 16,363 on main

Notes

References

@webern webern added enhancement New feature or request area/config Has to do with deslag configuration (deslag.yaml, etc.) area/lint Deals with the linting algorithms themselves, how they work. ai Primarily authored by AI (whether PR, Issue, Whatever) labels Sep 26, 2026
Add the banned_phrases lint. [md.lints.banned_phrases] maps each
phrase in ban to the advice its report shows, and allow exempts a
longer phrase that holds a banned one. deslag bans no phrase of its
own, so with nothing in ban the lint checks nothing.

Token::split splits a phrase with the code that splits the document's
prose. The phrase matches the same tokens within one block, in any
case and with either apostrophe, across whitespace, line breaks and
formatting. A code span, HTML, an image, a URL or a footnote reference
breaks a match. Phrases are indexed by their first token, so each
token of a file costs one lookup.

The config refuses a phrase with no words, one holding a token that
prose never holds, such as a URL, and one in both ban and allow of the
same table.
The README went stale with every lint: it listed the lints, spelled
out each one's rules and quoted corpus counts, and one of those
counts was already wrong. It now says what deslag is, how to install
and set it up, how to run it and the shape of the config. For the
details it points to the config schema, `deslag explain` and the
design docs, which cannot drift from the code.

`cargo install deslag` fails because the crate is not published, so
the README installs from a checkout and the setup guide tells the
agent to ask how CI should install it. The help text and the crate
description said deslag only checks size; they now describe the
linter.
every_lint_has_a_failing_case counted any case with a non-empty
.stderr file, so a case where deslag cannot run, which exits 2,
passed for a case where the lint fails a file. A case now fails a
file only when its files say deslag exits 1.
deslag check never reads a file that git ignores or that sits in
.git, but deslag explain printed its settings as if check used them.
It now says the file is ignored and stops there, as it does for a
file [md] does not select.
@webern webern mentioned this pull request Sep 26, 2026
4 tasks done
@webern
webern merged commit 371cf4e into main Sep 26, 2026
2 checks passed
@webern
webern deleted the m/banned-phrases branch September 26, 2026 15:00
@webern webern mentioned this pull request Sep 27, 2026
4 tasks done
webern added a commit that referenced this pull request Sep 27, 2026
## Summary

`banned_phrases` until now banned nothing by default: an adopter who
wanted phrase lints wrote a list from memory, with nothing behind any
entry. This PR gives it groups, like `banned_chars` has: `signposts`,
`insistence`, `metaphors` and `precision`, each on by default and
switched under `[md.lints.banned_phrases.groups]`. The report names the
group beside the phrase so a user can switch one off by name.

Every entry carries the evidence that put it in. It was measured on the
corpus image `measured_on` names: zero `human` files out of 11,873 (a
rule-of-three upper bound of about 0.03%), and `llm` files in at least
40 repositories. CI no longer takes those numbers on faith: `make
test-blobs` re-derives every count against the pinned image and fails on
drift, and `make fix-catalog` rewrites the file when the image moves. A
phrase whose evidence decays is removed and joins the refused list.

The matcher keeps its old semantics: a user's `ban` beats the
catalogue's advice and never turns a load error, `allow` of a catalogue
phrase stays legal (that is how a human switches one entry off), and no
token is reported twice. Group checks apply only where the phrase
matcher already applied.

Candidates considered and refused are recorded in
`tools/corpus/rejected.toml` with reasons — words people write in 2026,
prompt text rather than prose, rare words, and common English that sits
at zero only because the corpus's human tier is older prose. The
`candidates` tool skips both the catalogue and the refused list.

## Testing

- [x] `make ci`: exit 0
- [x] `make test-blobs`: every recorded count re-derived on the pinned
image, exact match
- [x] tree corpus: each group matches zero human fixtures and at least
five llm fixtures
- [x] case tests: group hit, group off, ban beating the catalogue, allow
of a catalogue phrase, overlap

## References

- Progresses #17: each entry ships a `since`, the first piece of not
opting an updating user into new checks unknowingly
- Builds on the phrase matcher from #41 and the corpus analysis from #55
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) 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.

Add a lint that bans phrases

1 participant