Skip to content

Improve community detection quality with typed Leiden - #314

Merged
forhappy merged 3 commits into
mainfrom
codex/community-detection-quality
Sep 12, 2026
Merged

Improve community detection quality with typed Leiden#314
forhappy merged 3 commits into
mainfrom
codex/community-detection-quality

Conversation

@forhappy

Copy link
Copy Markdown
Contributor

Summary

  • replace typed-graph production clustering with deterministic fixed-resolution Leiden over a versioned typed-evidence topology
  • add bounded quality evaluation, connectedness validation, candidate selection, incremental frozen anchors, and explicit full-run fallbacks
  • publish strict graph-bound compass.community-quality/1 evidence across normal, cluster-only, viewer, MCP, and immutable-history paths
  • retain seeded Louvain as the compatibility profile and keep three-candidate automatic resolution qualification-only

Motivation

The prior Louvain path treated most relationship evidence alike and could not demonstrate whether a changed partition improved connectivity, separation, stability, or reviewed planted expectations. This change implements the phased community-detection quality design while preserving Base Graph identity, direction, multiplicity, anchors, and provenance.

The fixed Leiden profile improves exact planted recovery from 7/12 to 10/12 and mean ARI from 0.746 to 0.901 in the matched fixture comparison. It records one false merge and one false split versus seven and three under compatibility Louvain. Automatic multi-resolution selection remains outside production because the compact timing gate did not qualify it.

Verification

cargo fmt --all -- --check
cargo clippy --workspace --lib --bins --locked -- -D warnings
cargo test --workspace --lib --bins --locked
cargo test -p compass-graph --locked
cargo test -p compass-core --test code_graph_v1_determinism --locked
cargo test -p compass-cli --test history_cli --locked
cargo test -p compass-cli --test viewer_export_cli --locked
cargo test -p compass-cli --test compass_product --locked
sh scripts/check_product_boundary.sh
./scripts/qualify_code_graph_v1.sh --fixtures-only
./scripts/qualify_code_graph_v1.sh --community-quality --report docs/implementation/community-detection-quality-qualification.json
npm run typecheck:js
npm run test:js
node scripts/check_viewer_assets.mjs

All listed checks passed before rebasing onto current main. After rebase, 77 graph unit tests, 14 history round-trip tests, 10 cluster-only tests, formatting, and cargo check -p compass-cli --lib --locked passed. A repeated full CLI test build was interrupted by the mounted build volume filling while unpacking parser sources; the narrower post-rebase CLI check then passed from a cleaned worktree-specific target.

The available pinned kache real-repository timing attempt did not reach a completed publication in either clustered or --no-cluster control form, so no real-corpus clustering performance claim is made. This omission is recorded in the qualification report.

Compatibility and documentation

Community membership, IDs, labels, architecture grouping, and derived reports can change when the new profile rebuilds a graph. Existing historical realizations remain immutable. The complete profile now participates in build identity, and strict readers validate the quality artifact schema, profile, graph generation, and digest.

Updated documentation includes the technical design, community-detection concept, qualification report, command/output references, compatibility ledger, migration guide, changelog, and performance notes.

Checklist

  • The change is focused and excludes unrelated formatting or generated files
  • Tests cover changed behavior, or this pull request changes documentation only
  • User-facing commands, flags, limits, and examples are documented
  • Compatibility or migration effects are described
  • No credentials, private source code, or sensitive report details are included
  • I agree to license my contribution under MIT OR Apache-2.0
  • I followed the Compass code of conduct

@forhappy
forhappy merged commit bc93f09 into main Sep 12, 2026
14 checks passed
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