π§ Rust Logic Graph
A high-performance reasoning graph framework for Rust with GRL (Grule Rule Language) support. Build complex workflows with conditional execution, topological ordering, and async processing.
use ;
async
β¨ Key Features
- π₯ GRL Support - rust-rule-engine v0.14.0 with RETE-UL algorithm (2-24x faster)
- π Topological Execution - Automatic DAG-based node ordering
- β‘ Async Runtime - Built on Tokio for high concurrency
- β‘ Parallel Execution - Automatic parallel execution of independent nodes (v0.5.0)
- πΎ Caching Layer - High-performance result caching with TTL, eviction policies, and memory limits (v0.5.0)
- π οΈ CLI Developer Tools - Graph validation, dry-run, profiling, and visualization (v0.5.0)
- π Multiple Node Types - RuleNode, DBNode, AINode
- π JSON Configuration - Simple workflow definitions
- π― 98% Drools Compatible - Easy migration from Java
- π Streaming Processing - Stream-based execution with backpressure (v0.3.0)
- ποΈ Database Integrations - PostgreSQL, MySQL, Redis, MongoDB (v0.2.0)
- π€ AI/LLM Integrations - OpenAI, Claude, Ollama (v0.2.0)
π Quick Start
Installation
[]
= "0.6.0"
# With specific integrations
= { = "0.6.0", = ["postgres", "openai"] }
# With all integrations
= { = "0.6.0", = ["all-integrations"] }
Simple Example
use ;
let grl = r#"
rule "Discount" {
when
cart_total > 100 && is_member == true
then
discount = 0.15;
}
"#;
let mut engine = new;
engine.add_grl_rule?;
CLI Tools (NEW in v0.5.0)
# Build the CLI tool
# Validate a graph
# Visualize graph structure
# Profile performance
# Dry-run without execution
Run Examples
# Basic workflow
# GRL rules
# Advanced integration
π Documentation
| Document | Description |
|---|---|
| CLI Tool Guide | Developer tools for validation, profiling, and visualization (NEW in v0.5.0) |
| Cache Guide | Caching layer with TTL and eviction policies (v0.5.0) |
| Migration Guide | Upgrade guide to v0.14.0 with RETE-UL (v0.5.0) |
| Integrations Guide | Database & AI integrations (v0.2.0) |
| GRL Guide | Complete GRL syntax and examples |
| Use Cases | 33+ real-world applications |
| Extending | Create custom nodes and integrations |
| Implementation | Technical details |
π― Use Cases
Rust Logic Graph powers applications in:
- π° Finance - Loan approval, fraud detection, risk assessment
- π E-commerce - Dynamic pricing, recommendations, fulfillment
- π₯ Healthcare - Patient triage, clinical decisions, monitoring
- π Manufacturing - Predictive maintenance, QC automation
- π‘οΈ Insurance - Claims processing, underwriting
- π Marketing - Lead scoring, campaign optimization
- βοΈ Compliance - AML monitoring, GDPR automation
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββ
β rust-rule-engine v0.14.0 (GRL) β
β RETE-UL Algorithm β’ 2-24x Faster β
ββββββββββββββββββ¬βββββββββββββββββββββββββ
β
ββββββββββββββββββΌβββββββββββββββββββββββββ
β Rust Logic Graph Core β
β β’ Graph Definition β
β β’ Parallel Executor β
β β’ Cache Manager (NEW) β
β β’ Context Management β
ββββββββββββββββββ¬βββββββββββββββββββββββββ
β
ββββββββββββββΌβββββββββββββ
β β β
βββββΌββββ βββββΌββββ βββββΌββββ
β Rule β β DB β β AI β
β Node β β Node β β Node β
βββββββββ βββββββββ βββββββββ
β β β
ββββββΌβββββββββββββΌβββββββββββββΌβββββ
β CLI Developer Tools β
β β’ Validate β’ Profile β’ Visualizeβ
ββββββββββββββββββββββββββββββββββββββ
π₯ GRL Example
rule "HighValueLoan" salience 100 {
when
loan_amount > 100000 &&
credit_score < 750
then
requires_manual_review = true;
approval_tier = "senior";
}
rule "AutoApproval" salience 50 {
when
credit_score >= 700 &&
income >= loan_amount * 3 &&
debt_ratio < 0.4
then
auto_approve = true;
interest_rate = 3.5;
}
π Performance
- RETE-UL Algorithm: Advanced pattern matching with unlinking (v0.14.0)
- 2-24x Faster: Than v0.10 at 50+ rules
- 98% Drools Compatible: Easy migration path
- Async by Default: High concurrency support
- Parallel Execution: Automatic layer-based parallelism
- Smart Caching: Result caching with TTL and eviction policies
π§ͺ Testing & CLI Tools
# Run all tests
# Build CLI tool
# Validate graph
# Visualize graph structure
# Profile performance
# Dry-run execution
Test Results: β 32/32 tests passing
Learn more about CLI tools β
π¦ Project Status
Version: 0.6.0 (Latest) Status: Production-ready with parallel execution, caching, and CLI tools
What's Working
- β Core graph execution engine
- β RETE-UL algorithm (v0.14.0) - 2-24x faster
- β Three node types (Rule, DB, AI)
- β Topological sorting
- β Async execution
- β JSON I/O
- β Database integrations (PostgreSQL, MySQL, Redis, MongoDB)
- β AI integrations (OpenAI, Claude, Ollama)
- β Streaming processing with backpressure and chunking
- β Parallel execution with automatic layer detection
- β Caching layer with TTL, eviction policies, memory limits (v0.5.0)
- β CLI Developer Tools - validate, profile, visualize, dry-run (v0.5.0)
- β Stream operators (map, filter, fold)
- β Comprehensive documentation
Roadmap
- Streaming processing (v0.3.0) - COMPLETED β
- Parallel node execution (v0.4.0) - COMPLETED β
- Caching layer (v0.5.0) - COMPLETED β
- CLI Developer Tools (v0.5.0) - COMPLETED β
- RETE-UL upgrade (v0.5.0) - COMPLETED β
- GraphQL API (v0.6.0)
- Web UI for visualization (v0.7.0)
- Production release (v1.0.0)
See ROADMAP.md for details
π€ Contributing
Contributions welcome! Please:
- Fork the repository
- Create your feature branch
- Write tests for new features
- Submit a pull request
π Examples
| Example | Description | Lines |
|---|---|---|
simple_flow.rs |
Basic 3-node pipeline | 36 |
advanced_flow.rs |
Complex 6-node workflow | 120 |
grl_rules.rs |
GRL rule examples | 110 |
grl_graph_flow.rs |
GRL + Graph integration | 140 |
postgres_flow.rs |
PostgreSQL integration | 100 |
openai_flow.rs |
OpenAI GPT integration | 150 |
streaming_flow.rs |
Streaming with backpressure | 200 |
parallel_execution.rs |
Parallel node execution | 250 |
CLI Tool Examples (v0.5.0)
| File | Description |
|---|---|
examples/sample_graph.json |
Linear workflow with 5 nodes |
examples/cyclic_graph.json |
Graph with cycle for testing |
examples/sample_context.json |
Sample input data |
See CLI_TOOL.md for usage examples
π Why Rust Logic Graph?
vs. Traditional Rule Engines
- β Async by default - No blocking I/O
- β Type safety - Rust's type system
- β Modern syntax - GRL support
- β Graph-based - Complex workflows
vs. Workflow Engines
- β Embedded - No external services
- β Fast - Compiled Rust code
- β Flexible - Custom nodes
- β Rule-based - Business logic in rules
π Changelog
v0.5.0 (2025-11-06) - Performance & Developer Tools Release
Breaking Changes:
- β‘ Upgraded rust-rule-engine from v0.10 β v0.14.0
- Now uses RETE-UL algorithm (2-24x faster)
- Better memory efficiency
- Improved conflict resolution
- See Migration Guide
New Features:
- π οΈ CLI Developer Tools (
rlgbinary)- Graph validation with comprehensive checks
- Dry-run execution mode
- Performance profiling with statistics
- ASCII graph visualization
- See CLI Tool Guide
- πΎ Caching Layer - High-performance result caching
- TTL-based expiration
- Multiple eviction policies (LRU, LFU, FIFO)
- Memory limits and statistics
- See Cache Guide
- β‘ Parallel Node Execution - Automatic detection and parallel execution
- Layer detection algorithm using topological sort
- Concurrent execution within layers
- Parallelism analysis and statistics
- π ParallelExecutor - New executor with parallel capabilities
- π New Examples - CLI examples and test graphs
- β 32 Tests - Comprehensive test coverage
Improvements:
- Updated documentation with CLI tools, caching, and migration guides
- Performance benchmarking utilities
- Example graph files for testing
Compatibility:
- All 32 tests passing
- API is backward compatible (100%)
- Performance: 2-24x faster rule matching
v0.3.0 (2025-11-03) - Streaming & Performance Release
New Features:
- π Streaming Processing - Stream-based node execution
- Backpressure handling with bounded channels
- Large dataset support with chunking
- Stream operators (map, filter, fold, async map)
- π New Example -
streaming_flow.rswith 6 demonstrations - β 8 New Tests - Streaming module testing
Performance:
- Processed 10,000 items in chunks
- ~432 items/sec throughput with backpressure
v0.2.0 (2025-11-02) - Integrations Release
New Features:
- ποΈ Database Integrations - PostgreSQL, MySQL, Redis, MongoDB
- π€ AI/LLM Integrations - OpenAI GPT-4, Claude 3.5, Ollama
- π Integration Examples -
postgres_flow.rs,openai_flow.rs - π INTEGRATIONS.md - Comprehensive integration guide
- ποΈ Feature Flags - Optional dependencies for integrations
v0.1.0 (2025-11-01) - Initial Release
Core Features:
- π§ Core graph execution engine
- π₯ GRL (Grule Rule Language) integration
- π Topological sorting
- β‘ Async execution with Tokio
- π Three node types (Rule, DB, AI)
- π JSON I/O for graphs
- π 4 working examples
- β 6/6 tests passing
π License
MIT License - see LICENSE for details.
π Links
- Repository: https://github.com/KSD-CO/rust-logic-graph
- rust-rule-engine: https://crates.io/crates/rust-rule-engine
- Documentation: docs/
- Issues: GitHub Issues
π₯ Authors
James Vu - Initial work
π Acknowledgments
Built with:
- rust-rule-engine v0.14.0 - GRL support with RETE-UL
- Tokio - Async runtime
- Petgraph - Graph algorithms
- Serde - Serialization
- Clap - CLI framework
β Star us on GitHub if you find this useful! β
Documentation β’ Examples β’ Use Cases