Repository navigation
feat: add deslag-corpus, which measures the corpus - #55
Merged
Merged
Conversation
Make the repository a cargo workspace with one new member, tools/corpus, the crate deslag-corpus. It is never published. The sidecar types and the loaders of both corpus tiers move there from tests/common/, which now calls them. The loaders return the first broken rule as a Problem instead of panicking, so the analysis tool that follows reads the corpus through the same code the tests use. The rules and their messages are unchanged. deslag takes the crate as a path-only dev-dependency, which cargo drops from the package, so check-publish still packages deslag alone. The lints and rust-version move to the workspace. Every cargo call in the Makefile covers the workspace but check-publish, which names deslag. cargo metadata now lists two packages, so the release workflow picks the one that publishes instead of the first. AGENTS.md's layout merges tests/corpus/ into tests/ to make room for tools/corpus/ within its 12 entries. deslag.asbuilt.md is reworded to fit its budget with the new layout entry, dropping text that its frontmatter or another doc states.
deslag-corpus becomes a binary as well as a library. Each command reads one tier of the corpus, the tree or the big tier, and prints tables or, with --json, JSON that opens with what was measured: the image digest or the tree's commit, and the filters. summary counts files and repositories by label, kind, language, batch, quarter, register and tool. chars counts the characters outside ASCII in English prose, as banned_chars finds them, and compares the llm files with the human ones. A comparison weighs each repository once: a rate is per million prose tokens, averaged over repositories, and a ratio's interval comes from resampling repositories. Files are read and tokenized once, over every thread, with the same result as on one.
ngrams counts runs of prose tokens as banned_phrases matches them: within one block and one sentence, starting and ending with a word or a number. It keeps a run found in at least 10 llm repositories and ranks it by the lower bound of its ratio's interval, so a phrase that few repositories carry does not rank high. candidates is the view of ngrams that could become banned phrases. It keeps a phrase no one repository owns, no human file of the tree holds, whose interval's lower bound is at least 4 and that the files of at least three tools hold, and merges each phrase into a shorter one it holds. Each candidate shows its human file counts by word, with words few human files hold flagged, and masked examples. It also counts the catalog gate: the phrases through the first five steps that no human file holds, in any language, found in at least 40 llm repositories. The gate runs before the merge and merges only the phrases it keeps, so load-bearing does not hide under bearing, which four human files hold.
lints runs a config's lints over the corpus and prints, for each lint, how many files of each label and of each tool it fails, by file and weighed by repository, with the paths. Each file is checked through check_file at its path in the repository it was quoted from, so the config's overrides apply as they would there. repo_layout is left out, since the corpus does not hold the files around a file. So is each lint that judges a change, such as list_growth: it is taken out of the config, since a corpus file has no base. The config is the one deslag finds, or --config; --every-file checks the files its globs do not select too. report prints summary, chars, candidates with the catalog gate, and lints as one Markdown page, for a pull request that grows the corpus to carry. Its lints run at tools/corpus/report.toml, which selects every file and holds the repository config's lint settings, so the human files are measured too. The page names the config.
golden.rs writes a small corpus to a temporary directory, a big tier of one batch with a ledger and a tree beside it, runs every command of the binary on it and compares the output with a file under tools/corpus/tests/golden/. A second run must print the same bytes. make fix-golden now rewrites these files too. tree.rs runs every command on the tree. Its round trip bans each of 500 n-grams and every candidate with banned_phrases, and requires each to match in exactly the files deslag-corpus says hold it. It also checks that the sieve keeps what it says, that no human file of the tree holds a candidate, that the summary adds up, that lints run under the repository's config though it sets list_growth, and that report checks every file.
sentence_lengths_by_label is ignored, and prints rather than checks. For each file of 10 sentences or more it takes the coefficient of variation of sentence length, in words and numbers, and prints its quartiles by label: over all prose, over paragraphs alone, and with each sentence that ends in an abbreviation joined to the next. It prints the one threshold that best parts llm files from human ones. It runs on the tree, and on the big tier when make fetch-blobs has unpacked it. Run it by name with --ignored and --nocapture.
analysis.asbuilt.md describes deslag-corpus's commands and modules, and analysis.md gives the reasons behind its numbers: the repository as the unit, the ranking by an interval's lower bound, words flagged rather than guarded, the sieve and the catalog gate, and what #33's measurement found. analysis.md has its own budget in the config. AGENTS.md and deslag.asbuilt.md now point to the analysis. ACKNOWLEDGEMENTS.md credits slop-lint, slop-forensics and llm-excess-vocab for methods, not code.
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.
Summary
This adds a second crate to the repository,
deslag-corpusintools/corpus/, and makes the repository a cargo workspace. It is never published: deslag takes it as a path-only dev-dependency, which cargo drops from the package, somake check-publishstill packages deslag alone. The corpus loaders move into it fromtests/common/, which now calls them, so the tests and the new tool read the corpus through the same code.deslag has chosen its thresholds and banned phrases by ear. The corpus now holds the evidence to choose them, and the crate's binary measures it: which characters and phrases set llm files apart from human ones, and how often each lint fails each label. Every statistic counts the tokens deslag's
Documentgives, so a phrase it names is onebanned_phrasescan ban as it stands. A test bans each one on the tree and checks that it matches exactly the files the tool claimed.The commands, each over one tier,
--tier tree(the default) or--tier blobs:summary: files and repositories by label, kind, language, batch, quarter, register and tool.chars: the characters outside ASCII in English prose, bybanned_charsgroup and one by one, llm against human.ngrams: runs of prose tokens, asbanned_phrasesmatches them, ranked by the lower bound of their ratio's interval.candidates: the view ofngramsthat could become banned phrases, with a funnel of each step of its sieve, word counts, masked examples, and the catalog gate.lints: what a config's lints fail, per label and per tool. Each file is checked throughcheck_fileat its path in the repository it came from, so overrides apply.repo_layoutis left out, and so is each lint whosereads_change()is true, such aslist_growth: it is taken out of the config, since a corpus file has no base.report: the four above as one Markdown page, for a pull request that grows the corpus to carry. Its lints run attools/corpus/report.toml, which selects every fixture and holds the lint settings of.agents/deslag.tomlwith no budget; the page's header names the config.Each prints tables, or JSON with
--json, which opens with the image digest or the tree's commit and the filters. Two runs print the same bytes.deslag-corpus --helplists the flags; the filters are--kind,--batch,--repo,--language,--quarter,--single-tooland--register, and--toolcompares one tool's files with the other tools'.How the numbers are made, in short (
docs/design/analysis.mdhas the reasons):mcplook like tells; a word fewer than 20 human files hold is flagged rare, and a person decides.Sentence length (#33) is an ignored test in
tests/corpus.rs, not a command. Structural patterns such as<verb>s no <noun>wait for a matcher in the library.Measurements on v2
All on
ghcr.io/webern/deslag-blobs:v2@sha256:33d0d99e2d588f31d7d69563d62599486bcd1e89fe8efcfed6fcdf047d6fca00, 21,891 live fixtures, from a release build. The machine was busy with other work (load average 5 to 7), so the times may be high.summarycharsngramscandidates --top 50lintsreportAbout 8 s of each is reading the tier: checking every fixture against its sidecar, then tokenizing it. On the tree every command takes under a second.
summary
labels (counts, unweighted)
tools: files (repos); a tool is compared when it alone marked llm files in 25 repositories
The whole of
summarychars
the English llm files, against the English human files; rates per million prose tokens, each repository weighing once.
banned_chars groups
characters, most frequent in the focus side first
candidates
the English llm files, against the English human files; rates per million prose tokens, each repository weighing once. Ranked by the lower bound of a 95% interval from resampling repositories. Compared tools: amp, claude-code, codex, copilot, cursor, devin, jules.
funnel
The catalog gate, n-grams through the sieve that no reference file holds, in any language, and at least 40 focus repositories do, merged among themselves: 104, of which 53 hold no rare word.
mcp,claude code,llm,copilot,worktree,this skill,agents.md,claude.md,2026-09,2026-07,2026-08,ai agent,anthropic,date: 2026,subagent,to claude,2026-06,system prompt,seam,ai agents,2026-03,skill's,agentic,guardrails,skill.md,skill is,load-bearing,success criteria,on 2026,byte-identical,subagents,for claude,needs no,2026-04,2026-05,coding agents,nothing here,do not invent,dedup,the committed,is refused,deliberately not,no per,context window,why it matters,coding agent,ships a,restate,follow-ups,fail-closed,falls back to the,collapses,the stale,reads it,exit 0,proves the,lands on,says so,per-session,verdicts,the 2026,not silently,stays a,reviewable,handed to,folds,not hand,or explicit,row per,not merely,evidence and,human review,no second,explicit user,carries its,substitutes,an unrelated,2–3,per run,exits 0,1–2,need no,survived,all six,not evidence,why this matters,absent from the,never silently,is untouched,cites,all five,gap is,only — no,of 2026,it carries,wired into,supplies the,no live,carry no,already carries,is authoritative,gains a,it lands,state, notcandidates
The catalog gate counts 104 phrases, 53 of them with no rare word; every one of those 53 is two tokens or more. At 50 repositories it would count 52, 27 with no rare word. The flag misses topic phrases of common words, such as
system promptandcontext window, so fewer than 53 are tells of prose.The gate runs on each n-gram through the first five steps of the sieve, then merges only among the phrases it keeps, so a longer phrase it keeps never hides under a shorter one it drops. Merging first, as the candidate list does, hid 21 of the 104:
load-bearing(0 human files) underbearing(4 human files), andclaude code,this skill,why it matters,do not invent,wired intoand 15 more. 7 of the 21 hold no rare word, which takes that count from 46 to 53.Sentence length (#33)
The median coefficient of variation of sentence length in a file, over files of 10 sentences or more:
Over all prose the claim that llm sentences are more even holds on the tree and reverses on v2. Over paragraphs, llm prose varies more on both tiers. No lint follows; the full tables and the recommendation are in a comment on #33.
lints
At
tools/corpus/report.toml, the configreportuses: every fixture, each at its path in the repository it came from, under the lint settings of.agents/deslag.tomlwith no budget.repo_layoutandlist_growthare left out.failing files by label: failing/checked, file share (repository-weighted share)
Under
.agents/deslag.tomlitself,lintschecks only the fixtures its globs select, at those paths, and runs withoutlist_growth, which that config sets forAGENTS.mdand the skills.Testing
make ci: exit 0 in 134 s with the build warm, against 94.6 s measured before the first change of this branch; 179 s just after the rebase onto main, when it rebuilt everything. The machine was busy (load average 5 to 7). The new crate's tests add about 17 s:tools/corpus/tests/tree.rs14.4 s andgolden.rs2.8 s;tests/corpus.rs, which this branch does not change, took 44 s.make check-publish: exit 0; it packages deslag alone, 40 filesdeslag check --base origin/mainlintsruns under.agents/deslag.toml, which setslist_growthon paths the tree's fixtures hold, and leaves it outmake fix-goldenrewritestests/golden/andtools/corpus/tests/golden/banned_phrases, match exactly the files the tool namessentence_lengths_by_labelon the tree and v2References
needs no(154 llm files in 79 repositories, no human file),carry noandneed nopass the catalog gate.ACKNOWLEDGEMENTS.mdcredits slop-lint, slop-forensics and llm-excess-vocab for methods, not code.