Treat business logic like code.
Most companies still make decisions like it's 2005:
- if statements scattered across services
- Refund logic in a Notion doc
- Rules buried in dashboards
- No way to test, version, or trace any of it
A minimal decision engine that gives you:
- 🧪 Testable decisions
- 🔁 Versioned logic
- 📜 Logged traces
- 🧠 DSL you can read and change
git clone https://github.com/data-riot/decision-layer
cd decision-layer
pip install -r requirements.txt
python cli.py refund_policy v3.2 --input examples/refund_input.json
You’ll see:
{
"refund": 100,
"reason": "Late delivery",
"rule_id": "late"
}
Trace saved to demo_trace.jsonl
# refund_policy.yaml
function: refund_policy
version: v3.2
rules:
- id: late
if: { field: "is_late", operator: "==", value: true }
then: { refund: 100, reason: "Late delivery" }
- id: damaged
if: { field: "issue", operator: "==", value: "damaged" }
then: { refund: 50, reason: "Damaged item" }
default:
refund: 0
reason: "Not eligible"
{
"input": { "issue": "late", "is_late": true },
"output": { "refund": 100, "reason": "Late delivery" },
"version": "v3.2",
"timestamp": "2025-07-14T12:34:56Z",
"caller": "cli",
"rule_id": "late"
}
- Refunds
- Risk holds
- Support escalation
- Account flags
- Access control
- Nested logic
- Rule priorities
- Boolean expressions (AND/OR)
- Type schemas
This is the starter kit, not the whole platform. Yet!
- refund_policy.yaml — your logic
- cli.py — run it
- test_decision.py — validate it
- demo_trace.jsonl — trace it
- entities.py — your input model
MIT
- Web UI to browse decisions
- FastAPI wrapper
Open an issue, submit a policy or fork it into your stack.