ordo-rule-development
Skill37 starsChanged 10 months agoMITView on GitHub
Ordo rule engine Rust development guide. Helps create RuleSet, Step, conditional branches, terminal results. Use for writing rule definitions, understanding Step Flow model, creating Decision/Action/Terminal steps.
In this repository6 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ordo-editor-componentSkill
- ordo-expression-syntaxSkill
- ordo-jit-optimizationSkill
- ordo-server-deploymentSkill
- ordo-testingSkill
The file
Files
Ordo Rule Engine Development
Core Concepts
Step Flow Model
Ordo uses Step Flow model to organize rules:
- Decision Step: Conditional judgment, jumps to different steps based on conditions
- Action Step: Execute actions (set variables, call external services)
- Terminal Step: Terminate execution, return result
RuleSet Structure
use ordo_core::prelude::*;
// Create ruleset
let mut ruleset = RuleSet::new("rule_name", "entry_step_id");
// Add steps
ruleset.add_step(step);
// Validate ruleset
ruleset.validate()?;
// Execute
let executor = RuleExecutor::new();
let result = executor.execute(&ruleset, input)?;Creating Steps
Decision Step
// Builder pattern
let step = Step::decision("check_balance", "Check Balance")
.branch(Condition::from_string("balance >= 1000"), "approve")
.branch(Condition::from_string("balance >= 500"), "review")
.default("reject")
.build();Terminal Step
let step = Step::terminal(
"approve",
"Approved",
TerminalResult::new("APPROVED")
.with_message("User has been approved")
.with_output("allowed", Expr::literal(true))
.with_output("discount", Expr::literal(0.2))
);Action Step
let step = Step::action("set_discount", "Set Discount")
.set("discount_rate", Expr::literal(0.15))
.set("applied_at", Expr::field("timestamp"))
.next("final_check")
.build();Condition Expressions
Basic Comparisons
Condition::from_string("age >= 18")
Condition::from_string("status == \"active\"")
Condition::from_string("balance > 0")Logical Combinations
Condition::from_string("age >= 18 && status == \"active\"")
Condition::from_string("tier == \"gold\" || tier == \"platinum\"")
Condition::from_string("!(is_blocked == true)")Field Access
Condition::from_string("user.profile.level >= 5")
Condition::from_string("items[0].price > 100")
Condition::from_string("len(orders) > 0")JSON/YAML Format
JSON Rule Definition
{
"config": {
"name": "discount-check",
"version": "1.0.0",
"entry_step": "check_vip"
},
"steps": {
"check_vip": {
"id": "check_vip",
"name": "Check VIP Status",
"type": "decision",
"branches": [
{ "condition": "user.vip == true", "next_step": "vip_discount" }
],
"default_next": "normal_discount"
},
"vip_discount": {
"id": "vip_discount",
"name": "VIP Discount",
"type": "terminal",
"result": { "code": "VIP", "message": "20% discount" }
}
}
}Loading and Executing
// Load from JSON and pre-compile
let mut ruleset = RuleSet::from_json_compiled(json_str)?;
// Or step by step
let mut ruleset = RuleSet::from_json(json_str)?;
ruleset.compile()?; // Pre-compile expressions
// Execute
let executor = RuleExecutor::new();
let input: Value = serde_json::from_str(r#"{"user": {"vip": true}}"#)?;
let result = executor.execute(&ruleset, input)?;Configuration Options
RuleSetConfig
| Field | Type | Default | Description |
name | String | Required | RuleSet name |
entry_step | String | Required | Entry step ID |
version | String | "1.0.0" | Version number |
field_missing | enum | Lenient | Missing field handling |
max_depth | usize | 100 | Max execution depth |
timeout_ms | u64 | 0 | Timeout (0=unlimited) |
enable_trace | bool | false | Enable execution tracing |
FieldMissingBehavior
Lenient: Treat missing field as nullStrict: Error on missing fieldDefault: Use default value
Compiled Rules (.ordo format)
// Compile to binary format
let compiled = RuleSetCompiler::compile(&ruleset)?;
compiled.save_to_file("rules.ordo")?;
// Load and execute
let loaded = CompiledRuleSet::load_from_file("rules.ordo")?;
let executor = CompiledRuleExecutor::new();
let result = executor.execute(&loaded, input)?;Execution Tracing
// Enable tracing
ruleset.config.enable_trace = true;
let result = executor.execute(&ruleset, input)?;
// Access trace information
if let Some(trace) = result.trace {
for step in trace.steps {
println!("Step: {} -> {}", step.step_id, step.result);
}
}Key Files
crates/ordo-core/src/rule/model.rs- RuleSet modelcrates/ordo-core/src/rule/step.rs- Step type definitionscrates/ordo-core/src/rule/executor.rs- Rule executorcrates/ordo-core/src/rule/compiler.rs- Rule compilercrates/ordo-core/examples/basic_usage.rs- Basic example
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

