Skip to content

fix(novelty): keep a question's leading Don't when the source opens with Do not - #1256

Open
antonwolfy wants to merge 4 commits into
intel:mainfrom
antonwolfy:fix/novelty-reversal-leading-dont
Open

antonwolfy wants to merge 4 commits into
intel:mainfrom
antonwolfy:fix/novelty-reversal-leading-dont

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On main, check_wording("reversal", ...) accepts a question that restates a source opening with a spelled-out negation, when the question opens with Don't. _claim_negations keeps a question's leading negative auxiliary only when the source matches _LEADING_NEGATIVE, which lists contracted forms (don't, isn't, ...). A source that opens with Do not, Does not or Never does not match, so the candidate's Don't is stripped as question phrasing: it counts 0 negations against the source's 1 and reads as a flipped polarity (#1232).

source candidate main here
Do not run the installer as root. Don't run the installer as root? [] ['restates_source']
Do not run the installer as root. Don’t run the installer as root? [] ['restates_source']
Does not run the installer as root. Don't run the installer as root? [] ['restates_source']
Never run the installer as root. Don't run the installer as root? [] ['restates_source']
Don't run the installer as root. Don't run the installer as root? ['restates_source'] ['restates_source']
Do not run the installer as root. Isn't it true that I should run the installer as root? [] []

