Skip to content

make OCI bless deterministic via content-addressed ext4 UUID#69

Merged
jaredLunde merged 1 commit into
mainfrom
deterministic-oci-bless
Jun 4, 2026
Merged

make OCI bless deterministic via content-addressed ext4 UUID#69
jaredLunde merged 1 commit into
mainfrom
deterministic-oci-bless

Conversation

@jaredLunde
Copy link
Copy Markdown
Contributor

Summary

The OCI bless pipeline was deterministic in every respect except one line: the ext4 filesystem UUID came from rand::random() (glidefs/src/cli/bless.rs). 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 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 --image bless path was already deterministic (it just hashes the bytes you hand it) and is unchanged.

Tests

  • ext4 test_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.
  • ext4 test_uuid_controls_output_bytes — prove the UUID genuinely flows into the image bytes, so reproducibility provably hinges on pinning it.
  • bless deterministic_uuid_is_stable_and_content_addressed — guard the derivation (stable, content-addressed, well-formed) and prevent reintroducing rand::random().

🤖 Generated with Claude Code

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>
@jaredLunde jaredLunde merged commit 88ee17b into main Jun 4, 2026
24 checks passed
@jaredLunde jaredLunde deleted the deterministic-oci-bless branch June 4, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant