Repository navigation
feat: lint a possessive noun padded with "own" - #240
Conversation
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.
Ready for your review. Three things are yours to decide; everything else is the design you set on 2026-11-01.
Two of your tics are designed misses and stay in #61: the four |
## 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`
…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.
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> ownplus 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 ownandtheir own4 of 21,your own0 of 4, the idioms 0 of 6. So the lint matches thenoun's ownframe, one instance fails a file, with no rate, no floor and no tagger.What counts, in one sentence: a word ending in
'sors'(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:'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 pronounseveryone's,someone's,nobody'sand their kin; soits own,their own,your ownandone's ownnever match;and,oror a comma between (X's and Y's own diagnostics): a real contrast;is the crate's own.,a place of its own) or before a preposition, conjunction, determiner or auxiliary;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 onlymessage,since = "next";deslag initwrites it on, with the standing ofnot_at_allafter #203. Theallowpage lists the lint.The claim, checked by
tests/slow/corpus.rson the tree and bymake test-blobson 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.tomlmirrors 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, intools/,scripts/and build files, is left as it is: deslag does not read it..agents/deslag.toml:110.agents/deslag.toml:148src/change/patch.rs:4src/config/allow.rs:22src/config/edit/lines.rs:216src/config/edit/lines.rs:217src/config/edit/remove.rs:7src/config/edit/tests.rs:783src/config/edit/tests.rs:1207src/config/edit/tests.rs:1879src/config/edit/toml.rs:336src/config/edit/toml/apply.rs:239src/config/mod.rs:215src/config/section.rs:174src/config/update.rs:228src/config/v1/mod.rs:45src/document/cpp_regions.rs:666src/document/edit.rs:15src/document/region.rs:178src/explain/mod.rs:6src/instructions/lints/max_size_bytes.md:1src/lib.rs:9src/lint/max_size_bytes.rs:3src/lint/mod.rs:645src/lint/not_at_all.rs:365src/tag/build_tables.rs:314src/tag/closed.rs:711src/tag/learned.rs:17src/tag/learned.rs:20src/tag/learned.rs:115src/tag/learned.rs:905src/tag/origin.rs:6src/tag/origin.rs:30src/tag/pass.rs:105src/tag/seen.rs:3tools/corpus/report.toml:2tools/sweep/Cargo.toml:36Testing
make ci-fast: exit 0make test: exit 0 (tree claim, goldens; no other lint's golden moved)make test-blobs: exit 0 on the big tier, claim row abovemake check-deslag: exit 0 with the lint ondeslag checkcatch all 12noun's owntics and pass everyok, withits ownand the predicativeis X's ownas designed missesReferences
archive/own)