Skip to main content

Module trend

Module trend 

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

Historical metric trend: the change-history (VCS) metrics computed at several points in time, so a consumer can see whether a file’s risk is improving or degrading rather than only its risk now (issue #333).

This module is backend-agnostic. It owns the time-point math (timestamps), the parameter validation (validate_points), the assembled Trend container, and the improving/regressing delta summary. The actual repeated history walks live in the backend (git::build_trend), which resolves the repository tip at each point in time and folds the per-snapshot Stats into a Trend via Trend::from_snapshots.

Structs§

Trend
The change-history metrics of a set of files sampled at several points in time (issue #333).
TrendDelta
One file’s risk-score movement across the trend (see Trend::deltas).
TrendDeltas
The improving / regressing split returned by Trend::deltas.

Constants§

MAX_TREND_POINTS
Maximum number of time points. Each point is a full history walk, so the count is capped to bound the worst-case runtime on deep histories (issue #333’s “very deep histories: cap point count”). 120 points is a decade of monthly snapshots — far beyond any practical trend chart.
MIN_TREND_POINTS
Minimum number of time points. A trend needs at least two snapshots to express a direction; a single point is just bca vcs --as-of.
TREND_SCHEMA_VERSION
Output-shape version for the trend document. Bumped on any shape-breaking change to the serialized time series so consumers can detect an incompatible schema (separate from the per-file VCS_SCHEMA_VERSION, which versions each point’s metric block).

Functions§

timestamps
The points Unix-second timestamps a trend samples, evenly spaced across span_secs and ending at end (the most recent point is exactly end, the oldest is end - span_secs). Returned oldest-first.
validate_points
Validate a requested point count against the MIN_TREND_POINTS / MAX_TREND_POINTS bounds. The single source of truth shared by every front end so the accepted range cannot drift between them.