Skip to content

feat: add ctx hotspots — churn × complexity ranking#4

Merged
saldestechnology merged 4 commits into
mainfrom
feat/hotspots
Jul 9, 2026
Merged

feat: add ctx hotspots — churn × complexity ranking#4
saldestechnology merged 4 commits into
mainfrom
feat/hotspots

Conversation

@saldestechnology

Copy link
Copy Markdown
Collaborator

Summary

PR 3 of 7 in the Quality Intelligence Suite. Stacked on #2 (feat/quality-foundation) — will be retargeted to main once #2 merges; review only the top 2 commits until then.

  • New ctx hotspots command ranking indexed files (or symbols with --by symbol) by churn × complexity: churn from git log --since history, complexity from the index (fan_out*2 + fan_in, same formula as the DuckDB analytics, computed in plain SQLite so it works on Windows builds too).
  • score = minmax(churn) × minmax(complexity); deterministic ordering with documented tie-breaks.
  • --since (default "6 months ago"), --limit, --min-churn, --against <REF> for diff-scoped use, global --json (entries include the top-3 most complex symbols per file as SymbolRefs).
  • Documented v1 approximations: symbol churn = file churn; renames reset churn (--no-renames).
  • Exit codes: 0 on success (informational), 2 on operational error (non-git dir, bad ref) — stated in --help.

Test plan

  • 13 unit tests (scoring, normalization degenerate cases, tie-breaks, JSON shapes) + 5 end-to-end tests driving the compiled binary against scripted-history git fixtures (dated commits for --since, non-git exit 2 with empty stdout, --by symbol, --min-churn).
  • cargo test (198 green), clippy -D warnings, fmt --check, --no-default-features build — all clean.

🤖 Generated with Claude Code

Combines git commit churn (via gitutil::churn_since) with indexed
complexity metrics into score = normalized_churn * normalized_complexity,
min-max normalized over the analyzed set. Supports --since, --limit,
--min-churn, --against REF, --by file|symbol, and the global --json flag.

Informational command: exits 0 on success, 2 on operational errors
(not a git repo, missing index, bad ref). --by symbol approximates a
symbol's churn by its file's commit count (documented v1 limitation),
and --no-renames means renames reset churn counts.

Also extends the GitRepo test helper with commit_all_with_date for
testing --since windows, and adds end-to-end CLI tests that index real
git fixtures.
@saldestechnology
saldestechnology deleted the branch main July 9, 2026 15:38
@saldestechnology
saldestechnology changed the base branch from feat/quality-foundation to main July 9, 2026 15:40
# Conflicts:
#	CHANGELOG.md
#	docs/json-output.md
#	src/main.rs
@saldestechnology
saldestechnology merged commit 43e8527 into main Jul 9, 2026
5 checks passed
@saldestechnology
saldestechnology deleted the feat/hotspots branch July 9, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant