[codex] split protocol crate modules#287
Conversation
📝 WalkthroughWalkthroughThe ChangesProtocol crate modularization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — This PR splits the protocol crate into focused private modules while preserving the flat public API used by daemon and CLI callers.
- Split protocol definitions by concern —
ProtocolError, request types, response types, events, transport helpers, and managed-resource update DTOs now live in separate private modules. - Preserve existing public imports —
src/lib.rsre-exports the sameprotocol::...names, includingDaemonResponse,write_line,DaemonTransport, update DTOs, andPROTOCOL_VERSION. - Move protocol tests unchanged in intent — the serialization and transport tests moved from inline
lib.rstests intotests.rs. - Verified focused behavior —
cargo test -p protocol --lockedandcargo check -p protocol --all-targets --lockedboth passed during review.
GPT | 𝕏
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/protocol/src/update_check.rs (1)
34-42: ⚡ Quick winPrefer top-level imports over repeated fully-qualified paths.
Lines 34-42 and 54-101 use
std::fmt::...andresources::...directly; pull these intousestatements to align with repo Rust style and reduce repetition.Suggested cleanup
use serde::{Deserialize, Serialize}; +use std::fmt::{self, Display, Formatter}; +use resources::{ + ManagedResourceUpdateBlocker as ResourcesManagedResourceUpdateBlocker, + ManagedResourceUpdateCheckTrack as ResourcesManagedResourceUpdateCheckTrack, + ManagedResourceUpdateRevocation as ResourcesManagedResourceUpdateRevocation, + ManagedResourceUpdateStatus as ResourcesManagedResourceUpdateStatus, +}; -impl std::fmt::Display for ManagedResourceUpdateBlocker { - fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl Display for ManagedResourceUpdateBlocker { + fn fmt(&self, formatter: &mut Formatter<'_>) -> fmt::Result { write!( formatter, "requires PV {}, current PV {}", self.minimum_pv_version, self.current_pv_version ) } } -impl From<resources::ManagedResourceUpdateStatus> for ManagedResourceUpdateStatus { - fn from(status: resources::ManagedResourceUpdateStatus) -> Self { +impl From<ResourcesManagedResourceUpdateStatus> for ManagedResourceUpdateStatus { + fn from(status: ResourcesManagedResourceUpdateStatus) -> Self { match status { - resources::ManagedResourceUpdateStatus::Current => Self::Current, - resources::ManagedResourceUpdateStatus::UpdateAvailable => Self::UpdateAvailable, - resources::ManagedResourceUpdateStatus::Blocked => Self::Blocked, - resources::ManagedResourceUpdateStatus::Revoked => Self::Revoked, - resources::ManagedResourceUpdateStatus::Unavailable => Self::Unavailable, + ResourcesManagedResourceUpdateStatus::Current => Self::Current, + ResourcesManagedResourceUpdateStatus::UpdateAvailable => Self::UpdateAvailable, + ResourcesManagedResourceUpdateStatus::Blocked => Self::Blocked, + ResourcesManagedResourceUpdateStatus::Revoked => Self::Revoked, + ResourcesManagedResourceUpdateStatus::Unavailable => Self::Unavailable, } } }As per coding guidelines, "PREFER top-level imports over local imports or fully qualified names in Rust".
Also applies to: 54-101
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/protocol/src/update_check.rs` around lines 34 - 42, The code uses fully-qualified paths like std::fmt::Display, std::fmt::Formatter, and std::fmt::Result in the impl block for ManagedResourceUpdateBlocker (lines 34-42) and additional fully-qualified resources:: paths elsewhere (lines 54-101). Add use statements at the top of the file to import these types (std::fmt::Display, std::fmt::Formatter, std::fmt::Result, and any resources:: types used), then replace all fully-qualified paths throughout the file with the imported names to reduce repetition and align with the repository's Rust coding style guidelines.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/protocol/src/update_check.rs`:
- Around line 34-42: The code uses fully-qualified paths like std::fmt::Display,
std::fmt::Formatter, and std::fmt::Result in the impl block for
ManagedResourceUpdateBlocker (lines 34-42) and additional fully-qualified
resources:: paths elsewhere (lines 54-101). Add use statements at the top of the
file to import these types (std::fmt::Display, std::fmt::Formatter,
std::fmt::Result, and any resources:: types used), then replace all
fully-qualified paths throughout the file with the imported names to reduce
repetition and align with the repository's Rust coding style guidelines.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f430921a-4c23-4468-a47a-9b6b0697eada
📒 Files selected for processing (8)
crates/protocol/src/error.rscrates/protocol/src/event.rscrates/protocol/src/lib.rscrates/protocol/src/request.rscrates/protocol/src/response.rscrates/protocol/src/tests.rscrates/protocol/src/transport.rscrates/protocol/src/update_check.rs

Summary
Splits the
protocolcrate out of its single largelib.rsinto focused private modules while keeping the existing flat public API intact.The new modules cover requests, responses, events, managed resource update DTOs, transport helpers, errors, and tests. Existing callers can continue using
protocol::DaemonResponse,protocol::write_line, and the other current re-exports unchanged.Validation
cargo fmt --allcargo nextest run -p protocolcargo clippy -p protocol --all-targets --all-features --locked -- -D warningscargo check --workspace --all-targets --lockedgit diff --check -- crates/protocol/srccargo nextest run --workspace --locked --no-fail-fastThe full local workspace suite ran 881 tests: 880 passed, 1 failed, 3 skipped. The failure was
daemon::daemon_foundation::dns_resolver_falls_back_when_preferred_port_is_unavailable; it also failed in isolation because the local PV daemon was already bound to DNS port35353(/Users/clovismuneza/.pv/bin/pv daemon:run). This appears local-environment related, so CI should give the clean-run signal.Summary by CodeRabbit
Release Notes
Refactor
New Features