Repository navigation
feat: add list_growth and --base - #54
Merged
Merged
Conversation
Move the git helpers of tests/diff.rs, which run git with no global or system config, into tests/common/git.rs, so that other tests can build repositories the same way.
--base <REV> gives a run a change to judge, from where REV and HEAD meet to the working tree, without narrowing the report as --diff does. check and fix both take it; --diff takes a base the same way and is refused beside --base. check_repo now takes the change, and the report records the base apart from the narrowing, so the JSON document gains a base field. FORMAT_VERSION stays 1. fix reads the change before it writes anything, so a base git cannot read stops it, and again after, since what it wrote is part of the change. No lint reads the change yet.
list_growth is the first lint that judges a change rather than a file. A file fails when the change leaves it with more list items, at every depth and new lists included, than it had at the merge base. There is no allowance: any number of free items per change is that many more items with every change. Lists are not matched, so moving or rewording an item costs nothing. A file the change added whole is not judged; its byte budget holds it. The report gives both counts, the advice from #16 (write the rule that makes the list, or take out an item for each one added, and leave the setting alone), then each item on a line the change added. The items are evidence for a verdict on the file, so --diff keeps the finding whole, and SARIF and GitHub point at the first new item. check_text now takes the run's change. For a file a change lint selects, it reads the file at the base with git cat-file --filters, which gives the line endings git would write, and passes it to the lint as a Before. A run with no base that selects such a file is exit 2, for check and for fix, and the message names the lint, the file and --base origin/main. Lint::reads_change marks these lints, and the golden set and the corpus location test skip them by it, since a fixture alone is no change. A case can now have a .base directory beside it: the harness commits it in the temp copy, puts the case's files in its place, runs with --base HEAD, and writes the commit as [BASE]. tests/growth.rs covers growth, a new list, a nested item, moved and replaced items, added and renamed files, CRLF, a git filter, a root below the top, no base, --diff and each --format. The guide drops its advice to remove the --diff job once the tree passes, which would leave a change lint with no base, and says to run check with --base origin/main instead.
A fixture alone is no change, so the golden set of tests/golden.rs leaves list_growth out. The big tier's pairs are the corpus's only changes: a mixed fixture and the earlier revision it names, a human fixture of the same file. tests/blobs.rs now runs list_growth over each pair, with the earlier revision as the base, and pins each pair it fails with both counts in tests/golden/list_growth.txt. It fails 281 of the 474 pairs. The pairs are not single agent edits: the two revisions are years apart, so this pins what the lint does, not how often agents grow a list. DESLAG_FIX_GOLDEN=1 make test-blobs rewrites the file.
.agents/deslag.toml turns list_growth on for AGENTS.md and the skills, the files agents read as instructions. make check-deslag now runs check --base origin/main, so a branch may not leave them with more list items than main has. On main the change is empty. CI fetches the whole history, which the merge base with origin/main needs.
This was referenced Sep 27, 2026
webern
added a commit
that referenced
this pull request
Sep 27, 2026
## Summary Every Markdown file deslag lints in its own repository has a byte budget, and the files that hold text per lint were full: the setup guide at 4996 of 5000 bytes, `lints.asbuilt.md` at 7496 of 7500, `deslag.asbuilt.md` at 8163 of 8192 (measured on main, e12b6d5). A new lint needed about 200 bytes of guide text, because `tests/instructions.rs` made the guide name every lint and turn every lint on in its example, and a section in `lints.asbuilt.md`. #54 paid for `list_growth` by cutting guidance from the guide. Raising a budget is not the fix, so this moves the per-lint text to homes that grow by a file per lint instead of by bytes in a full file. No budget is raised. A new lint now needs no bytes in the guide, `lints.asbuilt.md` (beyond its line in the module tree) or `deslag.asbuilt.md`. ## `deslag instructions lints` A new instructions topic. It prints a short intro, then a section per lint, headed by its id, in the order the lints run: what the lint fails, and one TOML table that turns it on. - Each section is its own file, `src/instructions/lints/<id>.md`. `instructions::lints` includes them through an exhaustive `match` on `Lint`, so a new lint does not compile until it has one. The heading comes from `Lint::id`, so it cannot drift from the config's table name. - `.agents/deslag.toml` now lints `src/instructions/**/*.md` and holds the intro and each lint's file to 800 bytes. The largest is 279. - The guide's step 3 now opens with "Run `deslag instructions lints`" and keeps a short example (`[md]`, one lint, one override) and the `message` and `config-schema` text. The guide stays the one entry point: step 3 cannot be done without the topic, as values already cannot be set without `config-schema`. What an agent reads: `deslag instructions` was 5057 bytes (120 lines) and is now 4124 (97 lines); `deslag instructions lints` is 1817 bytes (75 lines). Two homes were considered and not taken: - `deslag explain <lint>`. `explain` exits 2 when there is no config, which is the state of a repository being onboarded, and its `PATH` argument would clash with a lint id. - Printing the topic at the end of `deslag instructions`, to keep one command. That is raising the guide's budget by another name. ## What moved where Text was moved, not rewritten, except where noted. - The guide's seven lint bullets (`guide.md:64-77` on main) moved word for word, one to each `src/instructions/lints/<id>.md`. - The guide example's tables moved to the file of the lint they turn on: `max_emphasis`, `banned_chars`, `banned_phrases` and `density` under `[md.lints]`, and `repo_layout` and `list_growth` in an `AGENTS.md` override. `max_size_bytes` keeps its table in the guide and gets the same one in its file. - The check that the guide's example turns on every lint is now a check that the lint tables, joined, turn on every lint and run clean. - The `--diff` guidance #54 cut from step 6 is back, near its old words: `--diff` misses some failures, such as a path deleted from under an untouched layout, and a `pull_request` job may run `--diff HEAD^1` with `fetch-depth: 2`. This makes `README.md`'s "`deslag instructions` says how to run it in CI and what it misses" true again. "In its place" became "in place of `--base origin/main`", since a sentence now comes between them. - `lints.asbuilt.md`'s seven per-lint sections (3359 bytes) are gone. Most of it repeated the module doc comments. What only they held moved into the module docs: - `banned_chars.rs`: the byte order mark that `scan` skips, that `allow` beats `ban` and `ban` the groups, and that only `emoji` is off by default. - `repo_layout.rs`: the root is one word; a blank line ends a description; the width ignores trailing whitespace; `Malformed`; and the defaults, named by `RepoLayout`'s `DEFAULT_` constants rather than by value. - `density.rs`: a block of only whitespace is dropped, and the defaults, by `Density`'s constants. - `max_emphasis.rs`: an unset field counts as 0, and a table setting neither checks nothing. The doc said a run of capitals is split by spaces; the code splits on any whitespace, and the doc now says so. - `list_growth.rs`: a file the change did not edit is not judged. - `max_size_bytes.rs`: a file with no budget still counts in the tally. - `lints.asbuilt.md`'s Checking section says a lint's module doc is its as-built description, and a new test in `tests/asbuilt.rs` holds each lint's `//!` to 2000 bytes. The largest is 1788 (`repo_layout.rs`). - `deslag.asbuilt.md`'s Tests section and `tests/` tree moved to a new `tests.asbuilt.md` (`subsystems: [tests]`), indexed from `deslag.asbuilt.md`. Build stays in `deslag.asbuilt.md`: it covers the repo as a whole and does not grow per lint. - The proofs of one lint on the corpus moved to that lint: the default groups flagging four times as many `llm/` fixtures as `human/` ones to `banned_chars.rs`; the layouts read under real headings, and `core/rt-agents.md` with no malformed line, to `repo_layout.rs`; fix over the corpus to the Fixing section of `lints.asbuilt.md`. - `deslag.asbuilt.md` names the new topic and its files in the module tree and the command line section, and says `instructions` reads `Lint`. ## Budgets | File | Before | After | Budget | |---|---|---|---| | `src/instructions/guide.md` | 4996 | 4063 | 5000 | | `src/instructions/lints.md` | - | 302 | 800 | | `src/instructions/lints/*.md` | - | 146 to 279 | 800 each | | `docs/design/lints.asbuilt.md` | 7496 | 4570 | 7500 | | `docs/design/deslag.asbuilt.md` | 8163 | 5564 | 8192 | | `docs/design/tests.asbuilt.md` | - | 3108 | 4096 | | lint module `//!` comments | 599 to 1500 | 651 to 1788 | 2000 each | `AGENTS.md` and the skills are unchanged, so `list_growth` has nothing to judge there. Where a new lint's text goes: a new `src/instructions/lints/<id>.md`, its module's doc comment, and one line in `lints.asbuilt.md`'s module tree. None of them is a full file. ## Onboarding trial An agent with no other context was given the release binary built from this branch and an empty repository: a git repository with one commit, holding a `README.md`, an `AGENTS.md` and a `docs/design.md`, with no remote. It was told only to run `deslag instructions` and do what it says. - It ran `deslag instructions`, then `deslag instructions lints`, then `deslag instructions config-schema`, then `check`. - It wrote a `deslag.toml` covering `AGENTS.md` and `docs/`: `max_size_bytes` for both, `banned_chars`, and, in an `AGENTS.md` override, a smaller budget and `repo_layout` with `min_entries = 3` and `max_entries = 10`. It left `README.md` out, as the guide says to ask the human before linting a human-written file. - It skipped `banned_phrases`, since the phrases are the human's to choose, and `max_emphasis`, `density` and `list_growth`, as not needed yet. - The first `check` failed on `AGENTS.md` having no `Repository layout` section. It added one, and the last `check` exited 0. - `check --base origin/main` exited 2, because the repository has no remote. It skipped step 6 (CI), as the repository had no CI to add it to. ## Testing - [x] `make ci`: exit 0, 156 s (157 s on main e12b6d5; both warm, on the same machine). - [x] `tests/instructions.rs`: `deslag instructions lints` exits 0 with empty stderr and prints `instructions::lints()`; it has a section for every lint, in `Lint::ALL` order, and those are the schema's lints; each section has exactly one TOML table, which fits the schema and turns on its lint alone; the tables joined turn on every lint, fit the schema and run clean; the guide's example fits the schema, runs clean and names `deslag instructions lints`; neither text has a placeholder left. - [x] Checked that a lint file whose table turns on a second lint fails two of those tests. - [x] `tests/asbuilt.rs`: each lint's module doc is at most 2000 bytes; every `src/` module is still named in exactly one as-built doc. - [x] `make check-deslag`: every touched Markdown file under its budget and the other lints. ## References - Related to #17: `deslag instructions lints` lists every lint in a form an agent can act on, which new-lint discovery could build on. - Follows #54, which cut the `--diff` guidance restored here.
9 tasks done
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
list_growth, deslag's first lint that judges a change rather than a file, and--base <REV>, which gives a run the change to judge.#16 asks deslag to stop agents from turning AGENTS.md into a list of everything that exists: each change adds one more test directory or file to a list, and the list only grows. No lint of a single file can see that, because it needs to know what the file was before.
list_growthcompares a file with what it was at the merge base, and fails it when the change leaves it with more list items than it had.It enforces a policy; it does not detect agents. The measurement below found no rule of this kind that separates agents from people. The owner turns it on for the files where lists should not grow, as deslag now does for its own AGENTS.md and skills.
The lint
message.The finding is a verdict on the file, with the new items as evidence, like
max_size_bytesandmax_emphasis. So--diffkeeps it whole, SARIF gives one result for the file with the items as related locations, and--format githubpoints at the first new item.The base
--base <REV>goes on bothcheckandfix. The change runs from the commit whereREVandHEADmeet to the working tree, as--diffalready did, but the report is not narrowed: the whole tree is still checked.--diff <BASE>takes a base the same way and is refused beside--base.A run with no base that selects a file for
list_growthis exit 2, forcheckand forfix, before anything is written:A file with
list_growthoff needs no base, so a repository that does not turn it on sees no change.The JSON document gains a
baseobject (revandmerge_base) when a run has one, apart from thechangeobject of a narrowed run.FORMAT_VERSIONstays 1.The base file is read with
git cat-file --filters <merge base>:./<path>, so it has the line endings (and any other filter) git would give it in the working tree. It is read only for a modified or renamed file that a change lint selects. A renamed file is compared with its old path.deslag's own repository
.agents/deslag.tomlturnslist_growthon for AGENTS.md and the skills.make check-deslagnow runscheck --base origin/main, and the CI job fetches the whole history (fetch-depth: 0) so the merge base is there. On a push to main the change is empty. This branch does not touch AGENTS.md or the skills, so it passes.The guide
The guide turns
list_growthon in its example, describes it, and runscheck --base origin/mainin the measure and CI steps. It no longer says to remove the--diffjob once the tree passes: that would leave the job with no base. To stay within its 5000-byte budget it lost the--diff HEAD^1withfetch-depth: 2variant and the example of what--diffmisses (a path deleted from under an untouched layout).The measurement
The rules were measured on the corpus image v2 (
sha256:33d0d99e) at 85693ad. The 474 mixed/human pairs in the image turned out not to be agent edits: the two revisions of a pair are a median 4.7 years apart, with a median of 10 unmarked commits and 1 agent commit between them, and none of the files is an instruction file. So the evidence is per commit, with each commit's before and after fetched from GitHub by the blob SHAs the v3 sidecars record:llminstruction files in 140 repositories.Share of edits each rule would fail:
list_growth)The first row was checked again with
list_growthas built: the release binary, run with--base HEADon a git repository holding each edit's before and after, fails 368 of 1053, 523 of 1495 and 487 of 2047 edits, the same verdict as the measurement on every one.No threshold separates agents from people, so the rule chosen is the policy #16 states, not a detector.
Two caveats on the labels. Checked precision is lowest for the mixed labels that rest on session marks (9 checked, lower bound 0.70), and a mixed label can rest on an agent commit that a merge later dropped. Both affect the middle column.
Rules chosen and not:
list_growth: shipped, as above.collect.pybatch, which is for the owner to publish.#16's own example is not caught by any of these. The #15 edit changed one line inside the fenced layout block of AGENTS.md (
the schema in TOML, YAML or JSON): an inline series in a code block, not a list item. deslag does not read inline series yet (SpanKind::Seriesis a TODO insrc/document/mod.rs).The pairs still pin the lint:
tests/blobs.rsrunslist_growthover each pair, the earlier revision as the base, andtests/golden/list_growth.txtrecords the 281 of 474 it fails, with both counts.deslag's own history
list_growth, as built, over every edit to AGENTS.md and the skills in deslag's history, each commit judged with--base <commit>~1: 19 file edits in 12 commits. The 5 files added whole are not judged (the four in the initial commit, anddeslag-commit/SKILL.mdin 0ace521). Of the 14 edits to existing files, 3 fail, one in each of 3 commits:/deslag-commit: rules for git commits./deslag-commit.ACKNOWLEDGEMENTS.md.deslag-build-doctrine/SKILL.md/deslag-commit: a volatile list, the index of skills, which gains an entry with every skill (Stop listing things #16's complaint).0ace521 still fails with the exemption: its new skill file passes, but AGENTS.md gains two items. Two of the four items are rules, not inventory. The lint cannot tell them apart; its report asks for an item out for each one in either way, and a rule that earns its place can replace a weaker one.
How it is built
Five commits:
test: share the hermetic git helpersmoves the git helpers oftests/diff.rsintotests/common/git.rs.feat: add --base to check and fixadds the flag, passes the change tocheck_repo, and records the base in the report.feat: add the list_growth lintadds the lint,Change::base_text,Lint::reads_change, the exit 2, the cases,tests/growth.rs, the docs and the guide.test: pin list_growth over the corpus's pairsadds the golden file above.build: turn on list_growth for this repochanges.agents/deslag.toml, the Makefile and CI.check_textnow takes the run's change. For a file a change lint selects, it reads the base text and passes the lint aBefore: the base document and what the change did to the file. The lint itself reads no git.Lint::reads_changemarks such lints, and the golden set and the corpus location test skip them by it, since a fixture alone is no change.quotemoved frommax_emphasistolint, which both now use.A case under
tests/cases/can now have a.basedirectory beside it: the repo before the change. The harness commits it in the temp copy, puts the case's files in its place, runs with--base HEAD, and writes the commit as[BASE]. The check that every case is all change from an empty commit now runs the whole tree with--base HEAD~1.Testing
make ci: exit 0, 140.6 s (144.9 s before, on main).tests/growth.rs, 14 tests: growth; a change that removes as many items as it adds; a new list in an old file; an item moved to another list; a nested item; files added whole, committed or untracked; a rename with growth; CRLF; a git filter, which shows the base is read as git writes it; a root below the top of the repository; exit 2 forcheckandfixwith no base, with nothing written; no base needed where the lint is off;--diffkeeps the finding; SARIF and GitHub point at the first new item.tests/cases/list_growth/: broken, clean (with a file added whole), a custom message, and no base forcheckand forfix.tests/output.rsnow failslist_growthtoo, so every format is checked with a change lint.tests/diff.rs:--basedoes not narrow,--basewith--diffis refused,fixtakes a base and refuses a bad one before writing.make test-blobs: the pair golden file, 281 of 474.list_growthover the measured edits, and over deslag's own history, as above.make check-deslagwithlist_growthon: exit 0.References