Skip to content

feat(hydro_lang): add Stream::weaken_consistency() and cluster_with_consistency()#2926

Closed
jhellerstein wants to merge 1 commit into
feat/is-proved-fold-propertiesfrom
feat/drop-consistency-stream
Closed

feat(hydro_lang): add Stream::weaken_consistency() and cluster_with_consistency()#2926
jhellerstein wants to merge 1 commit into
feat/is-proved-fold-propertiesfrom
feat/drop-consistency-stream

Conversation

@jhellerstein

@jhellerstein jhellerstein commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Adds two utility methods for working with consistency-typed clusters:

  • Stream::weaken_consistency(): Weakens the consistency guarantee of a stream (e.g., going from EventualConsistency to NoConsistency), with the type system enforcing the direction is safe. No IR node is inserted. Follows the same pattern as weaken_ordering() and weaken_retries(). Useful when a stream produced by broadcast_closed needs to flow through APIs that expect NoConsistency.

  • FlowBuilder::cluster_with_consistency<C, Con>(): Creates a cluster with an explicit consistency type parameter (e.g. EventualConsistency), rather than defaulting to NoConsistency.

These are building blocks for the consistency label analysis in the next PR.

@jhellerstein jhellerstein force-pushed the feat/drop-consistency-stream branch from 12a6f18 to 49303cb Compare June 5, 2026 16:33
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 5, 2026

Copy link
Copy Markdown

Deploying hydro with  Cloudflare Pages  Cloudflare Pages

Latest commit: f713343
Status:⚡️  Build in progress...

View logs

@jhellerstein jhellerstein changed the title feat(hydro_lang): add Stream::drop_consistency() and cluster_with_consistency() feat(hydro_lang): add Stream::weaken_consistency() and cluster_with_consistency() Jun 5, 2026
@jhellerstein jhellerstein requested a review from Copilot June 5, 2026 16:38

Copilot AI left a comment

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.

Pull request overview

This PR adds new API surface in hydro_lang for working with consistency-typed clusters/streams, intended as building blocks for upcoming consistency label analysis.

Changes:

  • Adds Stream::weaken_consistency() to drop a stream’s consistency guarantees in the type system.
  • Adds FlowBuilder::cluster_with_consistency<C, Con>() to create a Cluster location with an explicit consistency type parameter.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
hydro_lang/src/live_collections/stream/mod.rs Adds a weaken_consistency method on Stream (currently duplicated in-file).
hydro_lang/src/compile/builder.rs Adds cluster_with_consistency to build clusters with an explicit consistency type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +524 to +537
/// Drop the consistency guarantee from this stream's location.
///
/// Weakens the consistency guarantee of this stream (e.g., going from
/// `EventualConsistency` to `NoConsistency`). No IR node is inserted —
/// enforcing the direction is safe. No IR node is inserted.
pub fn weaken_consistency(self) -> Stream<T, L::DropConsistency, B, O, R>
where
L: Location<'a>,
{
Stream::new(
self.location.drop_consistency(),
self.ir_node.replace(HydroNode::Placeholder),
)
}
@jhellerstein jhellerstein force-pushed the feat/drop-consistency-stream branch from 49303cb to ed4d130 Compare June 5, 2026 16:52
…ster_with_consistency()

- Stream::drop_consistency(): safely forgets a consistency guarantee
  (e.g. EventualConsistency → NoConsistency). Purely type-level, no IR
  node inserted. Useful when replication strategies need to return streams
  on NoConsistency clusters after using broadcast_closed internally.

- FlowBuilder::cluster_with_consistency<C, Con>(): creates a cluster with
  an explicit consistency guarantee (e.g. EventualConsistency) rather than
  the default NoConsistency.
@jhellerstein jhellerstein force-pushed the feat/drop-consistency-stream branch from ed4d130 to f713343 Compare June 5, 2026 16:59
@jhellerstein

Copy link
Copy Markdown
Contributor Author

Folded into #2927

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