-
Notifications
You must be signed in to change notification settings - Fork 59
Audit System
The Audit System automates pattern validation, deduplication detection, and approval workflows. It reduces manual review burden by intelligently recommending which patterns to approve while maintaining human oversight.
# Run a scan first
drift scan
# Run audit to analyze patterns
drift audit
# Auto-approve high-confidence patterns (β₯90%)
drift approve --auto
# Or use MCP tool
drift_audit action="run"Run a full audit on discovered patterns.
drift audit [options]
Options:
--review Generate review report for agent or human
--ci CI mode - exit 1 if health below threshold
--threshold <number> Health score threshold for CI (default: 85)
--export <file> Export audit to fileShow current audit status and health score.
drift audit statusOutput:
π Audit Status
βββββββββββββββββββββββββββββββββββββββββββββββ
Health Score: 87/100 β
Total Patterns: 127
Auto-approve eligible: 89 (β₯90% confidence)
Needs review: 28
Likely false positives: 10
Duplicate candidates: 5
Last audit: 2 hours ago
Show quality trends over time.
drift audit trendsAuto-approve patterns meeting the confidence threshold.
drift approve --auto [options]
Options:
--threshold <number> Confidence threshold (default: 0.90)
--dry-run Show what would be approved without approving
--categories <list> Limit to specific categories// Check audit status
drift_audit action="status"
// Run full audit
drift_audit action="run"
// Auto-approve recommended patterns
drift_audit action="approve-recommended" threshold=0.90
// View quality trends
drift_audit action="trends"| Action | Description |
|---|---|
status |
Show current audit status (health score, eligible patterns) |
run |
Run a full audit on discovered patterns |
approve-recommended |
Auto-approve patterns with β₯90% confidence |
trends |
Show quality trends over time |
| Parameter | Type | Default | Description |
|---|---|---|---|
action |
string | required | Action to perform |
threshold |
number | 0.90 | Confidence threshold for auto-approve |
compareToPrevious |
boolean | true | Compare to previous audit for degradation detection |
categories |
string[] | all | Categories to audit |
The health score (0-100) is calculated from:
| Factor | Weight | Description |
|---|---|---|
| Average Confidence | 30% | Mean confidence across all patterns |
| Approval Ratio | 20% | Approved patterns / Total patterns |
| Compliance Rate | 20% | Locations / (Locations + Outliers) |
| Cross-Validation | 15% | Patterns matching call graph |
| Duplicate-Free | 15% | Non-duplicate patterns |
- 85-100: Excellent - patterns are well-validated
- 70-84: Good - some patterns need review
- 50-69: Fair - significant review needed
- 0-49: Poor - many issues detected
The audit generates recommendations for each pattern:
| Recommendation | Confidence | Action |
|---|---|---|
auto-approve |
β₯90% | Safe to approve automatically |
review |
70-89% | Needs human review |
likely-false-positive |
<70% | Probably not a real pattern |
The audit detects duplicate patterns that may have been found by different detectors:
{
"duplicates": [
{
"patterns": ["pattern-abc", "pattern-def"],
"similarity": 0.92,
"reason": "Same file locations, different detector names",
"recommendation": "merge"
}
]
}Patterns are validated against:
- Call Graph: Does the pattern appear in the call graph?
- Constraints: Does it align with architectural constraints?
- Test Coverage: Is the pattern covered by tests?
name: Drift Quality Gate
on: [push, pull_request]
jobs:
drift-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Drift
run: npm install -g driftdetect
- name: Run Drift Scan
run: drift scan --incremental
- name: Run Drift Audit
run: drift audit --ci --threshold 85| Code | Meaning |
|---|---|
| 0 | Health score meets threshold |
| 1 | Health score below threshold |
Audit data is stored in .drift/audit/:
.drift/audit/
βββ latest.json # Current audit state
βββ snapshots/ # Historical audits
β βββ YYYY-MM-DD.json
βββ degradation.json # Quality trends
After running drift scan, you'll see a prompt:
π Scan Complete
ββββββββββββββββββββββββββββββββββββββββββββββββββ
Patterns discovered: 127
Auto-approve eligible: 89 (β₯90% confidence)
Needs review: 28
? Would you like an agent to help review and approve patterns? (Y/n)
If you select yes, you'll get instructions to copy to your AI assistant:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Run `drift audit --review` and approve high-confidence β
β patterns that match codebase conventions. Flag any that β
β look like false positives or duplicates. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- drift_patterns_list - List all patterns
- drift_quality_gate - Run quality gates on changes
- drift_constraints - Manage architectural constraints
- drift_status - Get codebase health overview
- Cortex V2 Overview
- Memory Setup Wizard
- Memory CLI
- Universal Memory Types
- Learning System
- Token Efficiency
- Causal Graphs
- Code Generation
- Predictive Retrieval
- Architecture
- Call Graph Analysis
- Impact Analysis
- Security Analysis
- Data Boundaries
- Test Topology
- Coupling Analysis
- Error Handling Analysis
- Wrappers Detection
- Environment Variables
- Constants Analysis
- Styling DNA
- Constraints
- Contracts
- Decision Mining
- Speculative Execution
- Watch Mode
- Trends Analysis
- Projects Management
- Package Context
- Monorepo Support
- Reports & Export
- Dashboard
- 10 Languages
- 21 Frameworks
- 16 ORMs
- 400+ Detectors
- 50+ MCP Tools
- 60+ CLI Commands
- 23 Memory Types