feat: replace BFS with Louvain clustering#211
Merged
Conversation
WHY The previous BFS-based clustering treated every connected component as a single cluster, ignoring community structure within large components. This resulted in oversized chunks that exceeded the `maxFilesPerChunk` limit and failed to group files by semantic density. WHAT * Replaced BFS traversal with a three-stage pipeline: Louvain community detection, bridge merging (weight > 500), and greedy splitting. * Implemented deterministic Louvain modularity optimization using sorted node ordering for reproducible cluster assignments. * Added `mergeBridgeClusters` to rejoin communities connected by strong semantic links that Louvain might have separated. * Assigned `c.maxFilesPerChunk` to `c.unifiedPass.maxFilesPerChunk` in the chunker configuration.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
4 tasks
…212) ## Chain Context | Field | Value | |-------|-------| | Chain | graph-clustering | | Tracker PR | #210 | | Position | 2 of 2 | | Base | `feat/graph-clustering-01-core` | | Depends on | #211 (core) | | Follow-up | None | | Review budget | 331 / 400 | | Starts at | #211 (core implementation) | | Ends with | Full test coverage + cleanup | ### Chain Overview ``` main └── #210 Tracker PR (draft) └── #211 Core implementation └── 📍 #212 This PR (tests) ``` ### Scope - Includes: Unit tests for louvainClusters, mergeBridgeClusters, splitOversizedClusters, integration test for createClusters end-to-end - Excludes: Production code changes ### Autonomy - [x] CI is expected to pass for this PR branch - [x] This PR has one deliverable scope - [x] This PR can be rolled back without unrelated changes - [x] Tests, docs, or manual verification cover this unit --- Closes #208
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Chain Context
feat/graph-clusteringChain Overview
Scope
Autonomy
Closes #208