Skip to content

chore: expose filter functions on rust cache#945

Open
ayushjain17 wants to merge 1 commit intomainfrom
chore/filter-cache
Open

chore: expose filter functions on rust cache#945
ayushjain17 wants to merge 1 commit intomainfrom
chore/filter-cache

Conversation

@ayushjain17
Copy link
Copy Markdown
Collaborator

@ayushjain17 ayushjain17 commented Mar 30, 2026

Change log

Exposing filter options on config and experiments to be used via ffi providers

Summary by CodeRabbit

Release Notes

  • New Features
    • Added filterConfig() method to ProviderCache to filter configurations based on dimension data and prefixes
    • Added filterExperiment() method to ProviderCache to filter experiments based on dimension data
    • Introduced new ExperimentConfig data type containing experiment and experiment group information
    • Both new methods and data type now available in Java and Python client bindings

@ayushjain17 ayushjain17 requested a review from a team as a code owner March 30, 2026 11:47
Copilot AI review requested due to automatic review settings March 30, 2026 11:47
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com bot commented Mar 30, 2026

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0c7b7af6-a560-4230-b2b5-a6329573a5d6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Added two new filter methods (filterConfig, filterExperiment) to the ProviderCache across Kotlin, Python, and Rust implementations. Refactored internal cache data structure in Rust from ConfigCacheData to CacheData with unified Config and ExperimentConfig storage. Extended ExperimentConfig to derive Default and uniffi::Record for FFI compatibility.

Changes

Cohort / File(s) Summary
Java Bindings
clients/java/bindings/src/main/kotlin/uniffi/superposition_client/superposition_client.kt
Added FFI bindings for filter_config and filter_experiment methods with integrity checksum validation. Introduced ExperimentConfig data class and FfiConverterOptionalMapStringString converter for optional map serialization.
Python Bindings
clients/python/bindings/superposition_bindings/superposition_client.py
Added ctypes FFI bindings and checksum validations for the two new filter methods. Implemented ExperimentConfig type and optional dictionary converter. Extended ProviderCache with public filter_config() and filter_experiment() methods.
Core Experiment Type
crates/superposition_core/src/experiment.rs
Extended ExperimentConfig to derive Default and uniffi::Record for FFI record mapping and default constructor support.
FFI Layer
crates/superposition_core/src/ffi.rs
Refactored cache storage from ConfigCacheData to CacheData structure. Added filter_config() and filter_experiment() methods to ProviderCache. Updated internal initialization and data access patterns to use unified config and experiment structures.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #909: Directly modifies the FFI provider-cache layer (crates/superposition_core/src/ffi.rs) and cache data types, with overlapping changes to exported cache structures and functions.

Suggested labels

P0

Suggested reviewers

  • Datron

Poem

🐰 Whiskers twitching with delight,
New filters shine so very bright,
Config and experiments dance with care,
Through FFI layers, they travel there—
Java, Python, Rust unite,
Cache refactored just right!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.83% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: expose filter functions on rust cache' accurately reflects the main changes in the PR, which add filter_config and filter_experiment methods to the ProviderCache interface and implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/filter-cache

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ProviderCache to store a Config and an ExperimentConfig in a single cache struct, and wires eval_config to use these.
  • Adds cache methods to return filtered Config and filtered ExperimentConfig based on optional dimension context and optional prefixes.
  • Updates UniFFI-generated Python and Kotlin bindings to include the new methods and the new ExperimentConfig record 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0d8a887 and 0e274ff.

📒 Files selected for processing (4)
  • clients/java/bindings/src/main/kotlin/uniffi/superposition_client/superposition_client.kt
  • clients/python/bindings/superposition_bindings/superposition_client.py
  • crates/superposition_core/src/experiment.rs
  • crates/superposition_core/src/ffi.rs

@ayushjain17 ayushjain17 force-pushed the chore/filter-cache branch 2 times, most recently from 0a6888f to 84607dc Compare March 30, 2026 12:31
@ayushjain17 ayushjain17 requested a review from Datron March 30, 2026 13:15
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.

3 participants