Skip to content

refactor: move version out of changelog and the schema walk into the library - #210

Merged
webern merged 1 commit into
m/deslag-ghnotesfrom
m/deslag-vermove
Oct 26, 2026
Merged

webern merged 1 commit into
m/deslag-ghnotesfrom
m/deslag-vermove

Conversation

@webern

@webern webern commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Two file moves. No behaviour changes.

src/changelog/version.rs is now src/version.rs, public as deslag::version. It holds Version, BASELINE, current_release and parse_release. BASELINE was declared in src/changelog/mod.rs and moves with them. The two tests of Version that were in the changelog module's tests (next_sorts_above_every_release, a_version_that_is_neither_semver_nor_next_is_refused) move too, with their bodies unchanged. The new test module has its own copy of the one-line version helper they call, because the changelog tests still use the original. The changelog module no longer re-exports any of these items and keeps everything else. Every use of them in src/, tests/ and tools/ now names deslag::version or crate::version.

tools/release/src/schema.rs, the walk over the config schema (SchemaPaths, resolve, the folding of override paths onto section paths, the reading of defaults), is now src/config/paths.rs, public as deslag::config::paths. The release tool and tests/common/schema.rs use it from the library, and the release tool's schema module is gone. The walk uses only std and serde_json, which the library already depends on, so the library gains no dependency, and no code in the file changed. The file had no unit tests to move.

Why: a later change gives every setting the release it arrived in. deslag reads that at run time, so it needs the schema walk in the library. Doing the moves on their own keeps that change's diff about arrival releases only.

The module docs in src/lib.rs, src/config/mod.rs, tools/release/src/lib.rs and the two moved files now describe the new homes. The Repository layout block in AGENTS.md names neither file, so it is unchanged. There is no changelog entry, because this is a refactor.

Testing

  • make ci-fast: exit 0
  • make test-tools: exit 0
  • cargo doc --no-deps -p deslag (with RUSTDOCFLAGS="-D warnings"): exit 0
  • No test body changed. Only use paths changed, plus the move of the two Version tests described above.

git diff -M --stat against the base shows both moves as renames:

 src/changelog/mod.rs                               | 24 +---------------
 src/cli/mod.rs                                     |  2 +-
 src/config/mod.rs                                  |  6 ++--
 tools/release/src/schema.rs => src/config/paths.rs |  3 +-
 src/config/update.rs                               |  8 +++---
 src/instructions/mod.rs                            |  3 +-
 src/instructions/update.rs                         |  3 +-
 src/lib.rs                                         | 14 ++++++----
 src/lint/banned_phrases.rs                         |  2 +-
 src/lint/mod.rs                                    |  2 +-
 src/main.rs                                        |  5 ++--
 src/news.rs                                        |  3 +-
 src/{changelog => }/version.rs                     | 32 +++++++++++++++++++++-
 tests/blobs.rs                                     |  2 +-
 tests/changelog.rs                                 |  3 +-
 tests/common/mod.rs                                |  3 +-
 tests/common/schema.rs                             |  2 +-
 tests/golden.rs                                    |  2 +-
 tests/instructions.rs                              |  3 +-
 tests/phrases.rs                                   |  2 +-
 tests/slow/corpus.rs                               |  2 +-
 tests/slow/update.rs                               |  3 +-
 tests/stamp.rs                                     |  2 +-
 tools/corpus/src/lints.rs                          |  2 +-
 tools/corpus/tests/tree.rs                         |  2 +-
 tools/release/src/freeze.rs                        |  2 +-
 tools/release/src/lib.rs                           |  4 +--
 tools/release/tests/release.rs                     |  2 +-
 28 files changed, 82 insertions(+), 61 deletions(-)
 rename tools/release/src/schema.rs => src/config/paths.rs (98%)
 rename src/{changelog => }/version.rs (74%)

git diff --stat without -M prints the same table, since git detects renames by default. paths.rs is 98% similar: only its module doc changed. version.rs is 74% similar: it gains BASELINE, the two tests and a longer module doc, and none of its code changed.

References

…library

Move src/changelog/version.rs to src/version.rs. It now holds Version,
BASELINE, current_release and parse_release, and the two tests of
Version that were in the changelog module. The changelog module keeps
everything else and no longer re-exports these items. Every use of
them in src/, tests/ and tools/ now names deslag::version.

Move the schema walk, SchemaPaths and resolve, from the release tool
to the library as deslag::config::paths. The release tool and the
tests use it from there, and the release tool's schema module is gone.
The walk needs only std and serde_json, so the library gains no
dependency.

Nothing changes in behaviour. A later change gives every setting the
release it arrived in, and it needs the schema walk in the library at
run time.
@webern webern added ai Primarily authored by AI (whether PR, Issue, Whatever) area/config Has to do with deslag configuration (deslag.yaml, etc.) labels Oct 25, 2026
@webern
webern added this pull request to stack #212 October 25, 2026 20:19
@webern
webern marked this pull request as ready for review October 25, 2026 20:21
@webern
webern merged commit 829520d into main Oct 26, 2026
6 checks passed
@webern
webern deleted the m/deslag-vermove branch October 26, 2026 06:23
webern added a commit that referenced this pull request Oct 26, 2026
## Human Summary

This changes the way upgrade instructions are organized and discovered.
The old method was causing some confusion in the coding agents as to
what needed to be documented, what should be immutable, etc. This
redesign should make it more straightforward to maintain.

## Summary

When an agent upgrades deslag in another repository, `deslag
instructions update` tells it what arrived after the config's
`deslag_version`: the new lints, the new settings, the settings that
were renamed or removed, and the new catalogue phrases. This PR changes
where that comes from. Each of those things now records the release it
arrived in, its `since`, right where it is defined, and the update topic
selects by `since` alone.

**How the agent is told, and how it is selected.**

- A setting has `#[schemars(extend("since" = "..."))]` beside its doc
comment, so the JSON schema carries a `since` keyword on every property
(`deslag instructions config-schema` prints it). The schema walk
(`src/config/paths.rs`) gives each path the latest `since` of itself and
the tables above it.
- A lint's `since` is the `since` of its field of `Lints`, read by
`Lint::since`.
- A redirect has a `since` field, and a catalogue phrase already had
one.
- `News` (`src/news.rs`) takes everything whose `since` is after the
stamp, up to the running release. A setting is a topmost new path, so a
new table is one setting, not one per key. A key under the table of a
lint that is itself new is left to that lint's page; a key added later
to an older lint is a setting. The new path of a rename shows under its
redirect only. `next` is in no range that ends at a release.
- The text prints, in order: `## Renamed or removed settings` (the
message `check` gives for each), `## New lints` (the page `deslag
instructions lints` prints for each, with "This config already has a
`<lint>` table." when it does), `## New settings` (each doc comment, in
path order; paths with the same doc comment share one heading, at the
first path, with the latest `since`), `## New phrases`, and `## Finish`.
`--format json` gives one item per redirect, lint, setting and phrase in
the same order, each with `version`, `kind`, `id` and `text`, plus
`already_set` for a lint, `new` for a redirect (null for a removal) and
`group` for a phrase.
- The note that `check` prints and the hold of a bare `deslag update`
ask the same `News`, so they cannot disagree.

**Worked example.** A config stamped 0.0.1 with only
`[md.lints.density]`, read by the release that ships what is `next`
today, 0.0.2 (run with a build made by `deslag-release prep 0.0.2`,
below):

````markdown
# What is new in deslag 0.0.2, since 0.0.1

## New lints

### `not_at_all` (0.0.2)

`not_at_all` fails a negation padded with "at all", such as `it does not parse at all`, `no
examples at all` or `it is not at all clear`; this repo writes "it does not parse". The padding adds
stress and nothing else, and in a review it reads as dismissal. The fix is to delete "at all".

It passes a question (`does it work at all?`), `whole or not at all`, a lone `Not at all.` with or
without a label such as `A:`, `at all times` and its kin, and `hardly`, `barely` and `scarcely`.
For text that is not English, scope it with `globs`. Ask the human before turning it off or
scoping it.

```toml
[md.lints.not_at_all]
message = "..."  # optional; replaces the advice
```

## New settings

### `cpp.allow`, `md.allow`, `rust.allow`, `toml.allow` (0.0.2)

The sentences of these files that stay as written, each exempted from one lint. Only a
human writes an entry. `deslag instructions lints` says how to write one.

### `cpp.exclude` (0.0.2)

Files `globs` match that this section leaves out, such as generated code. A pattern is
written as in `globs`, from the repo root with a `/`, else by file name, and not needing a C
or C++ extension. A file the walk skips stays skipped, and nothing re-includes one. Only a
human adds an exclude; never add one to make a check pass.

### `cpp.overrides[].exclude`, `md.overrides[].exclude`, `rust.overrides[].exclude`, `toml.overrides[].exclude` (0.0.2)

Files `globs` match that this override leaves alone, so they get the section's settings.
Written as `globs` are, from the repo root with a `/`, else by file name, and needing no
extension. Nothing re-includes a file. Only a human adds an exclude; never add one to make
a check pass.

### `md.exclude` (0.0.2)

Files `globs` match that this section leaves out, such as generated code. A pattern is
written as in `globs`, from the repo root with a `/`, else by file name, and needing no
extension. A file the walk skips stays skipped, and nothing re-includes one. Only a human
adds an exclude; never add one to make a check pass.

### `rust.exclude` (0.0.2)

Files `globs` match that this section leaves out, such as generated code. A pattern is
written as in `globs`, from the repo root with a `/`, else by file name, and not needing to
end in `.rs`. A file the walk skips stays skipped, and nothing re-includes one. Only a human
adds an exclude; never add one to make a check pass.

### `toml.exclude` (0.0.2)

Files `globs` match that this section leaves out, such as generated code. A pattern is
written as in `globs`, from the repo root with a `/`, else by file name, and not needing to
end in `.toml`. A file the walk skips stays skipped, and nothing re-includes one. Only a
human adds an exclude; never add one to make a check pass.

## Finish

Moving `deslag_version` to 0.0.2 turns on no phrase in this config. Nothing else `check` finds depends on `deslag_version`, so there is nothing to compare. Only the note that the config is behind goes.

Offer each new lint and phrase to the person, with what it fails. Add the table of each lint they
choose, and keep off each phrase they want off, as its section says: a phrase is on once the
version moves. A new setting keeps its default until the config sets it; name it to the person,
and set it only if they ask.

Once they have chosen, run `deslag update --to 0.0.2`, adding your `--config-path` if any. It sets
`deslag_version` to "0.0.2", ending this list, and edits renamed or removed settings. If the person
cannot be asked now, change nothing, not even `deslag_version`, and tell them what is new.
````

**What was deleted and why.** `src/changelog/` is gone, with its 48
entries, its README, the listing in `build.rs`, `tests/changelog.rs` and
`deslag-release`'s entry reader. The entries served two readers at once
and did neither well; release notes come from GitHub, instructions from
the lint pages, compatibility from the schema.

**What `prep` does now.** `deslag-release prep <version>` keeps its
version checks, clean-tree check and crate version edits. It sets
`"next"` to the version in three exact forms and no other text: `since =
"next"` in `src/lint/banned_phrases.toml`, `extend("since" = "next")` in
`src/**/*.rs`, and `since: "next"` in `src/config/redirect.rs`. Every
release then writes `tests/configs/<version>/` whole: the frozen config
in TOML, YAML and JSON, and `schema.json`, the config schema with each
`next` set to the version. A setting the newest frozen config leaves out
takes the schema default, else its value in the new
`tests/configs/fill.toml`, else `prep` stops before any write, naming
the setting and the file. `tests/configs/0.0.1/schema.json` is the
`deslag instructions config-schema` output of a `v0.0.1` build, and its
hash joins `tests/configs/hashes`. `make check-release` now runs the
ignored tests of `tests/since.rs` and `tests/frozen.rs`, with
`--no-fail-fast` so one run names every check left.

**The skill.** `.agents/skills/deslag-upgrade-instructions/SKILL.md`,
listed in `AGENTS.md`, says what a change writes: a new lint gets its
page and the `since` attribute on its `Lints` field; a new setting gets
a doc comment and the attribute; a renamed or removed setting gets a
redirect with `since: "next"`; a new phrase gets `since = "next"`.
Nothing else is written for the upgrading agent. `tests/since.rs` fails
on a schema property without a `since` and names the attribute to add.
`/deslag-release` now expects the `next` rewrites and a new frozen
directory of four files.

**Other changes.** `News` takes every `since`, lints included, from the
schema it is handed, so a unit test with a schema of its own sees no
real arrival, before or after a release. `Closing` in
`src/instructions/update.md` says a new setting keeps its default until
the config sets it, and is split into two paragraphs to stay under the
`density` limit; its budget rises to 1585 bytes. The `allow` doc comment
of each section points at `deslag instructions lints`.
`no_arrival_names_next` applies `prep`'s rewrite to `src/` in memory and
fails on any form the rewrite would leave, so it holds between releases
and still catches a form written where `prep` does not look.

## Testing

- [x] `make ci-fast`: exit 0
- [x] The network-free targets of `make ci` (`preflight check build
test-exam test-product test-tools`): each exit 0. `test-blobs` and
`test-scanners` were not run: they need the network, `test-blobs` to
fetch the corpus's big tier and `test-scanners` to fetch the crates it
sweeps.
- [x] `make check-release`: exit 2, failing exactly
`the_newest_frozen_configs_name_every_setting` (`tests/frozen.rs`) and
`nothing_arrives_in_next` (`tests/since.rs`). Both are expected on
`main` between releases: 15 schema fields are `next`, and the newest
frozen config, 0.0.1, does not name them.
`no_frozen_directory_is_above_the_crate_version`,
`the_crate_version_is_a_release`, `no_since_is_above_the_crate_version`
and `no_arrival_names_next` pass.
- [x] A real release, in a fresh scratch clone of the branch:
`deslag-release prep 0.0.2`, then `make ci-fast`, then `make
check-release`, then the frozen and since tests. `prep` printed:
  ```
  Cargo.toml and Cargo.lock: version 0.0.2
  src/lint/banned_phrases.toml: 0 of `since = "next"` set to 0.0.2
  src/**/*.rs: 15 of `extend("since" = "next")` set to 0.0.2
  src/config/redirect.rs: 0 of `since: "next"` set to 0.0.2
tests/configs/0.0.2: config.toml, config.yaml, config.json and
schema.json written, with their hash lines
  ```
It changed `Cargo.toml`, `Cargo.lock`, seven files under `src/config/`
and `tests/configs/hashes` (four new lines), and wrote
`tests/configs/0.0.2/config.toml`, `config.yaml`, `config.json` and
`schema.json`. The dump holds `"0.0.2"` 15 times and `"next"` none; no
form of `next` is left under `src/`. Then, in the clone:
  - `make ci-fast`: exit 0.
- `make check-release`: exit 0. `tests/frozen.rs`: 2 passed;
`tests/since.rs`: 4 passed.
- `cargo test --test frozen`: 8 passed, 2 ignored. `cargo test --test
since -- --ignored`: 4 passed.

  This is the run `bump-version.yml` makes. The clone was then deleted.
- [x] The worked example above, diffed against the design's text:
identical except that the closing paragraph is two paragraphs. With this
branch's own build, at 0.0.1, the same repo prints `Nothing is new in
deslag 0.0.1 since 0.0.1: the config is current.`, since `next` is in no
range; the library with `to = next` prints the same text with `next` for
0.0.2.
- [x] `grep -rni changelog` over `src tests tools scripts Makefile
.github .agents build.rs README.md AGENTS.md`, without `tests/corpus`,
`tests/gold`, `tests/golden` and `tools/exam`: only the places that name
other projects' changelog files remain: `src/glob/select.rs`,
`src/tag/weights.txt`, `scripts/llm-detection/collect.py`,
`tools/corpus/tests/golden.rs` and
`tools/corpus/tests/golden/summary.json`.
- [x] `git diff --stat` against the base, over `tests/cases`: empty.

## References

- Stacked on #209 and #210.
- Related to #16 and #68.
- No issue is closed.
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/config Has to do with deslag configuration (deslag.yaml, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant