Skip to content

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

Merged
vxfemboy merged 9 commits into
mainfrom
refactor/peer-manager-module-split
Jul 27, 2026
Merged

refactor(yipd): split peer_manager.rs into a module directory (#11)#119
vxfemboy merged 9 commits into
mainfrom
refactor/peer-manager-module-split

Conversation

@vxfemboy

Copy link
Copy Markdown
Member

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.

@vxfemboy
vxfemboy merged commit 34adf35 into main Jul 27, 2026
9 checks passed
@vxfemboy
vxfemboy deleted the refactor/peer-manager-module-split branch July 27, 2026 03:01
@vxfemboy
vxfemboy restored the refactor/peer-manager-module-split branch July 27, 2026 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant