FRE-4518: Replace hardcoded default score values with constants

- Created decision-engine.constants.ts with all scoring weights, thresholds, and behavioral scores
- Updated decision-engine.ts to import and use constants instead of inline values
- All 12 hardcoded values now have named, documented constants
- Pre-existing type errors are unrelated to this change
This commit is contained in:
2026-05-01 18:02:28 -04:00
parent 574bcf2264
commit 2241b97c81
2 changed files with 50 additions and 12 deletions

View File

@@ -0,0 +1,27 @@
/**
* Decision Engine Constants
*
* Scoring weights, thresholds, and behavioral factors used in spam detection.
* These values should be reviewed periodically and updated based on model performance.
*/
/** Scoring Weights */
export const DEFAULT_REPUTATION_WEIGHT = 0.4;
export const DEFAULT_RULE_WEIGHT = 0.3;
export const DEFAULT_BEHAVIORAL_WEIGHT = 0.2;
export const DEFAULT_USER_HISTORY_WEIGHT = 0.1;
/** Decision Thresholds */
export const DEFAULT_BLOCK_THRESHOLD = 0.85;
export const DEFAULT_FLAG_THRESHOLD = 0.60;
/** Behavioral Analysis Scores */
export const SHORT_CALL_SCORE = 0.3; // Call duration < 5 seconds
export const SHORT_SMS_SCORE = 0.1; // SMS call type
export const SHORT_CONTENT_SCORE = 0.2; // SMS body < 10 characters
export const URGENT_KEYWORD_SCORE = 0.3; // Contains urgent/act now/limited keywords
/** Default Fallback Values */
export const DEFAULT_EVALUATION_TIMEOUT = 200; // milliseconds
export const DEFAULT_FALLBACK_DECISION = 'ALLOW';
export const DEFAULT_FALLBACK_ON_TIMEOUT = true;