Skip to content

fix(pipeline): guard --burst progress rate against zero elapsed window (audit_28 §5 low)#104

Merged
brownjuly2003-code merged 1 commit into
mainfrom
fix/burst-progress-divzero
Jun 29, 2026
Merged

fix(pipeline): guard --burst progress rate against zero elapsed window (audit_28 §5 low)#104
brownjuly2003-code merged 1 commit into
mainfrom
fix/burst-progress-divzero

Conversation

@brownjuly2003-code

Copy link
Copy Markdown
Owner

Summary

Closes the last clean, no-Docker correctness item from audit_28_06_26.md §5
(low): the --burst pipeline progress log could raise ZeroDivisionError.

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. The finally-block avg_rate already guarded this with
max(elapsed, 0.001); the progress line did not.

Fix: extract a shared _format_rate(total, elapsed) helper that applies the
max(elapsed, 0.001) guard, and use it at both sites (de-duplicates the rate
format string).

Tests

  • New tests/unit/test_local_pipeline_rate.py: _format_rate(100, 0.0) no
    longer raises (counterfactual: old inline 100 / 0.0 raised); _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

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>
@github-actions

Copy link
Copy Markdown

DORA Metrics

  • Window: last 30 days
  • Branch: main
  • Deployment frequency: 166 total / 38.73 per week
  • Lead time for changes: avg 0.27h / median 0.0h
  • Change failure rate: 59.04% (98/166)
  • MTTR: 0.23h across 4 incident(s)

@brownjuly2003-code brownjuly2003-code merged commit a6092e8 into main Jun 29, 2026
22 of 23 checks passed
@brownjuly2003-code brownjuly2003-code deleted the fix/burst-progress-divzero branch June 29, 2026 11:59
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