Expand description
Immutable candidate versions: identity, pathname, mode, change and object per path. What: An immutable candidate version: the paths one Git state changes, each with its identity, mode and object. Why: Every policy of one pass must judge the same files. A version is listed once and then only read, so path metadata is shared instead of re-queried, and a later fix or replay produces a new version instead of altering this one.
In TS you’d write (pseudocode):
type CandidateVersion = { readonly candidates: readonly Candidate[] };Structs§
- Candidate
- What:
One changed path of a version.
Vec<u8>is an owned byte list (siblingStringwould require UTF-8).Option<ObjectId>is “an object name or nothing”. Why: Git pathnames are arbitrary bytes on Unix and are kept exactly. A deleted path has no object, which the type states. - Candidate
Identity - What:
The identity of one candidate within one invocation.
u64is an unsigned 64-bit counter (siblingsu32,usize);usizeis the unsigned integer every index uses. Why: Identity must not be derived from the pathname, which the scanner may mask. The generation tells a candidate of an invalidated version from a current one;u64cannot run out within a process. The index is the candidate’s position in its version, andusizeis what indexing and the scanner take. - Candidate
Version - What:
The candidates of one listed state.
Fields are private:
a version is built
once by
build_versionand never changed. Why: Immutability is what lets several policies share one listing safely.
Enums§
- Candidate
Source - What:
Which Git state a version lists,
and what it is compared with.
#[derive(...)]generates cloning, debug printing and==. Why: A commit being prepared is judged by what is staged; a landed commit by what it changed. Naming the comparison makes the version reproducible.
Functions§
- build_
version - What:
Build a version from listing records,
keeping the first record of each pathname.
Vec<CandidateRecord>is taken by value: the records’ bytes move into the version without being copied. Why: A merge commit lists one comparison per parent, so a pathname can appear more than once; the first appearance decides, as it did in the TypeScript wrapper.