feat(who): expand expert + overlap queries with mr_file_changes and mr_reviewers

Chain: bd-jec (config flag) -> bd-2yo (fetch MR diffs) -> bd-3qn6 (rewrite who queries)

- Add fetch_mr_file_changes config option and --no-file-changes CLI flag
- Add GitLab MR diffs API fetch pipeline with watermark-based sync
- Create migration 020 for diffs_synced_for_updated_at watermark column
- Rewrite query_expert() and query_overlap() to use 4-signal UNION ALL:
  DiffNote reviewers, DiffNote MR authors, file-change authors, file-change reviewers
- Deduplicate across signal types via COUNT(DISTINCT CASE WHEN ... THEN mr_id END)
- Add insert_file_change test helper, 8 new who tests, all 397 tests pass
- Also includes: list performance migration 019, autocorrect module, README updates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Taylor Eernisse
2026-02-08 13:35:14 -05:00
parent 435a208c93
commit 95b7183add
19 changed files with 2139 additions and 291 deletions

View File

@@ -0,0 +1,13 @@
-- Standalone updated_at DESC indexes for ORDER BY without temp B-tree sort.
-- The existing composite indexes (project_id, updated_at) only help when
-- filtering by project first.
CREATE INDEX IF NOT EXISTS idx_issues_updated_at_desc
ON issues(updated_at DESC);
CREATE INDEX IF NOT EXISTS idx_mrs_updated_at_desc
ON merge_requests(updated_at DESC);
-- Covering index for correlated subquery: unresolved discussion count per issue.
-- MRs already have idx_discussions_mr_resolved (migration 006).
CREATE INDEX IF NOT EXISTS idx_discussions_issue_resolved
ON discussions(issue_id, resolvable, resolved);

View File

@@ -0,0 +1,7 @@
-- Migration 020: Watermark column for MR diffs sync
-- Tracks which MRs have had their file changes fetched, same pattern as closes_issues_synced_for_updated_at
ALTER TABLE merge_requests ADD COLUMN diffs_synced_for_updated_at INTEGER;
INSERT INTO schema_version (version, applied_at, description)
VALUES (20, strftime('%s', 'now') * 1000, 'MR diffs sync watermark');