Addresses #4421 (policy.rs): extract SnapshotIntegrityError into a submodule - #4645
Merged
Merged
Conversation
Addresses #4421 (policy.rs modularity backlog) with a bounded, pure code-motion first increment: relocate the `SnapshotIntegrityError` enum plus its `Display` and `Error` impls (~888 LOC, the #1606 snapshot integrity error group) out of the 4483-LOC `userspace-dp/src/policy.rs` into a new `#[path]`-included sibling submodule `userspace-dp/src/policy_snapshot_error.rs`. The enum group is fully self-contained — variants use only primitive / prelude types (String, i32, u16, u32, u8), the `Display` impl is entirely `write!(f, ...)` over `Self::` variants, and the `Error` impl is empty, so the new file needs no imports. It is re-exported with `pub(crate) use snapshot_error::SnapshotIntegrityError;` so all ~20 crate-wide call sites keep the existing `crate::policy::SnapshotIntegrityError` path, and `policy_tests.rs` (attached via `use super::*`) is unchanged. This mirrors the `#[path = "policy_tests.rs"]` idiom already used in the same file. This is verified pure code-motion, not a behavior change: - the moved block is byte-identical to master `policy.rs` lines 14-901 (empty diff); - `policy.rs`'s retained content is byte-identical (empty diff) with only a 3-line `#[path]`/`mod`/`use` stub inserted; - `policy.rs` shrinks 4483 -> 3598 LOC. The moved block is left byte-identical (not rustfmt'd) to preserve the code-motion guarantee; only the new stub + module-doc lines are new. Validation: `cargo build` green; `cargo test` 3738 passed (245 policy tests + all 5 snapshot-integrity-error tests green). The single `native_gre_decap_checksum_present_yields_inner_packet` failure in the parallel run is a pre-existing shared-counter test-isolation flake — it touches no SnapshotIntegrityError code and passes in isolation. The README source-map table row for `policy.rs` is unchanged: it lists top-level feature modules, not their `#[path]` submodules (`policy_tests.rs` is likewise omitted), and the module contract is unchanged. The deeper policy.rs decomposition (parse / evaluate / applications splits) is a function-restructuring task that needs /triple-review; this ships only the clean, self-contained down-payment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015oARShYtiJJ2H4UB4nXGqi
Contributor
There was a problem hiding this comment.
Pull request overview
This PR is a focused modularity/code-organization change in the Rust userspace dataplane: it extracts the large SnapshotIntegrityError enum (and its Display/Error impls) out of the monolithic userspace-dp/src/policy.rs into a sibling submodule, while preserving the existing crate::policy::SnapshotIntegrityError access path via a re-export.
Changes:
- Moved
SnapshotIntegrityError(+Display/Errorimpls) intouserspace-dp/src/policy_snapshot_error.rsand wired it in via#[path] mod snapshot_error;. - Re-exported the type from
policy.rs(pub(crate) use snapshot_error::SnapshotIntegrityError;) to keep all existing call sites unchanged. - Added a corresponding
_Log.mdentry documenting the write action and touched files.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| userspace-dp/src/policy.rs | Replaces the in-file enum/impl block with a #[path] submodule include and re-export to keep the public-in-crate path stable. |
| userspace-dp/src/policy_snapshot_error.rs | New submodule containing the extracted SnapshotIntegrityError definition and impls (verbatim code-motion plus new module docs). |
| _Log.md | Records the extraction action per repository logging practice. |
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.
What
Bounded, pure code-motion first increment for the #4421
policy.rsmodularity backlog. Relocates the
SnapshotIntegrityErrorenum plus itsDisplayandErrorimpls (~888 LOC — the #1606 snapshot integrity errorgroup) out of the 4483-LOC
userspace-dp/src/policy.rsinto a new#[path]-included sibling submoduleuserspace-dp/src/policy_snapshot_error.rs.policy.rs: 4483 → 3598 LOC.Why this unit
The enum group is fully self-contained:
String,i32,u16,u32,u8);Displayimpl is entirelywrite!(f, …)overSelf::variants;Errorimpl is empty.So the new file needs no imports. It is re-exported with
pub(crate) use snapshot_error::SnapshotIntegrityError;so all ~20 crate-widecall sites keep the existing
crate::policy::SnapshotIntegrityErrorpath, andpolicy_tests.rs(attached viause super::*) is unchanged. This mirrors the#[path = "policy_tests.rs"]idiom already used in the same file.Pure code-motion proof
policy.rslines 14–901 (emptydiff).policy.rsretained content is byte-identical (emptydiff), only a 3-line#[path]/mod/usestub inserted.code-motion guarantee; only the stub +
//!module-doc lines are new.Validation
cargo buildgreen.cargo test— 3738 passed (245 policy tests + all 5 snapshot-integrity-errortests green). The single
native_gre_decap_checksum_present_yields_inner_packetfailure in the parallel run is a pre-existing shared-counter test-isolation
flake — it touches no
SnapshotIntegrityErrorcode and passes in isolation.Docs
README source-map table row for
policy.rsunchanged: it lists top-level featuremodules, not their
#[path]submodules (policy_tests.rsis likewise omitted),and the module contract is unchanged.
_Log.mdupdated.Scope
The deeper
policy.rsdecomposition (parse / evaluate / applications splits) is afunction-restructuring task that needs
/triple-review; this PR ships only theclean, self-contained down-payment.
🤖 Generated with Claude Code
https://claude.ai/code/session_015oARShYtiJJ2H4UB4nXGqi