Skip to main content

Module entropy

Module entropy 

Source
Available on crate feature vcs-git only.
Expand description

Shannon-entropy machinery shared by the two process-entropy signals added in issue #330.

Two distinct metrics are built on the same shannon_entropy core:

  • Change entropy (Hassan, 2009 — Predicting Faults Using the Complexity of Code Changes). Per commit, the entropy of the churn distribution across the files it touched measures how scattered that change was. Each file is then credited its History-Complexity share pᵢ · H of every commit it took part in (Hassan’s HCM with the modification-probability attribution factor). The git backend computes the per-commit term; this module only supplies the entropy core so the math is unit-testable without a repository.
  • Co-change graph entropy (arXiv 2504.18511, 2025). Files that change in the same commit are joined by a weighted edge (weight = number of shared commits). A file’s co-change entropy is the Shannon entropy of its edge-weight distribution: low when it always co-changes with the same partner, high when its changes ripple across many different files. CochangeGraph accumulates the edges during the single history walk and computes the per-file value at finalisation.

All entropies are in bits (base-2 logarithm), the convention in both source papers.

Structs§

CochangeGraph
A sparse, undirected, weighted co-change graph built incrementally across a history walk.
FileId
Interned identifier for a file participating in the co-change graph.

Constants§

MAX_COCHANGE_COMMIT_FILES
Initial-import commits touch thousands of files at once; a co-change graph grows O(width²) in commit width, so commits wider than this are excluded from the graph (only — their change entropy, which is O(width), is still counted). Tuned per issue #330’s worked example.

Functions§

shannon_entropy
Shannon entropy (base 2, in bits) of a weight distribution.