Skip to content

Introduce restate-platform foundation crate#4626

Merged
AhmedSoliman merged 1 commit intomainfrom
pr4626
Apr 22, 2026
Merged

Introduce restate-platform foundation crate#4626
AhmedSoliman merged 1 commit intomainfrom
pr4626

Conversation

@AhmedSoliman
Copy link
Copy Markdown
Contributor

@AhmedSoliman AhmedSoliman commented Apr 22, 2026

Part of the effort to decompose the restate-types monolith into focused,
composable utility crates.

Add restate-platform as a low-dependency foundation crate that provides
key type aliases, traits, and essential types the rest of the project can
reliably depend upon. It sits at the bottom of the dependency graph with
minimal transitive dependencies.

Moves the following into restate-platform:

  • Error traits (GenericError, CodedError) from restate-types
  • Storage traits (StorageEncode, StorageDecode) from restate-types
  • Network marker trait (NetSerde) from restate-encoding
  • Memory estimation trait (EstimatedMemorySize) from restate-memory
  • Hash re-exports (HashMap, HashSet) for consistent hashing
  • Sync utilities (OwnedSemaphorePermit)

Stack created with Sapling. Best reviewed with ReviewStack.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

Test Results

  8 files  ±0    8 suites  ±0   3m 42s ⏱️ +32s
 53 tests ±0   53 ✅ ±0  0 💤 ±0  0 ❌ ±0 
233 runs  ±0  233 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit ebd49dc. ± Comparison against base commit 6d70da2.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Contributor

@tillrohrmann tillrohrmann 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 cleaning up or crate structure @AhmedSoliman. LGTM. +1 for merging :-)

struct Inner(HashMap<u64, String>);

assert_impl_all!(SomeMessage: NetSerde);
const _: fn() = || {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Before we usually used const _: (). Any reason to use a function value here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is just the macro expansion as is. No strong opinion, just wanted to remove the dependency.

Comment on lines -136 to -179
/// Validates that `KeyRange`'s general bilrost encoding produces the same
/// wire format as `RangeInclusive<u64>` with `RestateEncoding`. This ensures
/// that `KeyRange` fields can use `#[bilrost(N)]` and remain wire-compatible
/// with the old `#[bilrost(tag(N), encoding(RestateEncoding))] RangeInclusive<u64>`.
#[test]
fn key_range_wire_compat_with_range_inclusive() {
use restate_sharding::KeyRange;

use super::RestateEncoding;

#[derive(Debug, PartialEq, bilrost::Message)]
struct WithKeyRange {
#[bilrost(1)]
range: KeyRange,
}

#[derive(Debug, PartialEq, bilrost::Message)]
struct WithRangeInclusive {
#[bilrost(tag(1), encoding(RestateEncoding))]
range: std::ops::RangeInclusive<u64>,
}

for (start, end) in [(0u64, 0u64), (1, 100), (0, u64::MAX), (42, 42)] {
let kr = KeyRange::new(start, end);
let ri = start..=end;

let kr_bytes = WithKeyRange { range: kr }.encode_to_vec();
let ri_bytes = WithRangeInclusive { range: ri.clone() }.encode_to_vec();

assert_eq!(
kr_bytes, ri_bytes,
"wire format mismatch for range ({start}, {end})"
);

// Cross-decode
let decoded: WithRangeInclusive =
WithRangeInclusive::decode(&*kr_bytes).expect("cross-decode KeyRange→RI");
assert_eq!(decoded.range, ri);

let decoded: WithKeyRange =
WithKeyRange::decode(&*ri_bytes).expect("cross-decode RI→KeyRange");
assert_eq!(decoded.range, kr);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why was this test removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(1) The test was added a couple of commits ago to prove wire compatibility, we don't really need to maintain it in the long run. (2) it was removed because restate-encoding doesn't really need to depend on restate-sharding.

Part of the effort to decompose the restate-types monolith into focused,
composable utility crates.

Add `restate-platform` as a low-dependency foundation crate that provides
key type aliases, traits, and essential types the rest of the project can
reliably depend upon. It sits at the bottom of the dependency graph with
minimal transitive dependencies.

Moves the following into restate-platform:
- Error traits (GenericError, CodedError) from restate-types
- Storage traits (StorageEncode, StorageDecode) from restate-types
- Network marker trait (NetSerde) from restate-encoding
- Memory estimation trait (EstimatedMemorySize) from restate-memory
- Hash re-exports (HashMap, HashSet) for consistent hashing
- Sync utilities (OwnedSemaphorePermit)
@AhmedSoliman AhmedSoliman merged commit 2a7ba58 into main Apr 22, 2026
40 checks passed
@AhmedSoliman AhmedSoliman deleted the pr4626 branch April 22, 2026 14:52
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants