Skip to content

Conversation

@jairad26
Copy link
Contributor

@jairad26 jairad26 commented Nov 11, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • This PR adds proptests to test try_from_config for collection config, and reconcile schema with config works as intended
  • New functionality
    • ...

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

@github-actions
Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@blacksmith-sh

This comment has been minimized.

@jairad26 jairad26 force-pushed the jai/schema-prop-tests-rust branch from fe605a3 to 67d62e4 Compare November 11, 2025 00:48
@jairad26 jairad26 marked this pull request as ready for review November 11, 2025 00:55
@propel-code-bot
Copy link
Contributor

[TST] Introduce property-based tests for Collection config⇄schema conversion & reconciliation

This PR is entirely test-focused. It adds comprehensive proptest suites that randomly generate CollectionConfiguration and CollectionSchema instances to verify two critical behaviors: (1) lossless conversion from configuration to schema via try_from_config, and (2) safe reconciliation of an existing schema with an updated configuration. To enable this, Arbitrary implementations and small helper generators were added for the relevant types, together with a few visibility tweaks. No production logic changes were made; the runtime behavior of the application is untouched. The main benefit is a much deeper safety net that will surface edge-case regressions early when the collection type layer is refactored in the future.

Key Changes

• Added proptest as a dev-dependency and wired it into cargo test.
• Implemented Arbitrary for CollectionConfiguration and CollectionSchema plus helper generators.
• Created property-based tests that assert round-trip conversion (try_from_config) and reconciliation invariants.
• Performed minimal visibility adjustments (pub(crate) / #[cfg(test)]) so tests can access internal helpers.

Affected Areas

• rust/types/src/collection_configuration.rs
• rust/types/src/collection_schema.rs
• Test harness (new #[cfg(test)] modules)
• Cargo.toml (dev-dependencies section)

This summary was automatically generated by @propel-code-bot

}

#[cfg(feature = "testing")]
mod proptests {
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

Great job on adding these comprehensive property-based tests! They significantly improve the coverage for the configuration logic.

I noticed that many of the proptest strategy helper functions are duplicated between collection_configuration.rs and collection_schema.rs. For example:

  • embedding_function_strategy
  • space_strategy
  • internal_hnsw_configuration_strategy
  • internal_spann_configuration_strategy
  • internal_collection_configuration_strategy
  • knn_index_strategy

To keep the code DRY and make these test utilities easier to maintain, consider extracting them into a shared test utility module. You could create a new file rust/types/src/test_utils.rs and declare it in your lib.rs like #[cfg(feature = "testing")] pub mod test_utils;.

The new test_utils.rs file could contain all the shared strategies:

// rust/types/src/test_utils.rs
#![cfg(feature = "testing")]

use crate::collection_configuration::{...};
use crate::hnsw_configuration::Space;
use proptest::prelude::*;
// ... other imports

pub fn embedding_function_strategy() -> impl Strategy<Value = Option<EmbeddingFunctionConfiguration>> {
    // ... implementation
}

// ... other shared strategies

Then, in your test modules, you can simply import them with use crate::test_utils::*;. This will remove the duplication and centralize the test data generation logic.

Context for Agents
[**BestPractice**]

Great job on adding these comprehensive property-based tests! They significantly improve the coverage for the configuration logic.

I noticed that many of the `proptest` strategy helper functions are duplicated between `collection_configuration.rs` and `collection_schema.rs`. For example:
- `embedding_function_strategy`
- `space_strategy`
- `internal_hnsw_configuration_strategy`
- `internal_spann_configuration_strategy`
- `internal_collection_configuration_strategy`
- `knn_index_strategy`

To keep the code DRY and make these test utilities easier to maintain, consider extracting them into a shared test utility module. You could create a new file `rust/types/src/test_utils.rs` and declare it in your `lib.rs` like `#[cfg(feature = "testing")] pub mod test_utils;`.

The new `test_utils.rs` file could contain all the shared strategies:
```rust
// rust/types/src/test_utils.rs
#![cfg(feature = "testing")]

use crate::collection_configuration::{...};
use crate::hnsw_configuration::Space;
use proptest::prelude::*;
// ... other imports

pub fn embedding_function_strategy() -> impl Strategy<Value = Option<EmbeddingFunctionConfiguration>> {
    // ... implementation
}

// ... other shared strategies
```

Then, in your test modules, you can simply import them with `use crate::test_utils::*;`. This will remove the duplication and centralize the test data generation logic.

File: rust/types/src/collection_configuration.rs
Line: 1084

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.

2 participants