Skip to content

feat: gyro vibration percentile plot and report section - #246

Draft
nerdCopter wants to merge 4 commits into
masterfrom
feat/vibration-percentile-plot
Draft

nerdCopter wants to merge 4 commits into
masterfrom
feat/vibration-percentile-plot

Conversation

@nerdCopter

@nerdCopter nerdCopter commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

AI Generated pull-request

Summary

Adds a gyro vibration percentile analysis: per-axis cumulative distribution of |gyro|, filtered and unfiltered, with P50/P90/P95/P99. Runs with --extended (no new flag). Output: stacked PNG, console lines and a report section, all built from one shared result struct and text function.

Percentile definition: value at sorted index (n-1)*p/100 (integer division) over finite samples. Non-finite samples are dropped.

Closes #110

Test plan

  • cargo clippy --all-targets --all-features -- -D warnings, cargo fmt --all, cargo test, cargo build --release pass.
  • One real log rendered; PNG, console and report show the same values.
  • CodeRabbit local: 0 findings. Remote Ollama (gemma4:26b): one claim (report table separator), checked against source and invalid.
  • Not verified: |gyro| includes intentional maneuvers, so it is not pure noise. The report text says so.
  • Not verified: only one log tested.

Summary by CodeRabbit

  • New Features
    • Added an optional Gyro Vibration Percentile plot, available with --extended, showing filtered and unfiltered gyro magnitude distributions by axis.
    • Added P50, P90, P95, and P99 percentile values to the plot legend, console output, and generated report.
  • Documentation
    • Updated the README and overview to describe the new plot and report section.

Add a per-axis cumulative distribution of |gyro| and |gyroUnfilt| with
P50/P90/P95/P99. Percentile value is sorted[(n-1)*p/100] with integer
division; non-finite samples are dropped. One module computes the
values, and the console, report table and plot legend share its
formatter. The plot is part of --extended and the section appears in
the report only when the plot is enabled.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KoqKWwCzFDgbyFBKx3fnAe
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds filtered and unfiltered gyro vibration percentile analysis. When enabled, the application prints available summaries, generates a per-axis ECDF plot, and adds available results to the Markdown report.

Changes: Gyro Vibration Percentile

Layer / File(s) Summary
Percentile analysis and ECDF data
src/constants.rs, src/data_analysis/mod.rs, src/data_analysis/vibration_percentile.rs
The new analysis builds sorted absolute-value series, calculates P50/P90/P95/P99 values, formats summaries, and generates ECDF points. Constants define plot colors and point limits.
Per-axis ECDF plot
src/plot_functions/mod.rs, src/plot_functions/plot_vibration_percentile.rs
The plot displays available filtered and unfiltered series by gyro axis. Each axis limit uses the larger available percentile with a scale factor and minimum floor.
Application, report, and documentation integration
src/main.rs, src/report.rs, tests/report_filter_config_test.rs, README.md, OVERVIEW.md
The plot is disabled by default and enabled by --extended. The application prints available summaries, tracks the plot in report links, and passes results to FlightReport. The report conditionally adds rows for present series. The documentation describes the plot and report section.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Main as main.rs
  participant Analysis as vibration_percentile
  participant Plot as plot_vibration_percentile
  participant Report as FlightReport
  Main->>Analysis: Analyze log data and build percentile results
  Main->>Analysis: Get console lines for available series
  Main->>Plot: Render per-axis ECDF plot
  Main->>Report: Pass percentile results
  Report->>Report: Render section when percentile data is present
Loading
Merge Risk: Minimal · up to ea6ad

This adds an opt-in gyro vibration percentile plot, console output, and report section under --extended. No merge-blocking risk was found; a single-sample axis may render an empty curve, which is cosmetic.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat: gyro vibration percentile plot and report section" names the main change. The PR adds a per-axis gyro vibration percentile analysis, a stacked ECDF plot, and a report section. The tit…
Linked Issues check Passed Issue #110 requires cumulative distribution plots for gyro noise energy and vibration percentiles at P90, P95, and P99. The PR adds per-axis ECDF plots in src/plot_functions/plot_vibration_percentile.…
Out of Scope Changes check Passed All changed files support the #110 objective. The changes cover the analysis module, the plot module, PlotConfig wiring under --extended, report section and table, shared constants, README and OVERVIE…
Full details: Title check

