Skip to content

[pull] main from databendlabs:main#504

Merged
pull[bot] merged 1 commit intoTCeason:mainfrom
databendlabs:main
Aug 29, 2025
Merged

[pull] main from databendlabs:main#504
pull[bot] merged 1 commit intoTCeason:mainfrom
databendlabs:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull bot commented Aug 29, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.3)

Can you help keep this open source service alive? 💖 Please sponsor : )

…18632)

* Add compile-time API freezing macro for struct compatibility

Implements frozen_api procedural macro that prevents accidental breaking
changes to critical data structures through SHA256 hash verification.

Features:
- Compile-time protection for struct definitions
- Detects changes to field names, types, visibility, and order
- Supports all struct types: named, tuple, unit, and generic
- Automatic detection of nested structure changes
- 8-character hash format for concise error messages

Use cases:
- Serialized/deserialized structs
- Network protocol definitions
- Cross-version compatibility requirements
- Persistent storage formats

* fix: remove unused proc-macro2 dependency from frozen_api

Remove direct proc-macro2 dependency as it's already included as
a transitive dependency through quote and syn crates.

* feat: add frozen_api protection to critical statistics structures

- Add frozen_api attribute to AdditionalStatsMeta (a2f68edd)
- Add frozen_api attribute to ColumnStatistics (7731ad45)
- Add frozen_api attribute to ClusterStatistics (de510c92)
- Add frozen_api attribute to Statistics (a40b473c)
- Improve error message with clear violation warning
- Add databend-common-frozen-api dependency to table_meta

These structures are now protected against accidental breaking
changes that could cause serialization/deserialization failures
in production environments.

* feat: protect core segment and snapshot structures with frozen_api

Add compile-time protection to prevent accidental breaking changes to critical
serializable structures used in table metadata persistence:

- v2::SegmentInfo, VirtualColumnMeta, VirtualBlockMeta, BlockMeta, ExtendedBlockMeta
- v2::SegmentStatistics
- v4::SegmentInfo, TableSnapshot, TableSnapshotStatistics

This prevents compatibility disasters like the AdditionalStatsMeta.location
field change that broke serialization between versions.

* feat: extend frozen_api protection to draft and compact structures

Add compile-time protection to remaining serializable structures:
- DraftVirtualColumnMeta, DraftVirtualBlockMeta (v2)
- RawBlockMeta, CompactSegmentInfo (v4)

Completes comprehensive coverage of all critical table metadata structures
to prevent serialization compatibility breakage.

* feat: upgrade frozen_api to deep hash implementation and update all hash values

- Enhance frozen_api macro with deep dependency detection capabilities
- Include nested type information in hash computation for comprehensive protection
- Add extensive test coverage for indirect dependency detection scenarios
- Update all existing hash values in table_meta structures to work with new deep hash algorithm
- Demonstrate cascading protection through multi-level dependency chains

Updated structures:
- v2: SegmentInfo, VirtualColumnMeta, VirtualBlockMeta, BlockMeta, ExtendedBlockMeta
- v2: SegmentStatistics, ColumnStatistics, ClusterStatistics, AdditionalStatsMeta, Statistics
- v4: SegmentInfo, RawBlockMeta, CompactSegmentInfo, TableSnapshot, TableSnapshotStatistics

The deep hash implementation ensures changes to nested protected types are detected
across dependency boundaries, providing stronger API compatibility guarantees.

* refactor: implement deep hash algorithm with comprehensive dependency detection

- Replace simple TokenStream hash with deep analysis including field type information
- Add extract_field_types() and type_to_string() helper functions
- Update compute_deep_hash() to include both structure and nested type data
- Update all existing test hash values to work with enhanced algorithm
- Add comprehensive test suite for indirect dependency detection scenarios

This ensures changes to nested protected types trigger hash violations in dependent structures,
providing stronger API compatibility guarantees across complex dependency chains.

* fix: sort workspace members and dependencies alphabetically

- Move src/common/frozen_api to correct alphabetical position in workspace members
- Move databend-common-frozen-api to correct position in workspace dependencies
- Ensures taplo formatting compliance

* fix: apply taplo auto-formatting to Cargo.toml files

- Reorder workspace dependencies alphabetically (frozen-api before functions)
- Reorder frozen_api crate dependencies alphabetically (hex, quote, sha2, syn)
- Ensure proper file endings and formatting compliance

* add frozen api protect for more structs

* add frozen api protect for more structs

* Add license header to deep_test.rs
@pull pull bot locked and limited conversation to collaborators Aug 29, 2025
@pull pull bot added the ⤵️ pull label Aug 29, 2025
@pull pull bot merged commit 79bec61 into TCeason:main Aug 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant