From c5478a369b05a8f26394f322c6738227176f9b28 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 May 2026 11:42:34 +0000 Subject: [PATCH 1/3] Harden WNN telemetry enforcement and rollback guards Agent-Logs-Url: https://github.com/dfeen87/HLV-RAPS/sessions/5cc1e5af-f700-41a0-b6a3-5ecf30bece8e Co-authored-by: dfeen87 <158860247+dfeen87@users.noreply.github.com> --- .../safety/deterministic_safety_monitor.hpp | 42 +++++++++++++++++-- src/raps/rollback_execution.hpp | 2 +- tests/sil/test_rollback_execution.cpp | 31 ++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/include/raps/safety/deterministic_safety_monitor.hpp b/include/raps/safety/deterministic_safety_monitor.hpp index ede7003..aac7bf9 100644 --- a/include/raps/safety/deterministic_safety_monitor.hpp +++ b/include/raps/safety/deterministic_safety_monitor.hpp @@ -80,6 +80,8 @@ class DeterministicSafetyMonitor { bool safing_sequence_active_; bool hasInvalidInputs(const DsmSensorInputs& inputs) const; + bool hasInvalidWnnTelemetry(const WnnTelemetry& wnn_telem) const; + bool isWnnThresholdBreached(const WnnTelemetry& wnn_telem) const; bool checkResonanceStability(double A_t, double J_coupling) const; double estimateCurvatureScalar(double dilation) const; bool checkCurvatureViolation(double R_estimated) const; @@ -120,6 +122,22 @@ DeterministicSafetyMonitor::hasInvalidInputs( !std::isfinite(inputs.current_resonance_amplitude); } +inline bool +DeterministicSafetyMonitor::hasInvalidWnnTelemetry( + const WnnTelemetry& wnn_telem +) const { + return !std::isfinite(wnn_telem.curvature_proxy) || + !std::isfinite(wnn_telem.oscillatory_prefactor); +} + +inline bool +DeterministicSafetyMonitor::isWnnThresholdBreached( + const WnnTelemetry& wnn_telem +) const { + return wnn_telem.curvature_proxy > DSM_Config::WNN_MAX_CURVATURE_PROXY || + wnn_telem.oscillatory_prefactor < DSM_Config::WNN_MIN_OSCILLATORY_PREFACTOR; +} + inline bool DeterministicSafetyMonitor::checkResonanceStability( double A_t, @@ -193,11 +211,29 @@ DeterministicSafetyMonitor::pollWnnAndEnforce( uint32_t rollback_count, PhysicsState& active_state_pointer ) { - if (wnn_telem.curvature_proxy > DSM_Config::WNN_MAX_CURVATURE_PROXY || - wnn_telem.oscillatory_prefactor < DSM_Config::WNN_MIN_OSCILLATORY_PREFACTOR) { + const bool invalid_wnn_input = hasInvalidWnnTelemetry(wnn_telem); + const bool threshold_breach = isWnnThresholdBreached(wnn_telem); + + if (invalid_wnn_input || threshold_breach) { + safing_sequence_active_ = true; + if (invalid_wnn_input) { + std::cerr << "DSM ALERT: Non-finite WNN telemetry detected — ROLLBACK\n"; + } + + const double logged_curvature = std::isfinite(wnn_telem.curvature_proxy) + ? wnn_telem.curvature_proxy + : 0.0; + const double logged_prefactor = std::isfinite(wnn_telem.oscillatory_prefactor) + ? wnn_telem.oscillatory_prefactor + : 0.0; // Breach detected! Log to ITL and execute immediate rollback - itl_manager.log_wnn_rollback_event(wnn_telem.curvature_proxy, wnn_telem.oscillatory_prefactor); + itl_manager.log_wnn_rollback_event(logged_curvature, logged_prefactor); + + if (rollback_count > 0 && rollback_store == nullptr) { + std::cerr << "DSM ALERT: rollback store unavailable during WNN safing\n"; + return false; + } return trigger_wnn_immediate_rollback( rollback_store, diff --git a/src/raps/rollback_execution.hpp b/src/raps/rollback_execution.hpp index 5ec9796..acdd0c4 100644 --- a/src/raps/rollback_execution.hpp +++ b/src/raps/rollback_execution.hpp @@ -53,7 +53,7 @@ inline bool trigger_wnn_immediate_rollback( uint32_t rollback_count, PhysicsState& active_state_pointer ) { - if (rollback_count == 0) { + if (rollback_count == 0 || rollback_store == nullptr) { return false; } diff --git a/tests/sil/test_rollback_execution.cpp b/tests/sil/test_rollback_execution.cpp index 759496b..87ec34e 100644 --- a/tests/sil/test_rollback_execution.cpp +++ b/tests/sil/test_rollback_execution.cpp @@ -76,6 +76,36 @@ void test_rollback_validation() { expect_true(tx_id.length() > 0, "tx_id is generated"); } +void test_wnn_rollback_hardening() { + std::cout << "--- Testing WNN Rollback Hardening ---\n"; + + PhysicsState active_state{}; + active_state.timestamp_ms = 10; + + // 1. Null rollback store with non-zero count must fail safely + bool null_store_result = trigger_wnn_immediate_rollback( + nullptr, + 1, + active_state + ); + expect_false( + null_store_result, + "trigger_wnn_immediate_rollback fails safely for null rollback store" + ); + + // 2. Empty rollback store must fail safely + RollbackPlan store[1]{}; + bool empty_store_result = trigger_wnn_immediate_rollback( + store, + 0, + active_state + ); + expect_false( + empty_store_result, + "trigger_wnn_immediate_rollback fails safely for empty rollback store" + ); +} + int main() { std::cout << "========================================================\n"; std::cout << " SIL TEST: Rollback Execution Logic\n"; @@ -85,6 +115,7 @@ int main() { PlatformHAL::seed_rng_for_stubs(12345); test_rollback_validation(); + test_wnn_rollback_hardening(); std::cout << "--------------------------------------------------------\n"; if (g_failures == 0) { From fae11270d692bc9947fa8d8dc98c35cfc7af1d93 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 May 2026 11:45:47 +0000 Subject: [PATCH 2/3] Refine DSM WNN telemetry diagnostics and logging sentinels Agent-Logs-Url: https://github.com/dfeen87/HLV-RAPS/sessions/5cc1e5af-f700-41a0-b6a3-5ecf30bece8e Co-authored-by: dfeen87 <158860247+dfeen87@users.noreply.github.com> --- include/raps/safety/deterministic_safety_monitor.hpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/include/raps/safety/deterministic_safety_monitor.hpp b/include/raps/safety/deterministic_safety_monitor.hpp index aac7bf9..c7a8e32 100644 --- a/include/raps/safety/deterministic_safety_monitor.hpp +++ b/include/raps/safety/deterministic_safety_monitor.hpp @@ -218,23 +218,20 @@ DeterministicSafetyMonitor::pollWnnAndEnforce( safing_sequence_active_ = true; if (invalid_wnn_input) { std::cerr << "DSM ALERT: Non-finite WNN telemetry detected — ROLLBACK\n"; + } else { + std::cerr << "DSM ALERT: WNN thresholds exceeded — ROLLBACK\n"; } const double logged_curvature = std::isfinite(wnn_telem.curvature_proxy) ? wnn_telem.curvature_proxy - : 0.0; + : -1.0; const double logged_prefactor = std::isfinite(wnn_telem.oscillatory_prefactor) ? wnn_telem.oscillatory_prefactor - : 0.0; + : -1.0; // Breach detected! Log to ITL and execute immediate rollback itl_manager.log_wnn_rollback_event(logged_curvature, logged_prefactor); - if (rollback_count > 0 && rollback_store == nullptr) { - std::cerr << "DSM ALERT: rollback store unavailable during WNN safing\n"; - return false; - } - return trigger_wnn_immediate_rollback( rollback_store, rollback_count, From 88a3f05d1c05638d6602f24e6b4c681323fe4386 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 7 May 2026 11:47:10 +0000 Subject: [PATCH 3/3] Use named invalid telemetry sentinel in DSM WNN path Agent-Logs-Url: https://github.com/dfeen87/HLV-RAPS/sessions/5cc1e5af-f700-41a0-b6a3-5ecf30bece8e Co-authored-by: dfeen87 <158860247+dfeen87@users.noreply.github.com> --- include/raps/safety/deterministic_safety_monitor.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/raps/safety/deterministic_safety_monitor.hpp b/include/raps/safety/deterministic_safety_monitor.hpp index c7a8e32..1a40eb3 100644 --- a/include/raps/safety/deterministic_safety_monitor.hpp +++ b/include/raps/safety/deterministic_safety_monitor.hpp @@ -31,6 +31,7 @@ constexpr double MIN_RESONANCE_AMPLITUDE_CUTOFF = 0.10; // WNN Constraints constexpr double WNN_MAX_CURVATURE_PROXY = 5.0e-11; constexpr double WNN_MIN_OSCILLATORY_PREFACTOR = 0.85; +constexpr double INVALID_TELEMETRY_SENTINEL = -1.0; } // namespace DSM_Config @@ -215,6 +216,7 @@ DeterministicSafetyMonitor::pollWnnAndEnforce( const bool threshold_breach = isWnnThresholdBreached(wnn_telem); if (invalid_wnn_input || threshold_breach) { + // Keep safing active until the broader control loop restores margins. safing_sequence_active_ = true; if (invalid_wnn_input) { std::cerr << "DSM ALERT: Non-finite WNN telemetry detected — ROLLBACK\n"; @@ -224,10 +226,10 @@ DeterministicSafetyMonitor::pollWnnAndEnforce( const double logged_curvature = std::isfinite(wnn_telem.curvature_proxy) ? wnn_telem.curvature_proxy - : -1.0; + : DSM_Config::INVALID_TELEMETRY_SENTINEL; const double logged_prefactor = std::isfinite(wnn_telem.oscillatory_prefactor) ? wnn_telem.oscillatory_prefactor - : -1.0; + : DSM_Config::INVALID_TELEMETRY_SENTINEL; // Breach detected! Log to ITL and execute immediate rollback itl_manager.log_wnn_rollback_event(logged_curvature, logged_prefactor);