Explanation

The title "feat: gyro vibration percentile plot and report section" names the main change. The PR adds a per-axis gyro vibration percentile analysis, a stacked ECDF plot, and a report section. The title is specific and matches the changeset and the linked issue #110 objective.

Full details: Linked Issues check

Explanation

Issue #110 requires cumulative distribution plots for gyro noise energy and vibration percentiles at P90, P95, and P99. The PR adds per-axis ECDF plots in src/plot_functions/plot_vibration_percentile.rs, built from VibrationSeries in src/data_analysis/vibration_percentile.rs. The series use absolute gyro samples, filtered and unfiltered, with P50/P90/P95/P99 values in the legend, console output, and report (src/report.rs). The analysis runs under --extended (src/main.rs). The issue does not define 'noise energy'. The |gyro| magnitude is a reasonable reading, and the PR description states this choice. The summary reports unit tests for percentile indexing, filtering, ordering, summaries, and ECDF behavior. This assessment relies on the summary and the PR description. I did not run the tests or inspect the test source.

Full details: Out of Scope Changes check

Explanation

All changed files support the #110 objective. The changes cover the analysis module, the plot module, PlotConfig wiring under --extended, report section and table, shared constants, README and OVERVIEW.md documentation of the new plot, and a test fixture update for the new FlightReport field. The new public module declarations and the FlightReport field follow from the feature. No change addresses an unrelated feature. The report-table header escaping and shared label work are part of the same feature output and do not extend scope. The summary does not show any unrelated change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bc2fdc22-be84-4ba4-9ff9-d73d87ddbac8
Commits

Reviewing files that changed from the base of the PR and between a4cf224 and ea6ad76.

Files selected for processing: 10

  • OVERVIEW.md
  • README.md
  • src/constants.rs
  • src/data_analysis/mod.rs
  • src/data_analysis/vibration_percentile.rs
  • src/main.rs
  • src/plot_functions/mod.rs
  • src/plot_functions/plot_vibration_percentile.rs
  • src/report.rs
  • tests/report_filter_config_test.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Additional context used

Code guidelines: 2

OVERVIEW.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 3

Applicability reference: AGENTS.md: ## Documentation **OVERVIEW.md Maintenance:** For new features, add documentation in `OVERVIEW.md` at proper, appropriate locations AGENTS.md: ## Documentation **OVERVIEW.md Maintenance:** For new feature...

CodeRabbit inference engine (OVERVIEW.md)

Files:

  • OVERVIEW.md
Source excerpt: **OVERVIEW.md Maintenance:** For new features, add documentation in `OVERVIEW.md` at proper, appropriate locations Information should be balanced or concise; never overly verbose Align verbosity with existing documentation s...

CodeRabbit inference engine (AGENTS.md)

Files:

  • OVERVIEW.md
Source excerpt: Keep README.md usage/examples synchronized with actual CLI flags in `src/main.rs` The README usage block holds the `--help` text verbatim (only the binary name differs); the test `readme_usage_block_matches_help_text` fails...

CodeRabbit inference engine (AGENTS.md)

Files:

  • README.md
  • src/main.rs
Learnings: 1

Common learnings

Learnt from: nerdCopter
URL: https://github.com/nerdCopter/blackbox_analyzer/pull/246

Timestamp: 2026-11-23T11:23:12.086Z
Learning: Within repository "nerdCopter/blackbox_analyzer", only for files matching one of ["src/data_analysis/vibration_percentile.rs","src/plot_functions/plot_vibration_percentile.rs","src/report.rs"]: For gyro vibration percentile output, the maintainer retained the existing plot-only debug suffix convention: `src/plot_functions/plot_vibration_percentile.rs` adds `format_debug_suffix` to the PNG legend when debug fallback is active, while the percentile console and report rows use `Unfiltered` without that suffix. Do not treat this suffix difference alone as a percentile-value mismatch.
Learnt from: CR
Repo: nerdCopter/blackbox_analyzer

Timestamp: 2026-11-23T11:37:28.360Z
Learning: Source excerpt:
## Code Changes

