WinstonRedGuard local-first deterministic rule evaluation engine (formerly rule-lab on PyPI, republished under WRG namespace)
Project description
wrg-rule-lab
A lightweight, local-first, deterministic rule evaluation engine for Python.
Define rules in JSON, evaluate them against any context, detect conflicts, and simulate outcomes — with zero external dependencies.
Note: Previously published as
rule-labon PyPI. Access to that account was lost; releases continue here aswrg-rule-labunder the WRG namespace. The import pathrule_labis unchanged.
Installation
pip install wrg-rule-lab
Quick Start
from rule_lab import load_rules_from_dict, evaluate_rules
ruleset = {
"rules": [
{
"rule_id": "r1",
"name": "Block high risk",
"conditions": [{"field": "risk_score", "op": "gt", "value": 80}],
"action": "block",
"priority": 10
}
]
}
rules = load_rules_from_dict(ruleset)
result = evaluate_rules(rules, context={"risk_score": 95})
print(result.matched_count) # 1
print(result.results[0].action) # block
CLI
# Validate a rule file
rule-lab validate --rules rules.json
# Simulate rules against a list of contexts
rule-lab simulate --rules rules.json --contexts contexts.json
# Detect conflicting rules
rule-lab diff --rules rules.json
API Reference
| Function | Description |
|---|---|
load_rules_from_file(path) |
Load rules from a JSON file |
load_rules_from_dict(data) |
Load rules from a dict |
load_rules_from_list(rules) |
Load rules from a list |
evaluate_rule(rule, context) |
Evaluate a single rule |
evaluate_rules(rules, context) |
Evaluate a list of rules |
simulate(rules, contexts) |
Simulate multiple contexts |
Rule Format
{
"rules": [
{
"rule_id": "unique-id",
"name": "Human readable name",
"conditions": [
{"field": "score", "op": "gt", "value": 50}
],
"action": "approve",
"priority": 10,
"tags": ["finance", "v1"],
"metadata": {}
}
]
}
Use Cases
- AI release gating — validate LLM app outputs before production
- Policy enforcement — define and run compliance rules as code
- Decision engines — replace hardcoded if/else logic with JSON rules
- Audit trails — every rule evaluation is traceable and reproducible
Design Principles
- Zero dependencies — stdlib only, no surprise installs
- Deterministic — same input always produces same output
- Local-first — no network calls, no cloud required
- Testable — every rule is independently verifiable
License
MIT — built by WinstonRed
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wrg_rule_lab-0.1.3.tar.gz.
File metadata
- Download URL: wrg_rule_lab-0.1.3.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de5dd62176e0a985dd63c5db312f318d856d4d2c89a4c5562e55dc838641f785
|
|
| MD5 |
ca7fdf61d32d7b3f92791f812a2f8cda
|
|
| BLAKE2b-256 |
f8c18b5d602ef11adfa1306598fb23e77981c2d0b89dce034d2a00aa0cb768de
|
Provenance
The following attestation bundles were made for wrg_rule_lab-0.1.3.tar.gz:
Publisher:
pypi-publish.yml on yakuphanycl/WinstonRedGuard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wrg_rule_lab-0.1.3.tar.gz -
Subject digest:
de5dd62176e0a985dd63c5db312f318d856d4d2c89a4c5562e55dc838641f785 - Sigstore transparency entry: 1342934152
- Sigstore integration time:
-
Permalink:
yakuphanycl/WinstonRedGuard@6924a9b4dde4ec2771385498cd6af2e5b8bf3b1b -
Branch / Tag:
refs/tags/wrg-rule-lab-v0.1.3 - Owner: https://github.com/yakuphanycl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@6924a9b4dde4ec2771385498cd6af2e5b8bf3b1b -
Trigger Event:
push
-
Statement type:
File details
Details for the file wrg_rule_lab-0.1.3-py3-none-any.whl.
File metadata
- Download URL: wrg_rule_lab-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65c6828c3a0a775aa0f713bcee28cc54ccb16cb03f317f4b3176b6ec3c643e84
|
|
| MD5 |
28bf54c403d192f1bbb027b1d92c4d22
|
|
| BLAKE2b-256 |
33dbd42eee1e444fe61fb48e862c7566bc1cb22edf4743fb9a752fc55d7c78a2
|
Provenance
The following attestation bundles were made for wrg_rule_lab-0.1.3-py3-none-any.whl:
Publisher:
pypi-publish.yml on yakuphanycl/WinstonRedGuard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wrg_rule_lab-0.1.3-py3-none-any.whl -
Subject digest:
65c6828c3a0a775aa0f713bcee28cc54ccb16cb03f317f4b3176b6ec3c643e84 - Sigstore transparency entry: 1342934163
- Sigstore integration time:
-
Permalink:
yakuphanycl/WinstonRedGuard@6924a9b4dde4ec2771385498cd6af2e5b8bf3b1b -
Branch / Tag:
refs/tags/wrg-rule-lab-v0.1.3 - Owner: https://github.com/yakuphanycl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@6924a9b4dde4ec2771385498cd6af2e5b8bf3b1b -
Trigger Event:
push
-
Statement type: