Skip to content

fix(mcp): weight hotspots by file churn - #3070

Open
devin-ai-integration[bot] wants to merge 3 commits into
masterfrom
devin/1791125982-hotspots-churn
Open

devin-ai-integration[bot] wants to merge 3 commits into
masterfrom
devin/1791125982-hotspots-churn

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • tracedecay_hotspots now ranks by score = total * (churn + 1). churn is the 90-day commit count for the symbol's file, read from the existing file_churn miner that test_risk already uses. Ties fall back to total, then to id.
  • Each HotspotV1 row now includes churn and score, so callers can see both factors.

Fixes #3011

Motivation

The module doc said "churn-weighted complexity ranking", but the sort used only incoming plus outgoing edge counts and never read git history. A heavily connected symbol that never changes outranked a moderately connected one that changes every week. The second case is the usual meaning of a hotspot.

Changes

  • crates/tracedecay-mcp/src/handlers/analysis/hotspots.rs: build the rows with churn/score, then sort and truncate them. file_churn errors propagate the same way they do in test_risk; a project that is not a repo, or has no commits yet, gets churn = 0, so score equals total there.
  • HotspotV1 contract: added churn and score. Regenerated sdks/typescript/src/operations.ts with sdks/codegen.
  • Rewrote the catalog and tool descriptions, the module doc and docs/USER-GUIDE.md to describe the churn-weighted ranking.

Test plan

  • New mcp_handler_test::graph_analysis_test::hotspots_weights_connectivity_by_file_churn: stable.ts (committed once) holds hub with 3 edges, and churned.ts (committed 3 times) holds mid with 2 edges. Through production MCP tools/call, mid (churn 3, score 8) ranks above hub (churn 1, score 6).
    • It fails on master with the product changes stashed: hub is ranked first and the rows have no churn/score fields.
    • It passes with this branch: bash scripts/require-exact-test.sh cargo test -p tracedecay --features test-transport --test mcp_suite mcp_handler_test::graph_analysis_test::hotspots_weights_connectivity_by_file_churn -- --exact (1 passed).
  • Updated hotspots_ranks_symbols_by_edge_degree_and_clamps_limit to the new literal churn/score values (single-commit fixtures, so churn is 1) and the new markdown field order. Passes under require-exact-test.sh.
  • cargo clippy -p tracedecay-mcp -p tracedecay-contracts -p tracedecay-mcp-catalog --all-targets -- -D warnings and cargo clippy -p tracedecay --features test-transport --test mcp_suite -- -D warnings are clean.
  • cargo test -p tracedecay-contracts -p tracedecay-mcp-catalog passes, and so does cargo test in sdks/codegen (codegen parity).
  • cargo fmt --all -- --check and node scripts/lint-commit-range.mjs --repository . origin/master HEAD both pass.

Checklist

  • CHANGELOG.md updated (under [Unreleased] if no version bump)
  • No secrets, credentials, or .env files included
  • Breaking changes documented (if any): HotspotV1 gains two required output fields (additive for readers)

Link to Devin session: https://app.devin.ai/sessions/78b7824a1ea149d1986e4c22568e80e1
Open in Devin Desktop: https://app.devin.ai/desktop/session/78b7824a1ea149d1986e4c22568e80e1?variant=devin
Requested by: @ScriptedAlchemy


Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@changeset-bot

changeset-bot Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1f0b113

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

devin-ai-integration[bot]

This comment was marked as resolved.

ScriptedAlchemy and others added 3 commits October 4, 2026 15:50
tracedecay_hotspots documented a churn-weighted ranking but sorted by
edge count only. Rank by score = total * (churn + 1), where churn is
the 90-day commit count from file_churn, and report churn and score per
row.

Fixes #3011

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1791125982-hotspots-churn branch from ee118ff to 1f0b113 Compare October 4, 2026 16:00

This branch has not been deployed

No deployments
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.

hotspots: documented as churn-weighted but ranks by edge count only

1 participant