Closes gap-analysis v2 §5.2 partial (Rules Engine was hardcoded).
- services/rulesEngine.ts — declarative JSON DSL with a closed
operator set (eq/neq/gt/gte/lt/lte/in/not_in/exists/matches/
length_gte/length_lte) + AND/OR/NOT combinators. No eval, no
runtime code injection. Dotted + indexed path resolver.
- evaluate(ruleSet, context) returns {ok, failures}; 'error'
severity blocks, 'warn' is reported but non-blocking. 'when'
clauses gate a rule (e.g. only check compliance.kyc if the
compliance block is present at all).
- Built-in rule sets mirror the pre-DSL hardcoded checks:
preconditions.builtin — plan + pay step + participants + KYC
commit.builtin — dlt tx hash + bank iso msg id +
state=VALIDATING + no exceptions (arch §9.2)
- Pluggable: RULES_FILE env points at a JSON map overriding any
built-in by id. Silent fall-through to built-ins on error.
- 16 unit tests across operators, combinators, severity semantics,
'when' gating, built-in rule sets, and loader behaviour.
- Full suite 96/96 green; tsc --noEmit clean.