Skip to content

Tracking issue of RFC-9166: Checksum Intent and Layer #9182

Backlog

Description

@Xuanwo

Track the implementation of RFC-9166: Checksum Intent and Layer (PR #9166, superseding the Capability and ChecksumLayer sections of RFC-6817; related to #5549, #5550, #5635, and #8399).

RFC-9166 replaces the unreleased per-algorithm Capability::checksum_* fields from #7830 with a single Capability::write_with_checksum: bool, generalizes WriteOptions::checksum to a four-variant WriteChecksum intent (Any, Fast, Algo(ChecksumAlgo), Expected(Checksum)), adds an opt-in checksum: bool metadata hint on StatOptions/ReadOptions/ReaderOptions, moves zero-buffered streaming checksum calculation and synchronous validation into each Service, and scopes ChecksumLayer (opendal-layer-checksum) to operator-level write policy injection and full-object streaming read verification.

Confirmed Decisions

  • Single capability flag: Replace Capability::checksum_{crc64_nvme,crc32c,md5,sha256} with Capability::write_with_checksum: bool before feat(core,services/s3): support full-file checksums on write (RFC-6817) #7830 ships; services validate specific classes/algorithms synchronously in Service::write before I/O.
  • Transport-level vs full-file checksums: WriteChecksum::{Any, Fast} may use transport-level per-part/per-block verification (such as Azure Blob per-block CRC64 or B2 per-part SHA-1), succeeding with Metadata::checksum() == None. Metadata::checksum() strictly holds backend-verified full-file digests only.
  • Opt-in read/stat checksum metadata hint: Add checksum: bool (default false) on StatOptions, ReadOptions, and ReaderOptions (OpStat/OpRead) so S3 sends x-amz-checksum-mode: ENABLED only when explicitly requested (preserving SSE-KMS IAM permissions, custom endpoints, and presigned URLs).
  • ChecksumLayer::require_read(true) scope: Applies only to recognizable single-response full-object reads; partial range reads and chunked Reader reads pass through unverified so mixed workloads (Parquet/Lance) can share one operator.
  • Per-service checksum_algorithm configs: New services must not add per-service checksum_algorithm configs. Existing S3Config::checksum_algorithm is retained without immediate deprecation until equivalent migration paths exist for Content-MD5, explicit custom-endpoint headers, and declarative/binding configs.

Implementation Plan

Phases are ordered so the unreleased Capability change and core invariants land first, AWS S3 completes the end-to-end streaming write + opt-in read/stat reference implementation, ChecksumLayer builds on verified core/S3 primitives, and additional services and bindings follow independently.

Phase 1: opendal-core — Types, options, capability, validation, and WriteState invariants

  • Capability cleanup: Landed in feat(core,services/s3): add write checksum intents and S3 support #9206. Replace unreleased checksum_crc64_nvme, checksum_crc32c, checksum_md5, and checksum_sha256 with pub write_with_checksum: bool in core/core/src/types/capability.rs, dev/src/generate/capabilities_docs.rs, website/data/capabilities.json, and existing bindings/java & bindings/dotnet capability mirrors so the workspace builds cleanly before release.
  • Core checksum intent types: Landed in feat(core,services/s3): add write checksum intents and S3 support #9206. Add WriteChecksum (Any, Fast, Algo(ChecksumAlgo), Expected(Checksum)) and WriteChecksumPolicy (Any, Fast, Algo(ChecksumAlgo)) in core/core/src/types/checksum.rs with From<Checksum>, From<ChecksumAlgo>, and From<WriteChecksumPolicy> conversions, and re-export them from opendal-core and core/src/lib.rs.
  • Write options & OpWrite: Landed in feat(core,services/s3): add write checksum intents and S3 support #9206.
    • Change WriteOptions::checksum from Option<Checksum> to Option<WriteChecksum> and update FutureWrite::checksum / FutureWriter::checksum to accept impl Into<WriteChecksum>.
    • Update OpWrite::checksum() -> Option<WriteChecksum>, add validated OpWrite::with_checksum(self, checksum: WriteChecksum, capability: &Capability) -> Result<Self>, and encode WriteField::Checksum with an explicit leading variant tag (leaving Metadata compact encoding unchanged).
    • Enforce OpWrite::check rules: invalid Expected digest length -> ConfigInvalid; any Some(WriteChecksum) when !capability.write_with_checksum -> Unsupported; append + Algo/Expected -> Unsupported; append + Any/Fast delegated to Service::write.
  • Opt-in stat / read checksum metadata hint: Landed in feat(core): expose checksum metadata hints for read and stat #9192.
    • Add pub checksum: bool (default false) to StatOptions, ReadOptions, and ReaderOptions, with .checksum(bool) builders on FutureStat, FutureRead, and FutureReader.
    • Expose OpStat::checksum(&self) -> bool, OpRead::checksum(&self) -> bool, and OpRead::with_checksum(self, checksum: bool) -> Self (hint semantics: never returns Unsupported on services without checksum metadata).
  • WriteState copy_from invariants (core/core/src/types/context/write.rs): Landed in fix(core): require abort on source checksum mismatch after partial copy #9191.
    • Keep native copy_from disabled whenever ctx.args().checksum().is_some().
    • When streaming copy_from receives ErrorKind::ChecksumMismatch from the source, require abort() if the destination writer has accepted any bytes from that logical copy, including bytes still queued or accepted on an earlier attempt. Reject further write, copy_from, and close calls in that state. If the failing copy has delivered zero bytes, the writer stays usable: the caller may copy from another source, continue writing, or call close() to commit only the previously accepted prefix. Ordinary temporary source read errors remain resumable.
  • Core unit tests: Landed in feat(core,services/s3): add write checksum intents and S3 support #9206. Cover OpWrite/OpRead/OpStat encoding and validation, OpWrite::with_checksum, WriteState::create disabling native copy_from, and the full streaming copy_from source-ChecksumMismatch sequence (first copy_from fails -> retrying copy_from fails -> close() fails -> abort() succeeds). Test both boundaries: after a successful prefix write, a zero-progress source checksum failure permits copying from another source and closing with the expected bytes. If the same logical copy delivered bytes before a retry and the retry reports a checksum mismatch, further writes, copies, and close must fail, and abort must succeed.

Phase 2: opendal-service-s3 — Streaming writes, opt-in read/stat checksum mode, and AWS S3 behavior tests

  • Workspace dependency hygiene: Promote crc-fast to [workspace.dependencies] in core/Cargo.toml (evaluating default-features = false if it avoids pulling duplicate digest versions) so services and opendal-layer-checksum share one version.
  • Capability & synchronous validation: Landed in feat(core,services/s3): add write checksum intents and S3 support #9206.
    • Advertise write_with_checksum: true on AWS S3 (scheme == "s3" && !is_s3_express); keep S3-compatible presets (minio, r2, etc.) at write_with_checksum: false until echo verification is verified against those services.
    • Validate args.checksum() and args.append() synchronously in S3Backend::write before I/O: support Any/Fast (selecting CRC64NVME), Algo(Crc64Nvme | Crc32c), and Expected(Crc64Nvme | Crc32c); synchronously return Unsupported for Md5/Sha256 and for append.
    • Reject oio::Write::copy_from with Unsupported when the writer was constructed with args.checksum().is_some() (defense in depth).
  • Zero-buffered streaming write execution: Landed in feat(core,services/s3): add write checksum intents and S3 support #9206.
    • Support Any/Fast/Algo(Crc64Nvme | Crc32c) on both single PutObject and concurrent uneven-part multipart uploads.
    • Populate oio::MultipartPart::size alongside checksum, combine per-part CRCs in part_number order using crc_fast::checksum_combine, send full-object digest on CompleteMultipartUpload with x-amz-checksum-type: FULL_OBJECT, verify echoed digest, and populate Metadata::checksum().
    • Classify is_temporary per protocol step: temporary on replayable single-PUT (Any/Fast/Algo) or per-part UploadPart mismatches; non-temporary on caller Expected mismatches, deterministic CompleteMultipartUpload rejections, and post-commit echo failures (ErrorKind::Unexpected).
    • Preserve S3Config::checksum_algorithm coexistence: per-operation OpWrite::checksum() takes wire-header precedence while build-time capability restrictions remain in effect.
  • Opt-in read/stat checksum mode: Landed in feat(services/s3): retrieve opt-in read and stat checksums #9205.
    • Send x-amz-checksum-mode: ENABLED on HeadObject and GetObject only when OpStat::checksum() / OpRead::checksum() is true (never on default requests or presigned URLs).
    • Parse Metadata::checksum() only when x-amz-checksum-type is FULL_OBJECT (or an unsuffixed single-part checksum), ignoring COMPOSITE.
  • Behavior tests & live AWS S3 verification: Update core/tests/behavior/async_write.rs and read/stat behavior tests to cover explicit S3 Crc32c/Crc64Nvme (Any, Fast, Algo, Expected, single PUT + concurrent uneven-part multipart, Expected mismatch without commit, Algo(Sha256)/Expected(Sha256) synchronous Unsupported, opt-in stat/read FULL_OBJECT vs COMPOSITE, default requests omit x-amz-checksum-mode) plus generic WriteChecksum::Any tests gated on write_with_checksum. Verify against live AWS S3. Landed in test(s3): cover AWS checksum intents and metadata #9217. The managed AWS matrix used SSE-S3 on c54097b4f8. The out-of-order part trace is in feat(core,services/s3): add write checksum intents and S3 support #9206.

Phase 3: opendal-layer-checksum — ChecksumLayer crate, facade wiring, and composition tests

  • New layer crate (core/layers/checksum): Implement ChecksumLayer (write: Option<WriteChecksumPolicy>, require_write: bool, verify_read: bool, require_read: bool with defaults Some(Fast), false, true, false), with no local fake write fallback and no stat() data reads.
  • Write path:
    • Preserve caller-supplied args.checksum() untouched.
    • Clear write_can_copy_from = false on ChecksumService::capability() whenever write injection is active and inner.capability().write_with_checksum is true.
    • Inject via OpWrite::with_checksum(policy.into(), &cap); in best-effort mode (!require_write), fall back once to un-injected args on synchronous zero-I/O Unsupported while preserving unrelated Unsupported errors (e.g., append or unsupported options).
  • Read path: Landed in feat(core,layers/checksum): add read checksum capability and verification layer #9209.
    • Apply verification (and require_read(true)) only to recognizable single-response full-object reads (0.. or 0..n when rp.metadata().content_length() <= n); pass partial range reads and chunked Reader reads through unverified without upgrading to full-object downloads.
    • Automatically set OpRead::with_checksum(true) on eligible full-object reads.
    • Verify oio::Read::read buffers and wrap oio::Read::open streams in a zero-buffered streaming hasher: finalize and compare before yielding the final chunk once bytes_read == content_length (catching op.read_with(path).limit(n)), fail immediately if bytes_read > content_length, finalize on empty EOF when length is unknown or 0, and permanently latch terminal ChecksumMismatch on repeated polls.
  • Facade wiring: feat(layers/checksum): expose typed ChecksumLayer from opendal #9218 added the optional layers-checksum feature and the opendal::layers::ChecksumLayer re-export. Rust callers attach it with .layer(ChecksumLayer::new()). URI/map registration for layers=checksum is a separate configuration decision.
  • Layer & composition tests: Cover best-effort vs strict write/read, zero-I/O fallback preserving unrelated Unsupported, op.read(path) and exact-size op.read_with(path).limit(n) corruption detection, terminal mismatch latching, partial/chunked passthrough under require_read(true), stat() never triggers read(), ChecksumLayer outside RetryLayer verifying resumed streams, and RouteLayer in both capability directions.

Phase 4: Follow-up service implementations (each requires live-service verification before enabling write_with_checksum = true)

  • GCS (core/services/gcs, new feature: Add CRC32C checksum support for GCS #5635): On the authenticated default JSON endpoint, verify CRC32C before commit using multipart insert metadata for single-request uploads or x-goog-hash on the final resumable data PUT. Recover lost resumable finalization responses by querying the session. Report stored CRC32C on stat and on reads covering the complete stored representation. Landed in feat(services/gcs): support CRC32C write verification and stored checksums #9216.
  • Azure Blob (core/services/azblob): Support Any/Fast via per-request x-ms-content-crc64 on PutBlob, PutBlock, and AppendBlock (transport-only, Metadata::checksum() stays None); synchronously reject Algo/Expected in Service::write. Landed in feat(services/azblob): verify transactional write checksums #9215.
  • Backblaze B2 (core/services/b2): Support Any via X-Bz-Content-Sha1 on single upload and per-part on large files (b2_finish_large_file); synchronously reject Fast/Algo/Expected in Service::write.
  • Alibaba Cloud OSS (core/services/oss): Added shared ChecksumAlgo::Crc64Ecma (CRC-64/XZ parameters; check value 0x995DC9BBDF1939FA for 123456789, distinct from CRC-64/ECMA-182) in feat(core): add shared CRC64-ECMA checksum algorithm #9240 and enabled write_with_checksum on signed native regional HTTPS endpoints (oss-*.aliyuncs.com, virtual-host and path addressing) in feat(services/oss): verify native write checksum receipts #9246. Supports non-append Any/Fast via x-oss-hash-crc64ecma receipt verification on PutObject, per-part UploadPart, and ordered multipart completion, populating Metadata::checksum(). Unconfirmed final receipts return a non-temporary Unexpected error without replaying publication (the object may already be visible). Synchronously rejects Algo/Expected, append with checksum, and presigned writes with checksum (Unsupported). Custom endpoints, CNAME addressing, HTTP, skip_signature, and read_with_checksum remain disabled.
  • Tencent Cloud COS (core/services/cos): Uses shared ChecksumAlgo::Crc64Ecma (feat(core): add shared CRC64-ECMA checksum algorithm #9240) and landed in feat(services/cos): verify native write checksum receipts #9245. Supports non-append Any/Fast via x-cos-hash-crc64ecma receipt verification on PutObject, per-part UploadPart, and ordered multipart completion, populating Metadata::checksum(). Unconfirmed final receipts return a non-temporary Unexpected error without replaying publication (the object may already be visible). Synchronously rejects Algo/Expected, append with checksum, and presigned writes with checksum (Unsupported). read_with_checksum remains disabled.
  • Volcengine TOS (core/services/tos): Uses ChecksumAlgo::Crc64Ecma (CRC-64/XZ) and landed in feat(services/tos): verify native write checksum receipts #9253. Enables write_with_checksum on signed endpoints (!skip_signature) for non-append Any/Fast via x-tos-hash-crc64ecma receipt verification on PutObject, per-part UploadPart, and ordered multipart completion, populating Metadata::checksum(). Distinguishes explicit HTTP-200 JSON rejections from ambiguous publication; an unconfirmed receipt after a successful terminal status returns a non-temporary Unexpected error without replaying publication (the object may already be visible), and abort() accepts NoSuchUpload while leaving any published version intact. Synchronously rejects Algo/Expected, append with checksum, and presigned writes with checksum (Unsupported). Unsigned endpoints and read_with_checksum remain disabled.
  • Additional services / S3-compatible presets:

Phase 5: Bindings alignment

Phase 6: Living specification, documentation, and RFC tracking link

  • Add this tracking issue link to the header of core/core/src/docs/rfcs/9166_checksum_intent_and_layer.md (and cross-link from new feature: Checksum #5549).
  • Add core/core/src/docs/specs/checksum.md codifying the portable checksum contract and wire it into core/core/src/docs/specs/mod.rs and website/specifications.sidebars.js.
  • Update rustdoc on WriteChecksum, WriteChecksumPolicy, WriteOptions::checksum, StatOptions/ReadOptions/ReaderOptions::checksum, Capability::write_with_checksum, ChecksumLayer, and services::S3 docs (recommending WriteChecksum / ChecksumLayer for AWS S3).

This tracking issue was prepared with AI assistance (Gemini 4 Neon) for Xuanwo.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions