Description
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}withCapability::write_with_checksum: boolbefore feat(core,services/s3): support full-file checksums on write (RFC-6817) #7830 ships; services validate specific classes/algorithms synchronously inService::writebefore 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 withMetadata::checksum() == None.Metadata::checksum()strictly holds backend-verified full-file digests only. - Opt-in read/stat checksum metadata hint: Add
checksum: bool(defaultfalse) onStatOptions,ReadOptions, andReaderOptions(OpStat/OpRead) so S3 sendsx-amz-checksum-mode: ENABLEDonly 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 chunkedReaderreads pass through unverified so mixed workloads (Parquet/Lance) can share one operator.- Per-service
checksum_algorithmconfigs: New services must not add per-servicechecksum_algorithmconfigs. ExistingS3Config::checksum_algorithmis retained without immediate deprecation until equivalent migration paths exist forContent-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, andchecksum_sha256withpub write_with_checksum: boolincore/core/src/types/capability.rs,dev/src/generate/capabilities_docs.rs,website/data/capabilities.json, and existingbindings/java&bindings/dotnetcapability 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)) andWriteChecksumPolicy(Any,Fast,Algo(ChecksumAlgo)) incore/core/src/types/checksum.rswithFrom<Checksum>,From<ChecksumAlgo>, andFrom<WriteChecksumPolicy>conversions, and re-export them fromopendal-coreandcore/src/lib.rs. - Write options &
OpWrite: Landed in feat(core,services/s3): add write checksum intents and S3 support #9206.- Change
WriteOptions::checksumfromOption<Checksum>toOption<WriteChecksum>and updateFutureWrite::checksum/FutureWriter::checksumto acceptimpl Into<WriteChecksum>. - Update
OpWrite::checksum() -> Option<WriteChecksum>, add validatedOpWrite::with_checksum(self, checksum: WriteChecksum, capability: &Capability) -> Result<Self>, and encodeWriteField::Checksumwith an explicit leading variant tag (leavingMetadatacompact encoding unchanged). - Enforce
OpWrite::checkrules: invalidExpecteddigest length ->ConfigInvalid; anySome(WriteChecksum)when!capability.write_with_checksum->Unsupported;append + Algo/Expected->Unsupported;append + Any/Fastdelegated toService::write.
- Change
- Opt-in
stat/readchecksum metadata hint: Landed in feat(core): expose checksum metadata hints for read and stat #9192.- Add
pub checksum: bool(defaultfalse) toStatOptions,ReadOptions, andReaderOptions, with.checksum(bool)builders onFutureStat,FutureRead, andFutureReader. - Expose
OpStat::checksum(&self) -> bool,OpRead::checksum(&self) -> bool, andOpRead::with_checksum(self, checksum: bool) -> Self(hint semantics: never returnsUnsupportedon services without checksum metadata).
- Add
-
WriteStatecopy_frominvariants (core/core/src/types/context/write.rs): Landed in fix(core): require abort on source checksum mismatch after partial copy #9191.- Keep native
copy_fromdisabled wheneverctx.args().checksum().is_some(). - When streaming
copy_fromreceivesErrorKind::ChecksumMismatchfrom the source, requireabort()if the destination writer has accepted any bytes from that logical copy, including bytes still queued or accepted on an earlier attempt. Reject furtherwrite,copy_from, andclosecalls 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 callclose()to commit only the previously accepted prefix. Ordinary temporary source read errors remain resumable.
- Keep native
- Core unit tests: Landed in feat(core,services/s3): add write checksum intents and S3 support #9206. Cover
OpWrite/OpRead/OpStatencoding and validation,OpWrite::with_checksum,WriteState::createdisabling nativecopy_from, and the full streamingcopy_fromsource-ChecksumMismatchsequence (firstcopy_fromfails -> retryingcopy_fromfails ->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-fastto[workspace.dependencies]incore/Cargo.toml(evaluatingdefault-features = falseif it avoids pulling duplicatedigestversions) so services andopendal-layer-checksumshare one version. - Capability & synchronous validation: Landed in feat(core,services/s3): add write checksum intents and S3 support #9206.
- Advertise
write_with_checksum: trueon AWS S3 (scheme == "s3" && !is_s3_express); keep S3-compatible presets (minio,r2, etc.) atwrite_with_checksum: falseuntil echo verification is verified against those services. - Validate
args.checksum()andargs.append()synchronously inS3Backend::writebefore I/O: supportAny/Fast(selectingCRC64NVME),Algo(Crc64Nvme | Crc32c), andExpected(Crc64Nvme | Crc32c); synchronously returnUnsupportedforMd5/Sha256and forappend. - Reject
oio::Write::copy_fromwithUnsupportedwhen the writer was constructed withargs.checksum().is_some()(defense in depth).
- Advertise
- 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 singlePutObjectand concurrent uneven-part multipart uploads. - Populate
oio::MultipartPart::sizealongsidechecksum, combine per-part CRCs inpart_numberorder usingcrc_fast::checksum_combine, send full-object digest onCompleteMultipartUploadwithx-amz-checksum-type: FULL_OBJECT, verify echoed digest, and populateMetadata::checksum(). - Classify
is_temporaryper protocol step: temporary on replayable single-PUT (Any/Fast/Algo) or per-partUploadPartmismatches; non-temporary on callerExpectedmismatches, deterministicCompleteMultipartUploadrejections, and post-commit echo failures (ErrorKind::Unexpected). - Preserve
S3Config::checksum_algorithmcoexistence: per-operationOpWrite::checksum()takes wire-header precedence while build-time capability restrictions remain in effect.
- Support
- Opt-in read/stat checksum mode: Landed in feat(services/s3): retrieve opt-in read and stat checksums #9205.
- Send
x-amz-checksum-mode: ENABLEDonHeadObjectandGetObjectonly whenOpStat::checksum()/OpRead::checksum()istrue(never on default requests or presigned URLs). - Parse
Metadata::checksum()only whenx-amz-checksum-typeisFULL_OBJECT(or an unsuffixed single-part checksum), ignoringCOMPOSITE.
- Send
- Behavior tests & live AWS S3 verification: Update
core/tests/behavior/async_write.rsand read/stat behavior tests to cover explicit S3Crc32c/Crc64Nvme(Any,Fast,Algo,Expected, single PUT + concurrent uneven-part multipart,Expectedmismatch without commit,Algo(Sha256)/Expected(Sha256)synchronousUnsupported, opt-instat/readFULL_OBJECTvsCOMPOSITE, default requests omitx-amz-checksum-mode) plus genericWriteChecksum::Anytests gated onwrite_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 onc54097b4f8. 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): ImplementChecksumLayer(write: Option<WriteChecksumPolicy>,require_write: bool,verify_read: bool,require_read: boolwith defaultsSome(Fast),false,true,false), with no local fake write fallback and nostat()data reads. - Write path:
- Preserve caller-supplied
args.checksum()untouched. - Clear
write_can_copy_from = falseonChecksumService::capability()whenever write injection is active andinner.capability().write_with_checksumistrue. - Inject via
OpWrite::with_checksum(policy.into(), &cap); in best-effort mode (!require_write), fall back once to un-injectedargson synchronous zero-I/OUnsupportedwhile preserving unrelatedUnsupportederrors (e.g.,appendor unsupported options).
- Preserve caller-supplied
- 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..or0..nwhenrp.metadata().content_length() <= n); pass partial range reads and chunkedReaderreads through unverified without upgrading to full-object downloads. - Automatically set
OpRead::with_checksum(true)on eligible full-object reads. - Verify
oio::Read::readbuffers and wrapoio::Read::openstreams in a zero-buffered streaming hasher: finalize and compare before yielding the final chunk oncebytes_read == content_length(catchingop.read_with(path).limit(n)), fail immediately ifbytes_read > content_length, finalize on empty EOF when length is unknown or0, and permanently latch terminalChecksumMismatchon repeated polls.
- Apply verification (and
- Facade wiring: feat(layers/checksum): expose typed ChecksumLayer from opendal #9218 added the optional
layers-checksumfeature and theopendal::layers::ChecksumLayerre-export. Rust callers attach it with.layer(ChecksumLayer::new()). URI/map registration forlayers=checksumis 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-sizeop.read_with(path).limit(n)corruption detection, terminal mismatch latching, partial/chunked passthrough underrequire_read(true),stat()never triggersread(),ChecksumLayeroutsideRetryLayerverifying resumed streams, andRouteLayerin 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 orx-goog-hashon the final resumable dataPUT. Recover lost resumable finalization responses by querying the session. Report stored CRC32C onstatand 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): SupportAny/Fastvia per-requestx-ms-content-crc64onPutBlob,PutBlock, andAppendBlock(transport-only,Metadata::checksum()staysNone); synchronously rejectAlgo/ExpectedinService::write. Landed in feat(services/azblob): verify transactional write checksums #9215. - Backblaze B2 (
core/services/b2): SupportAnyviaX-Bz-Content-Sha1on single upload and per-part on large files (b2_finish_large_file); synchronously rejectFast/Algo/ExpectedinService::write. - Alibaba Cloud OSS (
core/services/oss): Added sharedChecksumAlgo::Crc64Ecma(CRC-64/XZ parameters; check value0x995DC9BBDF1939FAfor123456789, distinct from CRC-64/ECMA-182) in feat(core): add shared CRC64-ECMA checksum algorithm #9240 and enabledwrite_with_checksumon 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-appendAny/Fastviax-oss-hash-crc64ecmareceipt verification onPutObject, per-partUploadPart, and ordered multipart completion, populatingMetadata::checksum(). Unconfirmed final receipts return a non-temporaryUnexpectederror without replaying publication (the object may already be visible). Synchronously rejectsAlgo/Expected, append with checksum, and presigned writes with checksum (Unsupported). Custom endpoints, CNAME addressing, HTTP,skip_signature, andread_with_checksumremain disabled. - Tencent Cloud COS (
core/services/cos): Uses sharedChecksumAlgo::Crc64Ecma(feat(core): add shared CRC64-ECMA checksum algorithm #9240) and landed in feat(services/cos): verify native write checksum receipts #9245. Supports non-appendAny/Fastviax-cos-hash-crc64ecmareceipt verification onPutObject, per-partUploadPart, and ordered multipart completion, populatingMetadata::checksum(). Unconfirmed final receipts return a non-temporaryUnexpectederror without replaying publication (the object may already be visible). Synchronously rejectsAlgo/Expected, append with checksum, and presigned writes with checksum (Unsupported).read_with_checksumremains disabled. - Volcengine TOS (
core/services/tos): UsesChecksumAlgo::Crc64Ecma(CRC-64/XZ) and landed in feat(services/tos): verify native write checksum receipts #9253. Enableswrite_with_checksumon signed endpoints (!skip_signature) for non-appendAny/Fastviax-tos-hash-crc64ecmareceipt verification onPutObject, per-partUploadPart, and ordered multipart completion, populatingMetadata::checksum(). Distinguishes explicit HTTP-200 JSON rejections from ambiguous publication; an unconfirmed receipt after a successful terminal status returns a non-temporaryUnexpectederror without replaying publication (the object may already be visible), andabort()acceptsNoSuchUploadwhile leaving any published version intact. Synchronously rejectsAlgo/Expected, append with checksum, and presigned writes with checksum (Unsupported). Unsigned endpoints andread_with_checksumremain disabled. - Additional services / S3-compatible presets:
- Verified S3-compatible presets (
core/services/s3): Directly advertisewrite_with_checksumwithoutenable_*switches (feat(services/s3): enable write checksums without preset switches #9241) while keepingread_with_checksum = falseacross all presets:seaweedfs(feat(services/s3): opt in to SeaweedFS write checksums #9221, feat(services/s3): enable write checksums without preset switches #9241; verified on SeaweedFS 4.52): full-objectAny/Fast(CRC-64/NVME) andAlgo/Expected(CRC-32C, CRC-64/NVME) on PUT and multipart, populatingMetadata::checksum(), plusExpectedon presigned PUT.minio(feat(services/s3): opt in to MinIO write checksums #9226, feat(services/s3): enable write checksums without preset switches #9241; verified on MinIORELEASE.2025-01-20T14-49-07Z): full-objectAny/Fast(CRC-64/NVME) andAlgo/Expected(CRC-32C, CRC-64/NVME) on PUT and multipart, populatingMetadata::checksum(), plusExpectedon presigned PUT. MinIORELEASE.2024-09-22T00-33-43Zcan store a PUT without checking or returning CRC-64/NVME (surfaces asUnexpected, object may already be visible).ceph-rgw(feat(services/s3): support opt-in CRC32C writes for the ceph-rgw preset #9237, feat(services/s3): enable write checksums without preset switches #9241; verified on Ceph RGW 20.2.5 and 21.2.0): full-object CRC-32C only (Any/Fast/Algo(Crc32c)/Expected(Crc32c)) on PUT and multipart, populatingMetadata::checksum(), plusExpected(Crc32c)on presigned PUT. Synchronously rejects CRC-64/NVME (Unsupported, as RGW can commit multipart uploads with an incorrect full-object CRC-64/NVME); RGW 18.2.8 and 19.2.7 can store objects without checking or returning CRC-32C.garage(feat(services/s3): enable verified write checksums for Garage #9244; verified on Garage 2.6.0): full-objectAny/Fast(CRC-64/NVME) andAlgo/Expected(CRC-32C, CRC-64/NVME) on PUT and multipart via the shared S3 writer, populatingMetadata::checksum(). Verified CRC-64/NVME multipart writes require Garage 2.5.0+; Garage 2.6.0 returnsInvalidDigeston CRC mismatches, which OpenDAL surfaces as non-temporaryUnexpectedrather thanChecksumMismatch(tracked in Track standard S3 write-checksum responses in Garage #9243).rustfs(feat(services/s3): verify RustFS upload checksums #9250; verified on RustFS 1.0.6): per-request CRC-32C receipt verification forAny/Faston single PUT (returnsMetadata::checksum()) and per-partUploadPartwith ordered ETag-only multipart completion (Metadata::checksum()staysNonefor multipart). Synchronously rejectsAlgo/Expected, append with checksum, and presigned writes with checksum (Unsupported).swift-s3api(feat(services/s3): verify Swift s3api upload requests with CRC32C #9252; verified on Swift 2.38.3): per-request CRC-32C verification forAny/FastonPutObjectandUploadPartwith ordered ETag-only multipart completion (Metadata::checksum()staysNone; rejected CRC-32C surfaces asChecksumMismatch). Requires Swift 2.38.3+; synchronously rejectsAlgo/Expected, append with checksum, and presigned writes with checksum (Unsupported).
- Withheld and unverified services / presets:
lakefs-s3remains disabled (write_with_checksum = false, feat(services/s3): enable write checksums without preset switches #9241) because live tests on lakeFS 1.88.0 with local storage committedPutObject,UploadPart, andCompleteMultipartUploadrequests with incorrect CRC-32C and CRC-64/NVME digests and omitted checksum receipts. Remaining S3-compatible presets (e.g.,r2and other cloud-provider S3 presets), S3 Express One Zone, and other native services remain disabled until live-service verification.
- Verified S3-compatible presets (
Phase 5: Bindings alignment
- Capability mirrors: Sync
Capability::write_with_checksumandCapability::read_with_checksumacross bindings that mirrorCapability(bindings/java,bindings/dotnet, and as applicablebindings/python,bindings/nodejs,bindings/c,bindings/go).- Java and .NET (
bindings/java,bindings/dotnet): Verified onmainat62bb66ff15(write_with_checksumin feat(core,services/s3): add write checksum intents and S3 support #9206,read_with_checksumin feat(core,layers/checksum): add read checksum capability and verification layer #9209). External consumer probes built against packaged Maven JARs (default and Linux x86-64 classifier JAR) and the .NET assembly with its rebuilt native library confirmed local operator capability reporting for memory (read=false,write=false), signed AWS S3 (read=true,write=true), and anonymous AWS S3 withskip_signature=true(read=false,write=true), with no live S3 I/O. Official Mavenorg.apache.opendal:opendal:0.50.8and NuGetApache.OpenDAL0.3.1predate feat(core,services/s3): add write checksum intents and S3 support #9206 and feat(core,layers/checksum): add read checksum capability and verification layer #9209 and do not include these fields. - Python (
bindings/python): Verified onmainat59faed46d9(feat(bindings/python): generate Capability from core #9123, matching the verified local merge tree25274d7166). Locally builtabi3wheels in an isolated CPython 3.11 venv confirmedread_with_checksumandwrite_with_checksumon bothopendal.Operatorandopendal.AsyncOperator(all 98 coreCapabilityfields exposed with the 50 existing properties preserved) for memory (read=False,write=False), signed S3 (read=True,write=True), S3 withskip_signature=true(read=False,write=True), and signed GCS (read=False,write=True), with no live cloud I/O, alongside externalmypy --strict/ Pyright stub checks and the Memory pytest suite (405 passed, 90 skipped). - Other bindings (
bindings/nodejs,bindings/c,bindings/go): In progress (feat(bindings/nodejs): generate Capability from core #9125, feat(bindings/c,go): generate Capability from core #9126).
- Java and .NET (
-
ChecksumMismatcherror mapping: Python (fix(bindings/python): preserve checksum mismatch errors #9222, feat(bindings/python): expose write checksum algorithms #9231), Java and .NET (fix(bindings): preserve checksum mismatch in Java and .NET #9228), Haskell (fix(bindings/haskell): preserve checksum mismatch errors #9230), and C, Go, and Zig (fix(bindings): expose checksum mismatch error code in C, Go, and Zig #9229) preserve checksum mismatches through their public exceptions or error codes. Python file writes and synchronous flush also preserveOSErrorcompatibility. Binding regression tests and consumer probes cover these mappings.
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.mdcodifying the portable checksum contract and wire it intocore/core/src/docs/specs/mod.rsandwebsite/specifications.sidebars.js. - Update rustdoc on
WriteChecksum,WriteChecksumPolicy,WriteOptions::checksum,StatOptions/ReadOptions/ReaderOptions::checksum,Capability::write_with_checksum,ChecksumLayer, andservices::S3docs (recommendingWriteChecksum/ChecksumLayerfor AWS S3).
This tracking issue was prepared with AI assistance (Gemini 4 Neon) for Xuanwo.
Activity
feat(services/s3): enable Garage write checksums
feat(services/s3): enable verified write checksums for Garage (#9244)