Function report_key
pub fn report_key(
head_sha: &str,
changes: &[WorktreeChange],
opts: &Options,
) -> Result<String>Expand description
The content key for a change set: lowercase-hex SHA-256 of
head_sha | sorted "path\0content-sha256" lines | crate version |
calib=<digest> | rows_limit=<n> | opts=<canonical-json digest> |
[KEY_SCHEMA]. A deleted path contributes the literal "deleted" in
place of its content hash.
The defect-calibration artifact’s CONTENT digest is folded in because
--defect-calibration substitutes smell weights inside the scoring
engine — it changes the MEASURED health scores in the report, not just
the verdict. Two runs on the same worktree and HEAD, one calibrated and
one not, must not share a cache entry. calib= is empty when no
artifact is configured. Thresholds stay excluded: they only affect
verdicts, which consumers always recompute from the cached report.
Every other report-affecting Options knob is folded in via
Options::canonical_json — the same digest the ingest cache uses —
so min_revs, exclude_patterns/include_ignored, the clone
thresholds, and any future field are covered with zero per-field
maintenance: build_change_set_report’s run_coupling(db, opts) and
clone_introductions(db, opts, …) calls pass the caller’s opts
straight through (unlike the health projection’s own opts_scan,
which pins min_revs = 1), so any of those knobs can change which
coupling-absence or clone-introduction findings this report contains.
rows_limit is folded in explicitly ALONGSIDE the canonical digest
rather than relying on it: canonical_json deliberately drops
rows_limit as cosmetic for the ingest cache, but
run_coupling(db, opts) truncates to it before the coupling-absence
filter runs, so it is not cosmetic here.
§Errors
Returns CodeLoreError::Analysis when a non-deleted change-set
file cannot be read from the working tree — the engine could not
project it either, so failing early is honest.