- **Output parity (console, report.md, PNG titles and legends):** any value, label or recommendation shown in more than one output must come from one shared function, never from a copy in each output.
  - All outputs use the same values and the same decision rules; only presentation differs.
  - Pass data the report needs through the result structs (`StepAxisReport`, `FlightReport`); do not re-derive it in `report.rs`.
  - Console and report may be more verbose (extra fields, thresholds, reasoning). Plot titles and legends stay minimal and concise.
  - Changing one output updates the others in the same change, with a test that the report carries the shared function's text.

@nerdCopter

Copy link
Copy Markdown
Owner Author

@coderabbitai — AI generated comment

Analysis requested on PR 246:

  1. Percentile index (n-1)*p/100 in percentile_of_sorted (src/data_analysis/vibration_percentile.rs): any edge case with 0, 1 or 2 samples, or pct above 100?
  2. Output parity: do the PNG, console and report section all take values from the same result struct and text function?
  3. Any panic path on empty or all-NaN gyro series in build_series or the plot function?
  4. Does the PR body match the code: --extended only, no new flag, the percentile definition?

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

Analysis chain

Script executed:

#!/bin/bash
set -u
echo '=== Named file outline ==='
ast-grep outline src/data_analysis/vibration_percentile.rs --items all
echo '=== Named file ==='
cat -n src/data_analysis/vibration_percentile.rs
echo '=== Relevant references ==='
rg -n -C 3 'percentile_of_sorted|build_series|[Vv]ibration[Pp]ercentile|vibration_percentile|gyro.vibration.percentile|gyro_vibration_percentile' .
echo '=== PR changed files ==='
gh pr diff 246 --repo nerdCopter/blackbox_analyzer --name-only
echo '=== CLI extended references ==='
rg -n -C 2 -- '--extended|\bextended\b' src README.md

Length of output: 36935


Script executed:

#!/bin/bash
set -u
echo '=== Plot outline and source ==='
ast-grep outline src/plot_functions/plot_vibration_percentile.rs --items all
cat -n src/plot_functions/plot_vibration_percentile.rs
echo '=== Plot framework locations ==='
fd -i 'plot_framework' .
rg -n -C 3 'fn draw_stacked_plot|struct PlotSeries|draw_stacked_plot\(' src/plot_framework*
echo '=== Report outline and relevant sections ==='
ast-grep outline src/report.rs --items all --match 'write|report|Report|vibration'
cat -n src/report.rs | sed -n '810,875p;1090,1145p'
echo '=== Main relevant source ==='
ast-grep outline src/main.rs --items all --match 'PlotConfig|process_file|main|usage'
cat -n src/main.rs | sed -n '55,165p;2440,2480p;2635,2655p;2670,2685p;2750,2930p'
echo '=== Constants and plot tests ==='
rg -n -C 2 'VIBRATION_(ECDF|PERCENTILES|X_AXIS)' src/constants.rs
rg -n -C 3 'vibration_percentile|Vibration Percentile' tests src/plot_functions/plot_vibration_percentile.rs
echo '=== Changes to argument parser ==='
gh pr diff 246 --repo nerdCopter/blackbox_analyzer | grep -n -C 4 -E '^\+.*(--[a-z]|extended_requested|vibration_percentile)'

Length of output: 48782


Script executed:

#!/bin/bash
set -u
echo '=== Plot framework outline ==='
ast-grep outline src/plot_framework.rs --items all --match 'draw_stacked_plot|draw|PlotSeries|chart'
echo '=== Stacked plotting ==='
cat -n src/plot_framework.rs | sed -n '140,160p;780,955p'
echo '=== Trimming and gyro source around analysis ==='
rg -n -C 3 'all_log_data|using_debug_fallback|debug_mode_label' src/main.rs | head -n 210
echo '=== Plot headroom constant ==='
rg -n -C 2 '\bUNIFIED_Y_AXIS_HEADROOM_SCALE\b' src/constants.rs

Length of output: 19305


Script executed:

