Skip to content

feat(hydro_lang): add forward consistency analysis for IR sinks#2927

Open
jhellerstein wants to merge 1 commit into
mainfrom
feat/consistency-label-analysis
Open

feat(hydro_lang): add forward consistency analysis for IR sinks#2927
jhellerstein wants to merge 1 commit into
mainfrom
feat/consistency-label-analysis

Conversation

@jhellerstein

@jhellerstein jhellerstein commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Adds a forward consistency analysis that operates directly on the in-memory IR, producing labels equivalent to the external coord-analysis tool.

For each observable sink, the analysis derives a consistency label from the output type (ordering + retry) and walks backward checking for untrusted ObserveNonDet nodes not resolved by a commutative+idempotent fold. Commutativity/idempotency are inferred from the fold's input CollectionKind (NoOrder → commutative, AtLeastOnce → idempotent), avoiding extra fields on IR nodes.

Labels: SEQ_CONSISTENT, PER_KEY_SEQ_CONSISTENT, CONVERGENT_MULTISET, CONVERGENT_SET, CONVERGENT_LATTICE, INCONSISTENT.

Also adds FlowBuilder::cluster_with_consistency() for creating clusters with explicit consistency types.

Includes 8 tests (unit, integration with broadcast_closed, and simulator-validated).

@jhellerstein jhellerstein force-pushed the feat/drop-consistency-stream branch from 12a6f18 to 49303cb Compare June 5, 2026 16:33
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch from 5d04b46 to 68deb32 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: 6600441
Status: ✅  Deploy successful!
Preview URL: https://738f83bc.hydroflow.pages.dev
Branch Preview URL: https://feat-consistency-label-analy.hydroflow.pages.dev

View logs

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

Adds an in-memory IR consistency labeling API for Hydro sinks, aiming to match the external coord-analysis labeling while also providing blame spans for unresolved nondeterminism.

Changes:

  • Introduces compile::consistency_label with label derivation, sink label extraction, and nondeterminism scanning.
  • Exposes new BuiltFlow APIs for (a) type-metadata-based sink labels and (b) forward (sink-oriented) analysis that downgrades labels on unresolved untrusted nondeterminism.
  • Adds unit + integration + simulator tests to validate label derivation and (partially) alignment with runtime behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
hydro_lang/src/compile/mod.rs Exposes the new consistency_label module from compile.
hydro_lang/src/compile/consistency_label.rs Implements label derivation + extraction/analysis + tests.
hydro_lang/src/compile/built.rs Adds public BuiltFlow::{sink_consistency_labels, analyze_consistency} APIs.

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

Comment thread hydro_lang/src/compile/consistency_label.rs
Comment thread hydro_lang/src/compile/consistency_label.rs Outdated
Comment thread hydro_lang/src/compile/consistency_label.rs Outdated
Comment thread hydro_lang/src/compile/consistency_label.rs Outdated
Comment thread hydro_lang/src/compile/consistency_label.rs Outdated
Comment thread hydro_lang/src/compile/consistency_label.rs Outdated
Comment thread hydro_lang/src/compile/consistency_label.rs Outdated
@jhellerstein jhellerstein force-pushed the feat/drop-consistency-stream branch from 49303cb to ed4d130 Compare June 5, 2026 16:52
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch from 68deb32 to 2707eb4 Compare June 5, 2026 16:53
@jhellerstein jhellerstein force-pushed the feat/drop-consistency-stream branch from ed4d130 to f713343 Compare June 5, 2026 16:59
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch 2 times, most recently from a1eddc2 to d552a26 Compare June 5, 2026 17:02
@jhellerstein jhellerstein changed the base branch from feat/drop-consistency-stream to feat/is-proved-fold-properties June 5, 2026 17:02
@jhellerstein jhellerstein force-pushed the feat/is-proved-fold-properties branch from f26d93a to feaf0f8 Compare June 5, 2026 17:20
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch from d552a26 to 81bc818 Compare June 5, 2026 17:20
@jhellerstein jhellerstein force-pushed the feat/is-proved-fold-properties branch from feaf0f8 to 1d58e7b Compare June 5, 2026 17:36
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch 2 times, most recently from f1a7765 to 78ce814 Compare June 5, 2026 17:45
@jhellerstein jhellerstein requested a review from Copilot June 5, 2026 17:46
@jhellerstein jhellerstein force-pushed the feat/is-proved-fold-properties branch from 1d58e7b to cc07401 Compare June 5, 2026 17:48
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch 2 times, most recently from 3526f92 to 5c49f5b Compare June 5, 2026 17:52

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread hydro_lang/src/compile/consistency_label.rs Outdated
Comment thread hydro_lang/src/compile/consistency_label.rs Outdated
Comment thread hydro_lang/src/compile/consistency_label.rs
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch 2 times, most recently from 15e0816 to 5863b64 Compare June 5, 2026 18:01
@jhellerstein jhellerstein force-pushed the feat/is-proved-fold-properties branch from cc07401 to 71bbf8b Compare June 5, 2026 19:30
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch 3 times, most recently from 8ff063d to 65b6a1b Compare June 5, 2026 19:56
@jhellerstein jhellerstein force-pushed the feat/is-proved-fold-properties branch from 2dd09ab to fb5d5ae Compare June 5, 2026 21:06
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch from 65b6a1b to 9abf61a Compare June 5, 2026 21:06
@jhellerstein jhellerstein marked this pull request as ready for review June 5, 2026 21:54
@jhellerstein jhellerstein requested a review from shadaj June 5, 2026 21:56
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch from 9abf61a to d434d8e Compare June 6, 2026 01:11
@jhellerstein jhellerstein changed the base branch from feat/is-proved-fold-properties to main June 6, 2026 01:11
@jhellerstein jhellerstein requested a review from a team June 6, 2026 01:11
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch from d434d8e to 0b55571 Compare June 6, 2026 01:20
@jhellerstein jhellerstein requested a review from Copilot June 8, 2026 16:49

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread hydro_lang/src/compile/consistency_label.rs
Comment thread hydro_lang/src/compile/built.rs Outdated
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch from 0e2a973 to f707981 Compare June 8, 2026 22:09
Adds a forward consistency analysis that operates directly on the in-memory IR,
producing labels equivalent to the external coord-analysis tool.

For each observable sink, derives a label from the output type and walks backward
checking for untrusted ObserveNonDet nodes not resolved by a c+i fold. Infers
commutativity/idempotency from the fold's input collection_kind (NoOrder → commutative,
AtLeastOnce → idempotent) per discussion with @shadaj.

Also adds FlowBuilder::cluster_with_consistency() for creating clusters with
explicit consistency types.
@jhellerstein jhellerstein force-pushed the feat/consistency-label-analysis branch from b9110c2 to 6600441 Compare June 8, 2026 22:18

@jhellerstein jhellerstein left a comment

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.

redundancy in API: extract_sink_labels was the first version (metadata-based, for comparing with coord-analysis JSON output). analyze_sink_labels supersedes it — it does the actual analysis AND includes all sinks.

we should just remove extract_sink_labels and sink_consistency_labels, keeping only analyze_sink_labels / analyze_consistency.

@MingweiSamuel MingweiSamuel force-pushed the main branch 2 times, most recently from a15a670 to e70eab6 Compare June 11, 2026 18:42
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