refactor(yipd): split peer_manager.rs into a module directory (#11) #119

Merged
vxfemboy merged 9 commits from refactor/peer-manager-module-split into main 2026-07-27 03:01:37 +00:00
vxfemboy commented 2026-07-26 19:21:01 +00:00 (Migrated from github.com)

Pure code-movement refactor — prerequisite for multi-core sharding (#10). Splits the 9,434-line bin/yipd/src/peer_manager.rs into a peer_manager/ module directory. Zero behavior change.

Approach

The PeerManager struct stays whole in mod.rs; method groups move into concern-focused sibling files as additional impl 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 in testutil.rs.

Result

mod.rs 9,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 in mod.rstick_dispatch holds 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 tests from mod.rs into peer_manager/tests.rs (mechanical, zero visibility changes — accounts for the mod.rs line 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.

Pure code-movement refactor — prerequisite for multi-core sharding (#10). Splits the 9,434-line `bin/yipd/src/peer_manager.rs` into a `peer_manager/` module directory. **Zero behavior change.** ## Approach The `PeerManager` struct stays whole in `mod.rs`; method groups move into concern-focused sibling files as additional `impl 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 in `testutil.rs`. ## Result `mod.rs` 9,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 in `mod.rs` — `tick_dispatch` holds 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 tests` from `mod.rs` into `peer_manager/tests.rs` (mechanical, zero visibility changes — accounts for the `mod.rs` line 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.
Sign in to join this conversation.
No description provided.