Skip to content

feat: add list_growth and --base - #54

Merged
webern merged 5 commits into
mainfrom
m/deslag-growth
Sep 27, 2026
Merged

webern merged 5 commits into
mainfrom
m/deslag-growth

Conversation

@webern

@webern webern commented Sep 27, 2026

Copy link
Copy Markdown
Owner

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_growth compares 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

  • Every list item counts, at every depth, and a new list in an old file counts too.
  • There is no allowance. Letting each change add N items free lets the list grow by N with every change, forever. The table has only a message.
  • Lists are not matched between the two versions, so an item moved from one list to another, or reworded, costs nothing. A change that adds one item and removes another passes.
  • A file the change added whole is not judged: there is nothing to compare, and its byte budget holds it.
  • The report gives both counts, then the advice from Stop listing things #16, then each item that starts on a line the change added:
ERROR: deslag detected list growth!

AGENTS.md has 10 list items, 2 more than the 8 it had at d502b15.

A list that gains an item with every change becomes an inventory of everything that exists, and stops helping anyone find anything. Where the items follow a rule, such as one entry for each directory of tests, write the rule once instead of the list. Otherwise, take out an item that matters less for each one you add.

Do not turn the items into paragraphs, a table or a code block to get past this check, and do not change its settings. Only a human can tell you to do that, and I am a linter, not a human.

The items on lines this change added:
  line 43: `/deslag-commit`: rules for git commits.
  line 57: The human is the author of the git commit and the PR. See...

The finding is a verdict on the file, with the new items as evidence, like max_size_bytes and max_emphasis. So --diff keeps it whole, SARIF gives one result for the file with the items as related locations, and --format github points at the first new item.

The base

--base <REV> goes on both check and fix. The change runs from the commit where REV and HEAD meet to the working tree, as --diff already 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_growth is exit 2, for check and for fix, before anything is written:

deslag: list_growth judges what a change did to AGENTS.md, and this run has no base to judge it from: give one, such as with --base origin/main

A file with list_growth off needs no base, so a repository that does not turn it on sees no change.

The JSON document gains a base object (rev and merge_base) when a run has one, apart from the change object of a narrowed run. FORMAT_VERSION stays 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.toml turns list_growth on for AGENTS.md and the skills. make check-deslag now runs check --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_growth on in its example, describes it, and runs check --base origin/main in the measure and CI steps. It no longer says to remove the --diff job once the tree passes: that would leave the job with no base. To stay within its 5000-byte budget it lost the --diff HEAD^1 with fetch-depth: 2 variant and the example of what --diff misses (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:

  • Agent edits of instruction files: 1053 commits to 309 llm instruction files in 140 repositories.
  • Agent edits in the mixed files: 1495 commits in 201 repositories.
  • Human edits of the same files before 2022: 2047 commits in 194 repositories.

Share of edits each rule would fail:

Rule Agent, instruction files Agent, mixed files Human, before 2022
File has 1+ more list items (list_growth) 34.9% 35.0% 23.8%
One list has 2+ more items 8.2% 4.6% 2.4%
500+ bytes added, none removed 11.7% 12.1% 2.9%
A heading added, none removed 14.0% 20.4% 16.4%

The first row was checked again with list_growth as built: the release binary, run with --base HEAD on 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.
  • A net growth rule (bytes added with nothing removed): not now. It is next, with these numbers; deslag's byte budgets already bind first on its own files.
  • A heading rule: rejected. It does not separate agents from people.
  • A baseline of human edits taken from the image itself needs a new collect.py batch, 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::Series is a TODO in src/document/mod.rs).

The pairs still pin the lint: tests/blobs.rs runs list_growth over each pair, the earlier revision as the base, and tests/golden/list_growth.txt records 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, and deslag-commit/SKILL.md in 0ace521). Of the 14 edits to existing files, 3 fail, one in each of 3 commits:

Commit File Items Added items
0ace521 AGENTS.md 8 -> 10 /deslag-commit: rules for git commits.
The human is the author of the git commit and the PR. See /deslag-commit.
a2edd2f AGENTS.md 10 -> 11 When you port code or borrow a design from another project, credit it in ACKNOWLEDGEMENTS.md.
89e3669 deslag-build-doctrine/SKILL.md 9 -> 10 publish: pushes a new version of something the repo pins
  • 0ace521, /deslag-commit: a volatile list, the index of skills, which gains an entry with every skill (Stop listing things #16's complaint).
  • 0ace521, "The human is the author...": a new rule.
  • a2edd2f: a new rule.
  • 89e3669: a volatile list, the vocabulary of Makefile verbs, which gains an entry with each new kind of target.

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:

  1. test: share the hermetic git helpers moves the git helpers of tests/diff.rs into tests/common/git.rs.
  2. feat: add --base to check and fix adds the flag, passes the change to check_repo, and records the base in the report.
  3. feat: add the list_growth lint adds the lint, Change::base_text, Lint::reads_change, the exit 2, the cases, tests/growth.rs, the docs and the guide.
  4. test: pin list_growth over the corpus's pairs adds the golden file above.
  5. build: turn on list_growth for this repo changes .agents/deslag.toml, the Makefile and CI.

check_text now takes the run's change. For a file a change lint selects, it reads the base text and passes the lint a Before: the base document and what the change did to the file. The lint itself reads no git. Lint::reads_change marks such lints, and the golden set and the corpus location test skip them by it, since a fixture alone is no change. quote moved from max_emphasis to lint, which both now use.

A case under tests/cases/ can now have a .base directory 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 for check and fix with no base, with nothing written; no base needed where the lint is off; --diff keeps the finding; SARIF and GitHub point at the first new item.
  • Cases under tests/cases/list_growth/: broken, clean (with a file added whole), a custom message, and no base for check and for fix.
  • tests/output.rs now fails list_growth too, so every format is checked with a change lint.
  • tests/diff.rs: --base does not narrow, --base with --diff is refused, fix takes a base and refuses a bad one before writing.
  • make test-blobs: the pair golden file, 281 of 474.
  • list_growth over the measured edits, and over deslag's own history, as above.
  • make check-deslag with list_growth on: exit 0.

References

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.
@webern webern added enhancement New feature or request ai Primarily authored by AI (whether PR, Issue, Whatever) area/cli Deals with the command line interface. area/lint Deals with the linting algorithms themselves, how they work. labels Sep 27, 2026
@webern
webern merged commit dcf4e54 into main Sep 27, 2026
2 checks passed
@webern
webern deleted the m/deslag-growth branch September 27, 2026 10:27
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.
@webern webern mentioned this pull request Oct 25, 2026
9 tasks done
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/cli Deals with the command line interface. 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