Repository navigation
feat: read the config from YAML and JSON as well as TOML - #15
Merged
Merged
Conversation
Every canonical config location now takes a .toml, .yaml, .yml or
.json extension, and the extension says which language the file is
in. The same schema applies to all three: toml, serde-saphyr and
serde_json read it into one ConfigFile, which still rejects unknown
keys. --config-path works the same way, and an extension deslag does
not know is an error. Two files at one location, such as deslag.toml
and deslag.yaml, are an error rather than a silent pick.
serde-saphyr is pure Rust and maintained; serde_yaml is archived. It
is built with only its deserialize feature.
A parse error printed its source twice: the Error messages held
{source} and main.rs also prints the chain. The messages no longer
hold it.
tests/formats.rs covers every canonical path in every language, one
config in all three languages giving the same report, the error
cases, and the once-only parse error.
The layout entry for src/config/ named the config languages and a file. Both go stale as the code changes, and neither helps an agent find its way. Say what the directory is for instead.
8 tasks done
webern
added a commit
that referenced
this pull request
Sep 27, 2026
## 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 #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 (#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 - [x] `make ci`: exit 0, 140.6 s (144.9 s before, on main). - [x] `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. - [x] Cases under `tests/cases/list_growth/`: broken, clean (with a file added whole), a custom message, and no base for `check` and for `fix`. - [x] `tests/output.rs` now fails `list_growth` too, so every format is checked with a change lint. - [x] `tests/diff.rs`: `--base` does not narrow, `--base` with `--diff` is refused, `fix` takes a base and refuses a bad one before writing. - [x] `make test-blobs`: the pair golden file, 281 of 474. - [x] `list_growth` over the measured edits, and over deslag's own history, as above. - [x] `make check-deslag` with `list_growth` on: exit 0. ## References - Progresses #16. The policy it asks for is enforced; its own example, an inline series, is not caught. - Related to #18: detecting an agent editing a human-owned file is out of scope, and no rule measured here suggests one.
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
The config can now be written in TOML, YAML or JSON. Every canonical location (
.deslag/config,deslag,config/deslag,.config/deslag,.agents/deslag,.claude/deslag) takes a.toml,.yaml,.ymlor.jsonextension, and the extension says which language the file is in.--config-pathworks the same way. The schema is identical in all three: the same keys and nesting, and unknown keys are still rejected everywhere.The search order is location first, then extension. An earlier location in any language wins over a later one, which is how the TOML locations already behaved. Two files at the same location, such as
deslag.tomlnext todeslag.yaml, are an error instead of a silent pick. An extension deslag does not know, such asdeslag.ini, is also an error.YAML is read by
serde-saphyr, built with only itsdeserializefeature.serde_yamlis archived andserde_ymlhas a poor reputation.serde-saphyris pure Rust and actively maintained, and it gives good error messages with a snippet and a caret. Its 1.1 line is the newest that fits ourrust-versionof 1.85.serde_jsonmoves from a dev-dependency to a dependency.This also fixes an existing bug: every parse error was printed twice. The
Errormessages held{source}, andmain.rsprints the whole chain with{error:#}, so each source appeared twice. The messages no longer hold{source}, so the chain prints each one once.The public config API changed a little.
CANONICAL_CONFIG_PATHSis replaced byCANONICAL_CONFIG_STEMS,CONFIG_EXTENSIONSandcanonical_config_paths(). There is a newConfigFormat, andError::Parsenow holds a boxed error.Testing
make ci: exit 0make check-publish: dry run uploads cleanlytests/formats.rs:.ymland JSON, gives byte-identical output--config-pathworks in each language, and an unknown extension is an errorschema_version: 0, broken syntax, a missingschema_version, and a laterschema_versionReferences
deslag instructions config-schemawill need to describe all three languages