From 2343f85afb34cf8a423dff8c18171b4426796bc4 Mon Sep 17 00:00:00 2001 From: Bartosz Burda Date: Tue, 1 Dec 2026 14:41:03 +0100 Subject: [PATCH] fault_manager: parse and validate rosbag retention rules * feat(fault_manager): parse and validate rosbag retention rules * fix(fault_manager): satisfy clang-tidy in the retention policy and node * feat(fault_manager): stop on parameters-file keys the loader moves, drive the own fault from events * feat(fault_manager): compare the loader's reading of parameters files with ours, re-report on every confirmation * docs(fault_manager): describe the moved-key comparison and the start-up failures * test(fault_manager): start from a correct section in the second document * fix(fault_manager): create the retention timer before the started message * fix(fault_manager): satisfy clang-tidy in the parameters file reading * feat(fault_manager): apply sections as rclcpp does, compare per section as multisets, verify confirmation candidates * fix(fault_manager): compare parameters files as rcl merges them, signal confirmations exactly * fix(fault_manager): treat a stop signal during startup as a clean stop * fix(fault_manager): keep construction and spinning as separate phases in main --- docs/config/fault-manager.rst | 119 ++++ src/ros2_medkit_fault_manager/CMakeLists.txt | 17 + src/ros2_medkit_fault_manager/README.md | 9 + .../config/rosbag_retention.example.yaml | 46 ++ .../design/index.rst | 25 + .../core/fault_manager_core.hpp | 12 + .../core/params_file_scan.hpp | 69 ++ .../core/retention_policy.hpp | 94 +++ .../fault_manager_node.hpp | 52 ++ .../ros2/ros_capture_hooks.hpp | 17 +- src/ros2_medkit_fault_manager/package.xml | 2 + .../src/core/fault_manager_core.cpp | 9 + .../src/core/params_file_scan.cpp | 148 ++++ .../src/core/retention_policy.cpp | 316 +++++++++ .../src/fault_manager_node.cpp | 329 +++++++++ src/ros2_medkit_fault_manager/src/main.cpp | 22 +- .../test/integration/rosbag_fm_harness.py | 52 +- .../integration/test_retention_config.test.py | 664 ++++++++++++++++++ .../test_retention_config_pg.test.py | 190 +++++ .../test/test_retention_policy.cpp | 145 ++++ 20 files changed, 2321 insertions(+), 16 deletions(-) create mode 100644 src/ros2_medkit_fault_manager/config/rosbag_retention.example.yaml create mode 100644 src/ros2_medkit_fault_manager/include/ros2_medkit_fault_manager/core/params_file_scan.hpp create mode 100644 src/ros2_medkit_fault_manager/include/ros2_medkit_fault_manager/core/retention_policy.hpp create mode 100644 src/ros2_medkit_fault_manager/src/core/params_file_scan.cpp create mode 100644 src/ros2_medkit_fault_manager/src/core/retention_policy.cpp create mode 100644 src/ros2_medkit_fault_manager/test/integration/test_retention_config.test.py create mode 100644 src/ros2_medkit_fault_manager/test/integration/test_retention_config_pg.test.py create mode 100644 src/ros2_medkit_fault_manager/test/test_retention_policy.cpp diff --git a/docs/config/fault-manager.rst b/docs/config/fault-manager.rst index e7590a081..26d78561b 100644 --- a/docs/config/fault-manager.rst +++ b/docs/config/fault-manager.rst @@ -773,6 +773,125 @@ messages before everything stopped. Note the condition: a single captured topic goes quiet while others keep publishing is pruned like anything else, because each arrival prunes the whole buffer by age. +Rosbag Retention Rules +~~~~~~~~~~~~~~~~~~~~~~ + +The parameters under ``snapshots.rosbag.retention.`` set a rule per fault: a ``priority`` and an +``over_quota`` choice. They are read at startup, validated and logged. They are read only while +rosbag capture is on (``snapshots.rosbag.enabled: true``); with it off, the fault manager warns once +and ignores them. Without any ``snapshots.rosbag.retention.*`` parameter the fault manager behaves as +before. An example file is ``config/rosbag_retention.example.yaml``. + +.. code-block:: yaml + + fault_manager: + ros__parameters: + snapshots: + rosbag: + retention: + defaults: + priority: 10 + severity: + ERROR: + priority: 50 + fault_codes: + MOTOR-STALL: + priority: 900 + patterns: + gnss_fix: + match: 'GNSS\.FIX_LOST' + priority: 300 + pattern_order: [gnss_fix] + +Grammar, relative to ``snapshots.rosbag.retention.``: + +.. list-table:: + :header-rows: 1 + :widths: 40 60 + + * - Key + - Meaning + * - ``defaults.`` + - Rule of every fault the other levels do not set. + * - ``severity..`` + - Rule of the faults with that severity. + * - ``fault_codes..`` + - Rule of one fault code. ```` has no ``.``; hyphens are allowed. + * - ``patterns.