Skip to content

Conversation

@danlaine
Copy link
Collaborator

@danlaine danlaine commented Jan 5, 2026

Closes: #2404

  • Adds an 8 byte header to the start of each Blob. The header is composed of 4 magic bytes, a u16 header version and a u16 application version. The application in this instance is whoever is using the Blob.
  • On Blob open, check for existing header and validate it. If the blob doesn't exist, we write a header.
  • Storage::open is now a default method which uses Header::DEFAULT_APPLICATION_VERSION (0) as the only acceptable version.
  • All usages of Blobs therefore now use application version 0 (since they are opened with Storage::open_versioned).
  • Files with length in [1, 7] are treated as corrupt (it should have at least the header) and overwritten on next open.

One thing I don't like about this PR is that all Blob implementations re-implement the logic for adding the header length to offset calculations. Is it worth making a wrapper type to handle that? Ehh I dunno.

@danlaine danlaine self-assigned this Jan 5, 2026
@danlaine danlaine added the breaking-format This PR modifies codec and/or storage formats. label Jan 5, 2026
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 5, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
commonware-mcp 4f3efd5 Jan 07 2026, 03:30 AM

@danlaine danlaine added this to Tracker Jan 5, 2026
@danlaine danlaine moved this to In Progress in Tracker Jan 5, 2026
@danlaine danlaine changed the title [Stprage] Add header to Blob [Storage] Add header to Blob Jan 5, 2026
@danlaine danlaine force-pushed the danlaine/add-header branch from b74c985 to d2ba62b Compare January 5, 2026 18:48
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 5, 2026

Deploying monorepo with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4f3efd5
Status: ✅  Deploy successful!
Preview URL: https://4d12b3b2.monorepo-eu0.pages.dev
Branch Preview URL: https://danlaine-add-header.monorepo-eu0.pages.dev

View logs

@danlaine danlaine force-pushed the danlaine/add-header branch 2 times, most recently from baa545c to 428bb3d Compare January 5, 2026 19:51
@danlaine danlaine marked this pull request as ready for review January 5, 2026 19:51
@danlaine danlaine changed the title [Storage] Add header to Blob [Storage] [Storage] Add header to Blob Jan 5, 2026
@danlaine danlaine changed the title [Storage] [Storage] Add header to Blob [Storage] [Runtime] Add header to Blob Jan 5, 2026
@danlaine danlaine moved this from In Progress to Ready for Review in Tracker Jan 5, 2026
@danlaine danlaine moved this from Ready for Review to In Progress in Tracker Jan 6, 2026
@danlaine danlaine marked this pull request as draft January 6, 2026 17:34
@danlaine danlaine force-pushed the danlaine/add-header branch 4 times, most recently from 7ca400b to c6b0941 Compare January 6, 2026 20:19
@danlaine danlaine force-pushed the danlaine/add-header branch from c6b0941 to c189830 Compare January 6, 2026 20:20
patrick-ogrady and others added 2 commits January 6, 2026 18:16
- Add versions to auditor hash in audited.rs
- Add Header to conformance testing with codec traits and Arbitrary impl
- Deduplicate header handling across storage implementations:
  - Header::missing() checks if blob needs fresh header
  - Header::for_new_blob() creates header for new blob
  - Header::from_existing() validates existing header
- Remove to_bytes()/from_bytes() in favor of codec encode()/decode()
- Propagate arbitrary feature to dependent crates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add test_header_validate_header_version_mismatch in lib.rs
- Add test_blob_version_mismatch in iouring.rs (matching memory.rs and tokio)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@patrick-ogrady patrick-ogrady marked this pull request as draft January 7, 2026 02:37
patrick-ogrady and others added 3 commits January 6, 2026 18:57
- Move Header struct to storage/mod.rs with pub(crate) visibility
- Rename fields: application_version -> blob_version, header_version -> runtime_version
- Rename methods: for_new_blob -> new, from_existing -> from
- Consolidate BlobMagicMismatch and BlobRuntimeVersionMismatch into opaque BlobCorrupt error
- Add standalone DEFAULT_BLOB_VERSION const in lib.rs
- Add versions to auditor hash in audited.rs
- Move conformance tests to storage/mod.rs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Remove Header section from Blob trait (implementation detail)
- Simplify Versions section to generic explanation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Fix Header import in iouring.rs (use super::Header)
- Add doc links to DEFAULT_BLOB_VERSION

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@patrick-ogrady patrick-ogrady changed the title [Storage] [Runtime] Add header to Blob [runtime/storage] Versioned Blobs Jan 7, 2026
patrick-ogrady and others added 5 commits January 6, 2026 19:08
Move partition/name context handling to call sites via map_err,
keeping Header methods focused on validation logic only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Move test_blob_version_mismatch to run_storage_tests
- Remove duplicate version mismatch tests from each backend
- Keep test_blob_header_handling (tests raw byte layout per backend)
- Keep test_blob_magic_mismatch (tests corrupted file integration)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Aligns error mapping with iouring backend for consistency.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@patrick-ogrady patrick-ogrady marked this pull request as ready for review January 7, 2026 03:30
@patrick-ogrady patrick-ogrady merged commit c16f312 into main Jan 7, 2026
130 checks passed
@patrick-ogrady patrick-ogrady deleted the danlaine/add-header branch January 7, 2026 04:25
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in Tracker Jan 7, 2026
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 97.11538% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.91%. Comparing base (f691a8a) to head (4f3efd5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
runtime/src/storage/mod.rs 95.27% 7 Missing ⚠️
runtime/src/storage/tokio/mod.rs 96.07% 4 Missing ⚠️
runtime/src/storage/memory.rs 98.73% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #2694      +/-   ##
==========================================
+ Coverage   92.90%   92.91%   +0.01%     
==========================================
  Files         363      363              
  Lines      107717   108104     +387     
==========================================
+ Hits       100075   100450     +375     
- Misses       7642     7654      +12     
Files with missing lines Coverage Δ
runtime/src/deterministic.rs 96.56% <100.00%> (+0.01%) ⬆️
runtime/src/lib.rs 97.05% <100.00%> (+0.03%) ⬆️
runtime/src/storage/audited.rs 93.67% <100.00%> (+0.47%) ⬆️
runtime/src/storage/metered.rs 92.65% <100.00%> (+0.30%) ⬆️
runtime/src/storage/tokio/unix.rs 100.00% <100.00%> (ø)
runtime/src/tokio/runtime.rs 83.13% <100.00%> (+0.25%) ⬆️
runtime/src/utils/cell.rs 75.55% <100.00%> (+0.18%) ⬆️
storage/src/journal/segmented/variable.rs 93.81% <100.00%> (+0.03%) ⬆️
runtime/src/storage/memory.rs 99.48% <98.73%> (-0.52%) ⬇️
runtime/src/storage/tokio/mod.rs 90.68% <96.07%> (+5.10%) ⬆️
... and 1 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f691a8a...4f3efd5. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-format This PR modifies codec and/or storage formats.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[storage] Add manifest / header for storage formats (magic + versioning)

3 participants