On this page

0240. One lock format for every source

Context

harness.lock v1 (ADR-0072) has [package.<name>] tables with version, source, deps, optional hash and exec_hash (ADR-0099). Sources are path:…, git+<url>#<rev> and edition:<e>. ADR-0203 proposed v2 only for registry graphs, adding release, tree, signatures and trust fields. Cargo notes that storing a registry URL in the lock means a registry should not offer two protocols. Goldens and existing locks must stay byte-identical.

Decision

One entry shape for every source: version, source, deps, hash, optional exec_hash, and tag for git tag dependencies only. hash is the existing tree_hash (sha256: + 64 hex) and is mandatory for every non-path entry. Path entries stay unhashed. Source strings: path:…, edition:<e>, git+<url>#<commit> and index+<canonical-url>/<path>. The VCS host uses index+ because it serves the same layout (0244).

lock_version = 2 is written only when the graph needs tag or index+; graphs v1 can express keep writing lock_version = 1 byte-identically. Readers accept both. No release, signature, trust, mirror, endpoint or credential data is ever stored in the lock.

fetch is the only lock writer and only networked command; add edits only the manifest. A locked version whose index hash changed, or a git tag that moved from the locked commit, is an error, never a silent update. Offline builds verify cached content against the lock without network or writes, as today.

Alternatives considered

Consequences

The lock is about integrity, not selection (0239). Mirrors can be swapped without changing lock bytes. Older toolchains reject v2 locks cleanly. Phase 3 signatures do not touch the lock.