Skip to content

refactor(reliability): collapse 3x retry + 3x circuit-breaker to one canonical each #876

@kcenon

Description

@kcenon

What

There are three parallel retry implementations and three hand-rolled circuit breakers; the "canonical" ADR-0004 machinery is unused. Collapse each set to one canonical implementation behind a behavior-parity test matrix.

Why

Triplicated resilience logic means fixes and tuning must be applied in three places and silently diverge. Consolidating reduces maintenance/audit surface and makes the ADR-0004 strategy actually load-bearing.

Where (analysis-located, LOC re-measured)

  • Retry (~2,210 LOC across 4 files): src/error-handler/RetryHandler.ts (642), src/error-handler/RetryExecutor.ts (615), src/worker/RetryHandler.ts (555), src/error-handler/RetryMetrics.ts (398).
  • Circuit breakers (~867 LOC across 2 files + 1 embedded): src/error-handler/CircuitBreaker.ts (517), src/pr-reviewer/CICircuitBreaker.ts (350), plus the breaker embedded in analysis-orchestrator.

How

  1. Pick/define the canonical retry engine and the canonical circuit breaker.
  2. Write a behavior-parity test matrix BEFORE deleting any duplicate (retry: backoff sequence, jitter bounds, max-attempts, give-up signal; breaker: open/half-open/close thresholds, reset-on-success).
  3. Migrate every caller, then delete the duplicates.

Acceptance

  • The behavior-parity matrix passes against the canonical implementation before duplicates are removed.
  • Full suite green after migration; duplicate files deleted; all callers point at the canonical module.

Part of #866.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-p2Medium: Nice to havereliabilityReliability and fault tolerance

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions