rule_engine_postgre_extensions
rule_engine_postgre_extensions · Rust/pgrx rule-engine extension supporting GRL rules, RETE and forward/backward chaining, versioned rule repositories, triggers, and optional external integrations.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101154 | rule_engine_postgre_extensions | rule_engine_postgre_extensions | 2.0.0 | FEAT | MIT | Rust |
PostgreSQL · 16, 17, 18
| Relationships | |
|---|---|
| Requires | pgcrypto |
Usage
Sources:
rule_engine_postgre_extensions runs business rules expressed in Grule Rule Language against JSON facts inside PostgreSQL. Version 2.0.0 offers RETE and forward-chaining execution, rule repositories and sets, debug-event persistence, built-in transformation functions, and optional outbound integrations. Treat rules as executable application logic and grant the API only to trusted roles.
Core Workflow
Install pgcrypto first because repository credentials introduced in later schema versions use it, then execute a small rule against copied JSON facts:
Use run_rule_engine_rete explicitly for RETE behavior or run_rule_engine_fc for the simpler forward-chaining path. Validate returned JSON before applying it to authoritative tables.
Important Objects
run_rule_engine,run_rule_engine_rete, andrun_rule_engine_fcexecute facts and rule text with different engines.run_rule_engine_debug,debug_get_events, anddebug_list_sessionsexpose execution traces.- Debug control functions enable, disable, persist, delete, or clear trace sessions.
- Repository functions store, version, activate, and execute named rules.
- Rule-set and statistics functions group rules and expose execution metrics.
- Webhook, external-data-source, and NATS functions connect rule processing to remote systems.
- Built-in GRL functions cover date, string, math, and JSON transformations.
Security and Operational Notes
Rule and fact inputs are limited to 1 MB according to the documented error contract, but complex rules can still consume backend CPU and memory. Debug persistence stores business facts and decisions and must be retained and protected deliberately. Repository credentials depend on pgcrypto; restrict the underlying tables and verify the encryption-key procedure before storing secrets. Webhooks, data sources, and NATS create external, nontransactional effects and can leak facts. Reproduce performance claims on the real workload and keep outbound integrations disabled until network, authentication, timeout, retry, and audit behavior are verified.