Overview
The decision engine executes decision flows to produce personalized offer recommendations. It processes each request through a pipeline of stages, each transforming the candidate set.Request Flow
Formula Engine
The formula engine (lib/formula-engine.ts) uses a tokenizer and recursive-descent parser. It does not use dynamic code execution — all formulas are parsed into an AST and interpreted safely. Supports arithmetic, comparison, ternary, and built-in functions.
Scoring Engines
Three scoring engines inlib/scoring/:
- Scorecard — Weighted attribute bins with configurable thresholds
- Bayesian — Prior probability updates with observed conversion data
- Gradient Boosted — Feature-based ML scoring with interaction history
Arbitration
Multi-objective arbitration (lib/arbitration.ts) computes a composite score:
Decision Traces
When tracing is enabled, the engine records every stage’s input/output for forensic debugging. Traces are stored in theDecisionTrace table with configurable sample rates.