Files
suaveplan/openspec/archive/2026-05-02-retry-spec-conformance/specs/retry/spec.md
2026-05-27 23:29:53 +01:00

1.8 KiB

Capability Spec Delta: retry (spec-conformance)

Package: @suaveplan/retry Status: PROPOSED

This delta annotates each existing requirement in openspec/specs/retry/spec.md with a **Verified by:** line and clarifies the language of RT-05 (4-arg withTimeout) and RT-10 (opt-in helper-based OTel emission). No public-API changes.

MODIFIED Requirements

RT-05 — Timeout

withTimeout(fn, ms, attemptNumber, signal?) MUST reject with AttemptTimeoutError (code RETRY.TIMEOUT) if fn does not settle within ms milliseconds. The internal timeout is cleaned up on both success and failure. Accepts an optional signal for external cancellation, forwarded to fn.

Verified by: src/retry/retry.test.ts::"resolves with fn result when within budget" AND src/retry/retry.test.ts::"throws AttemptTimeoutError when fn takes too long" AND src/retry/retry.test.ts::"AttemptTimeoutError has correct attemptNumber and timeoutMs" AND src/retry/retry.test.ts::"propagates fn rejection" AND src/retry/retry.test.ts::"passes signal to fn"

RT-10 — OTel instrumentation

retry.attempt.total counter (by outcome: success/failure/exhausted/aborted), retry.attempt.delay_ms histogram (by strategy), circuit_breaker.state_change.total counter (by from/to), circuit_breaker.call.duration_ms histogram MUST be available via createRetryMetrics(meter) for opt-in emission through @opentelemetry/api. All record functions are no-ops when no exporter is registered.

Verified by: src/otel/retry-otel.test.ts::"creates all four instruments" AND src/otel/retry-otel.test.ts::"calls add with outcome and strategy attributes" AND src/otel/retry-otel.test.ts::"records delay with strategy attribute" AND src/otel/retry-otel.test.ts::"records from/to attributes" AND src/otel/retry-otel.test.ts::"records duration and outcome"