#!/bin/bash
set -u
echo '=== Plot validation ==='
ast-grep outline src/plot_framework.rs --items all --match 'valid|Validity|draw_single_axis_chart'
rg -n -C 5 'stacked_axis_data_validity|is_stacked_axis_data_valid|plot_config_validity|series_data_validity|is_valid|data\.len\(' src/plot_framework.rs
cat -n src/plot_framework.rs | sed -n '180,320p;650,785p'
echo '=== Fallback labels in report ==='
rg -n -C 4 'debug_fallback|debug_mode_name' src/report.rs src/plot_functions/mod.rs
echo '=== Package target indications ==='
rg -n -C 2 '32.bit|i686|armv7|target:' Cargo.toml README.md OVERVIEW.md .github 2>/dev/null | head -n 100

Length of output: 23887


@nerdCopter I checked the source against the PR description and the repository’s shared-output guidance.

  1. Percentile edges — In src/data_analysis/vibration_percentile.rs, Line 31:

    • Zero samples return None. One sample returns that sample for every percentile.
    • With two samples, P50, P90, P95, and P99 all select the lower value. P100 selects the higher value.
    • Values of pct above 100 are clamped to 100.
    • The multiplication can overflow for very large slices. On a 32-bit target, P99 can overflow at about 43.4 million samples. An overflow-checked build would panic; a build without checks would wrap and could return a wrong value. Overflow-safe integer arithmetic would avoid this.
  2. Output parity — src/main.rs, Line 2448, computes one result vector for all three outputs. Console lines and PNG legends use percentile_summary_text. The report uses the same percentile values and format_percentile_value, but not the full summary text function. Its test checks fixed table values, not the shared summary text.

  3. Empty or all-NaN input — build_series drops non-finite samples and returns None if none remain. The plot skips missing series; if every axis is missing, draw_stacked_plot returns before creating a PNG. I found no panic path for these inputs in those functions. The normal file-processing path also rejects an empty log before analysis.

  4. PR description — The code matches --extended only and adds no new flag. It uses the stated integer-index definition over finite absolute values. The report section is omitted when no series has finite data.

Report wording needs attention: src/report.rs, Line 868, says P50 close to P99 means steady vibration. A steady intentional rotation can produce the same result, so steady |gyro| magnitude would be a safer description. The same text says “all finite samples of the flight,” but an active trim window limits the samples.

I inspected the tests but did not run them or render a plot. I recommend adding explicit tests for two samples, pct > 100, and the empty plot path.


Learnings used

Learnt from: CR
Repo: nerdCopter/blackbox_analyzer PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-18T18:09:05.111Z
Learning: Source excerpt:
## Code Changes

- **Output parity (console, report.md, PNG titles and legends):** any value, label or recommendation shown in more than one output must come from one shared function, never from a copy in each output.
  - All outputs use the same values and the same decision rules; only presentation differs.
  - Pass data the report needs through the result structs (`StepAxisReport`, `FlightReport`); do not re-derive it in `report.rs`.
  - Console and report may be more verbose (extra fields, thresholds, reasoning). Plot titles and legends stay minimal and concise.
  - Changing one output updates the others in the same change, with a test that the report carries the shared function's text.

You are interacting with an AI system.

- report.rs: the vibration percentile table now carries one cell per
  series built by percentile_summary_text, the same function the console
  and plot legend use; the test asserts the report contains that text.
- report.rs: wording says steady |gyro| magnitude (not only vibration)
  and names the analyzed data (whole flight or the --start/--end window).
- percentile_of_sorted: index product computed in u128, no usize overflow
  on 32-bit targets; results unchanged.
- tests: two samples, pct above 100 and usize::MAX, plot with all axes
  empty creates no PNG.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KoqKWwCzFDgbyFBKx3fnAe
@nerdCopter

Copy link
Copy Markdown
Owner Author

@coderabbitai — AI generated comment

Addressed the points from the earlier reply in commit 9c374d8:

  • Output parity: the report table now takes its cell text from percentile_summary_text, the same function the console and PNG legend use. A test asserts the report contains that text.
  • Report wording: now says steady |gyro| magnitude. The sentence also states that the --start/--end window limits the samples (main.rs trims all_log_data before analysis).
  • Index overflow: percentile_of_sorted computes the product in u128. Results are unchanged.
  • Tests added: two samples, pct above 100 and usize::MAX, and an all-missing plot that creates no PNG.

