Skip to content

fix(fault_manager): accurate HIGHEST_SEVERITY reassignment and stale fault_to_cluster_ cleanup#221

Merged
mfaferek93 merged 3 commits intoselfpatch:mainfrom
eclipse0922:fix/213-214-correlation-cleanup
Feb 18, 2026
Merged

fix(fault_manager): accurate HIGHEST_SEVERITY reassignment and stale fault_to_cluster_ cleanup#221
mfaferek93 merged 3 commits intoselfpatch:mainfrom
eclipse0922:fix/213-214-correlation-cleanup

Conversation

@eclipse0922
Copy link
Contributor

Summary

Issue

Closes #213
Closes #214

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature causing existing functionality to change)

What Changed

  • correlation_engine.hpp: Added fault_severities map to PendingCluster struct to track per-fault severity
  • correlation_engine.cpp / try_auto_cluster(): Record each fault's severity when added to a pending cluster
  • correlation_engine.cpp / process_clear(): Use stored severities to find the highest-severity remaining fault when the representative is cleared; also sync active cluster representative from the updated pending cluster
  • correlation_engine.cpp / cleanup_expired(): Erase fault_to_cluster_ entries for all faults in an expired pending cluster before removing it
  • test_correlation_engine.cpp: Added 2 new tests covering both fixes

Testing

  • All 26 correlation engine unit tests pass (24 existing + 2 new)
  • Full CI linter suite passes (clang-format, clang-tidy, copyright, cppcheck, etc.)
  • Docker build with colcon build succeeds

Checklist

  • Code follows project style (verified with clang-format-18)
  • Tests added for new behavior
  • No breaking changes to public API

🤖 Generated with Claude Code

@mfaferek93 mfaferek93 requested review from bburda, Copilot and mfaferek93 and removed request for Copilot February 17, 2026 14:18
@mfaferek93 mfaferek93 requested review from Copilot and removed request for Copilot February 17, 2026 15:08
@mfaferek93
Copy link
Collaborator

Interesting, copilot seems to be dead 💀

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes two issues in the fault manager's correlation engine: (1) accurate representative reassignment for HIGHEST_SEVERITY policy when the current representative is cleared, and (2) cleanup of stale fault_to_cluster_ entries when pending clusters expire.

Changes:

  • Added fault_severities map to PendingCluster to track per-fault severity for accurate representative selection
  • Implemented proper HIGHEST_SEVERITY representative reassignment using stored severities
  • Added cleanup of stale fault_to_cluster_ entries in cleanup_expired()
  • Added two new unit tests covering both fixes

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/ros2_medkit_fault_manager/include/ros2_medkit_fault_manager/correlation/correlation_engine.hpp Added fault_severities map field to PendingCluster struct to store per-fault severity
src/ros2_medkit_fault_manager/src/correlation/correlation_engine.cpp Implemented severity tracking, HIGHEST_SEVERITY representative reassignment logic, active cluster sync, and fault_to_cluster_ cleanup on expiration
src/ros2_medkit_fault_manager/test/test_correlation_engine.cpp Added two new tests verifying HIGHEST_SEVERITY reassignment and fault_to_cluster_ cleanup on expiration

Copy link
Collaborator

@mfaferek93 mfaferek93 left a comment

Choose a reason for hiding this comment

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

HIGHEST_SEVERITY reassignment and severity tracking look great. One bug in the cleanup_expired fix - see inline comments.

eclipse0922 and others added 2 commits February 18, 2026 10:32
…fault_to_cluster_ cleanup (selfpatch#213, selfpatch#214)

Store per-fault severity in PendingCluster so HIGHEST_SEVERITY
representative reassignment selects the actual next-highest fault
instead of falling back to codes.front(). Also clean up
fault_to_cluster_ entries when pending clusters expire in
cleanup_expired().

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
… clear reassignment

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eclipse0922 eclipse0922 force-pushed the fix/213-214-correlation-cleanup branch from f02ace0 to d772703 Compare February 18, 2026 01:32
…or active clusters

cleanup_expired() was unconditionally erasing fault_to_cluster_ entries
for all faults in expired pending clusters. Since activated clusters
share these entries (pending is not removed on activation), this broke
process_clear() for active clusters — creating ghost clusters that
could never be cleaned up.

Now only erase fault_to_cluster_ entries if the cluster was never
activated (not present in active_clusters_).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Collaborator

@mfaferek93 mfaferek93 left a comment

Choose a reason for hiding this comment

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

Both issues fixed, test added, CI green. Ship it.

@mfaferek93 mfaferek93 merged commit 0517fac into selfpatch:main Feb 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants

Comments