Skip to content

fix: FusedCodecPipeline must apply outer AA/BB codecs on partial paths - #255

Closed
d-v-b wants to merge 3 commits into
mainfrom
fix/fused-partial-aa-bb
Closed

fix: FusedCodecPipeline must apply outer AA/BB codecs on partial paths#255
d-v-b wants to merge 3 commits into
mainfrom
fix/fused-partial-aa-bb

Conversation

@d-v-b

@d-v-b d-v-b commented Jul 29, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

Fixes the most severe finding from the PR zarr-developers#3885 audit. Only the opt-in FusedCodecPipeline is affected.

FusedCodecPipeline.supports_partial_decode/supports_partial_encode passed require_no_aa_bb=False (where BatchedCodecPipeline passes True), so the partial-shard paths called the sharding codec's partial methods directly on the raw stored value — never applying codecs outside the sharding codec:

  • serializer=sharding + outer gzip compressor: fused wrote an un-gzipped shard blob while the array metadata declares gzip — unreadable by any conforming reader (BadGzipFile from batched; checksum mismatch when fused read batched-written data). Fused→fused round-trips passed, masking the corruption.
  • filters=[transpose] + sharding: silent wrong data in both cross-pipeline directions.

The fix passes require_no_aa_bb=True in both properties; chains with outer AA/BB codecs now fall through to the full-chunk fused paths, which apply the whole codec chain correctly.

Tests: the parity-matrix exclusion whose comment mislabeled this bug "a known limitation, not a pipeline-parity bug" is removed (gzip config re-enabled), and a new parametrized test covers outer-gzip and outer-transpose in both write/read directions (batched→fused and fused→batched) including a region write and region read. 15 of the new/re-enabled cases fail without the two-line fix (independently re-verified by the task reviewer via revert/rerun); 629 passed / 2 skipped on the verification suites plus a 2393-test broader sweep with no regressions.

🤖 Generated with Claude Code

FusedCodecPipeline.supports_partial_decode/supports_partial_encode passed
require_no_aa_bb=False, unlike BatchedCodecPipeline (True). With an outer
array-array or bytes-bytes codec around a sharding serializer (e.g.
compressors=[GzipCodec()], or filters=[TransposeCodec()]), the fused
pipeline's partial read/write branches called ShardingCodec's partial
sync methods directly on the raw stored value, skipping those outer
codecs entirely. That wrote non-conforming bytes for an outer BB codec
(unreadable by BatchedCodecPipeline or any conforming reader) and
silently produced wrong data for an outer AA codec.

Pass require_no_aa_bb=True in both fused properties so these chains fall
through to the full-chunk fused path instead, matching batched behavior.

Adds cross-pipeline parity coverage (full and partial read/write) for
sharding with an outer compressor and with an outer transpose filter, and
removes the "known limitation" exclusion that previously kept the
sharding+compressor case out of the nested-sharding parity matrix.

Assisted-by: ClaudeCode:claude-sonnet-5
@d-v-b
d-v-b force-pushed the fix/fused-partial-aa-bb branch from 6f44f3a to 3afccd2 Compare July 29, 2026 14:32
d-v-b added 2 commits July 29, 2026 17:54
…partial methods (zarr-developers#4201)

The partial dispatch in FusedCodecPipeline.read_sync/write_sync asserted
the private _decode_partial_sync/_encode_partial_sync methods, which only
ShardingCodec implements. A codec advertising the public partial mixins
(ArrayBytesCodecPartialDecodeMixin/-EncodeMixin) with only the documented
async partial methods died with a bare AssertionError — or, under
python -O, an AttributeError mid-IO. The asserts are now capability
gates: codecs without the sync partial methods take the full-chunk sync
path instead.

The related crash for sharded arrays with async-only inner codecs is
fixed separately in zarr-developers#4179.

Assisted-by: ClaudeCode:claude-fable-5
@d-v-b d-v-b closed this Jul 30, 2026
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