Expand description
Ref compare-and-swap and ref-name helpers (SPEC-TRANSPORT-CONNECT §3, SPEC-TRANSPORT §4.2.1, SPEC-REFS §3 and §4).
The canonical copy of logic that lived in mkit serve’s
pack_key_from_id/decode_update_ref (removed in WP-M0-13), vcs-worker’s
former refs.rs (removed in WP-M0-17), and mkit-transport-connect 0.4’s
refs_convert.rs and hashutil.rs (removed in WP-M0-15).
apps/repo-worker keeps its own copy (planner decision Q11).
Enums§
- CasDecision
- The outcome of
evaluate_casorevaluate_condition.Invalidis a malformed request (invalid_argument);Conflictis a precondition failure the client can rebase and retry (failed_precondition). - Conflict
Reason - Why a CAS update could not commit.
- Digest
Field - The wire field a digest came from; the ssh wire names it in its message.
- RefExpectation
Wire - A CAS expectation as its wire number, aligned with
mkit.transport.v1.RefExpectation. The numbers are load-bearing and matchmkit.rpc.v1.ssh.RefExpectationandmkit.repo.v1.RefExpectation. - RefWire
Error - A malformed ref or digest field. Every variant is
Code::InvalidArgument; the two message methods keep today’s text for each wire family, ascrate::upload::UploadErrordoes. - Unused
Expected Id - How a binding treats an
expected_idsent withANYorMISSING.
Constants§
- MAX_
REF_ NAME_ BYTES - Longest ref name, in bytes: SPEC-REFS §3’s bound,
mkit_core::refs::MAX_REF_NAME_BYTES. It bounds every ref key (store::keys) belowMAX_KEY_BYTES, with room for the longest repo name;store::keysasserts that at compile time. Clients check the same bound (mkit_rpc::MAX_REF_NAME) before sending. - REF_
NAME_ OUTSIDE_ REFS - The public message for a ref name outside
SERVED_REFS_PREFIX(SPEC-REFS §2), on every binding;mkit servesends it as-is. It points an operator whose repo holds such refs, written by an oldermkit serve, to the migration notes (docs/CLI.md, “Refs outsiderefs/”); it names no server path. - REF_
NAME_ TOO_ LONG - The public message for a ref name or
ListRefsprefix overMAX_REF_NAME_BYTES;mkit servesends it as-is. - SERVED_
REFS_ PREFIX - The prefix of every ref name the pipeline serves: refs live under
refs/(SPEC-REFS §2:refs/heads/,refs/tags/, and mkit’s ownrefs/mkit/packmap/).
Functions§
- condition_
from_ wire - Convert a wire
(expectation, expected_id)pair into aRefWriteCondition. An absentexpected_idis passed as empty.unusedsays what anexpected_idsent withANYorMISSINGmeans. - evaluate_
cas - Decide a CAS write from its wire form.
currentis the ref’s value (Nonewhen absent) andexpectedtheMATCHtarget, which must beNoneforANYandMISSING. Ids are compared as opaque bytes. - evaluate_
condition - Decide a CAS write from a decoded
RefWriteCondition, the check every storage backend shares. Same rules asevaluate_cas; a decoded condition is neverInvalid. - hash_
from_ slice - Parse a 32-byte digest from a wire
bytesfield (Nonewhen absent). - is_
served_ ref_ name - Whether the pipeline serves
name: a valid ref name (validate_ref_name) underSERVED_REFS_PREFIX. - list_
scan_ prefix - The scan prefix of a validated
ListRefsprefix (SPEC-REFS §4): empty for an empty prefix, otherwise the prefix with its trailing/s replaced by exactly one. A listing covers the refs whose full name starts with it, so a prefix matches only at a path-component boundary:refs/heads,refs/heads/andrefs//all scanrefs/heads/(andrefs/),refs/heads/mascansrefs/heads/ma/and does not matchrefs/heads/main, and a ref named exactly the prefix is never listed. - strip_
listed_ prefix - The name
ListRefsreturns for a stored reffullunderprefix:fullwithlist_scan_prefix(prefix)stripped, orNonewhen it does not extend the prefix at a component boundary (SPEC-REFS §4). - validate_
ref_ name - Validate a ref name: the SPEC-REFS §3 grammar and at most
MAX_REF_NAME_BYTESbytes (mkit_core::refs::validate_ref_name). - validate_
ref_ prefix - Validate a prefix passed to
list_refs. An empty prefix is allowed. A single trailing/is allowed; otherwise the prefix must satisfyvalidate_ref_name.