refactor(yipd): split peer_manager.rs into a module directory (#11)#119
Merged
Conversation
…i-core #10) Behavior-preserving refactor: keep the PeerManager struct whole in mod.rs, move method groups into concern-focused sibling files (handshake/rekey/relay/routing/ obf/gossip) as additional impl blocks. Sub-project 1 of the multi-core (Way A / per-peer sharding) effort; sharding gets its own spec after this lands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pure code-movement refactor — prerequisite for multi-core sharding (#10). Splits the 9,434-line
bin/yipd/src/peer_manager.rsinto apeer_manager/module directory. Zero behavior change.Approach
The
PeerManagerstruct stays whole inmod.rs; method groups move into concern-focused sibling files as additionalimpl PeerManager { … }blocks (Rust allows split inherent impls). Methods called by sibling modules were raised private→pub(super)(never wider). Tests moved beside the code they exercise; shared test helpers live intestutil.rs.Result
mod.rs9,434 → 3,503 lines (~1,314 production — the plan's target — plus 2,188 integration tests left in place). New files:handshake.rs,rekey.rs,relay.rs,routing.rs,obf.rs,gossip.rs,testutil.rs. The 3 dispatch drivers (on_udp_dispatch/on_tun_dispatch/tick_dispatch) stay inmod.rs—tick_dispatchholds the #116 escalation arm.How it was built & verified
Executed as 8 sequential byte-verified moves (one commit each), each gated on: full
cargo test -p yipd --bins= 262 passed, 0 failed (same names), fmt+clippy clean, and a per-commit "pure relocation" diff review. Confirmed on real rebuilds at every step. The #116 punch→relay netns money-test passes on this branch (DISTINCT_INIT_EPHEMERALS=2). All 37 methods verified defined exactly once across the module.A whole-branch review (most-capable model) verdict: mergeable, coherent split, visibility hygiene clean, no circular deps, no duplicated helpers.
Documented follow-up (not in this PR)
Extract
mod testsfrommod.rsintopeer_manager/tests.rs(mechanical, zero visibility changes — accounts for themod.rsline count).tick_dispatch's size is pre-existing, separate future work.Spec:
docs/2026-07-26-peer-manager-module-split-design.md(included in this branch). Each commit is reviewable as an isolated pure move.