| Crates.io | rust-logic-graph |
| lib.rs | rust-logic-graph |
| version | 0.12.0 |
| created_at | 2025-11-02 13:50:14.101411+00 |
| updated_at | 2026-01-20 15:16:33.63604+00 |
| description | Reasoning engine for distributed backend & AI orchestration. Coordinate services, databases, and AI agents with business rules (GRL). |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1913140 |
| size | 1,517,106 |
Current Version: 0.12.0
Reasoning Engine for Distributed Backend & AI Orchestration
A high-performance reasoning engine for distributed backend systems and AI orchestration. Build complex decision workflows, coordinate multiple services, and create intelligent agent systems with GRL (Grule Rule Language) support.
Not a no-code automation tool - Rust Logic Graph is an embeddable library for developers building distributed reasoning systems, not a UI-first workflow platform like n8n or Zapier.
Rust Logic Graph is a reasoning engine library for building intelligent backend systems:
π§ Distributed Reasoning
π€ AI Agent Orchestration
β‘ High-Performance Execution
π§ Production-Ready Patterns
[dependencies]
rust-logic-graph = "0.12.0"
# With specific integrations
rust-logic-graph = { version = "0.12.0", features = ["postgres", "openai"] }
# With all integrations
rust-logic-graph = { version = "0.12.0", features = ["all-integrations"] }
Saga Pattern (E-commerce order flow):
let mut saga = SagaCoordinator::new(Some(Duration::from_secs(10)));
saga.add_step(SagaStep {
id: "reserve_inventory".to_string(),
action: Box::new(|ctx| { /* ... */ Ok(()) }),
compensation: Some(Box::new(|ctx| { /* ... */ Ok(()) })),
status: SagaStepStatus::Pending,
timeout: Some(Duration::from_secs(3)),
});
// ... more steps (charge_payment, create_shipment, send_confirmation)
saga.execute()?;
Financial risk assessment across multiple data sources
let risk_engine = Graph::new()
.add_node("credit_history", DBNode::postgres(...))
.add_node("transaction_analysis", DBNode::mongodb(...))
.add_node("fraud_check", AINode::openai(...))
.add_node("risk_rules", RuleNode::grl("risk_assessment.grl"))
.add_node("decision", ConditionalNode::new(...));
Multi-step AI reasoning with tool calling
let ai_agent = Graph::new()
.add_node("understand_query", AINode::claude(...))
.add_node("search_knowledge", SubgraphNode::new(rag_pipeline))
.add_node("reason", AINode::openai_gpt4(...))
.add_node("validate", RuleNode::grl("validation.grl"))
.add_retry("reason", max_attempts: 3);
Microservice coordination with fault tolerance
let order_flow = Graph::new()
.add_node("inventory", GrpcNode::new("inventory-service"))
.add_node("payment", GrpcNode::new("payment-service"))
.add_node("shipping", GrpcNode::new("shipping-service"))
.add_circuit_breaker("payment", threshold: 5)
.add_saga_compensation(...);
| Document | Description |
|---|---|
| οΏ½π’ Case Study: Purchasing Flow | Real production system with microservices & monolithic implementations |
| π YAML Configuration Guide | Declarative graph configuration with YAML (NEW in v0.8.5) |
| Graph Editor Guide | Visual web-based graph editor with Next.js (NEW in v0.8.0) |
| Memory Optimization Guide | Context pooling and allocation tracking (v0.7.0) |
| CLI Tool Guide | Developer tools for validation, profiling, and visualization (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 |
Rust Logic Graph powers applications in:
Query multiple databases, apply business rules, make decisions:
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β PostgreSQL βββββΆβ MongoDB βββββΆβ Redis β
β (Users) β β (Analytics) β β (Cache) β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β β β
βββββββββββββββββββββ΄ββββββββββββββββββββ
β
βββββββββΌββββββββ
β Rule Engine βββββ GRL Rules
β (Decision) β
βββββββββ¬ββββββββ
β
βββββββββΌββββββββ
β Actions β
βββββββββββββββββ
LLM orchestration with tool calling and validation:
βββββββββββββββ
β User Query β
ββββββββ¬βββββββ
β
ββββββββΌβββββββββββ
β LLM (Claude) ββββββββ
β Understand β β
ββββββββ¬βββββββββββ β
β Tool Calls
ββββββββΌβββββββββββ β
β RAG Subgraph ββββββββ€
β (Vector Search) β β
ββββββββ¬βββββββββββ β
β βββββΌβββββββ
ββββββββΌβββββββββββ β Database β
β LLM (GPT-4) ββββ€ Query β
β Reason β ββββββββββββ
ββββββββ¬βββββββββββ
β
ββββββββΌβββββββββββ
β Validate (GRL) β
β Business Rules β
ββββββββ¬βββββββββββ
β
ββββββββΌβββββββββββ
β Response β
βββββββββββββββββββ
Coordinate microservices with compensation logic:
Order Service βββΆ Inventory Service βββΆ Payment Service βββΆ Shipping Service
β β β β
Success Success Success Success
β β β β
βββββββββββββββββββββ΄βββββββββββββββββββββ΄βββββββββββββββββββββ
β
ββββββββΌβββββββ
β Complete β
βββββββββββββββ
If Payment Fails:
β β β
β β Compensation
β ββββββββββββββββββββββ
β Release Inventory
βββββββββββββββββββββ
Cancel Order
View 6 complete architecture patterns β

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;
}
| Benchmark | v1.18.0-alpha | v1.3.0 | Speedup |
|---|---|---|---|
| Simple Rule (1 rule) | 2.95 Β΅s | 298 Β΅s | 101x faster |
| Complex Rule (1 rule) | 10.27 Β΅s | 305 Β΅s | 30x faster |
| Purchasing Rules (11 rules) | 71.6 Β΅s | 3,500 Β΅s | 49x faster |
| Rule Execution (11 rules) | 32.66 Β΅s | - | - |
| Chain Size | rust-logic-graph | dagrs | Speedup |
|---|---|---|---|
| 5 nodes | 271 Β΅s | 1.7 ms | 6.3x faster |
| 10 nodes | 526 Β΅s | 1.8 ms | 3.5x faster |
| 20 nodes | 996 Β΅s | 2.1 ms | 2.1x faster |
# Run all tests
cargo test
# Build CLI tool (YAML-only support)
cargo build --release --bin rlg
# Validate graph
./target/release/rlg validate --file examples/sample_graph.yaml
# Visualize graph structure
./target/release/rlg visualize --file examples/sample_graph.yaml --details
# Profile performance
./target/release/rlg profile --file examples/sample_graph.yaml --iterations 100
# Dry-run execution
./target/release/rlg dry-run --file examples/sample_graph.yaml --verbose
Test Results: β
74/74 tests passing
CLI Format: YAML only (.yaml or .yml files)
Learn more about CLI tools β
Version: 0.11.0 (Latest) Status: Production-ready with YAML-driven multi-database orchestration
See ROADMAP.md for details
Contributions welcome! Please:
| 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 |
| Example | Description | Features Demonstrated |
|---|---|---|
conditional_flow.rs |
If/else routing based on conditions | ConditionalNode, branch selection |
loop_flow.rs |
Foreach and while loop patterns | LoopNode, iteration over arrays |
retry_flow.rs |
Exponential backoff retry logic | RetryNode, configurable attempts |
error_handling_flow.rs |
Try/catch/finally patterns | TryCatchNode, error recovery |
circuit_breaker_flow.rs |
Circuit breaker fault tolerance | CircuitBreakerNode, failure thresholds |
subgraph_flow.rs |
Nested graph execution | SubgraphNode, input/output mapping |
| Example | Description | Features Demonstrated |
|---|---|---|
real_multi_db_orchestration.rs |
Query multiple databases in parallel with real data | ParallelDBExecutor, QueryCorrelator, DistributedTransaction |
Demo 1: Parallel Queries - Execute queries across 4 databases concurrently
Demo 2: Query Correlation - JOIN results from different databases (Inner/Left/Right/Full)
Demo 3: Distributed Transactions - Two-Phase Commit (2PC) for atomic operations
use rust_logic_graph::multi_db::{ParallelDBExecutor, QueryCorrelator, JoinStrategy};
// Execute queries in parallel across multiple databases
let mut executor = ParallelDBExecutor::new();
executor
.add_query("oms_db", "get_user", || async { /* query */ })
.add_query("orders_db", "get_orders", || async { /* query */ });
let results = executor.execute_all().await?;
// Correlate results with SQL-like JOINs
let correlator = QueryCorrelator::new();
let joined = correlator.join(
&users_data,
&orders_data,
"user_id",
"user_id",
JoinStrategy::Inner
)?;
Run examples:
# Conditional routing
cargo run --example conditional_flow
# Loop over products
cargo run --example loop_flow
# Retry with backoff
cargo run --example retry_flow
# Error handling
cargo run --example error_handling_flow
# Circuit breaker
cargo run --example circuit_breaker_flow
# Nested subgraphs
cargo run --example subgraph_flow
# Rich error messages (v0.10.0) π
cargo run --example error_messages_demo
# Multi-database orchestration (v0.10.0) π
cargo run --example multi_db_orchestration
Production-grade error messages with unique codes, actionable suggestions, and full context:
use rust_logic_graph::error::{RustLogicGraphError, ErrorContext};
// Rich error with context
let err = RustLogicGraphError::database_connection_error(
"Failed to connect to PostgreSQL"
).with_context(
ErrorContext::new()
.with_node("fetch_orders")
.with_graph("order_processing")
.add_metadata("database", "orders_db")
);
// Output:
// [E002] Failed to connect to PostgreSQL
// Graph: order_processing
// Node: fetch_orders
// database: orders_db
//
// π‘ Suggestion: Verify database connection string, credentials,
// and network connectivity.
// π Documentation: https://docs.rust-logic-graph.dev/errors/E002
// Automatic retry strategy
if err.is_retryable() {
retry_with_backoff(operation).await?;
}
12 Error Types: Node execution (E001), Database (E002), Rules (E003), Config (E004), Timeout (E005), Validation (E006), Serialization (E007), AI (E008), Cache (E009), Context (E010), Distributed (E011), Transaction (E012)
See docs/ERRORS.md for complete error reference
| File | Description |
|---|---|
examples/sample_graph.yaml |
Linear workflow with 5 nodes |
examples/cyclic_graph.yaml |
Graph with cycle for testing |
examples/sample_context.yaml |
Sample input data |
See CLI_TOOL.md for usage examples
Traditional workflow engines execute tasks. Rust Logic Graph reasons through decisions:
Not a monolithic workflow runner - designed for microservices from day one:
LLMs are first-class citizens, not afterthoughts:
Embedded library architecture means zero network overhead:
Designed for developers who write code, not click buttons:
MIT License - see LICENSE for details.
James Vu - Initial work
Built with:
β Star us on GitHub if you find this useful! β
Documentation β’ Examples β’ Use Cases β’ YAML Config Guide