Skip to main content

Module map

Module map 

Source
Expand description

blake3↔sha1 mapping cache and per-remote export state (SPEC-GIT-BRIDGE §12.3).

Everything here is a disposable cache: translation is deterministic, so a missing or corrupt file means “rebuild”, never an error. The map file is append-only text (<64hex> <40hex>\n); load_map skips lines that do not parse (so a partially-written file still loads), and map_is_intact reports ANY malformed or blank line so the import driver can trigger the full rebuild — surviving lines of a damaged file are not evidence the rest exists. Ref state is rewritten whole via temp-file + rename.

Structs§

RefState
Last-exported state for one ref: what the bridge last pushed. Used as the --force-with-lease expectation (§12.2).

Enums§

Direction
Recorded direction of a state dir (SPEC-GIT-IMPORT §6): one dir serves one direction; fork couples an import source with passthrough export. Immutable once stamped.

Functions§

append_map
Append newly translated pairs. Append-only by design: entries for rewritten-away commits stay valid forever (determinism), so no compaction or invalidation exists (§12.2).
append_map_import
Append pairs given in import orientation (sha1, blake3) — the file format stays blake3-first either way.
bind_direction
Stamp the direction, or verify it matches an existing stamp. Export → Fork upgrades are refused like any other mismatch (the map semantics differ); Import → Fork is the supported upgrade (fork = import + passthrough export over the same source).
bind_import_spec
Read / pin the import-spec version (SPEC-GIT-IMPORT §1.2).
bind_signer
Pin the importer key, or refuse a mismatch (SPEC-GIT-IMPORT §4).
load_import_ref_state
Load per-ref IMPORT state (last-seen upstream tips). Kept separate from the export leases: in a fork-mode state dir both directions track the same ref names against different remotes.
load_map
Load the blake3→sha1 map. Missing file = empty map. Lines that do not parse (torn tail from a crash) are ignored.
load_map_inverse
Load the map inverted (sha1 → blake3) for the import direction. Parsed directly from the file lines: translation is many-to-one (two historic-mode spellings of a tree normalize to ONE mkit tree), so inverting the blake3-keyed load_map would drop a sha1 and force a pointless re-translation every fetch.
load_ref_state
Load per-ref EXPORT state (push leases). Missing file = empty.
map_is_intact
Whether every non-empty line of the map file parses. A missing file is intact (nothing to distrust). Any malformed line — torn tail or mid-file corruption — means the cache may be MISSING entries that recorded refs rely on, so callers must rebuild rather than trust the surviving lines alone (§12.3).
mark_normalized
Record that this state dir’s imported history contains historic-mode-normalized trees (SPEC-GIT-IMPORT §3.3). Sticky: a normalized tree cannot reproduce its original sha1, so a later import→fork upgrade must refuse (SPEC-GIT-BRIDGE §14.3 fork audit would otherwise report false tampering forever).
read_direction
Read the recorded direction, if stamped.
read_normalized
Whether mark_normalized was ever stamped.
read_signer
Read the pinned importer pubkey (64 lowercase hex), if stamped.
state_dir
.mkit/git/<remote>/ — the per-remote bridge state directory. Remote names are restricted to the mkit ref-segment charset so the directory name is always safe.
store_import_ref_state
Rewrite the import ref-state file (see load_import_ref_state).
store_ref_state
Rewrite the whole export ref-state file atomically (temp + rename).
write_binding
Durable write of a named binding file (source, dest) — same guarantees as the internal stamps.