Feature Availability
Not all features can be used in real-time policy rules. Some require aggregation over historical windows and must be computed by a feature store.
Real-time features
These fields are available in every live API request and can be referenced in data/active_policy.json rules.
| Feature | Type | Validation |
|---|---|---|
transaction_id |
string | Required, non-empty |
tx_type |
string | Required |
amount |
float | Required, > 0.0 |
geo_velocity |
float | Required, 0–5000 km/h |
typing_entropy |
float | Required, 0.0–6.0 |
device_is_emulator |
bool | Optional, defaults to false |
Pydantic enforces range constraints at the API boundary (src/api/router.py). Requests violating these constraints return HTTP 422 before evaluation begins.
Batch-only features
These signals require historical aggregation and are not available in the synchronous request payload. Rules referencing them will log a warning and be silently skipped at runtime.
| Feature | Description | Requires |
|---|---|---|
velocity_7d |
Number of transactions in the last 7 days | Feature store / time-series aggregation |
consortium_match_count |
Cross-client device/behavior matches | External device graph integration |
account_age_days |
Days since account creation | Identity database query |
chargeback_rate_30d |
Rolling chargeback rate for this user | Aggregated label history |
What happens when a rule references a missing field
If a rule's condition references a field not present in the payload:
evaluate_policy()catches theKeyError- Logs:
WARNING: Missing field in payload during rule evaluation: <field> | rule=<rule> - Skips that rule
- Continues evaluating remaining rules
- The request never fails due to a missing feature
This design allows risk managers to author rules for future signals — the rule will activate automatically once the caller starts sending that field.
Adding a new real-time feature
- Add the field to
RiskPayloadinsrc/api/router.pywith appropriate Pydantic constraints - Verify the field is passed through to
evaluate_policy()in the data dict - If using it for ML scoring, add it to
FEATURE_COLSinsrc/models/train.pyand retrain - Reference the field in
data/active_policy.jsonrules