Skip to content

Conversation

skalwaghe-56
Copy link
Contributor

Description

This PR implements the legacy-states-v0 Cargo feature to guard backward compatibility code in the Rust codebase, as requested in issue #1076.

Changes Made

Cargo.toml

  • Added legacy-states-v0 feature flag, enabled by default
  • Feature is currently enabled to maintain backward compatibility

Source Code Changes

  • src/setup/states.rs: Guarded the deprecated key_schema field with #[cfg(feature="legacy-states-v0")]
  • src/builder/exec_ctx.rs: Updated backward compatibility logic to conditionally compile based on the feature flag

CI/CD Changes

  • .github/workflows/_test.yml: Added cargo test --no-default-features --verbose to ensure both code paths compile and test successfully

Implementation Details

The feature flag approach allows for:

  • Current state: Legacy compatibility code is included by default
  • Future state: When CocoIndex reaches v1.0, the default can be changed to default = [] and legacy code removed
  • Testing: Both configurations are tested in CI to ensure stability

Testing

  • ✅ All existing tests pass with default features (128 tests)
  • ✅ All tests pass with --no-default-features (128 tests)
  • ✅ Pre-commit checks pass (formatting, linting, type checking)
  • ✅ CI workflow includes testing for both feature configurations

Future Usage

This establishes a framework for managing backward compatibility. Additional legacy code can be guarded with the same feature flag pattern:

#[cfg(feature = "legacy-states-v0")]
// legacy code here

When ready to drop v0.x compatibility:

  1. Change default = [] in Cargo.toml
  2. Test thoroughly
  3. Remove the feature flag and guarded code

Closes #1076.

@badmonster0
Copy link
Member

thanks @skalwaghe-56 please revert the format changes and keep the diff minimum. due to the large volume of PRs it makes it easier for contributors to merge changes.

@skalwaghe-56
Copy link
Contributor Author

@badmonster0 Sure, I'll do it right away!

@skalwaghe-56 skalwaghe-56 force-pushed the add-legacy-states-v0-feature branch from ac9ef3b to f6d0458 Compare October 5, 2025 04:11
@skalwaghe-56
Copy link
Contributor Author

@badmonster0 Can you please review it now?

@skalwaghe-56 skalwaghe-56 force-pushed the add-legacy-states-v0-feature branch from f6d0458 to 8c79f98 Compare October 5, 2025 04:16
@georgeh0
Copy link
Member

georgeh0 commented Oct 5, 2025

@skalwaghe-56 Thanks for this PR! Mostly looks good except a minor comment on the workflow.

@skalwaghe-56 skalwaghe-56 force-pushed the add-legacy-states-v0-feature branch from 8c79f98 to 0080c42 Compare October 5, 2025 11:35
@skalwaghe-56 skalwaghe-56 requested a review from georgeh0 October 5, 2025 11:35
@skalwaghe-56
Copy link
Contributor Author

@georgeh0 Please check it now. Thanks!

Copy link
Member

@georgeh0 georgeh0 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@georgeh0 georgeh0 merged commit 07f16c8 into cocoindex-io:main Oct 5, 2025
8 checks passed
@skalwaghe-56 skalwaghe-56 deleted the add-legacy-states-v0-feature branch October 6, 2025 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Add a legacy-states-v0 Cargo feature for Rust codebase to guard code only exists for backward compatibility
3 participants