Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

Feedback suppressed issues of any severity with no record; never waive an error and list what is waived

FABIOTESS833db0435ce6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 28a447e6..9d5b017d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,21 @@ All notable changes to Open Ontologies are documented here.
## [Unreleased]
+### Fixed
+
+- **Lint and enforce feedback can no longer waive an error, and never drop an
+ issue without a record** (#325, reported by @noahgift). After
+ `suppress_threshold` dismissals (default 3) an issue was removed whatever its
+ severity, leaving only `suppressed_count`, so the orchestrator that loops
+ until enforce is clean could dismiss an error three times and read
+ "0 violations, 1 suppressed" with no rule, entity or severity anywhere. An
+ `error` is now never suppressed or downgraded (a dismissed one stays in
+ `issues`/`violations` at `error` and carries `dismissals`); a warning or info
+ that reaches the threshold moves to a new `suppressed[]` list with `rule`,
+ `entity`, `original_severity`, `dismissals` and `message`. `issue_count`,
+ `compliance` and `suppressed_count` are computed as before.
+ `tests/feedback_suppression_test.rs` holds it for both tools.
+
## [2.1.0] - 2026-10-23
### Fixed
diff --git a/CLAUDE.md b/CLAUDE.md
index 81b392d5..55265f17 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -110,8 +110,8 @@ Claude dynamically decides the next tool call based on what the previous tool re
| `onto_temporal_query` | To run a SPARQL graph pattern against only the graphs in temporal scope: what the graph said at a given valid time, as known at a given recorded time |
| `onto_temporal_conflicts` | To separate genuine contradictions from pairs that never met, from withdrawn assertions and from asserted corrections. A pair one side of which a `temporal:retracts` link has withdrawn lands in `retracted`, checked first as the snapshot does; the tool takes no `as_of`, so a recorded retraction counts whenever it was recorded, and the note says so. A pair where one graph `temporal:supersedes` the other, directly or through a chain, lands in `corrections` whatever its periods, lineage that is asserted and never inferred; otherwise a disjointness violation only counts when the two assertions claim OVERLAPPING validity, and everything else lands in `non_overlapping`, which proves only that the two share no instant, judged on their bounds read as instants on the UTC timeline so a timezone offset is honoured: not that one replaced the other, and it also holds pairs separated by a gap, which is missing coverage rather than history. A pair whose graph has temporal metadata that could not be read goes to `undecided`, in neither bucket, because an unreadable period is not an open one. `superseded` is the same set under its old name, deprecated and dropped at 2.0 |
| `onto_lineage` | To view the session's lineage trail (plan → enforce → apply → monitor → drift) |
-| `onto_lint_feedback` | To accept/dismiss a lint issue — teaches lint to suppress repeatedly dismissed warnings |
-| `onto_enforce_feedback` | To accept/dismiss an enforce violation — teaches enforce to suppress repeatedly dismissed violations |
+| `onto_lint_feedback` | To accept/dismiss a lint issue — teaches lint to suppress repeatedly dismissed warnings (listed in `suppressed[]`; errors are never suppressed) |
+| `onto_enforce_feedback` | To accept/dismiss an enforce violation — teaches enforce to suppress repeatedly dismissed non-error violations (listed in `suppressed[]`; errors are never suppressed) |
| `onto_dl_explain` | To explain why a class is unsatisfiable using DL tableaux reasoning — returns clash trace |
| `onto_dl_check` | To check if one class is subsumed by another using DL tableaux reasoning |
| `onto_fol_export` | To hand the ontology to the automated-theorem-proving ecosystem. Writes TPTP FOF (what E and Vampire read), ISO/IEC 24707 CLIF (the standards-track interchange syntax, and what ISO/IEC 21838-2 publishes BFO in), restricted both to the first-order-equivalent fragment of Common Logic and to the subdialect ISO/IEC 24707 A.4.2 calls exactly semantically conformant, each checked by a test rather than asserted, and ISO/IEC 24707 CGIF, the second of Common Logic's three dialects, in CORE CGIF and in the compact sub-dialect clause 7.1.1 names (no sequence markers, which is what clause 6.5 says takes Common Logic past first order; also no `#?` type label and no actor). CGIF conformance is pinned by a lexer, parser and checker written from Annex B's EBNF IN THE TEST, not by an independent parser, because no installable CGIF parser exists; the CLIF claims rest on two external parsers and the CGIF claims do not, and the report names XCL as the dialect still not emitted. Both are serialisers over ONE translation: the one `OwlLean.adequacy` in the sibling owl-lean project is machine-checked about, including the background axioms and the individual typing axioms that theorem requires. The correspondence between this emitter and that Lean is PINNED BY TESTS AND NOT PROVED, and the emitted file says so. Constructs outside the fragment are named with counts and reasons in `constructs_not_exported`, never dropped silently. CLIF sentences are emitted BARE with standalone `(cl:comment '...')` labels, because the two CLIF parsers that exist both return an EMPTY theory from the wrapped `(cl:comment '...' SENTENCE)` form that ISO/IEC 21838-2's own BFO files use; `clif_comments: "wrapped"` restores that form and loses the content. `smtlib` (SMT-LIB 2, what Z3 reads) and `ladr` (what Mace4 reads, every symbol MANGLED with the table in `symbols.tsv`, because LADR reads a name beginning with u, v, w, x, y or z as a VARIABLE) write the same translation for MODEL FINDERS, and assert the NEGATED goal because a countermodel to `G |= phi` is a model of `G + {not phi}`. Every run also writes `problem.tsv` with its digest, the format the verified checker reads. Pass `goals_file` to also write one problem per conjecture. A PROVER'S VERDICT ON THE OUTPUT IS AN ORACLE OPINION AND NEVER A CERTIFICATE: use tools/fol_differential.py, which reports disagreement between this engine and an ATP and does not adjudicate it. See docs/first-order-export.md and decision 0005 |
diff --git a/src/config.rs b/src/config.rs
index 523c07cc..0a73d002 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -553,11 +553,12 @@ impl Default for ReasonerConfig {
#[serde(default)]
pub struct FeedbackConfig {
/// Number of consecutive dismissals after which a lint/enforce issue
- /// is fully suppressed for that (tool, rule_id, entity) tuple. Default 3.
+ /// is fully suppressed for that (tool, rule_id, entity) tuple: moved to
+ /// the output's `suppressed[]` list. Errors are exempt. Default 3.
pub suppress_threshold: i64,
/// Number of consecutive dismissals after which a lint/enforce issue
- /// is downgraded one severity level. Must be `< suppress_threshold` to
- /// take effect. Default 2.
+ /// is downgraded one severity level (warning to info; errors are exempt).
+ /// Must be `< suppress_threshold` to take effect. Default 2.
pub downgrade_threshold: i64,
}
impl Default for FeedbackConfig {
diff --git a/src/enforce.rs b/src/enforce.rs
index 44ef1559..63bdaaee 100644
--- a/src/enforce.rs
+++ b/src/enforce.rs
@@ -38,36 +38,8 @@ impl Enforcer {
// Also run custom rules for this pack
self.run_custom_rules(rule_pack, &mut violations, &mut total_rules, &mut passed_rules);
- // Apply feedback adjustments
- let mut filtered_violations: Vec<serde_json::Value> = Vec::new();
- let mut suppressed_count: u64 = 0;
-
- for violation in violations {
- if let Some(db) = feedback_db {
- let rule = violation["rule"].as_str().unwrap_or("");
- let entity = violation["entity"].as_str().unwrap_or("");
- match crate::feedback::get_feedback_adjustment(db, "enforce", rule, entity) {
- crate::feedback::FeedbackAction::Suppress => {
- suppressed_count += 1;
- continue;
- }
- crate::feedback::FeedbackAction::Downgrade => {
- let original = violation["severity"].as_str().unwrap_or("info");
- let downgraded = crate::feedback::downgrade_severity(original);
- let mut adjusted = violation.clone();
- adjusted["original_severity"] = serde_json::json!(original);
- adjusted["adjusted_severity"] = serde_json::json!(downgraded);
- adjusted["severity"] = serde_json::json!(downgraded);
- filtered_violations.push(adjusted);
- }
- crate::feedback::FeedbackAction::Keep => {
- filtered_violations.push(violation);
- }
- }
- } else {
- filtered_violations.push(violation);
- }
- }
+ let (filtered_violations, suppressed) =
+ crate::feedback::apply_feedback(feedback_db, "enforce", "rule", violations);
let compliance = if total_rules > 0 {
passed_rules as f64 / total_rules as f64
@@ -81,7 +53,8 @@ impl Enforcer {
"total_rules": total_rules,
"passed_rules": passed_rules,
"compliance": compliance,
- "suppressed_count": suppressed_count,
+ "suppressed_count": suppressed.len(),
+ "suppressed": suppressed,
});
Ok(result.to_string())
diff --git a/src/feedback.rs b/src/feedback.rs
index be4db26c..6edb6db6 100644
--- a/src/feedback.rs
+++ b/src/feedback.rs
@@ -7,24 +7,45 @@ pub enum FeedbackAction {
Keep,
/// Downgrade severity one level (warning → info)
Downgrade,
- /// Suppress entirely (omit from output)
- Suppress,
+ /// Move out of the issue list into `suppressed[]`, carrying the number of
+ /// dismissals that put it there.
+ Suppress { dismissals: i64 },
}
// Severity-adjustment thresholds live in `crate::runtime` (initialised from
// `[feedback]` in config.toml).
-/// Check feedback history for a (tool, rule_id, entity) tuple.
-pub fn get_feedback_adjustment(db: &StateDb, tool: &str, rule_id: &str, entity: &str) -> FeedbackAction {
- let conn = db.conn();
- let dismiss_count: i64 = conn
+/// Number of times a (tool, rule_id, entity) tuple has been dismissed.
+pub fn dismissal_count(db: &StateDb, tool: &str, rule_id: &str, entity: &str) -> i64 {
+ db.conn()
.query_row(
"SELECT COUNT(*) FROM tool_feedback WHERE tool = ?1 AND rule_id = ?2 AND entity = ?3 AND accepted = 0",
rusqlite::params![tool, rule_id, entity],
|r| r.get(0),
)
- .unwrap_or(0);
- let accept_count: i64 = conn
+ .unwrap_or(0)
+}
+
+/// Check feedback history for a (tool, rule_id, entity) tuple reported at
+/// `severity`.
+///
+/// An `error` is never suppressed and never downgraded. The caller that
+/// dismisses issues is the same orchestrator that loops until lint and
+/// enforce are clean, so a feedback channel that can waive an error lets the
+/// gate weaken itself (issue #325: three dismissals of an error produced
+/// "0 issues, 1 suppressed"). Downgrading was rejected as well: error to
+/// warning is the same waiver one step slower, and it turns an error into
+/// something the next two dismissals can suppress. Removing an error takes
+/// changing the ontology or the rule, both of which leave a diff. Feedback
+/// keeps calibrating the warning and info tiers, which is what it was built
+/// for (missing labels on utility classes, intentional root classes).
+pub fn get_feedback_adjustment(db: &StateDb, tool: &str, rule_id: &str, entity: &str, severity: &str) -> FeedbackAction {
+ if severity == "error" {
+ return FeedbackAction::Keep;
+ }
+ let dismiss_count = dismissal_count(db, tool, rule_id, entity);
+ let accept_count: i64 = db
+ .conn()
.query_row(
"SELECT COUNT(*) FROM tool_feedback WHERE tool = ?1 AND rule_id = ?2 AND entity = ?3 AND accepted = 1",
rusqlite::params![tool, rule_id, entity],
@@ -38,7 +59,7 @@ pub fn get_feedback_adjustment(db: &StateDb, tool: &str, rule_id: &str, entity:
let suppress = crate::runtime::feedback_suppress_threshold();
let downgrade = crate::runtime::feedback_downgrade_threshold();
if dismiss_count >= suppress {
- return FeedbackAction::Suppress;
+ return FeedbackAction::Suppress { dismissals: dismiss_count };
}
if dismiss_count >= downgrade {
return FeedbackAction::Downgrade;
@@ -46,6 +67,62 @@ pub fn get_feedback_adjustment(db: &StateDb, tool: &str, rule_id: &str, entity:
FeedbackAction::Keep
}
+/// Split `items` into the issues that stay reported and the ones feedback
+/// suppressed. `rule_key` names the field holding the rule id ("type" for
+/// lint, "rule" for enforce).
+///
+/// A suppressed issue is moved, not dropped: its entry in the second list
+/// keeps rule, entity, message, original severity and the dismissal count,
+/// so a report that reads clean after waivers still says what was waived.
+/// Before #325 the only trace was `suppressed_count`. An error that has been
+/// dismissed stays in the first list at its own severity and gains a
+/// `dismissals` field, so a reviewer can see the orchestrator contested it.
+pub fn apply_feedback(
+ db: Option<&StateDb>,
+ tool: &str,
+ rule_key: &str,
+ items: Vec<serde_json::Value>,
+) -> (Vec<serde_json::Value>, Vec<serde_json::Value>) {
+ let Some(db) = db else {
+ return (items, Vec::new());
+ };
+ let mut kept = Vec::new();
+ let mut suppressed = Vec::new();
+ for mut item in items {
+ let rule = item[rule_key].as_str().unwrap_or("").to_string();
+ let entity = item["entity"].as_str().unwrap_or("").to_string();
+ let severity = item["severity"].as_str().unwrap_or("info").to_string();
+ match get_feedback_adjustment(db, tool, &rule, &entity, &severity) {
+ FeedbackAction::Suppress { dismissals } => {
+ suppressed.push(serde_json::json!({
+ "rule": rule,
+ "entity": entity,
+ "original_severity": severity,
+ "dismissals": dismissals,
+ "message": item["message"].clone(),
+ }));
+ }
+ FeedbackAction::Downgrade => {
+ let downgraded = downgrade_severity(&severity);
+ item["original_severity"] = serde_json::json!(severity);
+ item["adjusted_severity"] = serde_json::json!(downgraded);
+ item["severity"] = serde_json::json!(downgraded);
+ kept.push(item);
+ }
+ FeedbackAction::Keep => {
+ if severity == "error" {
+ let dismissals = dismissal_count(db, tool, &rule, &entity);
+ if dismissals > 0 {
+ item["dismissals"] = serde_json::json!(dismissals);
+ }
+ }
+ kept.push(item);
+ }
+ }
+ }
+ (kept, suppressed)
+}
+
/// Record feedback for a lint or enforce issue.
pub fn record_tool_feedback(db: &StateDb, tool: &str, rule_id: &str, entity: &str, accepted: bool) -> anyhow::Result<String> {
let conn = db.conn();
@@ -63,10 +140,10 @@ pub fn record_tool_feedback(db: &StateDb, tool: &str, rule_id: &str, entity: &st
.to_string())
}
-/// Downgrade a severity string by one level.
+/// Downgrade a severity string by one level. Errors never reach here (see
+/// `get_feedback_adjustment`), so the ladder is warning to info only.
pub fn downgrade_severity(severity: &str) -> &str {
match severity {
- "error" => "warning",
"warning" => "info",
_ => severity,
}
@@ -86,7 +163,7 @@ mod tests {
#[test]
fn test_no_feedback_keeps() {
let db = test_db();
- let action = get_feedback_adjustment(&db, "lint", "missing_label", "http://ex.org/Foo");
+ let action = get_feedback_adjustment(&db, "lint", "missing_label", "http://ex.org/Foo", "warning");
assert_eq!(action, FeedbackAction::Keep);
}
@@ -95,7 +172,7 @@ mod tests {
let db = test_db();
record_tool_feedback(&db, "lint", "missing_label", "http://ex.org/Foo", false).unwrap();
record_tool_feedback(&db, "lint", "missing_label", "http://ex.org/Foo", false).unwrap();
- let action = get_feedback_adjustment(&db, "lint", "missing_label", "http://ex.org/Foo");
+ let action = get_feedback_adjustment(&db, "lint", "missing_label", "http://ex.org/Foo", "warning");
assert_eq!(action, FeedbackAction::Downgrade);
}
@@ -105,8 +182,8 @@ mod tests {
for _ in 0..3 {
record_tool_feedback(&db, "lint", "missing_label", "http://ex.org/Foo", false).unwrap();
}
- let action = get_feedback_adjustment(&db, "lint", "missing_label", "http://ex.org/Foo");
- assert_eq!(action, FeedbackAction::Suppress);
+ let action = get_feedback_adjustment(&db, "lint", "missing_label", "http://ex.org/Foo", "warning");
+ assert_eq!(action, FeedbackAction::Suppress { dismissals: 3 });
}
#[test]
@@ -116,7 +193,7 @@ mod tests {
record_tool_feedback(&db, "lint", "missing_label", "http://ex.org/Foo", false).unwrap();
}
record_tool_feedback(&db, "lint", "missing_label", "http://ex.org/Foo", true).unwrap();
- let action = get_feedback_adjustment(&db, "lint", "missing_label", "http://ex.org/Foo");
+ let action = get_feedback_adjustment(&db, "lint", "missing_label", "http://ex.org/Foo", "warning");
assert_eq!(action, FeedbackAction::Keep);
}
@@ -126,7 +203,7 @@ mod tests {
for _ in 0..3 {
record_tool_feedback(&db, "lint", "missing_label", "http://ex.org/Foo", false).unwrap();
}
- let action = get_feedback_adjustment(&db, "lint", "missing_label", "http://ex.org/Bar");
+ let action = get_feedback_adjustment(&db, "lint", "missing_label", "http://ex.org/Bar", "warning");
assert_eq!(action, FeedbackAction::Keep);
}
@@ -136,13 +213,46 @@ mod tests {
for _ in 0..3 {
record_tool_feedback(&db, "lint", "missing_label", "http://ex.org/Foo", false).unwrap();
}
- let action = get_feedback_adjustment(&db, "enforce", "missing_label", "http://ex.org/Foo");
+ let action = get_feedback_adjustment(&db, "enforce", "missing_label", "http://ex.org/Foo", "warning");
+ assert_eq!(action, FeedbackAction::Keep);
+ }
+
+ #[test]
+ fn test_error_is_never_suppressed_or_downgraded() {
+ let db = test_db();
+ for _ in 0..10 {
+ record_tool_feedback(&db, "lint", "bad_axiom", "http://ex.org/Foo", false).unwrap();
+ }
+ let action = get_feedback_adjustment(&db, "lint", "bad_axiom", "http://ex.org/Foo", "error");
assert_eq!(action, FeedbackAction::Keep);
}
+ #[test]
+ fn test_apply_feedback_moves_suppressed_and_keeps_errors() {
+ let db = test_db();
+ for _ in 0..3 {
+ record_tool_feedback(&db, "lint", "missing_label", "http://ex.org/W", false).unwrap();
+ record_tool_feedback(&db, "lint", "bad_axiom", "http://ex.org/E", false).unwrap();
+ }
+ let items = vec![
+ serde_json::json!({"type": "missing_label", "entity": "http://ex.org/W", "severity": "warning", "message": "w"}),
+ serde_json::json!({"type": "bad_axiom", "entity": "http://ex.org/E", "severity": "error", "message": "e"}),
+ ];
+ let (kept, suppressed) = apply_feedback(Some(&db), "lint", "type", items);
+ assert_eq!(kept.len(), 1);
+ assert_eq!(kept[0]["entity"], "http://ex.org/E");
+ assert_eq!(kept[0]["severity"], "error");
+ assert_eq!(kept[0]["dismissals"], 3);
+ assert!(kept[0].get("adjusted_severity").is_none());
+ assert_eq!(suppressed.len(), 1);
+ assert_eq!(suppressed[0]["rule"], "missing_label");
+ assert_eq!(suppressed[0]["entity"], "http://ex.org/W");
+ assert_eq!(suppressed[0]["original_severity"], "warning");
+ assert_eq!(suppressed[0]["dismissals"], 3);
+ }
+
#[test]
fn test_downgrade_severity() {
- assert_eq!(downgrade_severity("error"), "warning");
assert_eq!(downgrade_severity("warning"), "info");
assert_eq!(downgrade_severity("info"), "info");
}
diff --git a/src/main.rs b/src/main.rs
index 0f166502..de6fcb76 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -145,7 +145,8 @@ data_dir = "~/.open-ontologies"
# [feedback]
# Lint / enforce self-calibration thresholds (number of dismissals before
-# downgrading then suppressing a (tool, rule_id, entity) triple).
+# downgrading then suppressing a (tool, rule_id, entity) triple). Suppressed
+# issues are listed in the output's `suppressed[]`; errors are never touched.
# suppress_threshold = 3
# downgrade_threshold = 2
diff --git a/src/ontology.rs b/src/ontology.rs
index 0db5b6f0..1f3906cf 100644
--- a/src/ontology.rs
+++ b/src/ontology.rs
@@ -182,7 +182,8 @@ impl OntologyService {
Ok(issues)
}
- /// Lint an ontology with feedback-based suppression.
+ /// Lint an ontology with feedback-based suppression (see
+ /// `crate::feedback::apply_feedback` for what suppression may touch).
pub fn lint_with_feedback(content: &str, db: Option<&crate::state::StateDb>) -> anyhow::Result<String> {
let store = Store::new()?;
let reader = Cursor::new(content.as_bytes());
@@ -191,40 +192,15 @@ impl OntologyService {
}
let raw_issues = Self::collect_lint_issues(&store)?;
- let mut issues: Vec<serde_json::Value> = Vec::new();
- let mut suppressed_count: u64 = 0;
-
- for issue in raw_issues {
- if let Some(db) = db {
- let rule_id = issue["type"].as_str().unwrap_or("");
- let entity = issue["entity"].as_str().unwrap_or("");
- match crate::feedback::get_feedback_adjustment(db, "lint", rule_id, entity) {
- crate::feedback::FeedbackAction::Suppress => {
- suppressed_count += 1;
- continue;
- }
- crate::feedback::FeedbackAction::Downgrade => {
- let original = issue["severity"].as_str().unwrap_or("info");
- let downgraded = crate::feedback::downgrade_severity(original);
- let mut adjusted = issue.clone();
- adjusted["original_severity"] = serde_json::json!(original);
- adjusted["adjusted_severity"] = serde_json::json!(downgraded);
- adjusted["severity"] = serde_json::json!(downgraded);
- issues.push(adjusted);
- }
- crate::feedback::FeedbackAction::Keep => {
- issues.push(issue);
- }
- }
- } else {
- issues.push(issue);
- }
- }
+ let (issues, suppressed) = crate::feedback::apply_feedback(db, "lint", "type", raw_issues);
+ // `issue_count` stays over `issues` only; `suppressed` lists what
+ // feedback waived so "clean" and "clean after waivers" read apart.
Ok(serde_json::json!({
"issues": issues,
"issue_count": issues.len(),
- "suppressed_count": suppressed_count,
+ "suppressed_count": suppressed.len(),
+ "suppressed": suppressed,
})
.to_string())
}
diff --git a/src/server.rs b/src/server.rs
index 74aa315f..d9b31b42 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -3057,7 +3057,7 @@ impl OpenOntologiesServer {
}
}
- #[tool(name = "onto_lint_feedback", description = "Accept or dismiss a lint issue to improve future lint runs. Dismissed issues are suppressed after 3 dismissals. Stores feedback for self-calibrating severity.")]
+ #[tool(name = "onto_lint_feedback", description = "Accept or dismiss a lint issue to improve future lint runs. A warning or info is downgraded after 2 dismissals and suppressed after 3 (configurable in [feedback]); a suppressed issue moves to the suppressed[] list of the lint output with its rule, entity, original severity and dismissal count. Error-severity issues are never downgraded or suppressed. Stores feedback for self-calibrating severity.")]
async fn onto_lint_feedback(&self, Parameters(input): Parameters<OntoLintFeedbackInput>) -> String {
match crate::feedback::record_tool_feedback(&self.db, "lint", &input.rule_id, &input.entity, input.accepted) {
Ok(result) => {
@@ -3068,7 +3068,7 @@ impl OpenOntologiesServer {
}
}
- #[tool(name = "onto_enforce_feedback", description = "Accept or dismiss an enforce violation to improve future enforce runs. Dismissed violations are suppressed after 3 dismissals. Stores feedback for self-calibrating compliance.")]
+ #[tool(name = "onto_enforce_feedback", description = "Accept or dismiss an enforce violation to improve future enforce runs. A warning or info is downgraded after 2 dismissals and suppressed after 3 (configurable in [feedback]); a suppressed violation moves to the suppressed[] list of the enforce output with its rule, entity, original severity and dismissal count. Error-severity violations are never downgraded or suppressed. Stores feedback for self-calibrating compliance.")]
async fn onto_enforce_feedback(&self, Parameters(input): Parameters<OntoEnforceFeedbackInput>) -> String {
match crate::feedback::record_tool_feedback(&self.db, "enforce", &input.rule_id, &input.entity, input.accepted) {
Ok(result) => {
diff --git a/tests/feedback_suppression_test.rs b/tests/feedback_suppression_test.rs
new file mode 100644
index 00000000..f0a5d9ec
--- /dev/null
+++ b/tests/feedback_suppression_test.rs
@@ -0,0 +1,136 @@
+//! Feedback may waive warnings and infos, never errors, and never silently.
+//!
+//! Issue #325: once a (tool, rule, entity) had been dismissed
+//! `suppress_threshold` times (default 3), lint and enforce dropped it whatever
+//! its severity, and the only trace left was `suppressed_count`. The caller that
+//! dismisses is the same orchestrator that loops until the report is clean, so
+//! three dismissals of an error produced a clean report with no record of which
+//! rule or entity had been waived.
+//!
+//! Pinned:
+//! 1. an error dismissed `suppress_threshold` times is still in `violations`
+//! at severity `error`, not downgraded;
+//! 2. a warning dismissed that many times leaves `issues`/`violations` and
+//! appears in `suppressed[]` with rule, entity, original severity and
+//! dismissal count;
+//! 3. `issue_count` is still computed over `issues` only.
+
+use open_ontologies::enforce::Enforcer;
+use open_ontologies::feedback::record_tool_feedback;
+use open_ontologies::graph::GraphStore;
+use open_ontologies::ontology::OntologyService;
+use open_ontologies::state::StateDb;
+use std::sync::Arc;
+
+fn db() -> StateDb {
+ let tmp = tempfile::NamedTempFile::new().unwrap();
+ let path = tmp.path().to_path_buf();
+ std::mem::forget(tmp);
+ StateDb::open(&path).unwrap()
+}
+
+fn threshold() -> i64 {
+ open_ontologies::runtime::feedback_suppress_threshold()
+}
+
+fn dismiss(db: &StateDb, tool: &str, rule: &str, entity: &str) {
+ for _ in 0..threshold() {
+ record_tool_feedback(db, tool, rule, entity, false).unwrap();
+ }
+}
+
+fn find<'a>(list: &'a serde_json::Value, key: &str, rule: &str, entity_part: &str) -> Option<&'a serde_json::Value> {
+ list.as_array().unwrap().iter().find(|v| {
+ v[key].as_str() == Some(rule) && v["entity"].as_str().unwrap_or("").contains(entity_part)
+ })
+}
+
+const IES4_OVERLAP: &str = r#"
+@prefix owl: <http://www.w3.org/2002/07/owl#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix ies: <http://ies.data.gov.uk/ontology/ies4#> .
+@prefix ex: <http://example.org/> .
+ex:Clash a owl:Class ; rdfs:subClassOf ies:Particular , ies:ClassOfEntity .
+"#;
+
+#[test]
+fn enforce_error_dismissed_to_threshold_stays_visible_at_error() {
+ let db = db();
+ let graph = Arc::new(GraphStore::new());
+ graph.load_turtle(IES4_OVERLAP, None).unwrap();
+ let enforcer = Enforcer::new(db.clone(), graph);
+
+ let before: serde_json::Value =
+ serde_json::from_str(&enforcer.enforce_with_feedback("ies4", Some(&db)).unwrap()).unwrap();
+ let v = find(&before["violations"], "rule", "ies4_particular_class_overlap", "example.org/Clash")
+ .expect("fixture must raise the error-severity overlap violation");
+ assert_eq!(v["severity"], "error");
+ let entity = v["entity"].as_str().unwrap().to_string();
+
+ dismiss(&db, "enforce", "ies4_particular_class_overlap", &entity);
+
+ let after: serde_json::Value =
+ serde_json::from_str(&enforcer.enforce_with_feedback("ies4", Some(&db)).unwrap()).unwrap();
+ let v = find(&after["violations"], "rule", "ies4_particular_class_overlap", "example.org/Clash")
+ .expect("an error must never be suppressed by feedback");
+ assert_eq!(v["severity"], "error");
+ assert!(v.get("adjusted_severity").is_none(), "an error must not be downgraded: {v}");
+ assert_eq!(v["dismissals"], threshold());
+ assert_eq!(after["suppressed_count"], 0);
+}
+
+#[test]
+fn enforce_warning_dismissed_to_threshold_moves_to_suppressed() {
+ let db = db();
+ let graph = Arc::new(GraphStore::new());
+ graph
+ .load_turtle("@prefix owl: <http://www.w3.org/2002/07/owl#> . <http://example.org/Dog> a owl:Class .", None)
+ .unwrap();
+ let enforcer = Enforcer::new(db.clone(), graph);
+
+ let before: serde_json::Value =
+ serde_json::from_str(&enforcer.enforce_with_feedback("generic", Some(&db)).unwrap()).unwrap();
+ let v = find(&before["violations"], "rule", "missing_label", "example.org/Dog").unwrap();
+ let severity = v["severity"].as_str().unwrap().to_string();
+ assert_ne!(severity, "error", "fixture must pick a non-error rule");
+ let entity = v["entity"].as_str().unwrap().to_string();
+
+ dismiss(&db, "enforce", "missing_label", &entity);
+
+ let after: serde_json::Value =
+ serde_json::from_str(&enforcer.enforce_with_feedback("generic", Some(&db)).unwrap()).unwrap();
+ assert!(find(&after["violations"], "rule", "missing_label", "example.org/Dog").is_none());
+ let s = find(&after["suppressed"], "rule", "missing_label", "example.org/Dog")
+ .expect("a suppressed violation must be listed in suppressed[]");
+ assert_eq!(s["entity"], entity.as_str());
+ assert_eq!(s["original_severity"], severity.as_str());
+ assert_eq!(s["dismissals"], threshold());
+ assert_eq!(after["suppressed_count"], after["suppressed"].as_array().unwrap().len());
+}
+
+#[test]
+fn lint_warning_dismissed_to_threshold_moves_to_suppressed() {
+ let db = db();
+ let ttl = "@prefix owl: <http://www.w3.org/2002/07/owl#> . <http://example.org/Dog> a owl:Class .";
+
+ let before: serde_json::Value =
+ serde_json::from_str(&OntologyService::lint_with_feedback(ttl, Some(&db)).unwrap()).unwrap();
+ let issue = find(&before["issues"], "type", "missing_label", "example.org/Dog").unwrap();
+ assert_eq!(issue["severity"], "warning");
+ let entity = issue["entity"].as_str().unwrap().to_string();
+ let count_before = before["issue_count"].as_u64().unwrap();
+
+ dismiss(&db, "lint", "missing_label", &entity);
+
+ let after: serde_json::Value =
+ serde_json::from_str(&OntologyService::lint_with_feedback(ttl, Some(&db)).unwrap()).unwrap();
+ assert!(find(&after["issues"], "type", "missing_label", "example.org/Dog").is_none());
+ let s = find(&after["suppressed"], "rule", "missing_label", "example.org/Dog")
+ .expect("a suppressed lint issue must be listed in suppressed[]");
+ assert_eq!(s["entity"], entity.as_str());
+ assert_eq!(s["original_severity"], "warning");
+ assert_eq!(s["dismissals"], threshold());
+ // issue_count covers `issues` only, as before.
+ assert_eq!(after["issue_count"].as_u64().unwrap(), count_before - 1);
+ assert_eq!(after["issue_count"], after["issues"].as_array().unwrap().len());
+}