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

propel-code-bot bot commented Nov 11, 2025

Introduce property-based tests for config⇄schema reconciliation and patch edge-case bugs

This PR adds a comprehensive proptest suite that randomly generates CollectionConfiguration / CollectionSchema pairs to ensure the conversion and reconciliation logic behaves correctly across thousands of permutations. While wiring up the tests, several latent corner-case bugs were surfaced and fixed—most notably around distance function mismatches, default embedding dimensions, metadata validation, and stricter TryFrom error handling. The change strengthens the type layer of the Rust vector-store backend without altering the public API and raises overall confidence in future schema-evolution work.

Key Changes

• New proptest modules (strategies.rs, proptest_utils.rs) with Arbitrary implementations for CollectionConfiguration and CollectionSchema
• End-to-end property-based test verifying try_from() and reconcile_with_config() round-trip behavior
• Bug fixes in collection_schema.rs (distance enum alignment, default dimension logic, metadata key checks)
• Tighter validation and consistent error variants in collection_configuration.rs::TryFrom
• lib.rs exports test-only helpers under cfg(test) so they remain private to production code
• CI updated to run the additional property-based tests

Affected Areas

• rust/types/src/collection_schema.rs
• rust/types/src/collection_configuration.rs
• rust/types/src/strategies.rs (new)
• rust/types/src/proptest_utils.rs (new)
• Overall test harness / CI runtime

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

@jairad26 jairad26 force-pushed the jai/schema-prop-tests branch from f1b64d9 to 95c36fd Compare November 12, 2025 23:56
@jairad26 jairad26 force-pushed the jai/schema-prop-tests-rust branch 2 times, most recently from 6f9aad9 to fa48c9c Compare November 13, 2025 00:15
@jairad26 jairad26 force-pushed the jai/schema-prop-tests branch from 95c36fd to 6cd92fc Compare November 13, 2025 00:15
) -> impl Strategy<Value = InternalSpannConfiguration> {
(
(
1u32..=128, // search_nprobe
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

The validation ranges in comments like // search_nprobe (max 128) and // split_threshold (min 50, max 200) are excellent documentation, but they should match the actual validation constraints. Consider adding compile-time assertions or centralizing these constants to ensure the test ranges stay in sync with the actual validation rules.

// Ensure test ranges match validation constraints
const MAX_SEARCH_NPROBE: u32 = 128;
const MIN_SPLIT_THRESHOLD: u32 = 50;
const MAX_SPLIT_THRESHOLD: u32 = 200;

// In strategy:
1u32..=MAX_SEARCH_NPROBE,               // search_nprobe
MIN_SPLIT_THRESHOLD..=MAX_SPLIT_THRESHOLD, // split_threshold
Context for Agents
[**BestPractice**]

The validation ranges in comments like `// search_nprobe (max 128)` and `// split_threshold (min 50, max 200)` are excellent documentation, but they should match the actual validation constraints. Consider adding compile-time assertions or centralizing these constants to ensure the test ranges stay in sync with the actual validation rules.

```rust
// Ensure test ranges match validation constraints
const MAX_SEARCH_NPROBE: u32 = 128;
const MIN_SPLIT_THRESHOLD: u32 = 50;
const MAX_SPLIT_THRESHOLD: u32 = 200;

// In strategy:
1u32..=MAX_SEARCH_NPROBE,               // search_nprobe
MIN_SPLIT_THRESHOLD..=MAX_SPLIT_THRESHOLD, // split_threshold
```

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

@jairad26 jairad26 force-pushed the jai/schema-prop-tests-rust branch from fa48c9c to 5c80b55 Compare November 13, 2025 19:03
@jairad26 jairad26 force-pushed the jai/schema-prop-tests branch from 6cd92fc to a021c46 Compare November 13, 2025 19:03
@jairad26 jairad26 force-pushed the jai/schema-prop-tests-rust branch from 5c80b55 to 31b9e5d Compare November 13, 2025 19:51
Comment on lines 5670 to 5699
fn partial_spann_index_config_strategy() -> BoxedStrategy<SpannIndexConfig> {
// Use internal strategy and convert, allowing None values by randomly setting some to None
internal_spann_configuration_strategy()
.prop_map(|config| {
// Randomly set some fields to None to test partial configs
let spann = SpannIndexConfig {
search_nprobe: Some(config.search_nprobe),
search_rng_factor: Some(config.search_rng_factor),
search_rng_epsilon: Some(config.search_rng_epsilon),
nreplica_count: Some(config.nreplica_count),
write_rng_factor: Some(config.write_rng_factor),
write_rng_epsilon: Some(config.write_rng_epsilon),
split_threshold: Some(config.split_threshold),
num_samples_kmeans: Some(config.num_samples_kmeans),
initial_lambda: Some(config.initial_lambda),
reassign_neighbor_count: Some(config.reassign_neighbor_count),
merge_threshold: Some(config.merge_threshold),
num_centers_to_merge_to: Some(config.num_centers_to_merge_to),
write_nprobe: Some(config.write_nprobe),
ef_construction: Some(config.ef_construction),
ef_search: Some(config.ef_search),
max_neighbors: Some(config.max_neighbors),
};
// For property testing, we'll test with full configs - the merge logic handles None correctly
spann
})
.boxed()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[TestCoverage]

The partial_spann_index_config_strategy function is intended to generate partial SpannIndexConfig objects where some fields can be None. However, the current implementation always sets all fields to Some(...), which means tests like merge_spann_configs_preserves_user_overrides are not correctly testing the fallback logic for individual fields when a user-provided configuration is partial.

The implementation should be updated to use proptest::option::of for each field, similar to partial_hnsw_index_config_strategy, to ensure that partial configurations are actually generated for testing the merge logic correctly.

Context for Agents
[**TestCoverage**]

The `partial_spann_index_config_strategy` function is intended to generate partial `SpannIndexConfig` objects where some fields can be `None`. However, the current implementation always sets all fields to `Some(...)`, which means tests like `merge_spann_configs_preserves_user_overrides` are not correctly testing the fallback logic for individual fields when a user-provided configuration is partial.

The implementation should be updated to use `proptest::option::of` for each field, similar to `partial_hnsw_index_config_strategy`, to ensure that partial configurations are actually generated for testing the merge logic correctly.

File: rust/types/src/collection_schema.rs
Line: 5697

@jairad26 jairad26 force-pushed the jai/schema-prop-tests-rust branch from 31b9e5d to 4913df6 Compare November 13, 2025 19:58

match (&internal_config.vector_index, &opposite_result.vector_index) {
(VectorIndexConfiguration::Hnsw(original), VectorIndexConfiguration::Spann(spann)) => {
let expected_space = original.space.clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

The Space enum derives Copy, so calling .clone() on it is redundant. You can remove the .clone() calls for cleaner, more idiomatic code. This applies to several places in this file where .clone() is called on a value of type Space.

For example, this line:

let expected_space = original.space.clone();

can be simplified to:

let expected_space = original.space;

Other instances are on lines 1249, 1282, 1283, 1340, 1343, 1344, 1372, 1375, and 1376.

Context for Agents
[**BestPractice**]

The `Space` enum derives `Copy`, so calling `.clone()` on it is redundant. You can remove the `.clone()` calls for cleaner, more idiomatic code. This applies to several places in this file where `.clone()` is called on a value of type `Space`.

For example, this line:
```rust
let expected_space = original.space.clone();
```
can be simplified to:
```rust
let expected_space = original.space;
```

Other instances are on lines 1249, 1282, 1283, 1340, 1343, 1344, 1372, 1375, and 1376.

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

@blacksmith-sh

This comment has been minimized.

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