Overview
Yggdrasil learns from your reviews. Every time you approve or dismiss a violation, the system updates a per-rule precision model using Bayesian inference:The Problem: Cold Start
New rules have no historical data. Traditional ML approaches require:- Hundreds of labeled examples
- Model retraining
- A/B testing
- Manual threshold tuning
- New rules start with a precision of 0.5 (neutral)
- The first review immediately shifts confidence
- No “warm-up” period — rules fire from day one
The Formula
Components
- True Positives (TP): User clicked “Approve” → violation was correct
- False Positives (FP): User clicked “Dismiss” → violation was wrong
- Bayesian Priors:
+1to numerator,+2to denominator (Beta distribution) - History Weight: Increases with review count (caps at 70%)
Why Bayesian?
Problem: Without priors, a rule with 1 TP and 0 FP would have 100% precision. Bayesian solution: Add pseudo-counts to smooth the estimate:Example: Early Reviews
| TP | FP | Precision (naive) | Precision (Bayesian) |
|---|---|---|---|
| 1 | 0 | 1.00 (overconfident) | 0.67 (realistic) |
| 2 | 0 | 1.00 (overconfident) | 0.75 |
| 0 | 1 | 0.00 (underconfident) | 0.33 |
| 5 | 1 | 0.83 | 0.75 |
| 10 | 2 | 0.83 | 0.79 |
Review Flow
1. User Reviews Violation
In the violation detail page, the user clicks:- Approve → True positive
- Dismiss → False positive
2. API Updates Counters
3. Database RPC
Theincrement_rule_stat function atomically increments the counter:
4. Next Scan Uses Updated Precision
The next time the rule runs:History Weight
The system gradually trusts history more as reviews accumulate:Weight Curve
| Reviews | History Weight | Rule Quality Weight |
|---|---|---|
| 0 | 0% | 100% |
| 5 | 25% | 75% |
| 10 | 50% | 50% |
| 15 | 75% (capped) | 25% |
| 20+ | 70% (capped) | 30% |
Why Cap at 70%?
Rule quality captures structural information:- Does the rule have a threshold?
- Does it combine multiple signals?
- Is it well-documented?
Example: Rule Lifecycle
Stage 1: New Rule (0 Reviews)
Stage 2: Early Feedback (5 Approvals, 1 Dismissal)
Stage 3: Established Rule (20 Approvals, 2 Dismissals)
Stage 4: Noisy Rule (10 Approvals, 20 Dismissals)
Impact on Ranking
Violations are sorted by confidence:Automatic Rule Tuning
No manual intervention required:| Scenario | System Response |
|---|---|
| Rule is too noisy | Confidence drops → violations ranked lower |
| Rule catches real issues | Confidence rises → violations prioritized |
| Rule needs refinement | Low precision signals need for review |
| Rule is perfect | High precision → trust increases |
Multi-User Feedback
If multiple users review the same rule:Feedback Loop Timeline
Database Schema
Therules table stores feedback counters:
Compliance Score Impact
Reviewing violations as false positives improves the compliance score:Score History
Thescans table tracks score changes:
Why This Works
1. No Model Retraining
Bayesian updates are instant. No need to:- Export training data
- Run expensive model training
- Deploy updated models
- A/B test new versions
2. No Threshold Tuning
Traditional systems require manual threshold adjustments:3. Transparent
Users can see:- Total reviews per rule
- Precision score
- How confidence is calculated
Limitations
1. Requires Human Feedback
The system only improves if users review violations. Zero reviews → no learning. Mitigation: Prioritize high-confidence violations for review first.2. Assumes i.i.d. Data
If your dataset changes dramatically (e.g., new transaction types), historical precision may not generalize. Mitigation: Track precision per scan and alert on sudden drops.3. No Cross-Rule Learning
If Rule A and Rule B are similar, feedback on Rule A doesn’t affect Rule B. Future work: Cluster rules by similarity and share feedback signals.Monitoring Rule Health
Use these metrics to identify problem rules:| Metric | Red Flag |
|---|---|
| Precision < 0.4 | Rule is too noisy |
| 0 reviews after 100 violations | Rule needs attention |
| Precision dropping over time | Dataset drift or rule decay |
| High violation count + low precision | Disable rule, refine conditions |
Next Steps
Confidence Scoring
See how Bayesian precision fits into the full confidence formula
Rule Types
Learn how different rule types are executed