Skip to content

fault_manager: on_healed and on_cleared per rosbag retention rule - #859

Draft
bburda wants to merge 1 commit into
feat/rosbag-retention-3from
feat/rosbag-retention-4a
Draft

bburda wants to merge 1 commit into
feat/rosbag-retention-3from
feat/rosbag-retention-4a

Conversation

@bburda

@bburda bburda commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

Today a fault's recordings are deleted on a clear only through auto_cleanup with max_bags_per_fault: 1, and nothing happens when a fault heals. Issue 705 asks for a per-rule action on both status changes. This PR adds the rule fields on_healed and on_cleared (keep or delete).

This PR is on top of seven PRs in the stack. Please review those first. The diff of this PR is against the branch of the PR directly below it.

What it adds:

  • on_healed (default keep). With delete, a fault that becomes HEALED loses its recordings. This applies to any transition into HEALED, including from PREFAILED.
  • on_cleared. An explicit value wins over auto_cleanup and the cap. Without it, the clear keeps today's default: delete when auto_cleanup is true and the fault's max_bags is 1.
  • Shared recordings. A status action removes only the link of the fault concerned. The directory goes with its last link. A fault that heals or is cleared during the post-fault window does not join the recording being made.
  • No recording slips past a delete. A per-fault-code counter moves with every delete action, and a recording made before the action is not stored after it. This also covers a fault that flaps (heals, then fails again) between the recording's close and its store, and the same case for a clear.
  • Startup. When the fault manager turns stale HEALED faults into CLEARED at startup (healing disabled), only an explicit on_cleared: delete removes their recordings. A restart with healing turned off deletes nothing that no rule asked for.
  • Docs: docs/config/fault-manager.rst, docs/tutorials/snapshots.rst, config/snapshots.yaml, the example retention file, the fault manager README and design doc.

What changes for users

  • Without retention parameters nothing changes.
  • New rule fields on_healed and on_cleared. An invalid value is reported as ROSBAG_RETENTION_CONFIG_INVALID.
  • With audit_log.fail_closed: true, a failed audit append stops the status actions that follow it. The stored recordings stay until a space limit or a later status change removes them.
  • New log lines. A removal on heal reads (fault healed), with an INFO "Heal cleanup" line.

Issue


Type

  • Bug fix
  • New feature or tests
  • Breaking change
  • Documentation only

Testing

  • colcon build --packages-up-to ros2_medkit_fault_manager --cmake-args -DPOSTGRES_SUPPORT=ON, then colcon test --packages-select ros2_medkit_fault_manager (with ROS2_MEDKIT_TEST_PG_CONN for the PostgreSQL cases) and colcon test-result --verbose.

  • The real-process test is src/ros2_medkit_fault_manager/test/integration/test_rosbag_status_actions.test.py. It covers:

    • heal and clear, keep and delete;
    • levels;
    • shared recordings, stored and in flight;
    • a status change during the post-fault window;
    • a flapping fault with a slowed store;
    • a capture that runs only after the heal;
    • the startup reclassification over two runs;
    • invalid values.

    test_rosbag_quota_pg.test.py has the PostgreSQL case.

  • I ran this on Jazzy with PostgreSQL 14. Humble and Lyrical run in CI. clang-tidy on the changed files reports nothing new.


Checklist

  • Breaking changes are clearly described (and announced in docs / changelog if needed)
  • Tests were added or updated if needed
  • Docs were updated if behavior or public API changed

@bburda
bburda added this pull request to stack #836 December 1, 2026 13:21
@bburda
bburda force-pushed the feat/rosbag-retention-4a branch from a18f9f5 to 38dfb2c Compare December 1, 2026 15:43
capture_on_confirm(report.fault_code);
}
if (just_healed) {
hooks_.on_healed(report.fault_code);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

With on_healed: delete and the default recapture_cooldown_sec: 60, a fault that heals and confirms again within 60 s loses its recording on the heal, and then capture_on_confirm() skips the new episode because last_capture_times_ still holds the code. The fault ends up CONFIRMED with no recording at all, and a fault that keeps flapping faster than the cooldown never gets one. clear_fault erases the cooldown entry for this reason. The heal path needs the same erase, at least when the heal deletes (the hook could return whether it did).

@bburda
bburda force-pushed the feat/rosbag-retention-4a branch from 38dfb2c to 2a169e1 Compare December 2, 2026 12:15
* feat(fault_manager): on_healed and on_cleared per rosbag retention rule
* fix(fault_manager): the rosbag store drops the row of a fault healed with delete
* fix(fault_manager): one rosbag decision per status change
* docs(fault_manager): fail-closed audit and unreadable faults in the rosbag status actions
* docs(fault_manager): a status action removes the fault's links, not a shared recording
@bburda
bburda force-pushed the feat/rosbag-retention-4a branch from 2a169e1 to 8dd1ca8 Compare December 2, 2026 18:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants