feat(dc_measurements): add the fault Measurement, raise/change/clear from diagnostics - #374
Merged
Minipada merged 3 commits intoAug 18, 2026
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## jazzy #374 +/- ##
==========================================
+ Coverage 67.82% 68.09% +0.28%
==========================================
Files 101 102 +1
Lines 6235 6320 +85
==========================================
+ Hits 4228 4303 +75
- Misses 2007 2017 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Minipada
force-pushed
the
feature/365-add-measurement-fault-raise-and-clear-ev
branch
from
August 18, 2026 14:13
595569d to
04b3a97
Compare
…from diagnostics MTBF and MTTR need Records that say when something broke and when it was fixed. diagnostics records snapshots -- every poll writes the current DiagnosticStatus level -- so recovering a transition means scanning for where a value changed in SQL, silently producing a wrong duration the moment one Record is dropped. fault subscribes to the same /diagnostics topic and emits a Record only when a component's level changes, following intervention's precedent (#362): a separate Measurement projecting the same signal rather than a mode on it. Built on #360's StateTransitionDetector, one instance per watched component, so components fault and recover independently. Each transition is classified as raise (left OK, opens a fault), change (between two non-OK levels, e.g. WARN to ERROR, stays open) or clear (back to OK, closes the fault and reports duration_s). Both the raise and the clear carry the same fault_started_at so the pair joins downstream for MTTR; MTBF is the gap between successive raises. Levels are reported by name so STALE is never mistaken for ERROR. A fault still open at shutdown keeps its last Record's state "open" and no duration_s -- no closing Record is invented, so it cannot be read as a zero-length outage. seq increments across every watched component, so a dropped Record is a detectable gap. names (default: everything seen) limits which components are tracked; the pending-Records queue caps at 64 like battery's charging events, since the DiagnosticArray callback and the polling timer run on different callback groups. Verified with 5 gtest cases: a raise, a clear, a change that is not a clear, a flapping component, and a fault open at shutdown. Documented in doc/src/dc/measurements/fault.md, listed in SUMMARY.md and the plugin table. Closes #365 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0144yNQyXN9xNdGTuj3K8m23 Signed-off-by: David Bensoussan <d.bensoussan@proton.me>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0144yNQyXN9xNdGTuj3K8m23 Signed-off-by: David Bensoussan <d.bensoussan@proton.me>
… transition in tests CI failed 4 of the 5 test_measurement_fault gtest cases: StateTransitionDetector treats a component's very first observed sample as a baseline, not a transition -- no Record comes out of it, matching every other consumer of the detector (battery, and the not-yet-merged intervention). Four of the five fault tests published their "raising" status as the very first sample ever seen for that component, so the plugin correctly produced no Record and every publishUntilRecord call past that point timed out waiting for one. Only the first test happened to publish OK first (to also assert "staying put produces nothing"), which incidentally established the baseline its own raise then relied on. Adds establishOkBaseline() and calls it before the first real transition in the other four tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0144yNQyXN9xNdGTuj3K8m23 Signed-off-by: David Bensoussan <d.bensoussan@proton.me>
Minipada
force-pushed
the
feature/365-add-measurement-fault-raise-and-clear-ev
branch
from
August 18, 2026 14:47
04b3a97 to
38b697e
Compare
Minipada
deleted the
feature/365-add-measurement-fault-raise-and-clear-ev
branch
September 2, 2026 12:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
faultMeasurement subscribing to/diagnosticsthat emits a Record only when a component'sDiagnosticStatuslevel changes --diagnosticsrecords periodic snapshots, so recovering "when did this break, when was it fixed" today means scanning for where a value changed in SQL, silently producing a wrong duration the moment one Record is dropped.dc_common::StateTransitionDetector<uint8_t>per watched component (the same building block as intervention, Add Measurement: intervention — human takeovers derived from driving-mode transitions #362), classifying each transition asraise(leftOK),change(between two non-OKlevels, e.g.WARN→ERROR), orclear(back toOK, carriesduration_s). Both the raise and the clear sharefault_started_at, so the pair joins downstream for MTTR; MTBF is the gap between successive raises.OK/WARN/ERROR/STALE) soSTALE(silent) is never mistaken forERROR(broken). A fault still open at shutdown keeps its last Record'sstate: "open"and noduration_s-- no closing Record is invented, so it can't be read as a zero-length outage.seqincrements across every watched component (one global stream), so a dropped Record is a detectable gap.names(default: watch everything seen) limits which components are tracked; a pending-Records queue caps at 64, mirroringbattery.cpp's charging-session flood guard.doc/src/dc/measurements/fault.md,SUMMARY.md, plugin table).Test plan
colcon build+colcon testfordc_measurements(running locally viatools/e2e/scripts/build.shin parallel with this PR's CI build; will report back if either turns up something the other didn't)prek run --all-files --skip build-doc: all 24 hooks passCloses #365
🤖 Generated with Claude Code
https://claude.ai/code/session_0144yNQyXN9xNdGTuj3K8m23