Consolidate connect-backoff schedule into henyey-common - #3888
Consolidate connect-backoff schedule into henyey-common#3888tomerweller wants to merge 1 commit into
Conversation
🔍 Reviewer: CorrectnessVerdict: APPROVE Summary: Clean, behavior-preserving dedup — the triplicated connect-backoff schedule (constants + ceiling) is collapsed into one Full reviewCycle 1 (no prior Correctness verdict on this PR) — complete class-labeled review. Correctness — verified equivalent, no behavior change:
Test coverage (Kind: refactor per converged plan):
No concerns. APPROVE. |
🔍 Reviewer: ParityVerdict: APPROVE Summary: No observable/interop surface is touched. Connect-retry timing carries no wire framing and is explicitly on the freely-divergeable side of Full reviewCycle 1 (no prior Parity verdict on this PR) — complete class-labeled review. Parity surface (per
No parity concern. APPROVE. |
Review: Bounce-Back Cycle 1Reason: CI failed (unrelated, will rebase) Reviewer A (Correctness): APPROVE — clean behavior-preserving dedup of the triplicated backoff schedule into Why unrelated (not diff-attributable): the diff is a pure internal Rust refactor (extract two constants + a ceiling function into Routing back to Bounce-back count: 1/3 (head-scoped), 1/6 (lifetime). |
The peer connect-backoff schedule (SECONDS_PER_BACKOFF=10, MAX_BACKOFF_EXPONENT=10, and the 2^min(n,10)*10 ceiling) was copied verbatim at three call sites: overlay's PeerManager::compute_backoff, the overlay tick loop's compute_connect_backoff, and app's compute_peer_backoff_secs. A change to one copy would silently leave the others stale with no test to catch it. Add a single leaf module henyey_common::peer_backoff owning the two constants and the deterministic ceiling (connect_backoff_ceiling_secs), and route all three sites through it. The unbiased uniform sampling (gen_range(1..=ceiling)) stays at each site so henyey-common remains rand-free. The sampled distribution is bit-for-bit identical to before (same ceiling, same range), so this is a pure dedup with no behavior change. A pinned-constant test makes any future schedule edit fail loudly. Refs #3871 Co-authored-by: Claude Code <claude-code@anthropic.com>
678d356 to
827b227
Compare
|
Rebased Local verification on the rebased tree: Ready for re-review. |
🔍 Reviewer: CorrectnessVerdict: APPROVE Summary: Clean, behavior-preserving dedup of the triplicated connect-backoff schedule into Full reviewReviewed against current
No correctness concerns. |
🔍 Reviewer: ParityVerdict: APPROVE Summary: No observable/interop surface touched; connect-retry timing is on the freely-divergeable side of Full reviewReviewed against current
No parity concerns. |
Review: Blocked — Unrelated CI Red Persists After RebaseReviewer A (Correctness): APPROVE — behavior-preserving dedup of the triplicated backoff schedule into Why blocked (not another bounce): Bounce-Back Cycle 1 already bounced this PR to The diff is a pure internal Rust refactor (extract two constants + a ceiling fn into Per
Bounce-back count: 0/3 (head-scoped, reset by the fresh push), 1/6 (lifetime). |
Closes #3871
Summary
The peer connect-backoff schedule was implemented three times with independent copies of the same spec-cited constants and ceiling formula (
SECONDS_PER_BACKOFF=10,MAX_BACKOFF_EXPONENT=10,random_uniform(1, 2^min(n,10)*10)):crates/overlay/src/peer_manager.rs::compute_backoffcrates/overlay/src/manager/tick.rs::compute_connect_backoff(the live dial-gate path, Overlay: escalating jittered backoff for outbound connect retries #3771)crates/app/src/app/types.rs::compute_peer_backoff_secs(live + persisted to thepeerstable)A change to one copy would silently leave the others stale, with no test to catch it. This PR adds a single leaf module
henyey_common::peer_backoffowning the two constants and the deterministic ceilingconnect_backoff_ceiling_secs(num_failures), and routes all three sites through it. The unbiased uniform sampling (gen_range(1..=ceiling)) stays at each site sohenyey-commonstaysrand-free. The sampled distribution is bit-for-bit identical to before, so this is a pure dedup with no behavior change.Plan reference
See the Converged Plan comment on #3871. Per the converged plan, this is scoped as a refactor (dedup); the residual preferred-peer restart-backoff behavioral gap is tracked separately as #3887.
Test plan
cargo fmt --checkcargo clippy -p henyey-common -p henyey-overlay -p henyey-app --all-targets(clean under-Dwarnings)cargo test -p henyey-common peer_backoff— 3 new tests passcargo test -p henyey-overlay backoff— 8 preserved backoff/escalation tests passcargo test -p henyey-app --lib peer— 81 peer-record/related tests passNew coverage
peer_backoff::tests::test_ceiling_schedule— ceiling yields10,20,…,10240forn=0..=10and clamps at10240forn=11, 1000, u32::MAX(exercises themin(n, MAX_BACKOFF_EXPONENT)cap).peer_backoff::tests::test_schedule_constants_pinned— pins both constants to their spec values; the load-bearing drift guard.peer_backoff::tests::test_ceiling_never_below_one— ceiling is always>= 1sogen_range(1..=ceiling)is never empty.Deviations from plan
None. (Per the plan's note,
henyey-commonis keptrand-free, so the sampled-bounds check lives at the call sites — the existing overlay tick-loop backoff-bounds test covers it — rather than in the shared module.)🤖 Generated with Claude Code