Data Model: Rules Engine
On this page
Overview
The rules engine stores JDM (JSON Decision Model) rule sets and a full audit trail of every evaluation.
Rule sets are cached in memory at startup; at runtime the cache converges on the database through
identity-aware conditional applies keyed on the trigger-enforced (id, revision) pair (#1188 / the
ADR-006 #1188 amendment) — driven by RabbitMQ rules.cache_invalidated events from peers AND a
periodic reconcile sweep (CRAIG_RULES__DECISION_REFRESH_SECONDS) that bounds staleness when an
event is lost.
Tables
| Table | Purpose |
|---|---|
|
JDM rule set definitions — content stored as JSONB, soft-deleted via |
|
Audit trail — every evaluation recorded with input, output, context, and evaluator (the #1130
SINGLE copy; past the archive hot window rows move COLD via #1129/ADR-058 — resolvable forever
through |
|
#1129 (ADR-058 D8): rules' OWN durable archive ledger — one row per archived batch (object keys, sha256, D9 store identity, the [min, max] id range per D17), written inside the prune transaction; the authority orphan GC consults (the event to security is secondary bookkeeping) |
|
#1556 (D2): insert-only content history — one row per API-path mutation, same-tx, keyed
|
|
#1556 (D2): the promote two-step’s DB-backed evidence — candidate hash + from_revision binding, corpus fingerprint, thin-corpus flag, the categorical diff report. Never burned (a successful execute bumps the live revision, so replays 409 on the CAS). Audit-class, keep-forever-hot. |
Key Indexes
-
idx_rule_evaluations_rule_set_id— FK lookup -
idx_rule_evaluations_context— composite on(context_type, context_id)for audit queries -
idx_rule_evaluations_evaluated_at— time-range queries