bloque-automation
Rule engine with composable condition evaluator and pluggable action handlers.
Features
- Condition tree: AND/OR/NOT logic + comparison operators (eq, gt, in, regex, etc.)
- Sync evaluator: Pure function, no I/O, fully testable
- Pluggable handlers: ActionHandler protocol - bring your own action implementations
- Tenant-aware: Optional multitenant isolation via ulfblk-multitenant context
- Error-resilient: Missing fields return False, failed actions don't crash the engine
Install
uv add bloque-automation
Quick Start
from bloque_automation import (
Action, ActionType, Condition, LogActionHandler,
Operator, Rule, RuleEngine,
)
# Define a condition: user.age >= 18
condition = Condition(operator=Operator.GTE, field="user.age", value=18)
# Define a rule with a log action
rule = Rule(
rule_id="adult-check",
name="Adult User Check",
conditions=condition,
actions=[Action(action_type=ActionType.LOG, name="log-adult")],
)
# Create engine and register handler
engine = RuleEngine()
engine.register_handler(ActionType.LOG, LogActionHandler())
engine.add_rule(rule)
# Evaluate an event
async with engine:
results = await engine.evaluate({"user": {"age": 25}})
assert results[0].matched is True
Condition Operators
Comparison
| Operator | Description |
|---|---|
eq |
Equal |
neq |
Not equal |
gt |
Greater than |
gte |
Greater than or equal |
lt |
Less than |
lte |
Less than or equal |
in |
Value in list |
not_in |
Value not in list |
contains |
String contains |
starts_with |
String starts with |
ends_with |
String ends with |
regex |
Regex match |
Logical
| Operator | Description |
|---|---|
and |
All children must match |
or |
Any child must match |
not |
Invert single child |
Nested Fields
Use dot-path notation to access nested dict keys:
condition = Condition(operator=Operator.EQ, field="user.plan.tier", value="premium")
event = {"user": {"plan": {"tier": "premium"}}}
# evaluates to True
Custom Action Handler
Implement the ActionHandler protocol:
class NotificationActionHandler:
def __init__(self, notification_service):
self.service = notification_service
async def execute(self, action, context):
await self.service.notify_simple(
action.config["recipient"],
action.config["subject"],
str(context),
)
return {"status": "sent"}
async def health_check(self):
return True
engine.register_handler(ActionType.NOTIFY, NotificationActionHandler(svc))
Dependencies
Only ulfblk-core. Handlers that need HTTP, notifications, etc. bring their own deps.
Metadata
Release files for ulfblk-automation 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ulfblk_automation-0.1.0.tar.gz | 11.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ulfblk_automation-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.7 kB
Release files / ulfblk_automation-0.1.0.tar.gz
| Download URL | ulfblk_automation-0.1.0.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3355dcd298eb3bbd88ea88826751b31be1189c33f809f922d5f41acda6f03d28
|
|
BLAKE2b-256 checksum How to use checksums |
fee7939e6207345b915cc6aa356c1cd46d48c692b0d9366e71471fbb3ae04429
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / ulfblk_automation-0.1.0-py3-none-any.whl
| Download URL | ulfblk_automation-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b08fb976dd55ebf7aa0d894350e768828626776e415b2351360dd9aae11499f
|
|
BLAKE2b-256 checksum How to use checksums |
dffb08a250583f7e3b2a1d23250823ae54462a3111690d845e2d08fbde77aa2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|