Analysis requested on this head: any remaining gap against the output parity rule in AGENTS.md, or any case where the report text and the console text can differ?

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

Analysis chain

Script executed:

#!/bin/bash
set -u
echo '=== Revision ==='
git rev-parse HEAD
git log -1 --format='%h %s'
echo '=== Instruction files ==='
fd -HI '^AGENTS\.md$' . --exclude .git
echo '=== Root instructions ==='
if [ -f AGENTS.md ]; then cat -n AGENTS.md; fi
echo '=== Relevant references ==='
rg -n -C 3 'percentile_summary_text|[Vv]ibration[Pp]ercentile|vibration_percentile|gyro vibration percentile' src
echo '=== Shared analysis outline ==='
ast-grep outline src/data_analysis/vibration_percentile.rs --items all
echo '=== Shared analysis ==='
cat -n src/data_analysis/vibration_percentile.rs
echo '=== Plot outline and source ==='
ast-grep outline src/plot_functions/plot_vibration_percentile.rs --items all
cat -n src/plot_functions/plot_vibration_percentile.rs
echo '=== Report and main outlines ==='
ast-grep outline src/report.rs --items all --match 'vibration|report|Report'
ast-grep outline src/main.rs --items all --match 'process_file|main'

Length of output: 43054


Script executed:

#!/bin/bash
set -u
echo '=== Report section and test ==='
cat -n src/report.rs | sed -n '790,875p;1080,1120p'
echo '=== Main analysis, output and report assembly ==='
cat -n src/main.rs | sed -n '2425,2480p;2625,2695p'
echo '=== Debug fallback flow ==='
rg -n -C 5 'using_debug_fallback|debug_mode_label|gyro_unfilt\s*=' src/main.rs src/data_input src/plot_functions/mod.rs
echo '=== Debug label helper ==='
ast-grep outline src/plot_functions/mod.rs --items all --match 'format_debug_suffix'
rg -n -A 20 -B 5 'fn format_debug_suffix' src/plot_functions/mod.rs
echo '=== Commit changes for report and shared output ==='
git show --format=fuller --stat 9c374d8
git show --format= -- src/report.rs src/data_analysis/vibration_percentile.rs src/plot_functions/plot_vibration_percentile.rs

Length of output: 34589


web_search executed:

What does the GitHub Flavored Markdown specification require for the number of header and delimiter cells in a table, and how are literal vertical bars escaped in table cells? Cite the official specification.

Length of output: 7647


Script executed:

#!/bin/bash
set -u
echo '=== Report fallback context ==='
rg -n -C 5 'debug_fallback|debug_mode_name|format_debug_suffix' src/report.rs
echo '=== Fallback selection and warning ==='
ast-grep outline src/data_input/log_parser.rs --items all --match 'resolve_gyro_unfilt_fallback'
cat -n src/data_input/log_parser.rs | sed -n '120,180p;685,710p;785,813p'
echo '=== Plot framework outline and validity ==='
ast-grep outline src/plot_framework.rs --items all --match 'valid|Validity|draw_stacked_plot|draw_single_axis_chart'
rg -n -C 4 'stacked_axis_data_validity|series_data_validity|draw_stacked_plot|is_finite|\.len\(\)' src/plot_framework.rs | head -n 280
echo '=== Plot framework drawing ==='
cat -n src/plot_framework.rs | sed -n '175,310p;650,770p;790,950p'

Length of output: 35280


@nerdCopter I checked commit 9c374d8 against the output-parity rule in AGENTS.md. I found two remaining gaps.

  1. The report table does not render as a table. In src/report.rs, Line 831, the unescaped pipes in |gyro| add two header cells. The delimiter row has four cells. GitHub Flavored Markdown requires matching cell counts, so it treats the block as text rather than a table. This is a new header in this commit, distinct from the earlier separator claim. Escape the pipes in the Rust string:

    writeln!(md, "| Axis | Signal | Samples | Percentiles of \\|gyro\\| |")?;

    The current test checks raw text, not rendered table structure. Add a table-rendering or header-escaping check. See the GFM table specification.

  2. Signal labels are duplicated. console_lines and the report each define their own Filtered and Unfiltered mappings in src/data_analysis/vibration_percentile.rs, Line 89, and src/report.rs, Line 834. They match today, but they do not meet the rule that repeated labels come from a shared function. A shared series iterator or label function would prevent drift.

