chore: expose filter functions on rust cache#945
Conversation
Changed Files
|
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdded two new filter methods ( Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client<br/>(Java/Python)
participant FFIBinding as FFI Binding Layer
participant RustFFI as Rust FFI<br/>(ProviderCache)
participant DataFilter as Data Filtering<br/>Logic
Client->>FFIBinding: filterConfig(dimensionData, prefix)
FFIBinding->>FFIBinding: Validate & Convert inputs
FFIBinding->>RustFFI: uniffi_superposition_core_fn_method_providercache_filter_config(...)
RustFFI->>DataFilter: Parse dimensions & prefix<br/>Convert to HashSet
DataFilter->>DataFilter: Filter Config<br/>by context/prefix
DataFilter-->>RustFFI: Return filtered Config
RustFFI-->>FFIBinding: RustBuffer (Config)
FFIBinding->>FFIBinding: Deserialize to Config
FFIBinding-->>Client: Config
Client->>FFIBinding: filterExperiment(dimensionData, prefix)
FFIBinding->>FFIBinding: Validate & Convert inputs
FFIBinding->>RustFFI: uniffi_superposition_core_fn_method_providercache_filter_experiment(...)
RustFFI->>DataFilter: Parse dimensions<br/>Filter via context
DataFilter->>DataFilter: Filter experiments<br/>Filter experiment groups<br/>by evaluation
DataFilter-->>RustFFI: Return ExperimentConfig
RustFFI-->>FFIBinding: RustBuffer (ExperimentConfig)
FFIBinding->>FFIBinding: Deserialize to ExperimentConfig
FFIBinding-->>Client: ExperimentConfig
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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.
Pull request overview
This PR exposes config/experiment filtering operations on the Rust-side ProviderCache so they can be consumed via UniFFI-based providers (with regenerated Python/Java bindings to match the expanded API).
Changes:
- Refactors
ProviderCacheto store aConfigand anExperimentConfigin a single cache struct, and wireseval_configto use these. - Adds cache methods to return filtered
Configand filteredExperimentConfigbased on optional dimension context and optional prefixes. - Updates UniFFI-generated Python and Kotlin bindings to include the new methods and the new
ExperimentConfigrecord type.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/superposition_core/src/ffi.rs | Refactors cache storage and adds filter_config / filter_experiment methods. |
| crates/superposition_core/src/experiment.rs | Makes ExperimentConfig a UniFFI record (and Default) so it can cross the FFI boundary. |
| clients/python/bindings/superposition_bindings/superposition_client.py | Regenerates bindings to include new cache methods and ExperimentConfig. |
| clients/java/bindings/src/main/kotlin/uniffi/superposition_client/superposition_client.kt | Regenerates bindings to include new cache methods and ExperimentConfig. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/superposition_core/src/ffi.rs`:
- Around line 323-342: The closure used to convert the optional prefix Vec into
a HashSet is redundant; in the method filter_config replace the call using the
explicit closure (prefix.map(|p| HashSet::from_iter(p))) with the simpler
function pointer form (prefix.map(HashSet::from_iter)) in order to satisfy
Clippy; update the expression in the filter_config function so prefix_list is
created via prefix.map(HashSet::from_iter) and keep the rest of the method
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fc0ed914-e573-40a3-b744-e02225d7c8f1
📒 Files selected for processing (4)
clients/java/bindings/src/main/kotlin/uniffi/superposition_client/superposition_client.ktclients/python/bindings/superposition_bindings/superposition_client.pycrates/superposition_core/src/experiment.rscrates/superposition_core/src/ffi.rs
0a6888f to
84607dc
Compare
84607dc to
fb9d504
Compare
Change log
Exposing filter options on config and experiments to be used via ffi providers
Summary by CodeRabbit
Release Notes
filterConfig()method to ProviderCache to filter configurations based on dimension data and prefixesfilterExperiment()method to ProviderCache to filter experiments based on dimension dataExperimentConfigdata type containing experiment and experiment group information