Skip to content

docs: tighten the setup guide - #247

Merged
webern merged 2 commits into
mainfrom
m/deslag-guideroom
Nov 2, 2026
Merged

webern merged 2 commits into
mainfrom
m/deslag-guideroom

Conversation

@webern

@webern webern commented Nov 2, 2026

Copy link
Copy Markdown
Owner

AI Summary

The setup guide, src/instructions/guide.md, sat 29 bytes under its 4,847-byte budget (0.6% free), so any later edit to it had no room. This PR says the same rules in fewer bytes: the guide goes from 4,818 to 4,700 bytes, which leaves 147 free (3.0%). The budget in .agents/deslag.toml is unchanged. Every command, path, number and "never" in the guide is still there. Paragraphs are reflowed to 100 columns.

Edits

Old New
These instructions are for an agent setting up deslag {version} ... To set it up, follow the steps in order. With a config, you need steps 4 and 5. For an agent setting up deslag {version} ... To set it up, follow the steps in order; with a config, steps 4 and 5.
The human who owns the repository owns the limits The repository's human owns the limits
add an override or an exclude, only to make a check pass add an override or exclude, only to pass a check
a config without the section does not read them without the section they are not read
Keep one only where comments should meet the standard of prose. Keep one only where comments should meet prose's standard.
With no globs, every file of the kind is read. Without globs, every file of the kind is read.
Files that git ignores, or a .ignore file lists, are never read. Files git ignores, or a .ignore lists, are never read.
A generated file must not show as selected. Change the globs until every file reads as you mean. Change the globs until no generated file is selected and every file reads as you mean.
a report on standard error and exit code 1 a report on stderr and exit 1
where the repository runs its checks where the repository's checks run
deslag is not on crates.io yet, so ask the human deslag is not on crates.io yet; ask the human
deslag runs from the root of the repository deslag runs from the repository root
lint the comments of those source files lint comments in those source files
A pattern with a / matches A pattern with / matches

--dry-run does not write a file is kept as it was. The shorter "writes nothing" fails verbs_nothing on the repo's own deslag check, and "writes no file" fails verbs_no_nouns.

Three of these were corrected after a review of the diff, because the first draft changed meaning or read badly: "should" had become "must" (a stronger rule, not a tighter one), "No globs reads every file of the kind" read like a command, and "that" had been dropped from "notes that an older deslag", which made "an older deslag" look like the object of "notes". It is restored.

Decided on the maintainer's behalf

The opening sentence is now a fragment ("For an agent setting up deslag ..."). It is the edit furthest from the old wording. It is kept because the fresh agent in the trial below read it as intended.

No-context trial

A fresh agent was given only the old guide (39b804f) and another only the new guide (02f1805), no tools, with version 0.7.0 and schema 2 filled in. Each answered the same eight questions. The three corrections above came after the trial and touch no sentence that a question exercises.

  1. Where is the config?
  2. What does init write?
  3. Which files does [md] read, and how do you keep generated code out?
  4. What can an override not do?
  5. What do exit 1 and exit 2 mean?
  6. How do you set a first limit?
  7. Who may write an allow entry?
  8. What goes in CI?

Old guide:

  1. The config is the first existing file among .deslag/config, deslag, config/deslag, .config/deslag, .agents/deslag and .claude/deslag. Each takes one of the extensions .toml, .yaml, .yml or .json, and deslag runs from the repo root.
  2. deslag init writes deslag.toml at the root, or the file --config-path names, with every lint on.
  3. [md] reads every *.md file unless its globs say otherwise, plus the comments of Rust, C, C++ and TOML code fences. To keep generated code out, use exclude, which takes the same patterns as globs. Files that git ignores or a .ignore file lists are never read.
  4. An override cannot turn a lint off.
  5. Exit 1 means a file failed and a report went to standard error. Exit 2 means deslag could not run.
  6. Propose a limit above the file's size: add 10%, at least 500 bytes. A file that needs more gets an override. The human owns the limits, so show them what each would fail.
  7. Only a human may exempt a sentence. The agent gives them the text and a reason and does not write the entry.
  8. Add deslag check --base origin/main where the repo runs its checks, with fetch-depth: 0 in GitHub Actions. --format github and --format sarif are optional. Do not upload the --diff log.

New guide:

  1. The config is the first existing path among .deslag/config, deslag, config/deslag, .config/deslag, .agents/deslag, .claude/deslag, each with extension .toml, .yaml, .yml or .json, read from the repository root.
  2. deslag init writes deslag.toml at the root (or the file --config-path names) with every lint on.
  3. [md] reads every *.md file unless its globs say otherwise, plus comments in Rust, C, C++ and TOML code fences. Keep generated code out with exclude, which takes the same patterns as globs and works in an override too.
  4. An override cannot turn a lint off.
  5. Exit 1 means a failing file got a report on stderr. Exit 2 means deslag could not run.
  6. Tell the human what each lint fails and propose a limit above the file's size: add 10%, at least 500 bytes. A file needing more gets an override.
  7. Only a human may exempt a sentence. The agent gives them its text and a reason.
  8. Add deslag check --base origin/main where the repository's checks run, with fetch-depth: 0 in GitHub Actions. --format github and --format sarif are optional outputs.

Comparison: the answers match in substance. The old agent mentioned three extras the new one did not (.ignore files, that the human owns the limits, not uploading the --diff log). Those sentences are in both guides, so the difference is variance in what each agent chose to mention, not an edit.

Testing

  • make ci-fast: exit 0
  • make check: exit 0, including deslag's own check of the guide
  • guide.md size: 4,818 bytes before, 4,700 after (budget 4,847)

References

No open issue is closed by this change.

Cut 117 bytes of wording from the setup guide so it has 3% of its
byte budget free. Every rule, command and number stays.
Say "should" again where the old text said it, say "Without globs,
every file of the kind is read", and keep "that" in "notes that an
older deslag". Cut a few other words so the guide stays at 4,700 bytes.
@webern webern added docs Documentation including agent instructions, readmes, code comments, etc. ai Primarily authored by AI (whether PR, Issue, Whatever) labels Nov 2, 2026
@webern
webern marked this pull request as ready for review November 2, 2026 14:28
@webern

webern commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

Ready for review. CI is green on 9f55b6d.

This frees 3% of the setup guide's byte budget so later edits to it fit; the budget itself is unchanged. The one choice made on the maintainer's behalf is the new opening fragment ("For an agent setting up deslag ..."), the edit furthest from the old wording; a fresh agent reading only the new text answered the eight trial questions the same as one reading the old text, and both answer sets are in the body.

@webern webern added the approved The PR is approved for merging. label Nov 2, 2026
@webern
webern added this pull request to stack #256 November 2, 2026 16:34
@webern
webern merged commit 5039f11 into main Nov 2, 2026
6 checks passed
@webern
webern deleted the m/deslag-guideroom branch November 2, 2026 16:36
webern added a commit that referenced this pull request Nov 2, 2026
This builds on #247 and shows only its own diff until #247 merges.

## AI Summary

deslag used to take the directory it ran in as the root of the
repository. Run from a subdirectory, `check --config-path
../deslag.toml` scanned that subdirectory alone, `init` wrote a config
there, and `init --config-path lint/my.toml` wrote a file that `check`
never looked at. A `.agents/deslag.toml` beside a `.deslag/config.toml`
of another schema left `check` exiting 0 with every lint off.

What changed:

- The config is found by searching from the current directory up to the
nearest directory that holds a `.git`, a file or a directory, and no
further. Outside a work tree only the current directory is searched. The
first directory with a config at a canonical location is the root.
- The root is the directory the config path is relative to:
`.agents/deslag.toml` gives the parent of `.agents/`. A config below the
top of the work tree roots a run at or below it.
- Findings and paths are relative to the root from any directory: globs,
`allow` paths, `--diff` and `--base`, the text report, JSON, SARIF and
GitHub annotations, and the paths `fix` and `explain` take. A path
copied from a report works anywhere. When the root is not the current
directory, `check`, `fix` and `explain` print one stderr line naming the
root and the config. The config is shown from the root where it is under
the root, and absolute otherwise.
- No config exits 2 and names the directories searched, the paths tried
and `deslag init`.
- Two configs in one directory, at any canonical locations and in any
language, exit 2 naming each.
- `init` refuses where the search finds a config. With no
`--config-path` it writes `deslag.toml` at the top of the work tree. A
`--config-path` must end in a canonical TOML location whose root is the
current directory or an ancestor within the work tree, else exit 2
listing them. `init` creates the one parent directory a stem needs. So
`check` from the same directory reads what `init` wrote, with no flag.
- `update` and `instructions update` use the same search, so they edit
the config `check` reads. Without it, `instructions update` from a
subdirectory said no config was found in a work tree that has one.
- The guide, the README, the help text and the code docs say this. The
JSON `path` doc comment, which reaches `deslag instructions
output-schema`, now says the path is relative to the config's directory.

