Repository navigation
feat: ban phrases the config lists - #41
Merged
Merged
Conversation
webern
force-pushed
the
m/banned-phrases
branch
from
September 26, 2026 13:53
bb0c528 to
2c1f451
Compare
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.
webern
force-pushed
the
m/banned-phrases
branch
from
September 26, 2026 14:28
2c1f451 to
6d8d1b4
Compare
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.
4 tasks done
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.banmaps each phrase to the advice its report shows, andallowexempts a longer phrase that holds a banned one. deslag ships no phrases: with nothing inban, the lint checks nothing..agents/deslag.tomlis unchanged.This config and report are the
brokencase intests/cases/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::splitinsrc/document/tokens.rssplits 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 byToken::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
Token::splitruns the tokenizer on the raw string instead of parsing it withDocument::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 rocksin a file matchesAT&T rocksin the config.+,>, emoji),C++ ruleswould pass validation and never match.110%is a valid phrase.worth notingandnoting thatbanned, "Worth noting that" reportsWorth notingonly.allowis applied before overlap is settled. A match inside an allowed match is discarded first, so an allowed phrase hides only what lies inside it. Withworth notingandnoting thatbanned andwell worth notingallowed, "well worth noting that" reportsnoting that.banandallowis an error within one table only, becauseinvalid()runs per table. That lets an override allow a phrase the section bans, and after the mergeallowwins; theallowcase pins this. The check compares folded tokens, soIt's worth notingandit's worth NOTINGcount as one phrase.banandallowwhole, as withbanned_chars."it's** worth noting", and"It's worth > noting"inside a block quote.delete it. It is advice, not a replacement, so the report does not put it in awrite ...the waybanned_charsdoes.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'reThe 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) andwhether 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:ensurealone flags 33 human files and 34 llm ones.comprehensive(4 / 14 / 25 files) andleverage(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:
deslag instructions config-schema,deslag instructions,deslag explainand the as-built doc for the details. This is also why the PR adds no README section forbanned_phrases.cargo install deslagfails: 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 writingcargo install deslag --locked.deslag --helpand the crate description said deslag only checks the byte budget; they now describe the linter.deslag explainon a file check skips.checknever reads a git-ignored file or one inside.git, butexplainprinted its settings as ifcheckused them. It now prints# ignored: yes, so deslag check never reads itand stops, as it does for a file[md]does not select.every_lint_has_a_failing_casecounted any case with a non-empty.stderrfile, 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 0tests/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, andToken::splitagreeing withDocument::markdownon sample texttests/cases/banned_phrases/:clean,broken,allow(with an override that allows a phrase the section bans),custom_message, andban_and_allow(an invalid config)deslag instructions config-schemashowsBannedPhrasestests/explain.rs: a file under a git-ignored directory, and one inside.git, each say# ignored: yesand nothing more; without the fix they print full settingstests/cases.rs: a case with a.exitfile holding 2 does not count as failing a file; with the old rule it diddeslag checkanddeslag explainin a scratch repo, andcargo install --locked --path .into a scratch directorydocs/design/deslag.asbuilt.mdis 16,379 bytes of its 16,384, from 16,363 onmainNotes
ban_and_allowis a config error, so it has a.exitfile holding2, as feat: exit with 2 when deslag cannot run #39 asks of such cases.BannedPhrasesderivesSerializelike the other lints, sodeslag explain(feat: show the settings a file gets #40) shows it, and explain's pinned output gains a# banned_phrases: offline.References