feat(data_privacy)!: introduce data_privacy_core #427
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #427 +/- ##
========================================
Coverage 100.0% 100.0%
========================================
Files 305 305
Lines 23698 23542 -156
========================================
- Hits 23698 23542 -156 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
52a562a to
1cf8061
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a new data_privacy_core crate that owns the core classification/redaction traits and types, and refactors the existing data_privacy crate to re-export those core APIs while keeping RedactionEngine and built-in redaction strategies. The change also updates dependent crates/macros to use the new Redactor-based interfaces and adjusts CI/scripts to include the new crate.
Changes:
- Add
crates/data_privacy_coreand move core types/traits (e.g.,Sensitive,DataClass,Redactor, redacted formatting traits) into it. - Refactor
data_privacyto re-exportdata_privacy_core, implementRedactorforRedactionEngine, and update redactor implementations/tests accordingly. - Update macros and
templated_uriintegration to useRedactor(&dyn Redactor) rather thanRedactionEnginein redacted formatting, and update snapshots/metadata.
Reviewed changes
Copilot reviewed 63 out of 64 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/run-examples.rs | Comment-only adjustment in excluded examples list. |
| scripts/publish-gh-release.rs | Comment-only adjustment in changelog parsing logic. |
| scripts/mutants.rs | Add data_privacy_core to mutation test grouping. |
| justfiles/basic.just | Comment-only adjustment in examples recipe docs. |
| crates/templated_uri/src/uri.rs | Switch redacted formatting to accept &dyn Redactor; adjust tests. |
| crates/templated_uri/src/path_and_query.rs | Switch redacted formatting to accept &dyn Redactor. |
| crates/templated_uri/Cargo.toml | Allow data_privacy_core::* types for external-types checking. |
| crates/templated_uri_macros_impl/src/struct_template.rs | Update generated RedactedDisplay signature to take &dyn Redactor. |
| crates/templated_uri_macros_impl/src/enum_template.rs | Update generated RedactedDisplay signature to take &dyn Redactor. |
| crates/templated_uri_macros_impl/src/snapshots/templated_uri_macros_impl__tests__templated_uri_impl.snap | Snapshot updates for new Redactor signature. |
| crates/templated_uri_macros_impl/src/snapshots/templated_uri_macros_impl__tests__templated_unredacted_uri_impl.snap | Snapshot updates for new Redactor signature. |
| crates/templated_uri_macros_impl/src/snapshots/templated_uri_macros_impl__tests__template_enum_impl.snap | Snapshot updates for new Redactor signature. |
| crates/templated_uri_macros_impl/src/snapshots/templated_uri_macros_impl__tests__query_param_is_kv_expansion.snap | Snapshot updates for new Redactor signature. |
| crates/templated_uri_macros_impl/src/snapshots/templated_uri_macros_impl__tests__optional_reference_field_codegen.snap | Snapshot updates for new Redactor signature. |
| crates/templated_uri_macros_impl/src/snapshots/templated_uri_macros_impl__tests__optional_field_with_unredacted_codegen.snap | Snapshot updates for new Redactor signature. |
| crates/templated_uri_macros_impl/src/snapshots/templated_uri_macros_impl__tests__optional_field_codegen.snap | Snapshot updates for new Redactor signature. |
| crates/templated_uri_macros_impl/src/snapshots/templated_uri_macros_impl__tests__field_level_unredacted.snap | Snapshot updates for new Redactor signature. |
| crates/data_privacy/tests/xxh3_redactor.rs | Add coverage for new would_redact behavior. |
| crates/data_privacy/tests/rapidhash_redactor.rs | Add coverage for new would_redact behavior. |
| crates/data_privacy/tests/redaction_engine.rs | Update to new Redactor-based redact call signature. |
| crates/data_privacy/tests/sensitive.rs | Add additional regression tests for redacted formatting and boundary behavior (with insta). |
| crates/data_privacy/src/sensitive.rs | Remove old Sensitive implementation (moved to core). |
| crates/data_privacy/src/redactors/xxh3_redactor.rs | Implement new would_redact method; adjust test coverage attrs. |
| crates/data_privacy/src/redactors/rapidhash_redactor.rs | Implement new would_redact method. |
| crates/data_privacy/src/redactors/simple_redactor.rs | Implement new would_redact method; import cleanup. |
| crates/data_privacy/src/redactors/redactor.rs | Remove old Redactor trait (moved to core). |
| crates/data_privacy/src/redactors/mod.rs | Remove local Redactor re-export; adjust tests for new trait contract. |
| crates/data_privacy/src/redaction_engine.rs | Make RedactionEngine implement Redactor; remove inherent redact/would_redact. |
| crates/data_privacy/src/redaction_engine_inner.rs | Update would_redact to delegate to the selected redactor/fallback; add tests. |
| crates/data_privacy/src/macros.rs | Remove local macro re-export module (moved to core re-exports). |
| crates/data_privacy/src/lib.rs | Re-export data_privacy_core APIs; update crate docs and module exports. |
| crates/data_privacy/README.md | Regenerated README reflecting the new data_privacy_core split and links. |
| crates/data_privacy/Cargo.toml | Bump version, add data_privacy_core, wire serde feature through, add insta dev-dep. |
| crates/data_privacy_macros/Cargo.toml | Version bump aligned with macro changes. |
| crates/data_privacy_macros_impl/tests/snapshots/taxonomy__success.snap | Snapshot updates to reference data_privacy_core paths. |
| crates/data_privacy_macros_impl/tests/snapshots/derive__redacted_display_unit.snap | Snapshot updates for &dyn Redactor and core paths. |
| crates/data_privacy_macros_impl/tests/snapshots/derive__redacted_display_single.snap | Snapshot updates for &dyn Redactor and core paths. |
| crates/data_privacy_macros_impl/tests/snapshots/derive__redacted_display_multiple.snap | Snapshot updates for &dyn Redactor and core paths. |
| crates/data_privacy_macros_impl/tests/snapshots/derive__redacted_display_multiple_named.snap | Snapshot updates for &dyn Redactor and core paths. |
| crates/data_privacy_macros_impl/tests/snapshots/derive__redacted_display_enum.snap | Snapshot metadata update. |
| crates/data_privacy_macros_impl/tests/snapshots/derive__redacted_debug_unit.snap | Snapshot updates for &dyn Redactor and core paths. |
| crates/data_privacy_macros_impl/tests/snapshots/derive__redacted_debug_single.snap | Snapshot updates for &dyn Redactor and core paths. |
| crates/data_privacy_macros_impl/tests/snapshots/derive__redacted_debug_multiple.snap | Snapshot updates for &dyn Redactor and core paths. |
| crates/data_privacy_macros_impl/tests/snapshots/derive__redacted_debug_multiple_named.snap | Snapshot updates for &dyn Redactor and core paths. |
| crates/data_privacy_macros_impl/tests/snapshots/derive__redacted_debug_enum.snap | Snapshot metadata update. |
| crates/data_privacy_macros_impl/tests/snapshots/classified__success.snap | Snapshot updates for core paths and &dyn Redactor usage. |
| crates/data_privacy_macros_impl/tests/snapshots/classified__success_named_field.snap | Snapshot updates for core paths and &dyn Redactor usage. |
| crates/data_privacy_macros_impl/src/taxonomy.rs | Use crate-path resolver so generated code targets data_privacy or data_privacy_core. |
| crates/data_privacy_macros_impl/src/lib.rs | Export new crate_path helper module. |
| crates/data_privacy_macros_impl/src/derive.rs | Update derive output to use resolved crate path and &dyn Redactor. |
| crates/data_privacy_macros_impl/src/crate_path.rs | New helper to resolve whether to generate ::data_privacy or ::data_privacy_core paths. |
| crates/data_privacy_macros_impl/src/classified.rs | Update classified macro output to use resolved crate path and &dyn Redactor. |
| crates/data_privacy_macros_impl/Cargo.toml | Add proc-macro-crate dependency; version bump. |
| crates/data_privacy_core/src/lib.rs | New core crate root exposing core traits/types and macro re-exports. |
| crates/data_privacy_core/src/macros.rs | New macro re-export module for core crate. |
| crates/data_privacy_core/src/redactor.rs | New Redactor trait definition (now in core). |
| crates/data_privacy_core/src/redacted.rs | Update redacted formatting traits to accept &dyn Redactor; add tests. |
| crates/data_privacy_core/src/sensitive.rs | New Sensitive implementation moved into core; add tests. |
| crates/data_privacy_core/src/data_class.rs | Restructure tests; separate serde-gated tests into a dedicated module. |
| crates/data_privacy_core/src/classified.rs | Update docs and minor trait doc tweaks for core crate. |
| crates/data_privacy_core/README.md | New crate README describing core responsibilities. |
| crates/data_privacy_core/Cargo.toml | New crate manifest with serde feature and dev-deps. |
| Cargo.toml | Add data_privacy_core and proc-macro-crate to workspace dependencies; bump versions. |
| Cargo.lock | Lockfile updates for new crate and new dependency versions. |
Comments suppressed due to low confidence (1)
crates/data_privacy_core/src/redacted.rs:106
- These tests use inline insta snapshots (e.g.
assert_snapshot!(result, @"...")). To align with the repository’s usual insta usage (file-backed.snapartifacts), consider converting these to external snapshots or simpleassert_eq!(the expected output is short).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0b9f929 to
4582bc7
Compare
4582bc7 to
0525c8f
Compare
0525c8f to
cba397a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 70 out of 71 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
crates/data_privacy_core/src/redacted.rs:106
- These unit tests use inline insta snapshots (e.g.,
@"..."). In this repo, snapshot tests are commonly file-backed via.snapfiles (for examplecrates/templated_uri_macros_impl/src/lib.rs:199-208). Consider converting to external snapshots to reduce noise in code diffs.
cba397a to
968d97a
Compare
| /// Implementations may return `false` when no transformation is applied — for | ||
| /// example, when a strategy operates in pass-through mode, or when redaction has | ||
| /// been explicitly suppressed for the given class. | ||
| fn would_redact(&self, data_class: &DataClass) -> bool; |
There was a problem hiding this comment.
Small nit as you're also releasing a new version, can we rename this to just redacts (in the general theme of shortening names)?
Breaking changes in data_privacy crate can lead to cascading breaking changes across all consumer crates. This PR decouples redaction engines from basic data_privacy types so we can have more stable crate for classification, and have more freedom when we do breaking changes in redaction itself.