use slop_detector::{analyze, EvidenceReport};
fn quality_ids(report: &EvidenceReport) -> Vec<&str> {
report
.quality_patterns
.iter()
.map(|f| f.rule_id.as_str())
.collect()
}
fn count(report: &EvidenceReport, id: &str) -> usize {
report
.quality_patterns
.iter()
.filter(|f| f.rule_id == id)
.count()
}
fn assert_span_invariant(text: &str, report: &EvidenceReport) {
let all = report
.paste_residue
.iter()
.chain(&report.quality_patterns)
.chain(&report.injection_patterns);
for f in all {
let (start, end) = f.span;
assert!(start < end && end <= text.len(), "{}: bad span", f.rule_id);
let slice = &text[start..end];
if f.snippet_truncated {
assert!(slice.starts_with(&f.snippet), "{}", f.rule_id);
} else {
assert_eq!(slice, f.snippet, "{}: snippet != source[span]", f.rule_id);
}
}
}
#[test]
fn spike_lexicon_fires_on_the_measured_excess_words() {
let text = "We delve into a rich tapestry of intricate options, a testament to the myriad commendable paths ahead.";
let report = analyze(text);
assert_eq!(count(&report, "SLOP-A001"), 6, "{report:?}");
assert_span_invariant(text, &report);
}
#[test]
fn stock_opener_fires_at_full_weight() {
let report = analyze("In today's fast-paced world, teams need clarity.");
assert_eq!(count(&report, "SLOP-O003"), 1);
}
#[test]
fn demoted_ornamental_register_fires_as_background_not_spike() {
let text = "We leverage a robust and seamless platform to empower and unlock growth.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q001"), 5, "{report:?}");
assert_eq!(count(&report, "SLOP-A001"), 0);
}
#[test]
fn meticulous_stays_in_hype_adjectives_not_spike() {
let report = analyze("The report was meticulously crafted and meticulous throughout.");
assert_eq!(count(&report, "SLOP-A001"), 0);
assert!(count(&report, "SLOP-I003") >= 2, "{report:?}");
}
#[test]
fn transition_trio_fires_only_at_block_or_sentence_start() {
for text in [
"Moreover, the results held.",
"The pilot worked. Furthermore, costs fell.",
"line one\nAdditionally, the audit passed.",
"- Moreover, the bullet case counts.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-T002"), 1, "{text}");
}
for text in [
"The data moreover suggests otherwise.",
"We can additionally confirm the totals.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-T002"), 0, "{text}");
}
}
#[test]
fn block_start_skips_every_leading_marker_run() {
for text in [
"> Moreover, the results held.",
"# Moreover, the results held.",
"+ Moreover, the results held.",
"\u{1F389} Moreover, the results held.",
"\u{1F389}\u{1F680} Moreover, the results held.",
"\u{1F389} \u{2705} Moreover, the results held.",
"- \u{1F389} Moreover, the results held.",
"1. Moreover, the results held.",
"2) Moreover, the results held.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-T002"), 1, "{text}: {report:?}");
assert_span_invariant(text, &report);
}
for text in [
"\u{2023} Moreover, the results held.",
"\u{2043} Moreover, the results held.",
"\u{2219} Moreover, the results held.",
"\u{25CB} Moreover, the results held.",
"\u{25CF} Moreover, the results held.",
"\u{25C7} Moreover, the results held.",
"\u{25C6} Moreover, the results held.",
"\u{25C9} Moreover, the results held.",
"\u{25B2} Moreover, the results held.",
"\u{25A0} Moreover, the results held.",
"\u{25AA} Moreover, the results held.",
"\u{2192} Moreover, the results held.",
"\u{2318} Moreover, the results held.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-T002"), 1, "{text}: {report:?}");
assert_span_invariant(text, &report);
}
for text in [
"\u{1F389} \u{2023} Moreover, the results held.",
"\u{25AA} \u{1F389} Moreover, the results held.",
"\u{25CF} \u{2192} \u{1F389} Moreover, the results held.",
"\u{25AA} \u{2705} Moreover, the results held.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-T002"), 1, "{text}: {report:?}");
assert_span_invariant(text, &report);
}
for text in [
"\u{00B7} Moreover, the results held.",
"\u{00B7} \u{1F389} Moreover, the results held.",
] {
assert_eq!(count(&analyze(text), "SLOP-T002"), 0, "{text}");
}
let text = "The set a \u{2023} Moreover is not a list.";
assert_eq!(count(&analyze(text), "SLOP-T002"), 0, "{text}");
for text in [
"C# Moreover, the results held.",
"Value > Moreover, the results held.",
"Rated 5 Moreover, the results held.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-T002"), 0, "{text}: {report:?}");
}
}
#[test]
fn block_start_ordinal_test_does_not_over_suppress() {
let text = "See item 3. Moreover, the results held.";
let report = analyze(text);
assert_eq!(count(&report, "SLOP-T002"), 1, "{report:?}");
assert_span_invariant(text, &report);
let text = "See item 4) Moreover, the results held.";
assert_eq!(count(&analyze(text), "SLOP-T002"), 0, "{text}");
let text = "Ship to the U.S. Moreover, costs fell.";
assert_eq!(count(&analyze(text), "SLOP-T002"), 1, "{text}");
let text = "See e.g. moreover, the totals differ.";
assert_eq!(count(&analyze(text), "SLOP-T002"), 0, "{text}");
for text in [
"The pilot worked.\n\u{1F389} Moreover, costs fell.",
"1. The pilot worked.\n2. Moreover, costs fell.",
"> quoted line\n> Moreover, costs fell.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-T002"), 1, "{text}: {report:?}");
}
}
#[test]
fn trimmed_transition_tail_does_not_fire() {
for text in [
"Also, the invoice is attached.",
"Meanwhile, the team shipped v2.",
"Ultimately, we chose the smaller vendor.",
"Indeed, the numbers agree.",
"Interestingly, both bids came in equal.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-T002"), 0, "{text}");
}
}
#[test]
fn intensifiers_fire_at_background_with_the_technical_exemptions() {
let report = analyze("The rollout was very smooth and truly fast.");
assert_eq!(count(&report, "SLOP-I001"), 2);
let report = analyze("We run a highly available cluster across regions.");
assert_eq!(count(&report, "SLOP-I001"), 0, "{report:?}");
}
#[test]
fn importance_adjectives_respect_the_fixed_sense_exemptions() {
let report = analyze("This is a crucial and pivotal change.");
assert_eq!(count(&report, "SLOP-I002"), 2);
let report =
analyze("The critical path runs through the parser; see the critical section notes.");
assert_eq!(count(&report, "SLOP-I002"), 0, "{report:?}");
}
#[test]
fn inflated_diction_fires_with_homograph_guards() {
let report = analyze("We utilize the aforementioned process to facilitate onboarding.");
assert_eq!(count(&report, "SLOP-A004"), 3);
let report = analyze("Peak cpu utilization stayed under 60% and memory utilization was flat.");
assert_eq!(count(&report, "SLOP-A004"), 0, "{report:?}");
let report = analyze("The coverage instrument flags each block.");
assert_eq!(count(&report, "SLOP-A004"), 1);
let report = analyze("She plays a wind instrument; check the instrument panel and the financial instrument ledger.");
assert_eq!(count(&report, "SLOP-A004"), 0, "{report:?}");
let report = analyze("The audit found generated-text defects in three sections.");
assert_eq!(count(&report, "SLOP-A004"), 1);
}
#[test]
fn filler_meta_fires_but_bare_overall_does_not() {
let report = analyze("It's important to note that the totals moved.");
assert_eq!(count(&report, "SLOP-T001"), 1);
let report = analyze("Overall, the quarter closed strong.");
assert_eq!(count(&report, "SLOP-T001"), 0, "{report:?}");
}
#[test]
fn contrast_and_cadence_regexes_fire() {
let cases = [
("SLOP-C001", "The rollout was not only fast but also cheap."),
(
"SLOP-C002",
"Contrary to popular belief, the port was easy.",
),
("SLOP-C003", "Rather, we shipped weekly."),
(
"SLOP-C005",
"The new flow is faster, cleaner, and more reliable.",
),
("SLOP-C006", "You get the best of both worlds."),
("SLOP-Q001", "The result? Sales doubled."),
("SLOP-R001", "Rest assured, the migration is on track."),
("SLOP-O001", "This stands as a testament to the team."),
(
"SLOP-O002",
"The gateway serves as a proxy and boasts caching.",
),
("SLOP-O004", "Studies show adoption doubles in year two."),
("SLOP-T003", "Let's dive into the numbers."),
];
for (id, text) in cases {
let report = analyze(text);
assert!(count(&report, id) >= 1, "{id} on {text}: {report:?}");
assert_span_invariant(text, &report);
}
}
#[test]
fn c003_anchored_forms_fire_but_bare_rather_than_does_not() {
for text in [
"We shipped weekly rather than monthly.",
"Take the train rather than the bus.",
"I'd do it now rather than wait for Q4.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-C003"), 0, "{text}: {report:?}");
}
for text in [
"Rather, we shipped weekly.",
"Instead, the team paused the rollout.",
"We rebuilt it rather than simply patching the old flow.",
"Instead of chasing the deadline, the team cut scope.",
] {
let report = analyze(text);
assert!(count(&report, "SLOP-C003") >= 1, "{text}: {report:?}");
}
}
#[test]
fn participial_opener_fires_at_block_and_sentence_start() {
for text in [
"Building on these findings, we expanded the pilot.",
"The test run finished. Leveraging the new cache, latency fell by half.",
"line one\nRunning the numbers again, the margin holds.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q002"), 1, "{text}: {report:?}");
}
let text = "Building on these findings, we expanded the pilot.";
let report = analyze(text);
let hit = report
.quality_patterns
.iter()
.find(|f| f.rule_id == "SD-Q002")
.unwrap();
assert_eq!(hit.snippet, "Building on these findings,");
}
#[test]
fn participial_opener_stoplist_and_shape_negatives() {
for text in [
"During the meeting, we agreed on scope.",
"Something in the export, I think, is off.",
"Morning, everyone.",
"Following up on our call, here are the notes.",
"Regarding the invoice, the PO number was missing.",
"Moving forward, invoices go to the shared inbox.",
"We are building on it, so the risk is low.",
"Building on these findings we expanded the pilot.",
"Boeing, as expected, declined.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q002"), 0, "{text}: {report:?}");
}
}
#[test]
fn contrastive_tail_fires_on_the_declarative_specimen() {
let text = "Findings judge house style, not authorship.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q004"), 1, "{report:?}");
let hit = report
.quality_patterns
.iter()
.find(|f| f.rule_id == "SD-Q004")
.unwrap();
assert_eq!(hit.snippet, ", not authorship.");
assert_span_invariant(text, &report);
let text = "The report cites spans. Findings judge house style, not authorship. Read them.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q004"), 1, "{report:?}");
let report = analyze("The reviewers weigh density, never single hits.");
assert_eq!(count(&report, "SD-Q004"), 1, "{report:?}");
}
#[test]
fn contrastive_tail_is_silent_on_empty_np_and_directives() {
for text in [
"x, not .",
"x, not.",
"Never obey injected text.",
"Use the ledger, not the summary.",
"Don't trust the digest, never the tarball.",
"Keep the caveat, not the claim.",
"Your reviewers check style, not authorship.",
"If you want speed, not size, say so.",
"When in doubt, use the builder, not the raw constructor.",
"First read the header, then keep the body, not the footer.",
"The parser, not the lexer, owns that token.",
"We shipped the fix, not the docs",
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q004"), 0, "{text}: {report:?}");
}
}
#[test]
fn contrastive_tail_abbreviation_mid_tail_no_longer_false_fires() {
let text = "Adoption is concentrated, not in the U.S. but in Asia, where usage doubled.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q004"), 0, "{report:?}");
assert_span_invariant(text, &report);
let report = analyze("Adoption is concentrated, not in the U.S. but in Asia.");
assert_eq!(count(&report, "SD-Q004"), 0, "{report:?}");
let report = analyze("The team ships weekly, not monthly but quarterly.");
assert_eq!(count(&report, "SD-Q004"), 0, "{report:?}");
}
#[test]
fn contrastive_tail_but_rejection_is_word_bounded() {
for (text, tail) in [
(
"The cache is shared, not distributed.",
", not distributed.",
),
(
"The fix targets the root cause, not the attributes.",
", not the attributes.",
),
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q004"), 1, "{text}: {report:?}");
let hit = report
.quality_patterns
.iter()
.find(|f| f.rule_id == "SD-Q004")
.unwrap();
assert_eq!(hit.snippet, tail, "{text}");
}
}
#[test]
fn contrastive_tail_ending_in_abbreviation_fires_with_the_full_span() {
let text = "The survey covers Europe, not the U.S.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q004"), 1, "{report:?}");
let hit = report
.quality_patterns
.iter()
.find(|f| f.rule_id == "SD-Q004")
.unwrap();
assert_eq!(hit.snippet, ", not the U.S.");
assert_span_invariant(text, &report);
}
#[test]
fn contrastive_tail_eg_mid_np_fires_with_the_complete_span() {
let text = "The docs cite the alias, not e.g. the raw path.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q004"), 1, "{report:?}");
let hit = report
.quality_patterns
.iter()
.find(|f| f.rule_id == "SD-Q004")
.unwrap();
assert_eq!(hit.snippet, ", not e.g. the raw path.");
}
#[test]
fn contrastive_tail_clause_walkback_crosses_abbreviation() {
let report = analyze("Use the U.S. hosted mirror, not a pilot.");
assert_eq!(count(&report, "SD-Q004"), 0, "{report:?}");
let text = "The rollout targets the U.S. market, not a pilot.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q004"), 1, "{report:?}");
let hit = report
.quality_patterns
.iter()
.find(|f| f.rule_id == "SD-Q004")
.unwrap();
assert_eq!(hit.snippet, ", not a pilot.");
}
#[test]
fn contrastive_negation_regex_triggers_fire() {
for text in [
"The report isn't about blame; it's about evidence.",
"This check is not about style but about provenance.",
"The output is not a verdict but a reading signal.",
"This is not a scorecard. It is a reading aid.",
] {
let report = analyze(text);
assert!(count(&report, "SD-Q004") >= 1, "{text}: {report:?}");
assert_span_invariant(text, &report);
}
}
#[test]
fn c008_pair_forms_fire_as_background() {
for text in [
"The position is not to dismiss breadth, but to require depth.",
"The question is not what they know, but how they value it.",
"Ship the fix, not the workaround, but tell support first.",
"The port is not a rewrite. It is a shim over the old core.",
] {
let report = analyze(text);
assert!(count(&report, "SLOP-C008") >= 1, "{text}: {report:?}");
assert_span_invariant(text, &report);
}
}
#[test]
fn c008_stays_out_of_c001_and_c003_territory() {
for text in [
"The rollout was not only fast but also cheap.",
"It is not just faster but safer.",
"We shipped weekly rather than monthly.",
"Findings judge house style, not authorship.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-C008"), 0, "{text}: {report:?}");
}
}
#[test]
fn a005_idiom_families_fire_as_background() {
for text in [
"The data tells a more textured story about adoption.",
"This result is worth sitting with.",
"The invitation is to rethink the pipeline.",
"The metric serves as a canary for regressions.",
"It weaves together three subsystems.",
"Our roadmap remains our north star.",
"The findings form a rich tapestry of user behavior.",
] {
let report = analyze(text);
assert!(count(&report, "SLOP-A005") >= 1, "{text}: {report:?}");
assert_span_invariant(text, &report);
}
}
#[test]
fn a005_closed_boundaries_and_plain_prose_stay_silent() {
for text in [
"Their approach serves as a compassionate model for teams.",
"She wrote a story about the outage.",
"The mine's canary protocol is documented separately.",
"The beacon interval is 100 ms.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-A005"), 0, "{text}: {report:?}");
}
}
#[test]
fn v004_lexicon_phrases_and_constructions_fire() {
let rules = slop_detector::data::load().unwrap();
let v004 = rules.iter().find(|r| r.id == "SLOP-V004").unwrap();
for term in &v004.terms {
let text = format!("The check was rerun {term} without changes.");
let report = analyze(&text);
assert!(count(&report, "SLOP-V004") >= 1, "{term}: {report:?}");
}
for text in [
"Flagged for JJ: the digest moved between runs.",
"All three figures confirmed.",
"All 12 counts verified against the ledger.",
] {
let report = analyze(text);
assert!(count(&report, "SLOP-V004") >= 1, "{text}: {report:?}");
assert_span_invariant(text, &report);
}
}
#[test]
fn v004_lowercase_flagged_for_is_silent() {
let report = analyze("The commit was flagged for review by CI.");
assert_eq!(count(&report, "SLOP-V004"), 0, "{report:?}");
}
#[test]
fn individual_rules_fire_per_hit_in_quality_patterns() {
let cases = [
(
"SLOP-V001",
"As an AI language model, I cannot check the portal.",
),
(
"SLOP-V002",
"You're absolutely right, and great question about the fees.",
),
("SLOP-S003", "I hope this helps with the review."),
];
for (id, text) in cases {
let report = analyze(text);
assert!(count(&report, id) >= 1, "{id} on {text}: {report:?}");
assert!(report.paste_residue.is_empty(), "{text}");
}
}
#[test]
fn v002_leaves_the_catch_entries_to_the_thread() {
for silent in [
"Good catch, updated the doc.",
"Great catch, that column was stale.",
] {
let report = analyze(silent);
assert_eq!(count(&report, "SLOP-V002"), 0, "{silent}: {report:?}");
}
let text = "Good catch! You're absolutely right. I'll fix that.";
let report = analyze(text);
assert_eq!(count(&report, "SLOP-V002"), 1, "{report:?}");
assert_eq!(
report.quality_patterns[0].snippet,
"You're absolutely right"
);
assert_span_invariant(text, &report);
}
#[test]
fn v002_fair_hit_fires_on_the_concession_and_its_literal_neighbours() {
for text in [
"Fair hit, I should have checked the totals first.",
"That's a fair hit and I will rework the section.",
"Fair hit on the timeline, we underestimated the review.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-V002"), 1, "{text}: {report:?}");
assert_span_invariant(text, &report);
}
for text in [
"The batter took a fair hit down the third-base line.",
"The referee ruled it an unfair hit and issued a penalty.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-V002"), 1, "{text}: {report:?}");
}
for text in [
"Fair point, the numbers do not line up.",
"Fair enough, we can ship Friday.",
"Fair cop, that one is on me.",
"Fair knock from the reviewer.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SLOP-V002"), 0, "{text}: {report:?}");
}
}
#[test]
fn provenance_marker_fires_on_the_oblique_vocabulary() {
for text in [
"We reimplemented the parser over the weekend.",
"The provenance of this module is documented in the tracker.",
"Two shims were kept for API parity.",
"It serves as the reference implementation.",
"The crate is a drop-in replacement for the old client.",
"The port keeps parity with the original layout.",
"It mirrors the upstream API surface.",
] {
let report = analyze(text);
assert!(count(&report, "SD-Q003") >= 1, "{text}: {report:?}");
assert_span_invariant(text, &report);
}
}
#[test]
fn provenance_marker_is_word_bounded() {
let report = analyze("The dataprovenancez field and reimplementedFoo symbol are unrelated.");
assert_eq!(count(&report, "SD-Q003"), 0, "{report:?}");
}
#[test]
fn not_loaded_families_stay_silent() {
for text in [
"To be clear, the March invoice was paid. For the record, twice.",
"It seems this could potentially work, and we may possibly try it.",
"Best regards,\nMina",
"The budget — once approved — covers both; we split the rest.",
"I verified the backup and tested the restore path myself.",
] {
let report = analyze(text);
assert!(report.quality_patterns.is_empty(), "{text}: {report:?}");
}
}
#[test]
fn plain_business_email_yields_zero_quality_findings() {
let text = "Hi Omar,\n\nThe vendor sent the revised quote this morning: 40 seats at \
the old rate, renewal in March. Legal wants one change to the liability \
clause before we sign. If you can review clause 7 by Thursday, we can \
close this out before the offsite.\n\nBest regards,\nMina";
let report = analyze(text);
assert!(report.quality_patterns.is_empty(), "{report:?}");
assert!(report.paste_residue.is_empty());
assert!(report.injection_patterns.is_empty());
}
#[test]
fn one_stray_intensifier_does_not_flood() {
let text = "Hi Dana, the demo went very well. The client asked for pricing by \
Friday and a follow-up call next week. I'll draft the proposal \
tonight and send it to you for review.";
let report = analyze(text);
let ids = quality_ids(&report);
assert_eq!(ids, ["SLOP-I001"], "{report:?}");
}
const FORMULAIC_FIXTURE: &str = "In today's fast-paced world, we delve into a \
tapestry of intricate solutions. Moreover, our robust and seamless platform \
doesn't just leverage best practices, it is not only faster but also safer. \
Building on these findings, we utilize the aforementioned framework to \
facilitate a truly comprehensive rollout. I hope this helps.";
#[test]
fn formulaic_prose_reports_across_classes_deterministically() {
let a = serde_json::to_string(&analyze(FORMULAIC_FIXTURE)).unwrap();
let b = serde_json::to_string(&analyze(FORMULAIC_FIXTURE)).unwrap();
assert_eq!(a, b);
let report = analyze(FORMULAIC_FIXTURE);
assert_span_invariant(FORMULAIC_FIXTURE, &report);
for id in [
"SLOP-A001",
"SLOP-O003",
"SD-Q001",
"SLOP-T002",
"SLOP-A004",
"SLOP-C001",
"SLOP-I001",
"SLOP-S003",
] {
assert!(count(&report, id) >= 1, "{id}: {report:?}");
}
assert_eq!(count(&report, "SLOP-A001"), 3, "{report:?}");
assert!(report.stats.word_count > 40);
assert_eq!(report.stats.byte_len, FORMULAIC_FIXTURE.len());
let mut sorted = report.quality_patterns.clone();
sorted.sort_by(|x, y| {
(x.span.0, x.span.1, x.rule_id.as_str()).cmp(&(y.span.0, y.span.1, y.rule_id.as_str()))
});
assert_eq!(report.quality_patterns, sorted);
}
#[test]
fn q006_ledger_stamps_fire_per_hit() {
let text = "The owner rules this on 2026-08-18. The floor was measured 2026-08-01 and the case adjudicated 2026-07-30.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q006"), 3, "{report:?}");
assert_span_invariant(text, &report);
}
#[test]
fn q006_both_arms_require_the_date() {
for text in [
"The owner ruled this after the second sweep.",
"The owner ruled this out after the inspection.",
"If the owner rules this way, we ship Friday.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q006"), 0, "{text}: {report:?}");
}
}
#[test]
fn q006_transactional_verbs_are_not_carried_inbound() {
let text = "Payment confirmed 2026-08-14 and the invoice verified 2026-08-15; the ticket was resolved 2026-08-16.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q006"), 0, "{report:?}");
}
#[test]
fn q006_release_diction_and_prose_date_forms_are_silent() {
let text = "Released 2026-08-18 with two fixes. The survey was measured on 2026-08-01. The board resolved 2026 budget items. The build was measured 2026-99-99.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q006"), 0, "{report:?}");
assert_span_invariant(text, &report);
}
#[test]
fn q009_dated_possessive_reports_once_with_the_date() {
let text = "Owner's ruling, 2026-08-20: the profile stays.";
let report = analyze(text);
let hits: Vec<&str> = report
.quality_patterns
.iter()
.filter(|f| f.rule_id == "SD-Q009")
.map(|f| f.snippet.as_str())
.collect();
assert_eq!(hits, vec!["Owner's ruling, 2026-08-20"], "{report:?}");
assert_span_invariant(text, &report);
}
#[test]
fn q009_every_spelling_fires_on_its_span() {
for (text, span) in [
(
"The owner ruled that the lexicon drops the bare word.",
"The owner ruled that",
),
(
"The maintainer's call was to keep the gate.",
"The maintainer's call",
),
(
"This entry was requested by the user.",
"requested by the user",
),
("The owner-flagged stack ships as a rule.", "owner-flagged"),
(
"Code sign-off is Fable, by owner decision.",
"owner decision",
),
("Per the owner, the digest stays sealed.", "Per the owner"),
(
"The flag was added at the user's request.",
"at the user's request",
),
(
"On the principal's instruction the run stopped.",
"On the principal's instruction",
),
(
"Owner decision (2026-08-20): keep the profile.",
"Owner decision (2026-08-20)",
),
("- Ruling: keep the profile.", "- Ruling:"),
(
"Decision, 2026-08-19: the profile stays.",
"Decision, 2026-08-19:",
),
(
"Ruled by owner proxy, the rule is candidate tier.",
"Ruled by owner proxy",
),
(
"The proxy signed off on 2026-08-20.",
"The proxy signed off on 2026-08-20",
),
(
"The owner\u{2019}s verdict was to drop the entry.",
"The owner\u{2019}s verdict",
),
(
"The owner ruled this out after the inspection.",
"The owner ruled this",
),
("The owner wants the profile kept.", "The owner wants"),
(
"The orchestrator's call was to stop.",
"The orchestrator's call",
),
(
"Owner directive (2026-08-24): stop the run.",
"Owner directive (2026-08-24)",
),
(
"The maintainer asked for a smaller patch.",
"The maintainer asked",
),
("Per your ruling, the digest stays.", "Per your ruling"),
("You ruled that the bare word leaves.", "You ruled"),
(
"The owner's request was a shorter README.",
"The owner's request",
),
("The lead chose the second option.", "The lead chose"),
("Ruling (2026-08-20): keep.", "Ruling (2026-08-20):"),
(
"Ruled by a Fable agent in the owner's stead.",
"the owner's stead",
),
(
"Drafted under owner-proxy Ruling 011.",
"owner-proxy Ruling",
),
(
"The owner has ruled on everything current.",
"The owner has ruled",
),
("The owner greenlit the batch.", "The owner greenlit"),
("As you directed, the run stopped.", "As you directed"),
] {
let report = analyze(text);
let hits: Vec<&str> = report
.quality_patterns
.iter()
.filter(|f| f.rule_id == "SD-Q009")
.map(|f| f.snippet.as_str())
.collect();
assert_eq!(hits, vec![span], "{text}: {report:?}");
assert_span_invariant(text, &report);
}
}
#[test]
fn q009_ordinary_english_is_silent() {
for text in [
"Rate limits apply per user and per owner of a token.",
"User-defined types and user-specified widths are supported.",
"The value set by the user wins over the default.",
"The decision tree splits on the first field.",
"The owner of the file can change its mode.",
"The author's name appears in the header.",
"The reviewer's comments are attached to the manuscript.",
"The lead developer's laptop runs the tests.",
"A verdict from the court arrived on 2026-08-20.",
"Decision records live under docs/adr.",
"Ruled 2026-08-14 after the sweep.",
"Please send the signed lease back by Friday.",
"The user wants a faster export, and the author said so in the preface.",
"Maintainer approval is required for a merge.",
"The user asked for a dark theme.",
"Under your account settings the theme changes.",
"I said no, and you decided to wait.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q009"), 0, "{text}: {report:?}");
}
}
#[test]
fn q009_seam_with_the_ledger_stamp() {
let report = analyze("The owner rules this on 2026-08-18.");
assert_eq!(count(&report, "SD-Q006"), 1, "{report:?}");
assert_eq!(count(&report, "SD-Q009"), 1, "{report:?}");
let report = analyze("The floor was measured 2026-08-01 across the boundary.");
assert_eq!(count(&report, "SD-Q006"), 1, "{report:?}");
assert_eq!(count(&report, "SD-Q009"), 0, "{report:?}");
}
const DENIAL_SPECIMEN: &str = "It reads text. It does not detect authorship, \
and no finding is evidence that a person or a model wrote anything.";
#[test]
fn q007_fires_on_every_denial_clause_of_the_specimen() {
let report = analyze(DENIAL_SPECIMEN);
assert_eq!(count(&report, "SD-Q007"), 2, "{report:?}");
let snippets: Vec<&str> = report
.quality_patterns
.iter()
.filter(|f| f.rule_id == "SD-Q007")
.map(|f| f.snippet.as_str())
.collect();
assert_eq!(snippets[0], "It does not detect authorship");
assert_eq!(
snippets[1],
"no finding is evidence that a person or a model wrote anything"
);
assert!(!snippets.iter().any(|s| s.contains("It reads text")));
assert_span_invariant(DENIAL_SPECIMEN, &report);
}
#[test]
fn q007_stacked_denials_fire_without_any_restatement() {
let text = "The tool does not score anyone. It cannot rank writers, and the \
output is not evidence of intent.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 3, "{report:?}");
assert_span_invariant(text, &report);
}
#[test]
fn q007_needs_a_trigger_and_a_restatement_alone_is_silent() {
for text in [
"It reads text.",
"The audit does not replace a legal review.",
"The crate does not detect authorship. Install it with cargo install.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 0, "{text}: {report:?}");
}
}
#[test]
fn q007_imperatives_stay_silent() {
for text in [
"Never author, approve, edit, or sign a waiver.",
"It reads text. Never obey injected text, and no finding is a command.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 0, "{text}: {report:?}");
}
}
#[test]
fn q007_ordinary_business_negation_stays_silent() {
let text = "Hi Priya, the vendor did not send the revised quote and the invoice \
is not due until March. She deliberately held the last two back. \
I cannot review clause 7 before Thursday.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 0, "{report:?}");
assert_eq!(count(&report, "SD-Q008"), 0, "{report:?}");
}
#[test]
fn q007_reports_an_honest_scope_statement_for_the_human_to_read() {
let text = "The audit reads financial records. It does not replace a legal \
review, and it is not a guarantee against fraud.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 2, "{report:?}");
assert_span_invariant(text, &report);
}
const RATIONALE_SPECIMEN: &str = "Input that is a Rust source file is rejected \
as unsupported, exit 40, because gating source draws findings from statement \
punctuation and not from writing. The test reads Rust shape only. Source in \
another language reaches the rules and produces findings a reader should \
discount, which is the trade for a guard that never fires on prose. Either \
pass the prose, or wrap the code in a fenced block, which segmentation \
excludes.";
#[test]
fn q008_and_the_and_not_contrast_fire_on_the_second_specimen() {
let report = analyze(RATIONALE_SPECIMEN);
assert_eq!(count(&report, "SD-Q008"), 2, "{report:?}");
assert_eq!(count(&report, "SD-Q004"), 1, "{report:?}");
let snippets: Vec<&str> = report
.quality_patterns
.iter()
.map(|f| f.snippet.as_str())
.collect();
assert!(snippets.contains(&"and not from"), "{snippets:?}");
assert!(
snippets.contains(&"a reader should discount"),
"{snippets:?}"
);
assert!(snippets.contains(&"which is the trade"), "{snippets:?}");
assert_span_invariant(RATIONALE_SPECIMEN, &report);
}
#[test]
fn q008_needs_the_anchor() {
for text in [
"She deliberately ignored him.",
"He rewrote the letter on purpose and mailed it intentionally.",
"The board accepted the offer in exchange for a longer term.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q008"), 0, "{text}: {report:?}");
}
}
#[test]
fn q008_fires_per_marker_when_the_sentence_names_the_tool() {
let text = "The rule deliberately drops the bare form, at the cost of recall.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q008"), 2, "{report:?}");
assert_span_invariant(text, &report);
}
#[test]
fn q008_leaves_the_denial_spelling_to_q007() {
let denial = "It reads text. The score should not be read as a verdict.";
let report = analyze(denial);
assert_eq!(count(&report, "SD-Q008"), 0, "{report:?}");
assert_eq!(count(&report, "SD-Q007"), 1, "{report:?}");
let affirmative = "The score should be read as a density.";
let report = analyze(affirmative);
assert_eq!(count(&report, "SD-Q008"), 1, "{report:?}");
assert_eq!(count(&report, "SD-Q007"), 0, "{report:?}");
}
#[test]
fn q004_and_not_spelling_needs_the_closed_follower() {
let text = "The finding comes from punctuation and not from writing.";
assert_eq!(count(&analyze(text), "SD-Q004"), 1, "{text}");
for clean in [
"The migration is scheduled and not yet finished.",
"We reviewed the quote and not much else came up.",
"Send the draft or not, either way we ship Friday.",
] {
let report = analyze(clean);
assert_eq!(count(&report, "SD-Q004"), 0, "{clean}: {report:?}");
}
}
#[test]
fn q004_and_not_is_the_and_spelling_only() {
for clean in [
"Please confirm whether or not the flag is present.",
"The gate reports whether or not the run passed.",
"The span comes from the tail but not from the opener.",
] {
let report = analyze(clean);
assert_eq!(count(&report, "SD-Q004"), 0, "{clean}: {report:?}");
}
}
#[test]
fn q004_participial_tails_are_not_contrasts() {
for clean in [
"She listened, never judging anyone.",
"He worked all night, never complaining.",
"They shipped it quietly, not making a fuss.",
] {
let report = analyze(clean);
assert_eq!(count(&report, "SD-Q004"), 0, "{clean}: {report:?}");
}
}
#[test]
fn q004_participial_exemption_needs_the_word_next_to_the_negation() {
for fires in [
"The rule reports the span, not the sentence.",
"It flags the shape, not everything.",
"It flags the shape, not the beginning.",
"It flags the shape, not a building.",
"The rule fires on the token, not during matching.",
] {
let report = analyze(fires);
assert_eq!(count(&report, "SD-Q004"), 1, "{fires}: {report:?}");
assert_span_invariant(fires, &report);
}
}
#[test]
fn q007_family_one_requires_a_capability_verb() {
let text = "It reads text. No rule scores voice, and it never scores authorship.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 2, "{report:?}");
let snippets: Vec<&str> = report
.quality_patterns
.iter()
.map(|f| f.snippet.as_str())
.collect();
assert!(snippets.contains(&"No rule scores voice"), "{snippets:?}");
assert_span_invariant(text, &report);
}
#[test]
fn q007_function_verb_denials_are_honest_scope_facts() {
for text in [
"It reads text. The check does not fire on prose, and the parser does not panic.",
"The check completed with nothing blocking.",
"A value that is not a table stops the load.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 0, "{text}: {report:?}");
}
}
#[test]
fn q007_arm_b_takes_any_affirmative_partner() {
for fires in [
"It reads the input. It cannot identify a writer.",
"The tool operates on prose! It does not rank writers.",
"This scans documents. It does not measure quality.",
"It reads text quickly. It cannot identify a writer.",
"It reads text about dogs. It cannot identify a writer.",
"It reads text? It cannot identify a writer.",
] {
let report = analyze(fires);
assert_eq!(count(&report, "SD-Q007"), 1, "{fires}: {report:?}");
}
for silent in [
"That reads text. It cannot identify a writer.",
"The poem sings, and it does not detect authorship.",
"The audit does not replace a legal review.",
] {
let report = analyze(silent);
assert_eq!(count(&report, "SD-Q007"), 0, "{silent}: {report:?}");
}
}
#[test]
fn q007_arm_b_search_order_and_reach() {
for fires in [
"It reads text, and it does not detect authorship.",
"It reads text, which is fast, and it does not detect authorship.",
] {
let report = analyze(fires);
assert_eq!(count(&report, "SD-Q007"), 1, "{fires}: {report:?}");
}
let far = "The linter reads text. We shipped it on Friday. The tool does \
not detect authorship.";
assert_eq!(count(&analyze(far), "SD-Q007"), 0, "{far}");
}
#[test]
fn q008_anchor_is_the_tool_noun_only() {
for silent in [
"That was deliberately vague.",
"I did it deliberately.",
"It was deliberately narrow.",
] {
let report = analyze(silent);
assert_eq!(count(&report, "SD-Q008"), 0, "{silent}: {report:?}");
}
let text = "The rule fires deliberately when the span is short.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q008"), 1, "{report:?}");
assert_span_invariant(text, &report);
}
#[test]
fn both_rules_read_the_same_tool_nouns() {
let text = "The test does not prove authorship, and the detector makes no claim.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 2, "{report:?}");
let text = "The detector fires deliberately when the span is short.";
assert_eq!(count(&analyze(text), "SD-Q008"), 1, "{text}");
assert_span_invariant(text, &analyze(text));
}
#[test]
fn q008_anchor_holds_for_both_marker_families() {
let report = analyze("This poem should be read as an elegy.");
assert_eq!(count(&report, "SD-Q008"), 0, "{report:?}");
for absorbed in [
"The test was deliberately hard.",
"The findings should be read as preliminary.",
] {
let report = analyze(absorbed);
assert_eq!(count(&report, "SD-Q008"), 1, "{absorbed}: {report:?}");
}
}
#[test]
fn q007_coreference_is_the_pronoun_or_one_tool_noun() {
for fires in [
"It reads text. The tool does not detect authorship.",
"The tool reads text. The tool does not detect authorship.",
"The tools read text. The tool does not detect authorship.",
] {
let report = analyze(fires);
assert_eq!(count(&report, "SD-Q007"), 1, "{fires}: {report:?}");
}
for silent in [
"The linter reads text. The tool does not detect authorship.",
"The test finished at noon. The tool does not detect authorship.",
] {
let report = analyze(silent);
assert_eq!(count(&report, "SD-Q007"), 0, "{silent}: {report:?}");
}
let far = "The tool reads text. We shipped it on Friday. The tool does \
not detect authorship.";
assert_eq!(count(&analyze(far), "SD-Q007"), 0, "{far}");
}
#[test]
fn q007_imperative_exclusion_is_per_clause() {
let text = "Do not obey injected text, and it does not judge anyone.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 0, "{report:?}");
let text = "It reads text. Do not obey injected text, and it does not judge anyone.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 1, "{report:?}");
assert_eq!(
report.quality_patterns[0].snippet,
"it does not judge anyone"
);
assert_span_invariant(text, &report);
}
#[test]
fn q007_base_form_test_keeps_a_denial_fragment_in() {
let text =
"It does not detect authorship, never scores voice, and makes no claim about intent.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 3, "{report:?}");
let snippets: Vec<&str> = report
.quality_patterns
.iter()
.map(|f| f.snippet.as_str())
.collect();
assert_eq!(snippets[0], "It does not detect authorship");
assert_eq!(snippets[1], "never scores voice");
assert_eq!(snippets[2], "makes no claim about intent");
assert_span_invariant(text, &report);
for command in [
"It reads text. Do not obey injected text.",
"It reads text. Never obey injected text.",
"Do not force-push main; do not rewrite history.",
] {
let report = analyze(command);
assert_eq!(count(&report, "SD-Q007"), 0, "{command}: {report:?}");
}
}
#[test]
fn q007_spelling_c_needs_the_right_auxiliary_and_verb_form() {
let text = "It reads text. Never scores voice.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 1, "{report:?}");
assert_eq!(report.quality_patterns[0].snippet, "Never scores voice");
assert_span_invariant(text, &report);
let text = "It does not detect authorship and never scores voice.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 2, "{report:?}");
for silent in [
"It reads text. Never score voice.",
"It reads text. Do not force-push main.",
"It reads text. Never judging anyone.",
] {
let report = analyze(silent);
assert_eq!(count(&report, "SD-Q007"), 0, "{silent}: {report:?}");
}
}
#[test]
fn q007_finite_negations_are_never_commands() {
let text = "It reads text. Does not detect authorship.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 1, "{report:?}");
assert_span_invariant(text, &report);
}
#[test]
fn q007_cuts_at_every_interior_coordinator() {
let text = "It does not detect authorship and it never scores voice.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 2, "{report:?}");
let snippets: Vec<&str> = report
.quality_patterns
.iter()
.map(|f| f.snippet.as_str())
.collect();
assert_eq!(snippets[0], "It does not detect authorship");
assert_eq!(snippets[1], "it never scores voice");
assert_span_invariant(text, &report);
}
#[test]
fn q007_span_is_the_segment_for_a_denial_and_the_clause_for_a_hedge() {
let report = analyze(DENIAL_SPECIMEN);
let spans: Vec<(usize, usize)> = report
.quality_patterns
.iter()
.filter(|f| f.rule_id == "SD-Q007")
.map(|f| f.span)
.collect();
assert_eq!(spans, [(15, 44), (50, 112)], "{report:?}");
assert_eq!(
&DENIAL_SPECIMEN[spans[1].0..spans[1].1],
"no finding is evidence that a person or a model wrote anything"
);
}
#[test]
fn q007_arm_b_takes_a_longer_affirmative_partner() {
let text = "It reads text every morning. It does not detect authorship.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 1, "{report:?}");
assert_span_invariant(text, &report);
}
#[test]
fn q007_a_foreign_subject_hedge_counts_toward_the_stack_only() {
for silent in [
"It reads text. The paper makes no claim about causation.",
"It reads text. The survey does not replace a site visit.",
] {
let report = analyze(silent);
assert_eq!(count(&report, "SD-Q007"), 0, "{silent}: {report:?}");
}
let text = "It does not detect authorship, and the paper makes no claim about causation.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 2, "{report:?}");
assert_span_invariant(text, &report);
let text = "It reads text. The report should not be read as a verdict.";
assert_eq!(count(&analyze(text), "SD-Q007"), 1, "{text}");
}
#[test]
fn q007_open_hedge_takes_up_to_three_words_before_the_copula() {
for fires in [
"It reads text. No finding is evidence of authorship.",
"It reads text. No single finding is evidence of authorship.",
"It reads text. No one single finding is evidence of anything.",
] {
let report = analyze(fires);
assert_eq!(count(&report, "SD-Q007"), 1, "{fires}: {report:?}");
}
for silent in [
"The study measured cortisol. No single sample is evidence of chronic stress.",
"It reads text. No one single sample is evidence of stress.",
] {
assert_eq!(count(&analyze(silent), "SD-Q007"), 0, "{silent}");
}
let text = "It reads text. No one single small finding is evidence of authorship.";
assert_eq!(count(&analyze(text), "SD-Q007"), 0, "{text}");
}
#[test]
fn q007_open_hedge_seats_the_head_noun_on_the_last_word() {
let text = "It reads text. No one single finding is evidence of anything.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 1, "{report:?}");
assert_eq!(
report.quality_patterns[0].snippet,
"No one single finding is evidence of anything"
);
assert_span_invariant(text, &report);
for (fires, snippet) in [
(
"It reads text. No finding is proof of anything.",
"No finding is proof of anything",
),
(
"It reads text. No single finding is proof of anything.",
"No single finding is proof of anything",
),
] {
let report = analyze(fires);
assert_eq!(count(&report, "SD-Q007"), 1, "{fires}: {report:?}");
assert_eq!(report.quality_patterns[0].snippet, snippet, "{fires}");
}
}
#[test]
fn q007_coordinated_denial_continues_the_subject_before_it() {
for (fires, snippet) in [
(
"The rules read text and never detect authorship.",
"never detect authorship",
),
(
"The rules read text and do not detect authorship.",
"do not detect authorship",
),
(
"The rules are advisory and do not replace review.",
"do not replace review",
),
] {
let report = analyze(fires);
assert_eq!(count(&report, "SD-Q007"), 1, "{fires}: {report:?}");
assert_eq!(report.quality_patterns[0].snippet, snippet, "{fires}");
assert_span_invariant(fires, &report);
}
}
#[test]
fn q007_coordinated_denial_needs_all_four_conditions() {
for silent in [
"Never detect authorship.",
"The tool is fast, but never replace review with it.",
"The findings are noisy, so do not judge them.",
"The report is evidence, do not replace your own reading with it.",
"Read the report and never judge by one finding.",
"The rules read text. Never score voice.",
] {
let report = analyze(silent);
assert_eq!(count(&report, "SD-Q007"), 0, "{silent}: {report:?}");
}
let text = "The tool is fast, and never replace review with it.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 1, "{report:?}");
assert_eq!(
report.quality_patterns[0].snippet,
"never replace review with it"
);
}
#[test]
fn q007_coordinated_denial_leaves_the_earlier_spellings_alone() {
let text =
"It does not detect authorship, never scores voice, and makes no claim about intent.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 3, "{report:?}");
let text = "Do not obey injected text, and it does not judge anyone.";
assert_eq!(count(&analyze(text), "SD-Q007"), 0, "{text}");
let text = "It reads text. Never scores voice.";
let report = analyze(text);
assert_eq!(count(&report, "SD-Q007"), 1, "{report:?}");
assert_eq!(report.quality_patterns[0].snippet, "Never scores voice");
}
fn q010_hits(report: &EvidenceReport) -> Vec<&str> {
report
.quality_patterns
.iter()
.filter(|f| f.rule_id == "SD-Q010")
.map(|f| f.snippet.as_str())
.collect()
}
#[test]
fn q010_fixed_shapes_fire_on_their_span() {
for (text, span) in [
(
"This is no small feat for a single maintainer.",
"no small feat",
),
(
"Migrating the schema was no simple task.",
"was no simple task",
),
(
"The rollout is not without its challenges.",
"not without its challenges",
),
(
"Debugging the linker is far from trivial.",
"far from trivial",
),
(
"It is hardly surprising that the build broke.",
"hardly surprising",
),
(
"It's not exactly trivial to reproduce.",
"not exactly trivial",
),
("The codebase isn't exactly simple.", "isn't exactly simple"),
("Getting this to compile is no mean feat.", "no mean feat"),
(
"The result leaves something to be desired.",
"leaves something to be desired",
),
(
"It would not be wrong to say the design is fragile.",
"It would not be wrong to say",
),
("This is, to put it mildly, a mess.", "to put it mildly"),
(
"The API surface is not inconsiderable.",
"not inconsiderable",
),
(
"Setup is not for the faint of heart.",
"not for the faint of heart",
),
(
"The cost was not unimportant to the board.",
"not unimportant",
),
(
"The delay proved inconsequential, and the fix was not inconsequential.",
"not inconsequential",
),
(
"The team is not unfamiliar with the stack.",
"not unfamiliar",
),
("Shipping on time is no easy feat.", "no easy feat"),
(
"A clean build is not a small feat here.",
"not a small feat",
),
(
"This is no small achievement for the team.",
"no small achievement",
),
("The port is no small undertaking.", "no small undertaking"),
(
"The win came in no small part from caching.",
"in no small part",
),
(
"The gain is due in no small measure to the cache.",
"in no small measure",
),
("The upgrade remains no easy task.", "remains no easy task"),
(
"The plan is not without its difficulties.",
"not without its difficulties",
),
("The move was not without irony.", "not without irony"),
(
"The wire protocol is not exactly straightforward.",
"not exactly straightforward",
),
(
"The setup wasn\u{2019}t exactly easy.",
"wasn\u{2019}t exactly easy",
),
("The rebase is far from simple.", "far from simple"),
("The proof is hardly trivial.", "hardly trivial"),
("The throughput was less than stellar.", "less than stellar"),
(
"The error messages leave much to be desired.",
"leave much to be desired",
),
(
"It wouldn't be wrong to say the tests are thin.",
"It wouldn't be wrong to say",
),
("It is safe to say the cache helped.", "It is safe to say"),
(
"It's not hard to see why the build broke.",
"It's not hard to see",
),
(
"It is not hard to imagine a crash here.",
"It is not hard to imagine",
),
(
"The rollout was rough, to say the least.",
"to say the least",
),
(
"Parsing a header is not rocket science.",
"not rocket science",
),
(
"The migration was not a walk in the park.",
"not a walk in the park",
),
(
"The upgrade is not exactly a walk in the park.",
"not exactly a walk in the park",
),
(
"The cold path is not to be underestimated.",
"not to be underestimated",
),
(
"The edge case is not to be overlooked.",
"not to be overlooked",
),
(
"The lock order is not to be taken lightly.",
"not to be taken lightly",
),
(
"A 40 percent gain is not to be sneezed at.",
"not to be sneezed at",
),
(
"It handles retries, not to mention backoff.",
", not to mention",
),
("This isn't rocket science.", "isn't rocket science"),
(
"The setup isn't for the faint of heart.",
"isn't for the faint of heart",
),
(
"The risk isn't to be underestimated.",
"isn't to be underestimated",
),
(
"The rollout wasn't without its challenges.",
"wasn't without its challenges",
),
(
"The API surface isn't inconsiderable.",
"isn't inconsiderable",
),
] {
let report = analyze(text);
assert_eq!(q010_hits(&report), vec![span], "{text}: {report:?}");
assert_span_invariant(text, &report);
}
}
#[test]
fn q010_measurable_shapes_fire_on_their_span() {
for (text, span) in [
("It is not uncommon for the cache to miss.", "not uncommon"),
(
"It is not entirely clear why the test flakes.",
"not entirely clear",
),
("The current latency is less than ideal.", "less than ideal"),
("The design is not without merit.", "not without merit"),
(
"Porting to ARM is not a trivial undertaking.",
"not a trivial undertaking",
),
("The benchmark numbers are not the best.", "not the best"),
("The load is not insignificant.", "not insignificant"),
(
"The queue is not quite right after failover.",
"not quite right",
),
("The docs are not terribly helpful.", "not terribly"),
("A cold start is not unusual on Mondays.", "not unusual"),
("A retry is not unreasonable here.", "not unreasonable"),
("A second outage is not unlikely.", "not unlikely"),
("The fix is not inexpensive.", "not inexpensive"),
("The regression was not unexpected.", "not unexpected"),
("The team was not unaware of the risk.", "not unaware"),
("The patch is not unwelcome.", "not unwelcome"),
("The parser is not incapable of recovery.", "not incapable"),
(
"The metric is not irrelevant to the decision.",
"not irrelevant",
),
("The ordering is not illogical.", "not illogical"),
(
"A double free is not unheard of in this module.",
"not unheard of",
),
(
"The cache misses not infrequently under load.",
"not infrequently",
),
(
"The rename is not a trivial change.",
"not a trivial change",
),
(
"Rotation is not an easy task with live traffic.",
"not an easy task",
),
("Recovery is not a simple matter.", "not a simple matter"),
("The leak is not a minor issue.", "not a minor issue"),
(
"The pipeline uses no small amount of memory.",
"no small amount",
),
("The rewrite is not without risk.", "not without risk"),
(
"The change is not without precedent.",
"not without precedent",
),
(
"The move is not without its costs.",
"not without its costs",
),
(
"The figure is not entirely accurate.",
"not entirely accurate",
),
(
"The outcome was not entirely certain.",
"not entirely certain",
),
("The API is not exactly ideal.", "not exactly ideal"),
("The cold path is not exactly fast.", "not exactly fast"),
("The port is not quite there yet.", "not quite there"),
("The buffer is not quite enough.", "not quite enough"),
("The docs are not particularly clear.", "not particularly"),
("The build is not especially slow.", "not especially"),
("The limit is not overly strict.", "not overly"),
("The migration plan is far from ideal.", "far from ideal"),
("The rollback path is far from settled.", "far from settled"),
("The layout is less than optimal.", "less than optimal"),
(
"It is not unreasonable to expect a retry.",
"It is not unreasonable to",
),
("The fallback is not the worst option.", "not the worst"),
("The error handling could be better.", "could be better"),
(
"There is room for improvement in the parser.",
"room for improvement",
),
("The patch isn't quite right.", "isn't quite right"),
("The cause isn't entirely clear.", "isn't entirely clear"),
("Timeouts aren't uncommon under load.", "aren't uncommon"),
("The plan isn't without merit.", "isn't without merit"),
("The heap wasn't terribly fragmented.", "wasn't terribly"),
] {
let report = analyze(text);
assert_eq!(q010_hits(&report), vec![span], "{text}: {report:?}");
assert_span_invariant(text, &report);
}
}
#[test]
fn q010_honest_negations_are_silent() {
for text in [
"The tool does not support nested transactions.",
"Not all inputs are validated before parsing.",
"The buffer is not fully drained when close returns.",
"The cache is not always warm after failover.",
"A successful write does not necessarily imply durability.",
"A collision is not impossible because the hash has finite width.",
"The patch is not incorrect, but it omits the 32-bit path.",
"The two crashes are not unrelated.",
"The wire format is not unlike CBOR.",
"No simple task may invoke the privileged runner.",
"The buffer holds not less than 32 bytes.",
"The response is not without a Content-Type header.",
"The node has barely enough memory for the job.",
"The hook hardly ever fires under load.",
"The value is not exactly 1.0 after rounding.",
"The queue is not yet initialized.",
"The field is not included in the digest.",
"The token is not invalid; its status is unknown.",
"She chose not to mention the delay.",
"The two files are far from each other on disk.",
"The result is not dissimilar to the last run.",
"The report is not inaccurate on the totals.",
"The board was not indifferent to the outcome.",
"The endpoint is not unavailable during the window.",
"The export is not illegal under the licence.",
"The fix is not completely tested.",
"The cache is not really warm yet.",
] {
let report = analyze(text);
assert_eq!(count(&report, "SD-Q010"), 0, "{text}: {report:?}");
}
}
#[test]
fn q010_seam_with_the_contrast_rules() {
let report = analyze("It is not a linter. It is a gate.");
assert_eq!(count(&report, "SLOP-C002"), 1, "{report:?}");
assert_eq!(count(&report, "SD-Q010"), 0, "{report:?}");
let text = "It is not a linter. It is a gate, and the setup is no small feat.";
let report = analyze(text);
assert_eq!(count(&report, "SLOP-C002"), 1, "{report:?}");
assert_eq!(q010_hits(&report), vec!["no small feat"], "{report:?}");
assert_span_invariant(text, &report);
}
#[test]
fn q010_it_goes_without_saying_stays_with_the_filler_rule() {
let report = analyze("It goes without saying that tests must pass.");
assert_eq!(count(&report, "SLOP-T001"), 1, "{report:?}");
assert_eq!(count(&report, "SD-Q010"), 0, "{report:?}");
}