For each present series, the percentile summary itself matches: the console, report, and PNG legend use percentile_summary_text on the same result. Axis names and sample counts also come from that result. The surrounding formatting differs.

When debug fallback is active, the PNG legend adds a debug suffix, but the percentile console and report rows still say Unfiltered. The parser prints a fallback warning, and the report has a separate metadata warning. If the percentile rows must identify the source directly, pass that context through shared output data and test the fallback case.

When all series are missing, neither the console percentile section nor the report percentile section is emitted. I inspected the tests but did not run them or render a plot.


Learnings used

Learnt from: CR
Repo: nerdCopter/blackbox_analyzer PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-18T18:09:05.111Z
Learning: Source excerpt:
## Code Changes

- **Output parity (console, report.md, PNG titles and legends):** any value, label or recommendation shown in more than one output must come from one shared function, never from a copy in each output.
  - All outputs use the same values and the same decision rules; only presentation differs.
  - Pass data the report needs through the result structs (`StepAxisReport`, `FlightReport`); do not re-derive it in `report.rs`.
  - Console and report may be more verbose (extra fields, thresholds, reasoning). Plot titles and legends stay minimal and concise.
  - Changing one output updates the others in the same change, with a test that the report carries the shared function's text.

If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

You are interacting with an AI system.

Escape the pipes in the vibration percentile report table header so the
header row and delimiter row have the same cell count.

Add SIGNAL_FILTERED/SIGNAL_UNFILTERED constants and
VibrationPercentileResult::present_series, used by the console lines,
the report table and the plot legend labels. Add tests for the label
helper and for header/delimiter cell parity.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KoqKWwCzFDgbyFBKx3fnAe
@nerdCopter

Copy link
Copy Markdown
Owner Author

@coderabbitai — AI generated comment

Addressed the points from the second reply in commit 629ae7b:

  • Table header: the pipes in |gyro| are escaped. A test checks that the header and delimiter rows have the same cell count.
  • Signal labels: SIGNAL_FILTERED, SIGNAL_UNFILTERED and present_series() are shared by the console, the report and the PNG legend. A test covers them.
  • Debug fallback: no change. format_debug_suffix is used only in plot code, and no other console or report text in this repo carries that suffix.

Analysis requested on this head: any remaining output parity gap, or any place the console and report can still diverge?

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

Analysis chain

Script executed:

#!/bin/bash
set -u
echo '=== Revision ==='
git rev-parse HEAD
git log -1 --format='%h %s'
echo '=== Instruction files ==='
fd -HI '^AGENTS\.md$' . --exclude .git
while IFS= read -r f; do echo "=== $f ==="; cat -n "$f"; done < <(fd -HI '^AGENTS\.md$' . --exclude .git)
echo '=== Source outlines ==='
ast-grep outline src/data_analysis/vibration_percentile.rs --items all
ast-grep outline src/plot_functions/plot_vibration_percentile.rs --items all
ast-grep outline src/report.rs --items all --match 'vibration|report|Report'
ast-grep outline src/main.rs --items all --match 'process_file|main'
echo '=== Shared result and tests ==='
cat -n src/data_analysis/vibration_percentile.rs
echo '=== Plot and tests ==='
cat -n src/plot_functions/plot_vibration_percentile.rs
echo '=== Relevant report, main, and fallback references ==='
rg -n -C 5 'vibration_percentile|percentile_summary_text|present_series|SIGNAL_FILTERED|SIGNAL_UNFILTERED|debug_fallback|debug_mode_name|format_debug_suffix' src/main.rs src/report.rs src/data_input/log_parser.rs src/plot_functions/mod.rs
echo '=== Latest commit summary ==='
git show --stat --oneline 629ae7b

Length of output: 51668


Script executed:

