A static analysis tool for Hydro IR that detects nondeterminism and CALM (Consistency As Logical Monotonicity) violations in dataflow programs.
Hydrolysis analyzes Hydro IR JSON files exported by hydro_lang::viz and produces annotated JSON with analysis metadata. It performs two main analysis passes:
- ND Pass (Nondeterminism): Propagates nondeterminism taint via transitive closure over dataflow edges
- CALM Pass (Monotonicity): Checks that cross-location edges use lattice types and monotone operators
# Build in debug mode
cargo build
# Build optimized release version (recommended)
cargo build --releaseThe binary will be located at:
- Debug:
target/debug/hydrolysis - Release:
target/release/hydrolysis
# Run the analyzer
cargo run --release -- input.json output.json
# Or use the binary directly
./target/release/hydrolysis input.json output.jsonThe tool expects Hydro IR JSON with the following structure:
{
"nodes": [
{
"id": "1",
"nodeType": "Source",
"shortLabel": "my_source"
}
],
"edges": [
{
"id": "e1",
"source": "1",
"target": "2",
"semanticTags": ["Local", "Stream"]
}
]
}See .ref for the complete JSON format specification.
The output JSON contains the same structure as the input, with added analysis fields on each node and edge, plus an overall summary:
{
"nodes": [
{
"id": "1",
"nodeType": "Source",
"shortLabel": "my_source",
"analysis": {
"nd_effect": "Deterministic",
"monotone": true,
"issues": []
}
}
],
"edges": [...],
"overall": {
"deterministic": true,
"calm_safe": true
}
}- Identifies nodes with non-deterministic effects (e.g.,
NonDeterministicnode type) - Computes transitive closure to find all tainted downstream nodes
- Annotates each node with its ND effect:
Deterministic,LocallyNonDet, orExternalNonDet
- Examines cross-location edges (edges with "Network" in
semanticTags) and edges to Sink nodes - Verifies all paths to these edges use monotone operators and lattice types
- Marks edges as
CalmSafeorCalmUnsafe - Computes overall
calm_safeboolean for the entire program
The tool generates three types of issues:
- NonDet: Node is nondeterministic
- NonMonotone: Non-monotone operator on a CALM-critical path
- NonLattice: Non-lattice type on a CALM-critical edge
# Run all tests
cargo test
# Run with verbose output
cargo test -- --nocapture
# Run specific test
cargo test test_calm_safe_network_edgeThe test suite includes both unit tests and property-based tests using proptest.
To install the tool globally:
cargo install --path .Then you can run it from anywhere:
hydrolysis input.json output.json├── src/
│ ├── lib.rs # Library root and re-exports
│ ├── model.rs # JSON data structures
│ ├── semantics.rs # Operator semantics table
│ ├── analysis.rs # ND and CALM analysis passes
│ ├── annotate.rs # Output annotation
│ └── bin/
│ └── main.rs # CLI entrypoint
├── Cargo.toml # Dependencies and project config
└── .ref # JSON format specification
See LICENSE file for details.