The issue's fix option is taken: when the source opens with a negation, spelled out or contracted, the candidate's leading negative auxiliary is kept; for a spelled-out source only an imperative Don't <verb> whose verb is a word of the source is kept, so the documented frame Isn't it true that I should run the installer as root? against Do not run the installer as root. stays [] (a first version of the change returned ['polarity_not_flipped'] for it, which review caught), and so does Don't applications store credentials in logs? against Do not store credentials in logs., whose applications is a noun subject (also caught in review). An adverb between Don't and the verb is skipped before that comparison, so Don't ever run the installer as root? against Do not run the installer as root. returns ['polarity_not_flipped'] (the adverb is new wording, so it is not restates_source); before, ever was read as the verb, was not a word of the source, and the Don't was stripped, giving [] (review of #1256). It changes the one place that decides it and leaves _strip_question_phrasing, the paraphrase path and the trailing-tag rule alone.

Closes #1232

Changes

  • dokimi/dokimi/novelty/probes.py: new _LEADING_SPELLED_NEGATION (do|does|did|can|will|must|should|may + not, cannot, never, after optional whitespace, case-insensitive) next to _LEADING_NEGATIVE; _claim_negations keeps the candidate's leading negative auxiliary when _LEADING_NEGATIVE matches the source, or when _LEADING_SPELLED_NEGATION matches it and the candidate opens with an imperative Don't <verb> (new _LEADING_IMPERATIVE_DONT: Don't not followed by it, you, we, the, ... which is a frame, and whose following word must also be a word of the source, so a noun subject such as applications is not taken for a verb). Its docstring names the spelled-out openers. A typographic Don’t source needs no case of its own: _normalise_negations writes it as ' first.
  • dokimi/tests/test_novelty_probes.py: a test over the openers Do not, Does not, Never, Cannot and the straight and typographic Don't candidate, asserting ["restates_source"]; a test that Should the installer be run as root?, Is it fine to run the installer as root? and Should the installer be run as root, shouldn't it? are still accepted as inversions of Do not run the installer as root.; a test that Isn't it true that I should run the installer as root?, with a straight and a typographic apostrophe, is accepted against Do not ... and Never ... sources; a test that Don't applications store credentials in logs? (both apostrophes) is accepted against Do not store credentials in logs..
  • _LEADING_IMPERATIVE_DONT also skips ever, always, just, still, also, even, really, actually, simply and again between Don't and the verb; test_a_dont_question_with_an_adverb_before_the_verb_is_no_inversion_of_a_do_not_source asserts ['polarity_not_flipped'] for ever, always, just and really.
  • Changelog fragments (Fixed): the Do not source, and the adverb.

Risk

A reversal question that opens with an imperative Don't <verb> against a source opening with Do not, Does not, Never, Cannot and the like is now counted as keeping that negation, so a restatement is rejected where it was accepted. For a source opening with Don't this is what already happened. A candidate that is a real inversion without a leading Don't <verb> is unchanged ([]), including Isn't it true that I should run the installer as root? against Do not run the installer as root.. A source that does not open with a negation (The installer must not run as root.) is unchanged: Isn't it fine to run the installer as root? still returns []. The paraphrase path is not affected.

Testing

On a Linux review host, at f3422801 (on main 4abc47d):

  • make ci-local: 38 passed, 0 failed, 15 skipped (matrix legs from other jobs, micromamba, semgrep, the fuzz job, deploy and report jobs, which need a PR or a tool this run lacks); 29696 tests passed, 23 skipped. An earlier run of the same tree had one failure, tests/test_fuzz_targets.py::test_any_text[verdict] (an unraisable-exception warning from a WeakKeyDictionary finalizer), which is outside this change and passed alone (136 passed) and in the rerun.
  • The adverb case: Don't ever run the installer as root? against Do not run the installer as root. returned [] at cc5af5e9 and returns ['polarity_not_flipped'] here; the new test fails on main's code (4 failed) and on a copy with the adverb group of the pattern replaced by one that never matches (4 failed).
  • On main's code the new test file fails: 8 failed, 118 passed, first on assert [] == ['restates_source']; with the change tests/test_novelty_probes.py passes.
  • Mutants, each failing the tests it targets: keeping only _LEADING_NEGATIVE (the main behaviour) fails the new restates test with assert [] == ['restates_source']; dropping never from the pattern fails its Never ... cases; keeping the trailing tag when the leading auxiliary is kept fails test_a_genuine_inversion_of_a_do_not_source_is_still_accepted with assert ['polarity_not_flipped'] == []; keeping the leading auxiliary for every candidate of a spelled-out source (dropping the imperative check) fails test_an_isnt_it_true_frame_inverting_a_spelled_out_source_is_not_a_restatement in all four cases, with assert ['polarity_not_flipped'] == []; keeping the leading Don't whatever word follows it (dropping the source-word check) fails test_a_dont_question_with_a_noun_subject_inverting_a_do_not_source_is_accepted in both apostrophe cases (2 failed, 130 passed).
  • Not run: the matrix legs on Python 3.11, 3.12 and 3.14.

Open questions

None.

Revert

A plain revert restores the old behaviour. Nothing is stored.

Checklist

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

…ith Do not (intel#1232)

`check_wording("reversal", ...)` kept a question's leading negative auxiliary only when the source opened with a contracted one (`_LEADING_NEGATIVE`). A source that opens with the spelled-out `Do not`, `Does not` or `Never` did not match, so the candidate's leading `Don't` was stripped as question phrasing: `Don't run the installer as root?` counted 0 negations against the source's 1 and was accepted as a reversal of `Do not run the installer as root.`

A second pattern, `_LEADING_SPELLED_NEGATION` (`do|does|did|can|will|must|should|may not`, `cannot`, `never`), now also makes `_claim_negations` keep the candidate's leading negative auxiliary, so the candidate is rejected as `restates_source`, as it already was for a source opening with `Don't`. `_strip_question_phrasing`, the paraphrase path and the trailing-tag rule are unchanged.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner November 26, 2026 13:17
@antonwolfy antonwolfy self-assigned this Nov 26, 2026
@exai-bot

exai-bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s).

CI at f342280: 21 passing, 4 skipped.

Review details
  • Commit reviewed: f342280 against merge base cc5af5e
  • Coverage: 3 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 106k tokens (70k from cache), 38s
  • Tool calls: 13 (8 file_read, 2 pr_threads, 1 code_search, 1 local_check_results, 1 pr_comments)
  • small change set: 3 files

@codecov-commenter

codecov-commenter commented Nov 26, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.18%. Comparing base (4abc47d) to head (f342280).
⚠️ Report is 28 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1256      +/-   ##
==========================================
+ Coverage   96.14%   96.18%   +0.03%     
==========================================
  Files         498      499       +1     
  Lines       66004    66470     +466     
  Branches    11461    11543      +82     
==========================================
+ Hits        63460    63933     +473     
+ Misses       1573     1564       -9     
- Partials      971      973       +2     
Files with missing lines Coverage Δ
dokimi/dokimi/novelty/probes.py 100.00% <100.00%> (ø)

... and 56 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class: LOCAL (head 0106095)

  • Contract: none
  • Responsibility: none
  • Dependency: none
  • Review depth: skim: local change, check diff + tests
  • Coverage gaps: none

The mixed-spelling restatement from #1232 is now rejected. All 126 novelty-probe tests passed, but a separate check against the merge base found a regression in a documented leading-question frame. I left the input and both results inline.

Comment thread dokimi/dokimi/novelty/probes.py Resolved
…lows it

A source that opens with a spelled-out negation kept every leading negative auxiliary of a question candidate, so the documented frame "Isn't it true that I should run the installer as root?" against "Do not run the installer as root." was rejected as polarity_not_flipped. Now only an imperative "Don't <verb>" is kept; "Isn't it true that", "Don't you" and the like stay question phrasing. Tests cover both cases with straight and typographic apostrophes.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

(commented) ### Change class: LOCAL (head 0106095)

@napetrov (#1256 (review)): The review body only points at the inline thread 4712116881, which is answered above (ac219655).

Comment thread dokimi/dokimi/novelty/probes.py Resolved
…he source

Settles the review point that `Don't applications store credentials in logs?` against `Do not store credentials in logs.` was rejected as polarity_not_flipped: `applications` is the question's subject, not an imperative verb. A spelled-out source now keeps the candidate's leading Don't only when the word after it is a word of the source.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
Comment thread dokimi/dokimi/novelty/probes.py Resolved
…ts verb

Settles the review point that `Don't ever run the installer as root?` read `ever` as the verb after `Don't`, found it absent from the source and stripped the leading `Don't`, so the prohibition counted no negation and `check_wording("reversal", ...)` returned `[]` against `Do not run the installer as root.`

The imperative pattern now skips `ever`, `always`, `just`, `still`, `also`, `even`, `really`, `actually`, `simply` and `again` before taking the verb, so the negation is kept and the candidate is rejected as `polarity_not_flipped`. A parametrized test pins the exact diagnostic.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from napetrov November 27, 2026 17:50

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

novelty reversal: a Don't question is accepted as the reversal of a Do not statement source

4 participants