#!/bin/bash
set -u
echo '=== Report percentile section and test ==='
cat -n src/report.rs | sed -n '815,880p;1080,1155p'
echo '=== Main percentile, skipped plots, and report sequence ==='
cat -n src/main.rs | sed -n '2438,2475p;2630,2695p'
echo '=== Plot validity outline ==='
ast-grep outline src/plot_framework.rs --items all --match 'valid|Validity|draw_stacked_plot|draw_single_axis_chart'
echo '=== Plot validity and rendering references ==='
rg -n -C 5 'stacked_axis_data_validity|series_data_validity|draw_stacked_plot|fn draw_single_axis_chart|is_finite|data.len\(\)' src/plot_framework.rs
echo '=== Current change ==='
git show --format= -- src/data_analysis/vibration_percentile.rs src/plot_functions/plot_vibration_percentile.rs src/report.rs

Length of output: 23715


@nerdCopter I checked commit 629ae7b against the AGENTS.md output-parity rule and the supplied Learning.

The console and report use the same results, present_series(), and percentile_summary_text. Their axis names, signal labels, sample counts, and percentile summaries match. The table header now escapes |gyro|.

Two small structural gaps remain:

  • In src/report.rs, Line 851, the explanatory text hardcodes Filtered and Unfiltered. If the shared labels change, this text can differ from the console and table. The text could use the shared label definitions.
  • In src/plot_functions/plot_vibration_percentile.rs, Line 46, the plot selects the series independently; it does not call present_series(). The mappings match today, and the plot uses the shared labels and summary. Reusing the shared selection would prevent future drift. The plot can retain its current series order.

I acknowledge the existing plot-only debug suffix convention. The suffix does not change the percentile values.

If plot generation returns an error, the console lines have already been printed, but the report is not generated. I inspected the tests but did not run them or render a plot.


Learnings used

Learnt from: CR
Repo: nerdCopter/blackbox_analyzer PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-18T18:09:05.111Z
Learning: Source excerpt:
## Code Changes

- **Output parity (console, report.md, PNG titles and legends):** any value, label or recommendation shown in more than one output must come from one shared function, never from a copy in each output.
  - All outputs use the same values and the same decision rules; only presentation differs.
  - Pass data the report needs through the result structs (`StepAxisReport`, `FlightReport`); do not re-derive it in `report.rs`.
  - Console and report may be more verbose (extra fields, thresholds, reasoning). Plot titles and legends stay minimal and concise.
  - Changing one output updates the others in the same change, with a test that the report carries the shared function's text.

You are interacting with an AI system.

The report explanation text takes the Filtered and Unfiltered names from the
shared SIGNAL_FILTERED and SIGNAL_UNFILTERED constants. The percentile plot
selects its series through present_series() instead of its own pair of
Option checks, and keeps its drawing order (unfiltered first).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KoqKWwCzFDgbyFBKx3fnAe
@nerdCopter

Copy link
Copy Markdown
Owner Author

@coderabbitai — AI generated comment

Addressed the two structural points from the third reply in commit ea6ad76: the report explanation text uses SIGNAL_FILTERED and SIGNAL_UNFILTERED, and the plot selects its series through present_series() (drawing order unchanged, unfiltered first). The percentile PNG has an identical md5 before and after on one log, and the report text is unchanged.

Analysis requested on this head: any remaining output parity gap between the console, the report and the PNG for this analysis?

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

Analysis chain

Script executed:

#!/bin/bash
set -u
echo '=== Current revision ==='
git rev-parse HEAD
git log -1 --format='%h %s'
echo '=== Instruction files ==='
fd -HI '^AGENTS\.md$' . --exclude .git
while IFS= read -r f; do echo "=== $f ==="; cat -n "$f"; done < <(fd -HI '^AGENTS\.md$' . --exclude .git)
echo '=== Outlines ==='
ast-grep outline src/data_analysis/vibration_percentile.rs --items all
ast-grep outline src/plot_functions/plot_vibration_percentile.rs --items all
ast-grep outline src/report.rs --items all --match 'vibration|report|Report'
ast-grep outline src/main.rs --items all --match 'process_file|main'
ast-grep outline src/plot_framework.rs --items all --match 'valid|Validity|draw_stacked_plot|draw_single_axis_chart'
echo '=== Shared analysis ==='
cat -n src/data_analysis/vibration_percentile.rs
echo '=== Plot implementation and tests ==='
cat -n src/plot_functions/plot_vibration_percentile.rs
echo '=== Report implementation and tests ==='
rg -n -C 10 'vibration_percentile|percentile_summary_text|present_series|SIGNAL_FILTERED|SIGNAL_UNFILTERED' src/report.rs
echo '=== Main analysis and report wiring ==='
rg -n -C 10 'vibration_percentile|plot_vibration_percentile' src/main.rs
echo '=== Plot validation and drawing ==='
rg -n -C 8 'stacked_axis_data_validity|series_data_validity|draw_stacked_plot|fn draw_single_axis_chart' src/plot_framework.rs
echo '=== Relevant commit diff ==='
git show --format=fuller --stat ea6ad76
git show --format= ea6ad76 -- src/data_analysis/vibration_percentile.rs src/plot_functions/plot_vibration_percentile.rs src/report.rs

