make OCI bless deterministic via content-addressed ext4 UUID#69
Merged
Conversation
The OCI bless pipeline was deterministic except for one line: the ext4 filesystem UUID came from rand::random(). That UUID seeds both the superblock uuid field and the directory hash_seed, so every bless of the same image produced byte-different output, which changed the content-addressed pack IDs downstream. Derive the UUID deterministically from the resolved manifest digest (sha256:..., itself content-addressed) by hashing it with blake3 and stamping RFC 4122 version/variant bits. Same image content -> same digest -> same UUID -> byte-identical ext4 image. Tests: - ext4 test_conversion_is_byte_deterministic: convert a representative multi-layer OCI image three times with fixed writer options, assert byte-for-byte identical output. - ext4 test_uuid_controls_output_bytes: prove the UUID actually flows into the image bytes, so reproducibility hinges on pinning it. - bless deterministic_uuid_is_stable_and_content_addressed: guard the derivation and prevent reintroducing rand::random(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OCI
blesspipeline was deterministic in every respect except one line: the ext4 filesystem UUID came fromrand::random()(glidefs/src/cli/bless.rs). That UUID seeds both the superblockuuidfield and the directoryhash_seed, so every bless of the same image produced byte-different output — which then changed the content-addressed pack IDs downstream.Everything else was already deterministic by construction: timestamps come from tar headers (not the clock), directory entries are sorted by
(inode, name), xattrs are sorted, block/inode allocation is sequential, and the superblock mtime/wtime fields are zeroed.Change
Derive the UUID deterministically from the resolved manifest digest (
sha256:..., itself content-addressed) by hashing it with blake3 and stamping RFC 4122 version/variant bits. Same image content → same digest → same UUID → byte-identical ext4 image → identical pack IDs.The raw-image
--imagebless path was already deterministic (it just hashes the bytes you hand it) and is unchanged.Tests
ext4test_conversion_is_byte_deterministic— convert a representative multi-layer OCI image (overrides, whiteout, opaque whiteout, nested dirs, binary content) three times with fixed writer options, assert byte-for-byte identical output.ext4test_uuid_controls_output_bytes— prove the UUID genuinely flows into the image bytes, so reproducibility provably hinges on pinning it.blessdeterministic_uuid_is_stable_and_content_addressed— guard the derivation (stable, content-addressed, well-formed) and prevent reintroducingrand::random().🤖 Generated with Claude Code