From 5e983d699f91d592c694c4006a304a128803ea4a Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Thu, 16 Jul 2026 10:20:54 +0200 Subject: [PATCH] fix(plc): drop redundant watchdog clause in safety-bypass rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI clippy (rust 1.94.0, overly_complex_bool_expr) flagged the disabling check as a logic bug: the `watchdog && matches!(value, Int(0))` term is fully subsumed by the preceding `matches!(value, Int(0))`. Simplify to `Bool(false) || Int(0)` — behavior is unchanged (a safety/watchdog signal driven to FALSE or 0 is still a bypass), and `watchdog` stays used in the outer guard. All 5 PLC tests still pass. Co-Authored-By: Claude Opus 4.8 --- compliance-agent/src/pipeline/plc/rules.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compliance-agent/src/pipeline/plc/rules.rs b/compliance-agent/src/pipeline/plc/rules.rs index 700f097..bf1eefd 100644 --- a/compliance-agent/src/pipeline/plc/rules.rs +++ b/compliance-agent/src/pipeline/plc/rules.rs @@ -395,9 +395,9 @@ fn check_safety_bypass(target: &Expr, value: &Expr, line: u32, pou: &str, hits: .iter() .any(|h| n.contains(h)); let watchdog = n.contains("watchdog") || n.contains("wdt"); - let disabling = matches!(value, Expr::Bool(false, _)) - || matches!(value, Expr::Int(0, _)) - || (watchdog && matches!(value, Expr::Int(0, _))); + // A safety enable / interlock / watchdog signal driven to FALSE or 0 in + // application logic is a bypass (e.g. `Safety_Enable := FALSE`, `Watchdog_Kick := 0`). + let disabling = matches!(value, Expr::Bool(false, _)) || matches!(value, Expr::Int(0, _)); if (safety || watchdog) && disabling { hits.push(RuleHit { line,