ComplianceEngine
class provides offline compliance monitoring with built-in and custom rules for banking and financial services. It evaluates agent interactions against regulatory requirements like PII detection, fair lending, and BSA/AML compliance.
Constructor
ComplianceEngine(config)
Creates a new ComplianceEngine instance with the specified configuration.Configuration object for the compliance engine.
Core Methods
evaluateInteraction(context)
Evaluates an agent interaction against all active compliance rules.The interaction context to evaluate for compliance violations.
ComplianceResult
Example:
Rule Management
addRule(rule)
Adds a new compliance rule to the engine or updates an existing rule.The compliance rule to add or update.
void
Example:
removeRule(ruleId)
Removes a compliance rule from the engine.The ID of the rule to remove.
boolean
- True if the rule was found and removed, false otherwise.
Example:
setRuleActive(ruleId, isActive)
Activates or deactivates a compliance rule without removing it.The ID of the rule to activate/deactivate.
Whether the rule should be active.
boolean
- True if the rule was found and updated, false otherwise.
Example:
getActiveRules()
Returns all currently active compliance rules. Returns:ComplianceRule[]
Example:
getAllRules()
Returns all compliance rules (both active and inactive). Returns:ComplianceRule[]
Example:
getRule(ruleId)
Retrieves a specific compliance rule by ID.The ID of the rule to retrieve.
ComplianceRule | undefined
Example:
Built-in Compliance Rules
The ComplianceEngine comes with several built-in rules for common banking compliance requirements:PII Detection Rules
privacy-pii-detection
privacy-pii-detection
Category: privacy
Severity: violation
Description: Detects potential PII like phone numbers and emails
Patterns: Email addresses, phone numbers (US format)
Risk Score: 15-20 points per detection
ssn-validation
ssn-validation
Category: privacy
Severity: violation
Description: Robust SSN validation with format checking
Patterns: Valid SSN formats, excludes known invalid ranges
Risk Score: 50 points per valid SSN detected
Fair Lending Rules
fair-lending-keywords
fair-lending-keywords
Category: fair_lending
Severity: violation
Description: Detects potentially discriminatory language
Patterns: “people like you”, “your kind”, “typical for”, “based on your background”
Risk Score: 60 points per discriminatory phrase
BSA/AML Rules
Additional BSA/AML rules can be added through custom rule implementation.Custom Rule Examples
Advanced PII Detection
BSA/AML Suspicious Activity Detection
Consumer Protection Rule
ComplianceResult Type
The result returned byevaluateInteraction()
and rule functions:
Best Practices
Rule Development
Rule Development
- Keep rules focused: Each rule should check for one specific type of violation
- Use descriptive IDs: Rule IDs should be clear and consistent
- Provide context: Include relevant context in violation objects
- Test thoroughly: Test rules with various input scenarios
- Document patterns: Clearly document what patterns trigger violations
Performance Optimization
Performance Optimization
- Optimize regex patterns: Use efficient regular expressions
- Cache compiled patterns: Pre-compile complex patterns in rule constructors
- Limit text processing: Only process relevant text content
- Set appropriate severity: Use ‘info’ for low-impact violations
- Batch evaluations: Process multiple interactions efficiently
Compliance Management
Compliance Management
- Regular rule updates: Keep rules current with regulatory changes
- Audit trail: Log all rule changes and activations
- False positive monitoring: Track and reduce false positives
- Risk scoring consistency: Use consistent risk scoring across rules
- Review thresholds: Set appropriate review thresholds for your organization
Banking Compliance
Banking Compliance
- Stay current: Keep up with regulatory guidance and changes
- Industry standards: Follow established compliance patterns
- Documentation: Maintain thorough documentation of compliance procedures
- Human oversight: Always include human review for high-risk violations
- Regular auditing: Perform regular compliance audits and assessments