feat: rules engine — json-rules-engine integration with worklist scoring

- Self-contained NestJS module: types, storage (Redis+JSON), fact providers, action handlers
- PriorityConfig CRUD (slider values for task weights, campaign weights, source weights)
- Score action handler with SLA multiplier + campaign multiplier formula
- Worklist consumer: scores and ranks items before returning
- Hospital starter template (7 rules)
- REST API: /api/rules/* (CRUD, priority-config, evaluate, templates)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-01 16:59:10 +05:30
parent 7b59543d36
commit b8556cf440
20 changed files with 959 additions and 3 deletions

43
package-lock.json generated
View File

@@ -24,6 +24,7 @@
"ai": "^6.0.116",
"axios": "^1.13.6",
"ioredis": "^5.10.1",
"json-rules-engine": "^6.6.0",
"kafkajs": "^2.2.4",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
@@ -8234,6 +8235,12 @@
"node": ">=6"
}
},
"node_modules/eventemitter2": {
"version": "6.4.9",
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.9.tgz",
"integrity": "sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg==",
"license": "MIT"
},
"node_modules/events": {
"version": "3.3.0",
"resolved": "http://localhost:4873/events/-/events-3.3.0.tgz",
@@ -9175,6 +9182,12 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hash-it": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/hash-it/-/hash-it-6.0.1.tgz",
"integrity": "sha512-qhl8+l4Zwi1eLlL3lja5ywmDQnBzLEJxd0QJoAVIgZpgQbdtVZrN5ypB0y3VHwBlvAalpcbM2/A6x7oUks5zNg==",
"license": "MIT"
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "http://localhost:4873/hasown/-/hasown-2.0.2.tgz",
@@ -10490,6 +10503,27 @@
"dev": true,
"license": "MIT"
},
"node_modules/json-rules-engine": {
"version": "6.6.0",
"resolved": "https://registry.npmjs.org/json-rules-engine/-/json-rules-engine-6.6.0.tgz",
"integrity": "sha512-jJ4eVCPnItetPiU3fTIzrrl3d2zeIXCcCy11dwWhN72YXBR2mByV1Vfbrvt6y2n+VFmxc6rtL/XhDqLKIwBx6g==",
"license": "ISC",
"dependencies": {
"clone": "^2.1.2",
"eventemitter2": "^6.4.4",
"hash-it": "^6.0.0",
"jsonpath-plus": "^7.2.0"
}
},
"node_modules/json-rules-engine/node_modules/clone": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
"integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==",
"license": "MIT",
"engines": {
"node": ">=0.8"
}
},
"node_modules/json-schema": {
"version": "0.4.0",
"resolved": "http://localhost:4873/json-schema/-/json-schema-0.4.0.tgz",
@@ -10549,6 +10583,15 @@
"graceful-fs": "^4.1.6"
}
},
"node_modules/jsonpath-plus": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-7.2.0.tgz",
"integrity": "sha512-zBfiUPM5nD0YZSBT/o/fbCUlCcepMIdP0CJZxM1+KgA4f2T206f6VAg9e7mX35+KlMaIc5qXW34f3BnwJ3w+RA==",
"license": "MIT",
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/jwa": {
"version": "2.0.1",
"resolved": "http://localhost:4873/jwa/-/jwa-2.0.1.tgz",