Expand description
Cargo local-registry export (REQ-CRATE-001).
A crate-kind entry carries a .crate tarball. export-cargo materialises
a Cargo LOCAL REGISTRY from the verified store — the .crate files plus a
registry index — and emits a .cargo/config.toml source-replacement, so a
consumer builds fully offline against crates whose bytes varve signed.
The trust chain needs nothing new: a .crate is signed like any blob (its
digest is in the DSSE-signed layer manifest), and that digest IS the sha256
Cargo records as the index cksum. Cargo re-checks the .crate against the
cksum, so the consumer verifies a second time on its own terms.
Structs§
- Crate
Entry - One crate to place in the registry: its identity, the Cargo cksum (bare
sha256 hex of the
.crate), and the tarball bytes. - Crate
Meta - Everything an index line needs beyond identity and cksum, read from the
Cargo.tomlinside the signed.crate(REQ-CRATEIDX-001 clause 1). - Index
Dep - One dependency exactly as a Cargo registry index expresses it (REQ-CRATEIDX-001 clause 1). Field names and order mirror crates.io’s index so a line varve writes and a line crates.io writes are the same shape.
Enums§
Constants§
- REGISTRY_
SUBDIR - The subdirectory
export-cargoputs the local registry in, relative to the export root. A constant, not a caller’s path, so the generated config is a function of the layer alone (REQ-REPRO-001 clause 1). - VENDOR_
SUBDIR - The subdirectory
export-crates-vendorputs the vendored trees in.
Functions§
- cargo_
checksum_ json - The
.cargo-checksum.jsonfor a vendored crate.packageis the sha256 of the.cratetarball — the SAME digest varve signs, so the upstream integrity anchor is preserved into the vendored tree, not discarded (REQ-BRIDGE-001).filesempty is valid for a registry-sourced crate (matches realcargo vendoroutput for registry crates). - cargo_
config_ toml - The
.cargo/config.tomlthat redirects crates.io to the local registry, so an unmodifiedCargo.tomlresolves against varve’s verified bytes. - export_
distdir - Materialise a Bazel distdir of the verified
.cratetarballs (REQ-VENDOR-002, air-gap rules_rust). Bazel’s--distdirresolves anhttp_archivefrom a local file whose sha256 matches — with NO network and NO URL rewrite. Because varve’s signed.cratedigest IS thecrate_universepin (== the crates.io checksum), a consumer that pre-generates itscrate_universeoutput once and then builds withbazel build --distdir=<this dir>(network off) resolves every crate from varve’s verified bytes. varve emits the bytes; the consumer commits the generatedcrate_universeoutput (so no repin/index lookup at build time). Returns the number of tarballs written. - export_
local_ registry - Materialise a Cargo local registry at
registry_dir: write each.cratefile and its index entry. Returns the number of crates written. - export_
vendor_ dir - Materialise a
cargo vendor-shaped directory from verified crate entries: each.crateUNPACKED into<vendor>/<name>-<version>/with its.cargo-checksum.json. Proven offline-consumable by bare Cargo and Corrosion. (rules_rust needs BUILD files over this tree — REQ-VENDOR-002.) Returns the crate count. - index_
line - One index line for a crate version, carrying the crate’s REAL
depsandfeaturesread from theCargo.tomlinside its signed.crate(REQ-CRATEIDX-001). Cargo resolves the dependency graph from this line, so an emptydeps/featuresis not a conservative default — it is a lie that resolves, builds, and exits 0 with the crate compiled featureless. - index_
line_ from_ meta - The line for an entry whose metadata is already in hand. Split out so the transcription can be unit-tested without a tarball, and so both halves are exercised by the same serialisation.
- index_
path - The registry-index sub-path for a crate name, per Cargo’s layout: 1/2/3 char names get special prefixes, 4+ use first-two/next-two. Lowercased.
- read_
crate_ meta - Read the
depsandfeaturesof a crate from theCargo.tomlinside its signed.cratetarball (REQ-CRATEIDX-001 clause 1). - validate_
crate_ name - Refuse a crate name Cargo’s registry index cannot express, or that would
corrupt the index line’s JSON. Cargo’s rule: ASCII alphanumeric,
-,_, non-empty. Failing closed here keepsindex_path/index_linehonest — the alternative is a panic or a silently malformed registry (REQ-CRATENAME-001). - validate_
crate_ version - Refuse a version string that would corrupt the index line’s JSON. Semver’s
own alphabet (alphanumerics,
.,-,+) admits no quote or backslash. - vendored_
config_ toml - The consumer config pairing with a vendored directory: redirects crates.io
to the on-disk unpacked trees. Consumed natively by bare Cargo and by
Corrosion (both proven offline). rules_rust needs generated BUILD files on
top of this tree — its
crate.from_cargosplice wants a registry index and rejects a bare directory source (v0.16.0 spike); see REQ-VENDOR-002.