Out of scope: a global config (#63), a smarter `init`, ignore files
above a root below the top of the work tree, and
`GIT_CEILING_DIRECTORIES`.

### Decided on the maintainer's behalf

- Stop at the nearest `.git` and never search to `/`. `.config/deslag`
is a canonical stem, so a search to `/` would take
`~/.config/deslag.toml` and walk the home directory. The probe is a file
test, not git, so `check` needs no git without `--base`.
- The nearer config wins over a farther one, silently. Nothing above the
first directory with a config is read and nothing is merged, as #34
asks. The alternative, refusing or merging, would read two files.
- A submodule or nested repository hides the parent's config. Its `.git`
ends the search, so a run inside it does not find the config of the
repository around it. This follows from the first decision.
- `--config-path` is rooted at the top of the work tree, or at the
current directory outside one, so the same flag gives the same report
from any directory.
- Two configs in one directory are refused, not ordered. A silent pick
between a `.agents/` config and a `.deslag/` one is how `check` came to
exit 0 with every lint off.
- `init` accepts only a path `check` would look at. Other commands still
take any `--config-path`.
- `update` and `instructions update` follow the search, as above.

### Tests

New, in the fast tier: unit tests for the search in
`src/config/search.rs` (config at the current directory, two levels up,
above `.git`, `.git` as a file, nearer and farther configs, two stems,
no work tree, an explicit path) and `tests/root.rs` (check,
`--config-path`, an `allow` entry, `explain` and `fix`, a config below
the top, nothing read above the top, `.git` as a file, no work tree, two
stems, `update` from a subdirectory, `init` from a subdirectory, `init
--config-path` and its refusals, and the note line for a config outside
the work tree). `tests/slow/diff.rs` runs `--diff` and `--base` from a
subdirectory.

Changed, each read: `an_earlier_location_in_any_language_wins` in
`tests/formats.rs` is now a refusal naming both files; the `init
--config-path` test in `tests/slow/init.rs` now refuses `lint.toml` and
accepts `.agents/deslag.toml`; the subdirectory test in
`tests/instructions.rs` now finds the config from a subdirectory; the
missing-config test in `tests/unit.rs` expects `deslag init` in place of
"are you in the root". Two assertions moved from "at one location" to
"in one directory" with the new message.

Deleted: the corpus case `the-earlier-canonical-location-wins` and the
test `the_earlier_canonical_location_wins`. Both asserted the opposite
of the new rule, that the first of two configs wins. The case was a test
config over fixtures; no fixture or golden changed. No golden, case or
corpus output moved, because every one of them runs at its root.

Mutations, each failing at least one test with the change in place:

- search to `/`: three search unit tests and three integration tests
- `.git` a directory only: the search unit test for a `.git` file and
`a_git_file_ends_the_search_as_a_directory_does`
- farthest config wins: the nearest-wins unit test and
`a_config_below_the_top_roots_a_run_at_or_below_it`
- first stem wins: one search unit test and four integration tests
- `--config-path` rooted at the current directory: the explicit-path
unit test and
`config_path_from_a_subdirectory_scans_the_repo_from_its_top`
- `init` makes no parent directory:
`init_config_path_makes_its_parent_and_check_finds_the_file` and the
slow `init` test
- `update` reading the current directory:
`update_from_a_subdirectory_edits_the_config_at_the_root`

`src/instructions/guide.md` is 4,730 bytes of its 4,847.

## Testing

- [x] `make ci-fast`: exit 0
- [x] `make test`: exit 0
- [x] `make test-tools`: exit 0

## References

- Builds on #247
- Related: #63 (a global config, out of scope), #34
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) approved The PR is approved for merging. docs Documentation including agent instructions, readmes, code comments, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant