Skip to content

feat: lint a possessive noun padded with "own" - #240

Merged
webern merged 3 commits into
mainfrom
m/deslag-own
Nov 1, 2026
Merged

webern merged 3 commits into
mainfrom
m/deslag-own

Conversation

@webern

@webern webern commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Human Summary

This seems like a reasonable starting point that catches a lot of the "own" overuse that bugs me.

Summary

A new lint, possessive_own, fails a possessive noun padded with "own": the tool's own reference, the crate's own version, the rules' own reading. The possessive already says whose, and "own" re-asserts it. The fix is to delete "own", or, where the contrast is the point, to name what it contrasts with ("deslag's config, not the user's").

#194 built this lint as every <possessive> own plus a per-file rate and was shelved: that matcher could not tell a padded "own" from a meaningful one. This PR narrows the match to the frame that carries the tic. The owner labelled 47 sentences blind, mixed from the human and llm sides of the corpus and from this repo's text: <noun>'s own <noun> was the tic 13 times of 16, its own and their own 4 of 21, your own 0 of 4, the idioms 0 of 6. So the lint matches the noun's own frame, one instance fails a file, with no rate, no floor and no tagger.

What counts, in one sentence: a word ending in 's or s' (either apostrophe), then "own" or "very own", then a word or a code span. Not counted, each pinned by a unit test or a case:

  • pronouns and contractions in 's: it's, that's, there's, what's, who's, let's, here's, where's, how's, he's, she's, one's, and the indefinite pronouns everyone's, someone's, nobody's and their kin; so its own, their own, your own and one's own never match;
  • coordinated possessors, where another possessive precedes with only and, or or a comma between (X's and Y's own diagnostics): a real contrast;
  • "own" with nothing after it (is the crate's own., a place of its own) or before a preposition, conjunction, determiner or auxiliary;
  • a quote standing apart from its word (users 'own files'), owns, owner, ownership, and anything in code.

There is no contrast-marker exemption: the owner's tics included sentences holding "but" and "rather than".

The report names each place and gives the advice above, in the shape of not_at_all. The config table is [md.lints.possessive_own] with only message, since = "next"; deslag init writes it on, with the standing of not_at_all after #203. The allow page lists the lint.

The claim, checked by tests/slow/corpus.rs on the tree and by make test-blobs on the big tier, English fixtures only: the tree has 2 of 380 human files and 41 of 380 llm files; the big tier (ghcr.io/webern/deslag-blobs:v7@sha256:d9a3047c38e2f9e7845f15f4a4f8a66b715595879f818e4ad4cd0997077c85fb) has 50 of 10,037 human (0.50%) and 824 of 7,498 llm (10.99%), about 22x against the 3x and 3.5% the other taste lints hold to. The human hits read are real uses ("GitHub's own review feature", "Ruby's own OptionParser class"): the lint flags them too and cannot tell them apart, which is one of the two reasons #61 stays open; the other is that padded "own" outside this frame exists and is not caught.

The repo's own text

With the tables in .agents/deslag.toml (md, rust, toml; tools/corpus/report.toml mirrors the md settings) the lint found 40 lines in the files deslag reads. Each is reworded below by deleting "own" or by naming the contrast; the audit classed 3 as better, 37 as neutral, none as a side-step and none as worse. Text outside those sections, in tools/, scripts/ and build files, is left as it is: deslag does not read it.

File Before After
.agents/deslag.toml:110 # The comments of deslag's own source. A comment may not hold the characters and phrases the # The comments of deslag's source. A comment may not hold the characters and phrases the
.agents/deslag.toml:148 # The comments of deslag's own TOML outside tests/, and not the golden files of tools/sweep, which # The comments of deslag's TOML outside tests/, and not the golden files of tools/sweep, which
src/change/patch.rs:4 //! it replaces. Paths come from the header's own lines, rename from, --- and the like, since //! it replaces. Paths come from the header's other lines, rename from, --- and the like, since
src/config/allow.rs:22 //! the text after parsing, so an escape in the config's own syntax, such as TOML's \u200B, is no //! the text after parsing, so an escape in the config's syntax, such as TOML's \u200B, is no
src/config/edit/lines.rs:216 /// For each line of old, whether an edit may take it away: a TOML key's own lines, the comment /// For each line of old, whether an edit may take it away: a TOML key's lines, the comment
src/config/edit/lines.rs:217 /// lines right above them, and the run of blank lines on each side; a YAML or JSON key's own lines /// lines right above them, and the run of blank lines on each side; a YAML or JSON key's lines
src/config/edit/remove.rs:7 //! the table's only one, the table's own line gains {} after its colon and any anchor or tag, //! the table's only one, the table's line gains {} after its colon and any anchor or tag,
src/config/edit/tests.rs:783 /// extension: the editor's own plan, with its text changed. /// extension: the editor's plan, with its text changed.
src/config/edit/tests.rs:1207 // The table's own line may hold an anchor or a tag and a comment, and the {} goes before // The table's line may hold an anchor or a tag and a comment, and the {} goes before
src/config/edit/tests.rs:1879 let right = run(extension, text, Some("0.0.1")).expect("the editor's own text"); let right = run(extension, text, Some("0.0.1")).expect("the editor's text");
src/config/edit/toml.rs:336 /// key's own indentation, and, unless keep_comments, the comment lines directly above the key. /// key's indentation, and, unless keep_comments, the comment lines directly above the key.
src/config/edit/toml/apply.rs:239 /// How a new table in parent is written: as the parent's own tables are. /// How a new table in parent is written: as the parent's other tables are.
src/config/mod.rs:215 // which words it best; the head's own stands only if the file reads. // which words it best; the head's error stands only if the file reads.
src/config/section.rs:174 /// The section's own lints table. /// The section's lints table.
src/config/update.rs:228 /// The release these tests run as, which is what the stamp moves to. The crate's own version /// The release these tests run as, which is what the stamp moves to. The crate's version
src/config/v1/mod.rs:45 /// The section's own table. /// The section's table.
src/document/cpp_regions.rs:666 /// The alphabet of the scanner's own property tests, and the markers, splices and directives /// The alphabet of the scanner's property tests, and the markers, splices and directives
src/document/edit.rs:15 //! 4. The document's own reader, reading the result, finds the same blocks, spans, line breaks and //! 4. The document's reader, reading the result, finds the same blocks, spans, line breaks and
src/document/region.rs:178 /// template, so the region's own text encodes to the bytes it was read from. /// template, so the region's text encodes to the bytes it was read from.
src/explain/mod.rs:6 //! file's own frontmatter. For each file this names the config, says whether the walk skips the //! file's frontmatter. For each file this names the config, says whether the walk skips the
src/instructions/lints/max_size_bytes.md:1 max_size_bytes fails a file larger than its budget. A max_size_bytes key in a file's own max_size_bytes fails a file larger than its budget. A max_size_bytes key in a file's
src/lib.rs:9 //! 1. the max_size_bytes key in the file's own YAML frontmatter; //! 1. the max_size_bytes key in the file's YAML frontmatter;
src/lint/max_size_bytes.rs:3 //! The budget comes from, most specific first, the max_size_bytes key in the file's own //! The budget comes from, most specific first, the max_size_bytes key in the file's
src/lint/mod.rs:645 /// bytes as the lints read them: the file's own text when it is valid UTF-8, else the text with /// bytes as the lints read them: the file's text when it is valid UTF-8, else the text with
src/lint/not_at_all.rs:365 // The question mark has to be at the end of the match's own sentence. // The question mark has to be at the end of the match's sentence.
src/tag/build_tables.rs:314 /// bias, the previous tags and the rules' own reading. A word adds one row of each sort whole, so /// bias, the previous tags and the rules' reading. A word adds one row of each sort whole, so
src/tag/closed.rs:711 // The table's own contractions are read from it. // The table's contractions are read from it.
src/tag/learned.rs:17 //! tagger and of the perceptron taggers after it) and four that read the rules' own reading: its //! tagger and of the perceptron taggers after it) and four that read the rules' reading: its
src/tag/learned.rs:20 //! tags are the learned stage's own choices, so a sentence is read from its start. The weights, //! tags are the learned stage's choices, so a sentence is read from its start. The weights,
src/tag/learned.rs:115 /// In the token's own text, or a constant. /// In the token's text, or a constant.
src/tag/learned.rs:905 // A word that is the rules' own Likely guess stays Likely below the cutoff, keeping what // A word that is the rules' Likely guess stays Likely below the cutoff, keeping what
src/tag/origin.rs:6 //! finds it from a gold file's own text. //! finds it from a gold file's text.
src/tag/origin.rs:30 //! travels with the lists; they are written by hand from git's own command list, the GNU //! travels with the lists; they are written by hand from git's command list, the GNU
src/tag/pass.rs:105 /// the neighbour's own rule chose, so its guess does not wait on a tag still open. None for a /// the neighbour's rule chose, so its guess does not wait on a tag still open. None for a
src/tag/seen.rs:3 //! A repository's own lowercase names (kubectl, tinytuya) are missing from both tables, and the //! A repository's lowercase names (kubectl, tinytuya) are missing from both tables, and the
tools/corpus/report.toml:2 # where the repository's own config selects only the repository's files, and holds that config's # where the repository's config selects only the repository's files, and holds that config's
tools/sweep/Cargo.toml:36 # so that the sweep's own code and the other crates keep the dev profile's fast builds. # so that the sweep's code and the other crates keep the dev profile's fast builds.

Testing

  • make ci-fast: exit 0
  • make test: exit 0 (tree claim, goldens; no other lint's golden moved)
  • make test-blobs: exit 0 on the big tier, claim row above
  • make check-deslag: exit 0 with the lint on
  • Audit: every exclusion fails its test when removed from the code (mutation checked one by one); the 47 labelled sentences run through deslag check catch all 12 noun's own tics and pass every ok, with its own and the predicative is X's own as designed misses

References

Adds `possessive_own`, which fails a noun's possessive followed by
"own" and a word, as in "the crate's own version". The possessive
already says whose, so the advice is to delete "own", or to name what
the sentence contrasts with.

A match is a word in 's, or a word in s and an apostrophe, then "very"
or nothing, then "own", then a word that is not a function word, or a
code span. It does not match:

- pronoun contractions such as it's and one's, nor its, their, your
- coordinated possessors joined by and, or or commas
- "own" with nothing after it, or before a function word
- owns, owner, ownership, and anything in code

There is no rate and no floor: one match fails the file. The sentence
that names a contrast ("but", "rather than") is still a match.

The lint is a table with only `message`, on a `Pattern`, with no tagger.
It takes an allow entry. The tree test checks that llm files hold it
more often than human files, and the big tier's test holds it to the
claim of the other taste lints.

This commit leaves the repo's own config alone; a later one turns the
lint on here and rewords the text it finds.
Adds the `possessive_own` table to the md, rust and toml sections of
.agents/deslag.toml, and to the report config of tools/corpus, which
has to match the repo's md settings. Each possessive padded with "own"
in the files those sections read is reworded, by deleting "own", or by
naming what the sentence sets the noun against.

Text outside those sections, in tools/, scripts/ and build files, is
left as it is: deslag does not read it.
The pronoun list now also holds everyone's, everybody's, someone's,
somebody's, anyone's, anybody's and nobody's. They are the same idiom
as one's own, so "everyone's own idea" is no longer flagged. This
changes behaviour, which is why this is a fix. CONTRACTIONS is renamed
PRONOUNS_IN_S, since it no longer holds only contractions. The golden
file does not change.

Several exclusions had no test that failed without them:

- Eight of the pronouns were only tested by a loop over the constant,
  or sat in the case README before punctuation or a function word.
  The unit test now has a literal list, one sentence per word, and the
  README puts each before a plain noun.
- The check for a quote apart from its word was hidden by the
  next-word rule. The test now uses 'own files'.
- The coordination check could be widened to the whole document with
  no test failing. A new test ends a block in "ccgo's and" with no
  terminator and starts the next with a possessive and own.
- A new test covers a lone apostrophe before "and" in the plural
  coordination check.

The instructions page used two corpus project names as examples.
They are now the tool and the crate.
@webern webern added enhancement New feature or request ai Primarily authored by AI (whether PR, Issue, Whatever) area/lint Deals with the linting algorithms themselves, how they work. labels Nov 1, 2026
@webern
webern marked this pull request as ready for review November 1, 2026 13:45
@webern

webern commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

An LLM wrote the following.

Ready for your review. Three things are yours to decide; everything else is the design you set on 2026-11-01.

  1. The 40 rewordings in the body. Two of them are sentences you passed when labelling: "The comments of deslag's own source" (.agents/deslag.toml:110, now "deslag's source") and "A word that is the rules' own Likely guess" (src/tag/learned.rs, now "the rules' Likely guess"). You chose to reword rather than write allow entries; say so if you would rather have the entries back.

  2. Text deslag does not read. About 150 more lines of the frame sit in tools/, scripts/, build.rs and the Makefile. A commit that reworded them all, including the note in scripts/label/voters.json (a pinned file whose hash the silver kits record) and a silver-fixture datasheet with its template hash, was dropped as out of scope. It is recoverable if you want it; the lint does not require it.

  3. Indefinite pronouns. everyone's own idea and someone's own copy are excluded, as the same idiom as one's own, which the design excluded. They were not in your 47; the audit raised them.

Two of your tics are designed misses and stay in #61: the four its own sentences, and the predicative "The line count is selfie's own".

@webern
webern merged commit 9b1e775 into main Nov 1, 2026
9 checks passed
@webern
webern deleted the m/deslag-own branch November 1, 2026 14:06
@webern webern mentioned this pull request Nov 1, 2026
4 tasks done
webern added a commit that referenced this pull request Nov 1, 2026
## AI Summary

CI on `main` failed at 9b1e775, the merge of #240, in
`score_holdout_prints_aggregates_for_a_gold_that_lost_its_header`
(`tools/exam/tests/cli.rs`) with "the saved run names `s4`". The failure
does not come from #240. That PR changed nothing under `tools/exam`, and
the test passes on 9b1e775 with an ordinary temp dir. It is a flake that
was always possible.

The test copies a gold file into a temp dir, scores it with `--save`,
and checks that the saved run names none of the words of the done-when
gold (`s1` to `s4`, `cats`, `page` and so on). A saved run records the
path of its gold, and the temp dir's name is random (`.tmpXXXXXX`), so
about one run in a few hundred holds one of those short words by chance.
#148 fixed this for `assert_no_words` by skipping any token that holds
the temp dir's path. The two loops that read a saved run did their own
`contains` and were left out.

This moves the skip into `without_temp_paths` and adds
`assert_no_words_in_run`, which both saved-run checks in `cli.rs` now
call. The word list is the same as before: the gold's words plus `send`,
but not `like`, because the run's column names hold "likely". The other
two raw loops over the words (`score.rs`, `gate.rs`) check fixed error
strings that carry no path, so they stay.

## Testing

- [x] Before the change, `TMPDIR` set to a directory named `s4tmp` and
`cargo test --locked -p deslag-exam --test cli` fails with the same
message at the same line as CI; after it, all 15 pass, and they pass
with an ordinary `TMPDIR` too
- [x] With `sha256` added to the helper's word list for a moment, both
saved-run tests fail with "the saved run names `sha256`", so the helper
still catches a word outside a temp path; reverted
- [x] `make ci-fast`: exit 0
- [x] `make test-tools`: exit 0

## References

- Failing run: https://github.com/webern/deslag/actions/runs/41314500778
- Follows #148, which did this for `assert_no_words`
webern added a commit that referenced this pull request Nov 2, 2026
…ng the C++ lexer (#260)

This builds on #257 and shows only its own diff until #257 merges. This
PR resolves neither the golden-file question nor the library-oracle
corpus tests.

## AI Summary

Three test files were copies of one another, one test measured elapsed
time, and a few tests checked things that something else already breaks
on. This removes the copies and puts a counter where the clock was. No
`.stderr`, `.json`, golden or corpus file changes, and no case is
deleted.

### The section tests are one table

`tests/rust_section.rs`, `tests/toml_section.rs` and
`tests/cpp_section.rs` (45 tests, each file a copy of the others with
the language changed) are now `tests/sections.rs`: one written-out
table, `ROWS`, with a row per code section, and one test over it per
rule. A rule only one language has is its own test: TOML refuses
`doc_comment`, C++ reads eight extensions, TOML's fix leaves a string
and keeps CRLF. `the_md_section_keeps_any_glob` is kept once.

A test that loops over the list it pins passes when an entry goes (#197,
#240). So `the_table_has_a_row_for_each_code_section` compares the
table's names with the sections the config schema names, minus `md`, in
both directions. Each row's expected messages are written out, never
formatted from the name. A test picks its row by name (`row("cpp")`), so
reordering the table cannot swap languages.

### Tests and assertions deleted, and what still pins each

- `a_config_message_replaces_the_advice` (`tests/unit.rs`): the case
`tests/cases/max_size_bytes/custom_message`, whose `.stderr` is the
whole report and so shows the advice gone.
- The one-possessive half of
`the_report_names_the_count_the_places_and_the_advice`
(`possessive_own.rs`) and the one-negation half of the same-named test
in `not_at_all.rs`: the cases `possessive_own/custom_message` and
`not_at_all/custom_message`.
- `sentence_lengths_by_label` and its helpers (`tests/slow/corpus.rs`):
an ignored test that printed a spread and checked nothing.
`every_category_is_well_stocked` stays.
- `update_md_meets_its_budget` (`tests/instructions.rs`): `make
check-deslag` holds `src/instructions/update.md` to the same budget, as
it holds every file.
- `the_acknowledgements_credit_the_two_designs_the_entry_takes`
(`tests/allow.rs`): it grepped the wording of `ACKNOWLEDGEMENTS.md` and
checked no behaviour. Nothing pins it now.
- `the_hash_is_fnv_1a_64` (`tests/frozen.rs`):
`no_frozen_config_is_edited_and_each_has_a_line_in_hashes` fails on any
change to `frozen::hash`.
- `lints_turned_on_reads_every_section` (`tests/instructions.rs`):
`each_lint_section_turns_on_its_lint_alone` and
`the_lints_tables_together_are_valid`. This was the only test that used
a non-`md` section. The survivors catch an empty set, ignored overrides
and ignored section-level lints, but not a reader that looks only at
`md`.
- `assert_eq!(Tag::ALL.len(), 13)` (`src/tag/types.rs`, an assertion):
the type `[Tag; 13]` says it.

Kept on purpose: the ten `custom_message` cases and their `.json` files
(each lint substitutes its own placeholders in its own code),
`tests/emphasis.rs`, `tests/since.rs`, `stamp.rs`, `phrases.rs`, the
guide and README tests in `instructions.rs`, `src/lint/mod.rs` and the
88 tests in `src/config/edit/`.

### The C++ lexer's clock is a read counter

One test in `src/document/cpp.rs` timed the lexer with `Instant`, so it
could fail on a slow machine and prove nothing on a fast one. It now
counts reads. `Scanner` holds a `Reader` in its own module, whose bytes
are private. Every read goes through `at`, `byte`, `slice`, `has_at` or
`find`, which count what they hand out in a test build and do nothing
more otherwise. The compiler refuses code that reads the source without
the counter, so a rescan written as a direct slice scan cannot hide.

The bound is 32 reads per byte, argued from the code in the comment on
`MOST_READS_PER_BYTE`, not found by running it. A lexeme start makes at
most 11 reads and steps over a byte; each loop in a lexeme makes at most
2 reads per byte; a blank after a backslash costs at most 6 more; a `<`
with no `>` costs 2 more. That is under 21. In a raw string, `find`
counts each byte once and the check after each `)` reads the delimiter
(at most 16 bytes) and the quote, so under 18. A rescan of the file per
directive reads the source length per line, far over any such constant.
Two tests feed it: 10,000 `#define X R"(a` lines and 10,000 `#define X
1` lines. The first has one directive in effect (the first raw string
swallows the file), so the second is the one that sees a per-directive
rescan.

### Before and after

| | Before | After |
|---|---|---|
| Fast-tier test binaries | 27 | 25 |
| Fast-tier tests | 1,299 | 1,268 |
| Section tests | 45 in 3 binaries | 18 in 1 binary |
| Run CPU | equal | equal |
| Clean-build CPU | unchanged | unchanged |
| CPU to rebuild after an edit | | about 2.8 s less (a review of the
diff measured it) |

The saving is two fewer test binaries to link, not a faster run. CPU per
binary is within noise on a loaded machine.

### Decided on the maintainer's behalf

1. The three section files become one table, with the row-per-section
test. Why: one rule in three copies drifts, and two fewer binaries
build.
2. The ten `custom_message` cases stay, and the three copies of them go.
Why: each lint substitutes its own placeholders in its own code, so each
case pins other code; the three deleted checks pinned only what a case
already shows.
3. `sentence_lengths_by_label` goes and `every_category_is_well_stocked`
stays. Why: the first prints and checks nothing; the second keeps the
ratio tests from passing on an empty category, and the corpus loads
once, so it saves no CPU.
4. Repo-state tests stay except two. Why: each reads a repo file because
that file is its subject, and a fixture would test nothing.
`update_md_meets_its_budget` is held by `make check-deslag` and the
acknowledgements test checked wording only.
5. The clock becomes a read counter, bounded by a constant argued from
the code. Why: a rescan per directive is orders of magnitude over any
small constant, and a count does not depend on the machine.
6. Three tests of helpers go. Why: each helper's tests elsewhere fail
first if it breaks.
7. `src/config/edit/` tests stay. Why: each refusal pins that `deslag
update` never writes a config it cannot edit safely.
8. The 600-line size guide for `tests/sections.rs` is lifted:
`#[rustfmt::skip]` kept it at 600 lines by leaving 38 lines over 100
columns, the longest 241. The table is formatted by rustfmt and the file
is 723 lines. Why: unreadable rows are worse than a longer file.
9. The counter bound is 32 reads per byte. Why: the argued worst cases
are under 21 for non-raw text and under 18 for a raw string, and the
worst measured were 7.0 and 17.98, so 32 leaves room without letting a
rescan through.

### Tests

Each mutation was made in a scratch copy and not committed.

- The `cpp` row dropped: `the_table_has_a_row_for_each_code_section`
fails, left `["rust","toml"]`, right `["cpp","rust","toml"]`.
- "selects it" reworded in `src/config/mod.rs`:
`a_file_that_two_sections_select_is_an_error_that_names_both` fails and
names the row.
- `max_size_bytes.rs` and then `possessive_own.rs` stop replacing
`{path}`: `tests/cases.rs` fails on each `custom_message` case.
- An unterminated raw string made to give up, so each opening searches
to the end: the counter fails at 750,565,002 reads of 150,000 bytes.
- `directive` reads the rest of the file again through `at`:
`many_plain_directives_are_read_in_linear_time` fails at 600,570,002
reads of 120,000 bytes, while the raw-string test passes.
- `directive` scans the rest of the file with a direct slice,
`self.bytes[after_hash..]`, counting newlines. This passed both tests
before the `Reader`. It no longer compiles, because the bytes are
private. The same scan through the reader's `slice` fails
`many_plain_directives_are_read_in_linear_time` at 600,590,005 reads of
120,000 bytes.
- `frozen::hash` with another multiplier:
`no_frozen_config_is_edited_and_each_has_a_line_in_hashes` fails.
- `lints_turned_on` returns an empty set:
`each_lint_section_turns_on_its_lint_alone` and
`the_lints_tables_together_are_valid` fail.
- `update.md` grown past its budget: `make check-deslag` exits 2 with
"src/instructions/update.md is 1884, which is larger than 1585 bytes".

The schema-fit test checks, for every row, `surfaces = ["doc_comment",
"comment"]` (`["comment"]` for `toml`), a `banned_chars` groups table
and an override, as the three replaced tests did, and an unknown surface
is refused.

## Testing

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

## References

- Builds on #257.
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/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