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-leaseexpectation (§12.2).
Enums§
- Direction
- Recorded direction of a state dir (SPEC-GIT-IMPORT §6): one dir
serves one direction;
forkcouples 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 → Forkupgrades are refused like any other mismatch (the map semantics differ);Import → Forkis 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_mapwould 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_normalizedwas 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.