lvd-diagram: A Layer Diagram You Cannot Flatter, and a Volatility Heatmap
lvd-diagram draws layer diagrams from the real dependency graph, and its heatmap overlays git history to show where code changes more than its layer predicts.
"Is our architecture in good shape?" is usually answered with a shrug, or with whichever opinion is loudest in the meeting. Opinions do not make a good gate in a build pipeline. Numbers do, provided they are few, well defined and tied to the thing you actually care about. lvd-metrics offers five.
The tool computes each metric with a fixed definition and a recommended target.
The book calls VA the flagship metric, since it asks whether the real dependency graph respects the ordering the whole model is built on. A score under the target points to systematic misalignment between the architecture and the way the code really changes.
CIR is the one developers feel. If changing a single file regularly means editing a dozen others, the layering is not containing change, whatever the diagram says. It is calculated over the last n commits, and n is configurable.
Running the analysis prints a boxed report with each metric, its value, its target and a pass or fail status, followed by a per-layer breakdown of coverage, cohesion and alignment.
# the full report
lvd-metrics analyse
# pass or fail against your thresholds
lvd-metrics gate --config .lvd-gates.yml
The second command is the one for a pipeline. Thresholds live in a .lvd-gates.yml file, where each gate carries a limit and a severity. The same file can set different coverage targets for each layer, which matches the differentiated targets described in the LVD testing pyramid, and it can hold a trends section too.
The trends idea is the most practical thing in the chapter. A fixed threshold only tells you when the damage has been done. Imagine a ticketing service whose alignment score is 98 per cent in spring, 97 in summer and 96 in autumn. Every build passes its 95 per cent gate, yet the line is clearly heading for the floor. A trend report would flag that drift while there is still room to act, and the gate configuration can raise an early warning when a metric degrades by more than a set amount even if the absolute limit still holds.
To make that possible the tool keeps its results in a history file, .lvd-metrics-history.json, or in an external store for larger organisations. The trend command compares current values with averages over the last 30, 60 and 90 days and marks each metric as improving or worsening, taking into account that lower is better for CIR and DCC while higher is better for the rest.
lvd-metrics trend --window 90d
This is also how a migration proves itself. If a team is untangling a legacy codebase, a trend report shows whether the refactoring is producing measurable results rather than just feeling productive. The migration articles pick that thread up in assessing a codebase before you migrate.
For dashboards and other tooling the tool can export a JSON report containing each metric with its value, target and pass flag. The book's pipeline examples use the form lvd-metrics analyse --format json --output metrics-report.json, then feed the file into a pull request comment.
The linter tells you which import is wrong. The metrics tool tells you whether the codebase as a whole is getting healthier or sicker. Use both: lvd-lint for the individual violation, lvd-metrics for the direction of travel, and a gate to make sure the direction stays right.