Skip to main content

Module shape

Module shape 

Source
Expand description

Shape classes and hunk digests.

A shape class groups hunks whose diff text is identical after normalising away identifiers, string and numeric literals — on BOTH sides (ADR 0004: hashing only added lines collapses every deletion-only hunk into one class, turning “same shapes, skippable” into a lie).

Line normalisation is pluggable per language (ADR 0015, crate::lang); the framing here — sigil prefixes, sorting, disposition in the key, sha1/12-hex — is language-independent and deliberately identical to the validated prototype, so class populations stay comparable with its recorded outputs.

Structs§

Partition
The mechanical partition: every hunk assigned to a shape class. Classes are ordered by descending member count (ties broken by first appearance, so the ordering is deterministic); class_of[i] is the class index of canonical hunk i. Coverage is total by construction.

Functions§

hunk_digest
Exact content digest — NOT normalised and NOT language-dependent. The stable anchor that lets comments and review state survive regeneration (positional ids do not).
norm_lines
Normalise one side’s lines: language normalisation, sigil prefixed, sorted.
partition
pure_substitution
True iff, after erasing identifiers and literals, removed and added lines match: a structure-free substitution. Insertion-only and deletion-only hunks are never pure. This is a property of the shape, so it is computed once per class from the exemplar. Computed, never claimed — there is no setter.
shape_hash
Shape key: normalised removed + added lines, the file disposition, and whether the file is generated. Returns the 12-hex sha1 used as the class key.