Skip to main content

Module import

Module import 

Source
Expand description

The git→mkit import driver (SPEC-GIT-IMPORT §3).

Pure translation engine: reads git objects through a GitSource, writes serialized mkit objects through an ObjectSink, signs through caller-supplied callbacks (the crate stays crypto-free — the CLI passes its CommitSigner), and records sha1→blake3 pairs plus retained raw commit/tag bytes through caller-supplied hooks.

Everything here is deterministic given (git bytes, signing key, import-spec version): deterministic Ed25519 means the engine can be re-run idempotently and the map is a rebuildable cache under the same key (SPEC-GIT-IMPORT §1.2).

Structs§

DepthMemo
Memoized tree heights and tag-chain lengths, keyed by git id. Needed because a map hit skips recursion: a previously-imported LEGAL subtree (or tag chain) re-referenced deeper in a new parent could compose past the normative caps without it.
ImportOptions
Per-run options.
ImportSigner
Signing callbacks: given the unsigned object (zeroed signature), return the 64-byte signature. The signer pubkey is supplied separately so the engine can fill the signer field first.
ImportedRef
Outcome of importing one ref tip.
Importer
The import engine. map is the sha1→blake3 cache (load it from the state dir; pairs accumulate across calls).
MemGitSource
In-memory source for tests and golden vectors.
MemSink
In-memory sink for tests.

Constants§

CHUNK_THRESHOLD
SPEC-GIT-IMPORT §3.1: the normative chunking threshold.
IMPORT_SPEC_VERSION
This implementation’s import-spec version (SPEC-GIT-IMPORT §1.2).
MAX_TAG_CHAIN
SPEC-GIT-IMPORT §3.4: tag→tag chains beyond this depth refuse.
MAX_TREE_DEPTH
Tree nesting cap, matching mkit-core’s MAX_TREE_DEPTH defense (the importer is the most untrusted boundary in the system).

Traits§

GitSource
Where the driver reads git objects from. CatFileBatch for real repositories; an in-memory map for hermetic tests/vectors.
ObjectSink
Where serialized mkit objects land. Implemented for mkit_core::ObjectStore (per-object fsync) and the CLI’s bulk writer; tests use an in-memory map.

Type Aliases§

RetainRawFn
Hook receiving (upstream sha1, framed raw git bytes) for retention. The explicit lifetime keeps the trait object bound to the borrower’s scope (a bare dyn alias would default to 'static).