Stagger Iroh relay credential refreshes
Merged
AZ
4mo ago+139+139+012345678901234567890123456789-0-0-0123456789
Summary
- assign stable refresh slots from each endpoint identity
- keep Mac refreshes in seconds 0–14 and iOS refreshes in seconds 30–44
- prevent both peers from rotating relay credentials together while preserving the endpoint
Verification
- regression tests committed first and failed on the missing scheduler: https://github.com/manaflow-ai/cmux/actions/runs/30906067161
- Swift parse and diff checks pass
- hosted package and relay-only staging gates dispatched for the fix commit
Principled fix: refresh ownership is encoded as a deterministic scheduling invariant instead of a timing retry.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Staggered Iroh relay credential refreshes by role and endpoint so host and client don’t rotate at the same time. Slots are stable per endpoint to reduce reconnect churn.
- Bug Fixes
- Introduced a deterministic scheduler (
CmxIrohRelayRefreshSchedule) that assigns per-endpoint refresh slots using FNV hashing: host 0–14s, client 30–44s within each minute. - Wired the schedule into client and host runtimes via the
jittercallback to compute deadlines clamped betweennowandrefreshAfter. - Expanded tests to assert stable per-endpoint slots across cycles, per-role slot spread, and bounded deadlines.
- Introduced a deterministic scheduler (
Summary by CodeRabbit
-
Improvements
- Relay credentials now refresh on client- and host-specific schedules, reducing simultaneous refresh activity.
- Refresh timing is deterministically distributed across short time windows while still respecting required deadlines.
- Relay connectivity management is more balanced and predictable across endpoints.
-
Tests
- Added coverage to verify refresh timing separation, deadline compliance, and distribution across multiple scheduling slots.