# File Hotspot Report - **Command:** `lore hotspots [--since ]` - **Confidence:** 85% - **Tier:** 2 - **Status:** proposed - **Effort:** low — single query on mr_file_changes (requires Gate 4 population) ## What Rank files by frequency of appearance in merged MRs over a time window. Show change_type breakdown (modified vs added vs deleted). Optionally filter by project. ## Why Hot files are where bugs live. This is a proven engineering metric (see "Your Code as a Crime Scene" by Adam Tornhill). High-churn files deserve extra test coverage, better documentation, and architectural review. ## Data Required - `mr_file_changes` (new_path, change_type, merge_request_id) — needs Gate 4 population - `merge_requests` (merged_at, state='merged') ## Implementation Sketch ```sql SELECT mfc.new_path, p.path_with_namespace, COUNT(*) as total_changes, SUM(CASE WHEN mfc.change_type = 'modified' THEN 1 ELSE 0 END) as modifications, SUM(CASE WHEN mfc.change_type = 'added' THEN 1 ELSE 0 END) as additions, SUM(CASE WHEN mfc.change_type = 'deleted' THEN 1 ELSE 0 END) as deletions, SUM(CASE WHEN mfc.change_type = 'renamed' THEN 1 ELSE 0 END) as renames, COUNT(DISTINCT mr.author_username) as unique_authors FROM mr_file_changes mfc JOIN merge_requests mr ON mfc.merge_request_id = mr.id JOIN projects p ON mfc.project_id = p.id WHERE mr.state = 'merged' AND mr.merged_at >= ?1 GROUP BY mfc.new_path, p.path_with_namespace ORDER BY total_changes DESC LIMIT ?2; ``` ## Human Output ``` File Hotspots (last 90 days, top 20) File Changes Authors Type Breakdown src/auth/middleware.rs 18 4 14 mod, 3 add, 1 del src/api/routes.rs 15 3 12 mod, 2 add, 1 rename src/db/migrations.rs 12 2 8 mod, 4 add tests/integration/auth_test.rs 11 3 9 mod, 2 add ``` ## Downsides - Requires `mr_file_changes` to be populated (Gate 4 ingestion) - Doesn't distinguish meaningful changes from trivial ones (formatting, imports) - Configuration files (CI, Cargo.toml) will rank high but aren't risky ## Extensions - `lore hotspots --exclude "*.toml,*.yml"` — filter out config files - `lore hotspots --dir src/auth/` — scope to directory - Combine with `lore silos` for risk scoring: high churn + bus factor 1 = critical - Complexity trend: correlate with discussion count (churn + many discussions = problematic)