Drift Detection
How Koalr identifies when CODEOWNERS files diverge from actual file ownership based on commit activity.
Drift detection identifies when the owners declared in your CODEOWNERS files no longer reflect who is actually contributing to those files. Over time, teams change, codebases evolve, and CODEOWNERS files go stale — drift detection surfaces these discrepancies before they become governance problems.
What drift means
A drift event occurs when Koalr detects a meaningful gap between:
- Declared ownership — the owners listed in the CODEOWNERS file for a given file or directory pattern.
- Actual ownership — the set of contributors who have committed to those files in the past 90 days, weighted by commit count and recency.
For example: if src/payments/** is declared as owned by @alice, but @bob and @carol have made 85% of the commits to that directory in the past 90 days, Koalr will flag this as drift. The CODEOWNERS file says one thing; recent commit history says another.
How drift is detected
Koalr runs a scheduled drift check daily at 3 AM UTC across all connected repositories. The check:
- Reads the current CODEOWNERS file for each repository.
- Queries the last 90 days of commit history, grouped by file path and author.
- For each CODEOWNERS pattern, computes the actual top contributors to matching files.
- Compares declared owners to actual contributors.
- If the declared owners account for less than 20% of recent commits to a file group, a drift event is created.
The 20% threshold prevents false positives — a declared owner who is still actively contributing at a lower rate is not flagged as drift.
Drift event log
All drift events are recorded in the CODEOWNERS dashboard under the Drift tab. Each event shows:
- Repository and the specific file pattern affected
- Declared owners — who the CODEOWNERS file says should own this code
- Actual top contributors — who has been committing to this code recently
- Drift severity — calculated from the gap between declared and actual ownership
- First detected — when Koalr first identified the drift
- Status — Open, Acknowledged, or Resolved
Drift events remain in the log until the CODEOWNERS file is updated to reflect the current ownership patterns, at which point Koalr automatically marks them as Resolved.
Drift severity levels
| Severity | Description |
|---|---|
| Low | Declared owner is still contributing but others have taken on most of the work |
| Medium | Declared owner has made fewer than 10% of recent commits to the affected files |
| High | Declared owner has made zero commits to the affected files in the past 90 days |
High-severity drift events also trigger a Slack notification if you have the CODEOWNERS drift alert channel configured. See Slack Integration for setup instructions.
How to resolve drift
Drift is resolved by updating the CODEOWNERS file to reflect actual ownership. The typical resolution workflow:
- Review the drift event in Koalr to identify the affected file patterns and the contributors who should be declared as owners.
- Update the CODEOWNERS file in the repository (
.github/CODEOWNERSis the recommended location). - Push the change to the default branch.
- Koalr detects the push, re-syncs the CODEOWNERS file within 60 seconds, and re-evaluates drift for the affected patterns.
- If the updated CODEOWNERS file aligns with actual commit patterns, the drift event is automatically marked as Resolved.
Acknowledging drift without resolving it
Sometimes drift is intentional — an engineer may own code conceptually even if they have not committed to it recently (for example, an architect who reviews but does not author code). You can acknowledge a drift event without resolving it by clicking Acknowledge in the drift log. Acknowledged events remain visible but are excluded from the ownership health score penalty.
Drift and the ownership health score
Open drift events reduce a repository's ownership health score. High-severity open drift events have the greatest impact. Resolving or acknowledging drift events improves the health score. See Syncing CODEOWNERS Files for the full health score breakdown.