Length of output: 53923


Script executed:

#!/bin/bash
set -u
echo '=== Stacked plot drawing ==='
cat -n src/plot_framework.rs | sed -n '259,355p;785,875p'
echo '=== Plot settings and legend calls ==='
rg -n -C 5 'draw_series|configure_series_labels|LineSeries|VIBRATION_ECDF_MAX_POINTS|VIBRATION_X_AXIS_MIN_SCALE|VIBRATION_X_AXIS_PERCENTILE_INDEX|UNIFIED_Y_AXIS_HEADROOM_SCALE' src/plot_framework.rs src/constants.rs
echo '=== Debug suffix helper ==='
ast-grep outline src/plot_functions/mod.rs --items all --match 'format_debug_suffix'
rg -n -A 24 -B 4 'fn format_debug_suffix' src/plot_functions/mod.rs
echo '=== Report parity test ==='
cat -n src/report.rs | sed -n '1088,1145p'

Length of output: 23791


@nerdCopter I found no remaining percentile-value or signal-selection mismatch at commit ea6ad76. I checked against the AGENTS.md output-parity rule and the supplied Learning.

  • src/main.rs, Line 2448, passes one result vector to all three outputs.
  • The console, report, and PNG use present_series() and percentile_summary_text(). The report explanation also uses the shared signal labels.
  • The PNG draws unfiltered first and adds signal details and, when applicable, a debug suffix. Those are presentation differences.
  • The PNG limits ECDF points and uses a P99-based x-axis range. Samples beyond that range are not visible, but the legend percentiles use the full series.

One rendering case remains unverified: a single-sample series produces one ECDF point, which the plot passes to LineSeries. A single-sample render would check whether the point is visible. I did not run the tests or render a PNG.


Learnings added

Learnt from: nerdCopter
URL: https://github.com/nerdCopter/blackbox_analyzer/pull/246

Timestamp: 2026-11-23T11:23:10.826Z
Learning: Within repository "nerdCopter/blackbox_analyzer", only for files matching one of ["src/data_analysis/vibration_percentile.rs","src/plot_functions/plot_vibration_percentile.rs","src/report.rs"]: For gyro vibration percentile output, the maintainer retained the existing plot-only debug suffix convention: `src/plot_functions/plot_vibration_percentile.rs` adds `format_debug_suffix` to the PNG legend when debug fallback is active, while the percentile console and report rows use `Unfiltered` without that suffix. Do not treat this suffix difference alone as a percentile-value mismatch.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


Learnings used

Learnt from: CR
Repo: nerdCopter/blackbox_analyzer PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-18T18:09:05.111Z
Learning: Source excerpt:
## Code Changes

- **Output parity (console, report.md, PNG titles and legends):** any value, label or recommendation shown in more than one output must come from one shared function, never from a copy in each output.
  - All outputs use the same values and the same decision rules; only presentation differs.
  - Pass data the report needs through the result structs (`StepAxisReport`, `FlightReport`); do not re-derive it in `report.rs`.
  - Console and report may be more verbose (extra fields, thresholds, reasoning). Plot titles and legends stay minimal and concise.
  - Changing one output updates the others in the same change, with a test that the report carries the shared function's text.

You are interacting with an AI system.

@nerdCopter

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

feat: Add Vibration Percentile Analysis

1 participant