fix(pipeline): guard --burst progress rate against zero elapsed window (audit_28 §5 low)#104
Merged
Merged
Conversation
The inline `total / elapsed` rate string in the burst progress log could raise ZeroDivisionError: on coarse-resolution monotonic clocks (e.g. Windows, ~15ms tick) the first 100-event progress tick can land within a single tick, making elapsed == 0.0. The finally-block avg_rate already guarded this with max(elapsed, 0.001); the per-100 progress line did not. Extract a shared `_format_rate` helper (guarded), use it at both sites (de-duplicates the rate format), and add a unit regression test for the zero-elapsed case. (audit_28_06_26.md §5 low) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
DORA Metrics
|
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
Closes the last clean, no-Docker correctness item from
audit_28_06_26.md§5(low): the
--burstpipeline progress log could raiseZeroDivisionError.The per-100-event progress line computed the rate as inline
total / elapsed.On coarse-resolution monotonic clocks (e.g. Windows, ~15ms tick) the first
progress tick of a burst run can land within a single clock tick, so
elapsed == 0.0. Thefinally-blockavg_ratealready guarded this withmax(elapsed, 0.001); the progress line did not.Fix: extract a shared
_format_rate(total, elapsed)helper that applies themax(elapsed, 0.001)guard, and use it at both sites (de-duplicates the rateformat string).
Tests
tests/unit/test_local_pipeline_rate.py:_format_rate(100, 0.0)nolonger raises (counterfactual: old inline
100 / 0.0raised);_format_rate(100, 2.0) == "50 evt/s".Verification (no-Docker)
ruff / ruff format / mypy clean; new unit tests pass; diff CRLF-clean.
Note: this is the tail of the §5 backlog — the audit's HIGH (16 + M4) and the one
clean §5-medium (escalation, #102) are already merged. Remaining §5 items are
deliberate trade-offs, entangled with merged work, Docker-gated, or owner-scope
alert-semantics decisions.
🤖 Generated with Claude Code