Skip to content

fix: reject reserved node names on creation - #4484

Closed
barlowa124 wants to merge 132 commits into
zarr-developers:mainfrom
barlowa124:reserved-node-names-4453
Closed

barlowa124 wants to merge 132 commits into
zarr-developers:mainfrom
barlowa124:reserved-node-names-4453

Conversation

@barlowa124

@barlowa124 barlowa124 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Covers item 1 of #4453. The spec reserves node names beginning with
__ and the name zarr.json, yet creation accepted both:
create_group("__a") wrote the reserved name outright, and
create_group("a/zarr.json") produced a/zarr.json/zarr.json. That
directory shadows the group's own metadata document and leaves the
subtree unreachable through members().

A _validate_node_name helper in zarr.core.common rejects any
/ segment that is zarr.json, __-prefixed, . or .., raising
MetadataValidationError before anything is stored. It runs inside
AsyncGroup.create_group, AsyncGroup.create_array and the
module-level create_array/create_group name/path arguments, so the
require_* and sync wrappers are covered through delegation.

Two boundaries are deliberate: empty segments still pass through
(store_path / has always normalized leading and repeated slashes),
and the open_* read paths are untouched so existing stores holding
such names still open. create_nodes keeps its documented
caller-responsibility contract.

For reviewers

Worth a second look. Whether open_group/open_array in create
modes should share the check is open (mode "a" is also a read mode,
so it would block opening stores that already contain such nodes).
Whether rejecting ./.. segments is welcome is open too, as is
whether the check belongs in Zarr format 2 at all, where zarr.json
is not a metadata name though a directory so named still orphans its
parent. The check is one
loop and narrows easily. Locally each rejected name raised before any
write and members() stayed consistent. tests/test_group.py is
green including the leading-slash parametrization.

Author attestation

  • I am a human. These are my changes. I have reviewed and understood every change and can explain why each is correct.

TODO

Done:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md
  • Changes documented as a new file in changes/

CI:

  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

d-v-b and others added 30 commits September 24, 2026 12:00
…lopers#4397)

* fix(sharding): reject variable-size codecs in index_codecs

The spec forbids variable-size codecs (e.g. compressors) in a sharding
codec's `index_codecs`. ShardingCodec accepted them, and the first write
then failed with a bare NotImplementedError from compute_encoded_size.
Check `is_fixed_size` on every index codec at construction time, and mark
the numcodecs checksum wrappers as fixed-size so they stay valid there.

Closes zarr-developers#2030

Assisted-by: ClaudeCode:claude-opus-5-5

* docs: add changelog fragment for zarr-developers#4397

Assisted-by: ClaudeCode:claude-opus-5-5
…nversions (zarr-developers#4340)

* Fix structured dtype v2 round-trip and silent loss of field offsets/padding

Bug 1: Nested structured dtypes failed the Zarr V2 JSON round-trip. The inner
type guard check_structured_dtype_v2_inner recursed into itself for a nested
field's last element, but that element is a list of [name, dtype] field pairs,
not a single pair. It now validates that element with check_structured_dtype_name_v2,
so metadata written by to_json(zarr_format=2) can be read back.

Bug 2: Structured dtypes with non-default (aligned / padded) field layouts were
silently re-packed contiguously on round-trip, changing field offsets and itemsize
and corrupting stored bytes. from_native_dtype now detects non-packed layouts
(recursively) and raises a clear ValueError instead. Reading existing packed data
is unaffected.

* fix(dtype): reject unrepresentable structured dtypes and fix nested v2 round trip

Nested structured dtypes written with Zarr format 2 could not be read back,
because the inner data type name check recursed as if the nested field were a
single [name, dtype] pair instead of a list of fields.

Structured dtypes that NumPy allows but the Zarr struct metadata cannot record
were accepted and rebuilt as something else: aligned or explicitly offset
layouts came back packed with a different itemsize, a titled field came back
as two fields (the fields mapping lists titles as extra keys), and a subarray
field came back as raw bytes. Struct.from_native_dtype now raises ValueError
naming the offending field for all three, and iterates over names rather than
the fields mapping.

Add zdtypes() and structured_dtypes() hypothesis strategies to
zarr.testing.strategies, and three property tests: every registered data type
round-trips through JSON and through NumPy, and structured dtype resolution
either raises or returns the input dtype exactly. The last property is the one
every bug above violated.

Assisted-by: ClaudeCode:claude-fable-5-1

* chore: renumber changelog fragment to upstream PR 4340

Assisted-by: ClaudeCode:claude-fable-5-1

* style: use single backticks for code in docstrings

Assisted-by: ClaudeCode:claude-fable-5-1

* fix(dtype): preserve padded structured array writes

Keep packed conversion for non-default layouts with a user warning, and verify field values survive both Zarr formats.

Assisted-by: Codex:GPT-6

* fix(dtype): warn once for padded structured dtypes and reword the rejection message

Repack the dtype once at the top level before resolving fields, so a padded
nested field warns once rather than once per level of nesting. Attribute the
warning to the first frame outside the zarr package; this reaches the caller
for direct uses of the dtype API, while the synchronous array API runs on the
event loop thread where no caller frame exists.

The title/subarray error message no longer claims that stored bytes would be
misinterpreted; the field information simply has no place in the metadata.
The changelog now says those dtypes used to fail with an unrelated NumPy error
rather than losing information silently.

Assisted-by: ClaudeCode:claude-fable-5-1

* docs: remove redundant structured dtype packing advice

Assisted-by: Codex:GPT-6

* docs: distinguish structured dtype limitations from format rules

Correct unsupported format claims using V2 history and runtime probes. Tighten the generated dtype property so unexpected rejection fails.

Assisted-by: Codex:GPT-6

* docs(dtype): explain generic scale string serialization loss

Assisted-by: Codex:GPT-6

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
… struct (zarr-developers#4387)

* feat(dtype): resolve nested data types with the registry that resolves their container

A structured data type resolved its field data types with the default data
type registry, whatever registry resolved the structured data type itself,
so a DataTypeRegistry other than the default could not supply field data
types.

- DTypeResolver (exported from zarr.dtype) is the signature of
  DataTypeRegistry.match_json.
- HasNestedDTypes is a mix-in for data types that contain data types. A
  registry creates them with the _from_json_nested hook, passing its own
  match_json as the resolver. Other data types are created with from_json as
  before, so data types that override from_json keep working.
- Structured and Struct are HasNestedDTypes, and their from_json takes an
  optional resolver (the default registry when omitted).
- get_data_type_from_json, get_data_type_from_native_dtype, parse_dtype and
  parse_data_type take an optional registry (the default registry when
  omitted).

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(dtype): load entry point data types when the registry is first used

zarr.registry collects data type entry points into
DataTypeRegistry._lazy_load_list, but nothing in src called _lazy_load, so
data types registered through the "zarr.data_type" entry point group never
loaded. get, match_dtype and match_json now load them first, as the other
registries do in their getters. _lazy_load imports each entry point once
instead of twice.

The test fixture that clears pending entry points now clears the data type
registry's too, since _collect_entrypoints does not return it, and the
entry point test no longer loads them by hand.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs: add changelog fragment

Assisted-by: ClaudeCode:claude-opus-5-5

* refactor(dtype): resolve nested data types in a DTypeContext with a path

Replaces the DTypeResolver callable with a context object, as mature
decoders do (Jackson's DeserializationContext, Gson's Gson instance,
PyYAML's loader), so it can grow without changing the hook's signature.

- DTypeContext (exported from zarr.dtype) holds the registry, the Zarr
  format and the path of the data type within the data types that contain
  it. Composites resolve each contained data type with
  context.child(name).resolve(json). The Zarr format is part of the context
  because contained data types always share their container's format.
- HasNestedDTypes._from_json_nested takes the context.
- Structured.from_json / Struct.from_json take registry= like the other
  entry points, instead of a resolver.
- NestedDataTypeValidationError (a DataTypeValidationError) reports a
  contained data type that matches nothing, with its path. The registry
  re-raises it instead of trying other data types, since the JSON has the
  shape of the containing data type. This restores a specific error for an
  invalid struct field (e.g. "... matches {'name': '|i9', ...} at path
  ['a']"), which zarr-developers#351 had reduced to a mismatch of the whole struct.

Assisted-by: ClaudeCode:claude-opus-5-5

* refactor(dtype): split resolution into a Context value and a Reading state

DTypeContext mixed two things: which extensions a read may resolve (the
same for a whole read, chosen by the caller) and where the read has got to
(changing at every nested step). That does not extend to other kinds of
extension: a codec read that meets a data type (cast_value) must hand the
same extensions to a data type read.

- zarr.registry.Context is the set of extensions, by kind. It holds only
  data_types for now; codecs, chunk key encodings and chunk grids can be
  added as fields with defaults. Context.default() refers to the default
  registries. This mirrors zarr-metadata's Context, passed as context=.
- Reading (zarr.core.context) is the state of a read: the context, the Zarr
  format and the location in the document. Composites read contained
  extensions with reading.at(*keys).resolve_data_type(json).
- The location is the JSON location in the document, reported as a JSON
  Pointer, so it stays unambiguous once codecs nest data types. A Zarr V2
  data type is located by its name as written in the document.
- The containing data type decides that a failure is nested: Structured
  raises NestedDataTypeValidationError for a field that matches nothing,
  since a non-empty location no longer means "inside another data type"
  once metadata parsing starts reads at /data_type.
- The dtype entry points and Structured.from_json take context= instead of
  registry=.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs: name the zarr-developers#4385 changelog fragment after its pull request

It was merged under its fork pull request number (351), which towncrier
would link to the wrong pull request.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs: name the changelog fragment after the upstream pull request

Assisted-by: ClaudeCode:claude-opus-5-5

* refactor(dtype): rename Reading to Resolver

A Resolver is a Context positioned in a document; it resolves the
extensions there. The pair mirrors referencing.Registry and
referencing.Resolver in python-jsonschema. "Reading" read as a verb.

Assisted-by: ClaudeCode:claude-opus-5-5

* refactor(dtype): give every data type the resolver hook

ZDType._from_json_resolved(data, *, resolver) is the one way a registry
creates a data type. Its default ignores the resolver and calls from_json in
the resolver's Zarr format, so data types that override from_json keep
working; a data type that contains others (Structured, Struct) overrides it
to resolve them. This replaces the HasNestedDTypes mix-in and the registry's
issubclass branch: every type receives the context and leaves ignore it, as
in pydantic's __get_pydantic_core_schema__(source, handler), serde's
Deserialize, and zarr-metadata's resolve(data, context).

Assisted-by: ClaudeCode:claude-opus-5-5

* refactor(dtype): keep the resolution context internal

Context, the context= keywords, and the nested data type error were public
API without a caller that needs them, and their shape is expected to change
once codecs join the context or zarr-python reads metadata through
zarr-metadata.

- zarr.registry no longer exports Context; it stays in zarr.core.context.
- get_data_type_from_json, get_data_type_from_native_dtype, parse_dtype,
  parse_data_type and Structured.from_json are unchanged from main.
  Structured's _from_json_v2/_v3 resolve fields with the default registry;
  a DataTypeRegistry resolves them with itself through _from_json_resolved.
- The nested error is _NestedDataTypeValidationError in the dtype registry
  module, a DataTypeValidationError, and no longer in zarr.errors.

What remains user-visible is bug fixes: a structured data type read by a
DataTypeRegistry resolves its fields with that registry, a bad field is
reported with its JSON location, and entry point data types load.

Assisted-by: ClaudeCode:claude-opus-5-5
…arr-developers#4353)

* fix(store): run every LocalStore filesystem call off the event loop

LocalStore.get and .set already hand their I/O to asyncio.to_thread,
but open/_open, clear, delete, delete_dir, list, list_prefix, list_dir,
move and getsize still called pathlib/shutil directly inside `async
def`, stalling every task that shares the loop for the duration of a
stat, a directory walk or an rmtree. Each of those now runs exactly one
small module-level sync helper via to_thread; the synchronous methods
(_ensure_open_sync, delete_sync) call the same helpers directly so the
two paths cannot drift.

Because _open now suspends, concurrent lazy opens (every `set` of a
`set_many` on a store that has not been opened yet) all pass the
`_is_open` check and the second to finish hit Store._open's "already
open" error. LocalStore._ensure_open is overridden to tolerate that
race; explicit double-open still raises as the conformance suite
requires.

The LocalStore test class gains an autouse fixture that patches the
os/io entry points every pathlib and shutil helper bottoms out in and
fails the test if any of them is reached on a running loop's thread
from inside a LocalStore coroutine or async generator (calls from
asyncio.to_thread workers, and from the store's synchronous methods,
are allowed). Ruff's ASYNC rules cannot see these calls because it does
not infer `self.root / key` to be a Path. Before this fix the detector
flagged open/_open (also reached lazily via get and set), clear, delete,
delete_dir, list, list_prefix, list_dir, move and getsize. A companion
test asserts the hooks really observe the store's I/O in worker threads
so the detector cannot pass vacuously, and another pins the concurrent
lazy-open race.

list_prefix now materializes its directory walk in the worker thread,
as list already did; the key relativization uses str.removeprefix
instead of str.replace, which also removed any later occurrence of the
root path inside a key.

Assisted-by: ClaudeCode:claude-fable-5-1

* chore(store): widen the event-loop detector and polish LocalStore notes

Review nits: patch os.open, os.fsync, os.utime and os.access as well so
the blocking-call detector is not tied to the calls LocalStore makes
today; note on LocalStore._ensure_open that it calls Store._open
directly and so bypasses a subclass's _open override on lazy open; use
single backticks in the changelog fragment and the _list_files
docstring.

Assisted-by: ClaudeCode:claude-fable-5-1

* chore: renumber changelog fragment to upstream PR 4353 as a bugfix

Assisted-by: ClaudeCode:claude-fable-5-1

* test(store): ignore coverage's own filesystem calls in the LocalStore detector; cover delete_dir on a file

coverage.py resolves a source file's path with os.path.realpath the first
time its tracer sees code from that file, on whatever thread runs that code.
The event-loop detector patched os.lstat and attributed those calls to the
LocalStore coroutine that happened to be executing, so the LocalStore suite
errored whenever it ran under coverage with a fresh tracer. Calls carrying
coverage's own frames are now ignored.

Also add the missing error-case test for delete_dir on a prefix that names
a file.

Assisted-by: ClaudeCode:claude-fable-5-1

* test(store): check the detector observes every async LocalStore method

Parametrize the non-vacuity test over all fifteen async entry points
instead of only get and set. Doing so showed exists and getsize were
invisible to the detector: they handed a bare Path method to to_thread,
so no _local.py frame was on the worker stack. Both now go through
module helpers like every other method.

Set the open flag directly in _ensure_open rather than re-checking and
calling Store._open, and reword the comment so it no longer reads as if
Store._open's error is what flips the flag.

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
…arr-developers#4402)

* fix(storage): yield only direct children from FsspecStore.list_dir

An HTTP listing is scraped from the links on an HTML index page. A link to
the site root ("/") becomes a self-link that list_dir reduced to "", so a
group listed itself as a member named "". In-page anchors ("#usage") became
keys whose metadata fetch returned the HTML page, and directories carried a
trailing "/".

list_dir now skips http(s) entries with a fragment or query, strips the
trailing "/", drops empty or nested names, and yields each name once.

Closes zarr-developers#3575

Assisted-by: ClaudeCode:claude-opus-5-5

* docs: add changelog fragment for zarr-developers#4402

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(storage): scope HTTP link filtering to the child name in list_dir

The "#"/"?" check ran on the whole URL, so a store rooted at a URL
containing either character would list nothing. It now runs on the name
left after stripping the prefix. HTTP names are also normalized with
posixpath.normpath, so "./a" lists as "a" and "./" no longer lists as ".".

Assisted-by: ClaudeCode:claude-opus-5-5
…lias (zarr-developers#4342)

* fix(dtype): preserve scaled generic time units and normalize the μs alias

`DateTime64` and `TimeDelta64` read unit and scale from the dtype object
rather than `dtype.name`, which drops a generic unit's scale. V2 metadata
writes an explicit `[Ngeneric]` suffix; the constructor stores `μs` as `us`.

NumPy allocation drops a generic time dtype's scale and byte order, and
`astype` between generic time dtypes ignores the target. The CPU buffer
restores the dtype with a view after allocation and converts endian-only
casts through the integer counts. Integer fill values for generic datetimes
decode through `datetime_from_int`, and structured defaults build a zero
count for generic datetime fields.

Assisted-by: ClaudeCode:claude-opus-5-5

* test(dtype): cover the time unit grid through the dtype test harness

Generate the valid native dtypes and V2/V3 JSON for `DateTime64` and
`TimeDelta64` from every unit, scales 1, 2 and 2**31 - 1, and both byte
orders, instead of a separate round-trip test that repeated the harness's
native and JSON round trips.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(dtype): keep the scale factor on NaT time scalars

`DateTime64.default_scalar`, `TimeDelta64.default_scalar`, and the NaT
branch of `TimeDelta64.cast_scalar` built NaT in the bare unit, dropping
the scale factor. On NumPy < 2.2, casting a timedelta NaT between scales
yields a count instead of NaT, so missing chunks of a `m8[2us]` array
read back as 2**62 - 1 instead of NaT.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(changelog): note the scaled NaT fill fix

Assisted-by: ClaudeCode:claude-opus-5-5
…zarr-developers#4229)

* docs: show package tag instead of monorepo release in subpackage doc headers

* refactor: DRY mkdocs configuration

* perf: cache tag

* fix(docs): ship real files in package sdists; build sites on shared-file changes

The docs/_static/source-version.js symlink points outside the package, so
each sdist carried a dangling link and pip refused to unpack it ("would
link to ... outside the destination"). mkdocs.yml's INHERIT of
../mkdocs-base.yml likewise broke `mkdocs build` from an unpacked sdist.

Link mkdocs-base.yml into each package too, INHERIT it from the package
directory, and have the sdists exclude both links and force-include the
files they point at. The sdist is self-contained again.

Package CI and the RTD PR-build skip only watched packages/<name>, so an
edit to the shared base or script built no site. Add both shared files to
every package workflow's paths and to each .readthedocs.yaml diff.

Assisted-by: ClaudeCode:claude-opus-5-5

* build(docs): align sub-package docs pins with the root docs environment

The three sites share packages/mkdocs-base.yml but resolved different
plugin versions (mkdocstrings 1.0.4 vs 1.0.6, mkdocstrings-python 2.0.5,
ruff 0.15.20 / 0.15.22 / 0.16.0), and two packages' comments claimed to
match the root docs group while not doing so. Pin all three to the root's
versions (mkdocstrings 1.0.6, mkdocstrings-python 2.0.8, ruff 0.16.8) and
relock zarr-indexing and zarr-http-server.

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
…rr from just (zarr-developers#4406)

* chore: keep sub-package pyproject.toml standalone; overlay in-repo zarr from just

The packages reached in-repo zarr two different ways: zarr-http-server
pinned it with `[tool.uv.sources] zarr = { path = "../.." }` in
pyproject.toml, and zarr-indexing ran its tests in the repo root's
environment (`uv run --project ../..`). Both reach outside the package, so
neither package's unpacked sdist could run its own `just test`.

Now every package's pyproject.toml stands alone, and the justfiles add
the in-repo zarr as an editable overlay (`--with-editable ../..`) only
when ../.. is the repository. From an sdist there is no overlay:
zarr-http-server resolves zarr from PyPI, and zarr-indexing's zarr suites
skip. zarr-metadata needs no zarr and is unchanged.

zarr-http-server's uv.lock now resolves zarr from PyPI, and zarr-indexing
CI syncs the package environment instead of the root one.

Assisted-by: ClaudeCode:claude-opus-5-5

* chore: add changelog fragments for zarr-developers#4406

Assisted-by: ClaudeCode:claude-opus-5-5
…_on_failure (zarr-developers#4409)

The test assumed the slow write is always in flight when the failing write
raises. When the failing chunk's encode lands first, its write raises
while the loop still awaits the other encode; `gather` then runs the done
callback of that already-failed child eagerly and returns an outer future
that has already failed, so `await gather(...)` does not suspend, and the
`finally` cancels the slow write before its first step. `write_started`
is never set.

That outcome is correct (no stray write), but it is not what the test
checks. Make the failing write wait until the slow write has started
before raising, so the in-flight case is exercised every time.

Reproduced at 8/400 (py3.13) and 3/400 (py3.14) with 16 parallel
workers; with the fix, 2000/2000 on both. It had failed in CI five times
since the test landed, on Linux, macOS and Windows.

Assisted-by: ClaudeCode:claude-opus-5-5
…m guidance (zarr-developers#4407)

* chore: keep sub-package pyproject.toml standalone; overlay in-repo zarr from just

The packages reached in-repo zarr two different ways: zarr-http-server
pinned it with `[tool.uv.sources] zarr = { path = "../.." }` in
pyproject.toml, and zarr-indexing ran its tests in the repo root's
environment (`uv run --project ../..`). Both reach outside the package, so
neither package's unpacked sdist could run its own `just test`.

Now every package's pyproject.toml stands alone, and the justfiles add
the in-repo zarr as an editable overlay (`--with-editable ../..`) only
when ../.. is the repository. From an sdist there is no overlay:
zarr-http-server resolves zarr from PyPI, and zarr-indexing's zarr suites
skip. zarr-metadata needs no zarr and is unchanged.

zarr-http-server's uv.lock now resolves zarr from PyPI, and zarr-indexing
CI syncs the package environment instead of the root one.

Assisted-by: ClaudeCode:claude-opus-5-5

* chore: add changelog fragments for zarr-developers#4406

Assisted-by: ClaudeCode:claude-opus-5-5

* build: replace deprecated git_describe_command; commit zarr-metadata uv.lock

setuptools-scm deprecates the top-level `git_describe_command` in favour of
`scm.git.describe_command` (a DeprecationWarning builds swallow). Move the
root and all three sub-packages to the new key; hatch-vcs passes raw-options
to setuptools_scm.get_version, which accepts `scm` from setuptools-scm 9.0
(8.4, which the docs name, was never released), so require
setuptools-scm>=9 at build time. Computed versions are unchanged.

`tag.prefix`, setuptools-scm's documented monorepo option, is not reachable
through hatch-vcs 0.5.0: get_version() takes no `tag` argument.

uv's docs say uv.lock "should be checked into version control", with no
library exception, and the other two sub-packages already commit theirs.
Stop ignoring zarr-metadata's.

Assisted-by: ClaudeCode:claude-opus-5-5

* ci: test each sub-package sdist standalone before release

`hatch build` builds the wheel from the source tree, so nothing exercised
the sdist: zarr-developers#4229's first cut shipped sdists whose symlinks pip refuses to
unpack, and the release workflows would have uploaded them. The
test_artifacts job now builds a wheel from the sdist with pip, then runs
the package's `just test` and `just docs-check` from the unpacked sdist.
The job has no checkout, so zarr (for zarr-http-server) resolves from
PyPI, which also covers the `zarr>=3.1` floor that repo runs, overlaying
in-repo zarr, never check.

Assisted-by: ClaudeCode:claude-opus-5-5

* chore: add changelog fragment for zarr-developers#363

Assisted-by: ClaudeCode:claude-opus-5-5

* chore(zarr-metadata): relock for the docs pins aligned in zarr-developers#4229

Assisted-by: ClaudeCode:claude-opus-5-5

* chore: renumber changelog fragment for zarr-developers#4407

Assisted-by: ClaudeCode:claude-opus-5-5
…pers#4414)

* fix(array): reject unknown keys in ArrayConfig.from_dict

from_dict read only the keys it models and silently ignored the rest,
so create_array(config={"nope": 1}) succeeded and a misspelled key such
as "write_empty_chunk" had no effect. with_config, which builds the
config with ArrayConfig(**...), already raised for the same key. Raise
a TypeError naming the unknown keys and the valid ones.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(changes): add fragment for zarr-developers#4414

Assisted-by: ClaudeCode:claude-opus-5-5
…developers#4420)

zarr-python writes attributes with the defaults of Python's `json`
module, so an xarray `_FillValue` of NaN is stored as a bare `NaN`, and
the model refused to read such a store. Attributes are user data, which
the spec asks only to be JSON values and never interprets, so a
non-finite number in them is now read, validated and written back as
Python's `json` writes it. Anywhere the spec interprets a value one is
still refused, and the store reader now says where instead of failing to
decode the document.

`refine_json` walks a value once, normalizing and judging it, and
`refine_user_data` is the same walk where a non-finite number is the
float it is. Only the validators say where user data is: they walk a
node's attributes with `refine_user_data`, the store reader decodes and
leaves the judging to them, and `to_key_value` validates what it writes
with the `parse_*` its reader uses, so it no longer writes a document
the reader refuses.

Assisted-by: ClaudeCode:claude-opus-5-5
…ec reads it (zarr-developers#4432)

* feat(zarr-metadata): the checker: parsers and writers compiled from annotations

The second of the stack, and a module on its own: `v3/_typed_json`
compiles, once per annotation, a parser for each shape JSON takes --
`int`, `float`, `bool`, `str`, `JSONValue`, a `Literal`, `tuple[T, ...]`
and `tuple[T1, T2]`, a union, a TypedDict, a record dataclass,
`Mapping[str, V]`, a `NewType`, and `| UNSET` for a member a document may
leave out -- and the writer that is its inverse. A parser is
`(value, loc, state) -> (typed value, problems)`, generic in a state it
hands through untouched, so a caller's leaf can read its own shapes at
any depth: the entity layer's leaf, in the next PR, reads a field that
holds another entity in a scope. The module knows nothing of entities.

Read once per class, cached: `field_hints` resolves a dataclass's
annotations where each class was defined, under PEP 649 as before it,
and skips class variables, which `declared_class_vars` reports so a
base can owe one.

Assisted-by: ClaudeCode:claude-fable-5-1

* docs(zarr-metadata): the fragment for the checker

Assisted-by: ClaudeCode:claude-fable-5-1

* fix(zarr-metadata): the checker reads a TypedDict as the typing spec defines it

The definition layer makes a configuration's TypedDict the one
declaration of its JSON, so the checker has to read a TypedDict the way
the typing spec does, and it did not:

- Whether a key is required came from `NotRequired` wrappers alone, so
  `total=False` was ignored, and callers that asked `__required_keys__`
  instead got a different answer: the runtime works that out before the
  annotations are evaluated, and a qualifier written as a string, as
  `from __future__ import annotations` writes every one, is invisible
  to it. `typeddict_keys` now reads `Required` and `NotRequired` off the
  evaluated annotations and falls back on the declaring class's `total`
  for a key with neither.
- Every TypedDict was treated as closed. `closed`, `extra_items` and
  openness are now read as the spec says, inherited from the bases when
  a class says nothing, which the runtime does not record; bases that
  disagree are a `TypeError`.
- The typed value kept a closed TypedDict's unknown keys, so a value
  typed as the TypedDict held keys the type says cannot exist. It is now
  a new dict of the keys the type admits, in the order they came.
- `None` is JSON null, a type alias reads as what it stands for, and a
  TypedDict or alias that holds itself compiles instead of recursing
  without end. An annotation that does not resolve is a `TypeError`
  naming its TypedDict at any depth, not a `NameError` from inside.

Parsers are pure, `(value, loc) -> (typed value, problems)`. The state
argument was for the entity layer's scoped reads; the definition layer
finds nested fields in the typed value instead, so the branch of a
union that did not match leaves nothing behind. The record dataclasses,
the writers, `| UNSET` members, `field_hints` and `declared_class_vars`
were the entity layer's too, and have no caller in this stack.

`test_typed_json_properties` holds the checker to a reference predicate
worked out from a drawn spec -- TypedDicts with bases, per-class
`total`, qualifiers in any order, every kind of openness, classes that
hold themselves -- built with evaluated and with postponed annotations,
over JSON values of capped depth that conform, nearly conform, or are
drawn at large. Each of the bugs above, put back, fails it.

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(zarr-metadata): check, the checker as a public tool

The checker was private, so a layer meant to stand alone gave a caller
nothing to call until the definition layer. `zarr_metadata.typed_json`
is its door: `check(value, SomeTypedDict)` type-checks a JSON value
against any TypedDict -- the package's own document and configuration
types, or a caller's -- and gives back a value of it, or None, with
every problem located; `typeddict_keys` says what a TypedDict declares.
The module moves out of `v3`, since nothing in it is version-specific.

Every TypedDict the package declares now compiles, and a test says so:
the v2 `dtype` alias names itself through a string, which is now
resolved in the alias's module.

What other runtime checkers do, and what their test suites catch, was
surveyed first -- pydantic, typing-inspection, typeguard, cattrs,
msgspec, trycast, typedload, beartype, typing_extensions and CPython --
and taken in:

- Each annotation is evaluated in the module of the class that wrote
  it. `get_type_hints` reads what a subclass inherited in the subclass's
  module, so a base's `x: Foo` read as the subclass's `Foo`, a silent
  wrong answer, and a string nested in a base's annotation failed to
  resolve at all (CPython #90531). pydantic and typeguard get the first
  right; none of them the second.
- A union of TypedDicts tagged by a `Literal` key is read by the branch
  the tag names, so a gzip with a bad level is reported as a gzip; an
  untagged union is reported by its closest branch; and of clean
  TypedDict branches, the one declaring the most of the value's keys
  reads it.
- A key both `Required` and `NotRequired`, and runtime keys that are not
  the annotated keys, are a `TypeError`.
- A recursive alias is named in a message rather than expanded.
- Tests: every declaration under both `typing.TypedDict` and
  `typing_extensions.TypedDict`; bases in other modules holding names
  their subclasses' modules lack or mean otherwise; redeclared and
  narrowed keys, diamonds, quoted qualifiers, keys that are not names.
  The property suite now builds each class in a module of its own,
  mixes postponed and evaluated classes, quotes names by hand,
  redeclares read-only keys, notes a failing example's source, and
  asserts it still reaches each of these.

Assisted-by: ClaudeCode:claude-opus-5-5

* build(zarr-metadata): hypothesis for the checker's property tests

The first tests that import it are the checker's, so it joins the test
group here.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): problem() says what a caller does with it

Nothing raises `MetadataValidationError` from a rule; a caller that
collects problems extends with the tuple `problem()` returns.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(zarr-metadata): check refuses null

`check(None, SomeTypedDict)` came back `(None, ())`: no value and no
problem. `refine_json` gives JSON's `null` as None with no problem, and
`check` read a None refinement as "not JSON, and its problems say why".
It now asks the problems whether the value is JSON, so `null` is checked
like any other value, and refused as not an object.

Assisted-by: ClaudeCode:claude-opus-5-5

* refactor(zarr-metadata): JSON and its problems below the model

The checker imported `ValidationProblem`, `ProblemKind`, `refine_json`
and `is_json` from the model, so the layer that stands alone depended on
the one it feeds. They move, with the rest of what reads JSON and
reports on it, into `zarr_metadata._json`: the problem types,
`MetadataValidationError`, `refine_json` and `refine_user_data`,
`validate_json`, `is_json`, `parse_json` and `arrays_to_tuples`.
`zarr_metadata.model` exports every name it did; the checker, and the
model's own modules, import from where the names now live.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): the checker's fragment takes this PR's number

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
…arr-developers#4434)

* feat(zarr-metadata): must_understand false refused at every extension point

Ignoring a codec gives wrong bytes as surely as ignoring a data type
gives wrong values, so no extension point may be declared ignorable:
`validate_array_metadata_v3` now refuses `must_understand: false` on a
codec or a storage transformer, as it already did on a data type, a
chunk grid and a chunk key encoding. The spec names only those three,
which this package reads as an oversight rather than a licence.
`must_understand: false` keeps its meaning where it has one: an unknown
top-level extension field, which a reader really can skip.

It changes verdicts and nothing else depends on it, so it stands on its
own as a reading of the spec. The definition layer above reads every
metadata field under the same policy.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): the fragment for must_understand false refused everywhere

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(zarr-metadata): the array schema refuses must_understand false where the validator does

The JSON schema the pydantic integration generates typed a codec and a
storage transformer with the envelope that allows `must_understand:
false`, so it accepted an array document the validator refuses. Every
extension point of an array document now has the mandatory envelope,
and the test that holds schema and runtime together covers all five.
A metadata field read on its own keeps the general envelope, as
`parse_metadata_field_v3` does.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): cite the spec lines that name the three points

The comment linked the section's opening rules, not the sentence that limits `must_understand=False` to three extension points.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): the fragment takes this PR's number and says what breaks

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(zarr-metadata): one metadata field read against its definition

The one-field layer, JSON first: the type check stands alone and feeds
the rules, and nothing is built from a configuration to judge it.

A definition is a value: the name the metadata carries, the TypedDict
its configuration is -- the one declaration of that JSON, which the
checker is compiled from -- and plain functions over that TypedDict for
the rules. Its kind is its type (`CodecDefinition`, `ChunkGridDefinition`,
...), and a generic frozen dataclass checks itself in `__post_init__`:
no `__init_subclass__`, no metaclass, no abstract base. A scope holds
definitions by kind.

Three steps, each usable on its own by a caller holding JSON: `check`
(JSON against a TypedDict, no scope: zarr-developers#347's, re-exported),
`Definition.judge` (the check, each nested field's envelope judged -- a
member annotated `CodecField` holds one -- then the rules), and
`resolve` (a whole field in a scope, returning `Resolved` with a
`Resolution` and every problem located). gzip, bytes, crc32c and the
regular grid are defined.

What the rules are handed is what the type says: a configuration holding
the keys its TypedDict admits and nothing else, whose nested fields'
envelopes are sound, so a rule may index a table by key or read a nested
field's name; a rule's problems land in the configuration in `judge` and
`resolve` alike. The checker hands nested fields back in the typed value,
so the branch of a union that did not match reads none. A definition
refuses at build what it could not read with -- a TypedDict that says
nothing of the keys it does not declare, a member typed
`ZarrV3MetadataFieldJSON`, an annotation that does not resolve, a name
that is not a string, a codec kind outside the three, rules or `names`
that are not functions -- and a field is read as one of the five kinds,
with or without type arguments, anything else a `TypeError`.
`configuration_of` types a read configuration as its definition's
TypedDict, and the configuration's type parameter has a default, so
`resolve(field, CodecDefinition, scope)` infers nothing unknown.

The definitions read JSON and its problems from `zarr_metadata._json`,
and a metadata field's own validators from `zarr_metadata.v3._common`,
where they move from the model, so nothing this layer adds imports the
model it supports.

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(zarr-metadata): every extension as a definition

Layer 2b interpolates 2a's single field across the package: each codec,
data type, chunk grid and chunk key encoding is a definition -- its name,
the TypedDict main already declares for its configuration, and its rules
as a function over that TypedDict.

- Codecs: blosc, zstd, transpose, scale_offset, sharding_indexed and
  cast_value join gzip, bytes and crc32c. A shard's two pipelines and a
  cast's target type are nested fields: their TypedDicts annotate them
  `CodecField` and `DataTypeField`, statically the same envelope type,
  and they are read in the scope the containing field is read in.
- Data types: the sixteen with nothing to configure take
  `EmptyConfiguration`; the numpy time types share their scale-factor
  rule; struct judges its field names; the raw-bytes family claims every
  `r<N>` and judges its width.
- The rectilinear grid, and the default and v2 chunk key encodings.
- `canonical` per definition, and `canonicalize` for a field in scope:
  blosc drops a `typesize` that `noshuffle` ignores, rectilinear
  run-length encodes, and nested fields and envelopes simplify without
  code of their own. The configuration it starts from holds what its
  TypedDict admits at every depth, and what `canonical` gives is judged
  again: one that does not hold is a `ValueError`, the definition's
  fault rather than the field's.

`CORE` holds the 24 the specification defines and `CORE_AND_EXTENSIONS`
the 9 more zarr-extensions registers, as on zarr-developers#4379.

Against zarr-developers#4379's entity layer, over every metadata field in the
40k-document corpus (157,254): the same resolution for every field, and
the same canonical spelling for all 114,445 that read. Problems and
messages are the same for all but 9, sharding codecs with a stray member
in an inner codec's envelope: the shard's own rule is not asked of a
configuration whose nested envelopes are not sound, as `judge` would not
ask it, so its problem waits until the envelope is fixed. Deferred to
the layer that reads types together: whether a struct field's type is
fixed-size.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): the fragments for metadata fields read against their definitions

2a and 2b land together, here: alone, 2a's scopes hold four definitions
and read a core data type as out of scope. So 2a's fragment is named
for this PR, beside 2b's.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(zarr-metadata): a field with a problem has no simplest spelling

`canonicalize` gave a spelling for a field with an unknown key, a stray
envelope member or a `must_understand` of `false`, reporting the problem
beside a form that had quietly dropped what the author wrote: `{"name":
"bytes", "configuration": {"endain": "big"}}` came back as `"bytes"`.
Now a field with any problem comes back None, with its problems. A
field with an unknown key is still read, and `resolve` still hands back
its configuration, so a consumer that tolerates one filters by kind;
the guide says the field is valid only when there is no problem at all.

Assisted-by: ClaudeCode:claude-opus-5-5

* test(zarr-metadata): resolve refuses must_understand false wherever the model does

The definition layer judges a field's envelope with the same refusal the
model's validator applies at each extension point. One test now holds
the two together at all five points, so a change to the reading that
reaches one and not the other fails here.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): one fragment for metadata fields read against their definitions

The two fragments were 2a's and 2b's, and the first still said the
scopes hold four definitions. zarr-developers#350 lands both, so one fragment says
what it lands.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(zarr-metadata): null is not a verdict for a field or a configuration

`resolve(None, ...)` answered "invalid" with no problem, and
`Definition.judge(None)` and `canonicalize(None, ...)` answered with no
value and no problem. `refine_json` gives JSON's `null` as None with no
problem, and each read a None refinement as "not JSON, and its problems
say why". They now ask the problems whether the value is JSON, so
`null` is read like any other value, and refused as a value of the
wrong type.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(zarr-metadata): a reader's definition takes a name over from a family

`CORE_AND_EXTENSIONS.extended_with(my_r16)` still read `r16` with the
raw-bytes family, since `claimant` asked the definitions in the order
they were filed and the family came first, so a reader could not
substitute its own reading of one name a family claims. It now asks the
one filed last first, as `Context.of` and `extended_with` say: a
definition passed later takes a name over, whether the earlier one was
filed under it or claims it as a family. No two definitions the package
files claim the same name, so its own scopes read as before.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(zarr-metadata): a regular grid's chunk extent may be 0

The core spec: "The chunk shape elements are non-zero when the
corresponding dimensions of the arrays have non-zero length." So 0 is
right on a dimension of length 0 -- zarr-python 3.0 and 3.1 wrote it,
and this package's own `create_default(shape=(0, 4))` does -- and a grid
alone cannot tell that dimension from one of non-zero length. The field
now refuses only a negative extent; an extent of 0 on a dimension that
is not empty is for the layer that reads the grid beside the shape.

Needed before the model reads grids through their definitions: without
it the model would refuse to read back a zero-length array it wrote.

Assisted-by: ClaudeCode:claude-opus-5-5

* refactor(zarr-metadata): no re-check of a TypedDict a definition vetted

`_configuration_checked` refused a shape that is not a TypedDict, but its
one caller hands it a definition's configuration, which the definition
vetted when it was built.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(zarr-metadata): a definition's rules are checked where they are called

The rules are an extension author's code, and a slip there surfaced far
from it: a rule yielding a string failed on `.loc`, a plain function
that forgot to yield failed as `'NoneType' object is not iterable` on
valid documents, and a rule that raised let a bare `KeyError` out of a
validator with nothing to say whose it was. What the rules yield is now
checked to be what they declare, naming the definition, and an error
one raises carries a note naming the definition and where it was
reading. The refusal of an open TypedDict, and the guide, name
`typing_extensions.TypedDict`, since `typing.TypedDict` takes no
`closed` on the versions the package supports.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(zarr-metadata): a family's name rules are checked as its rules are

A family's `name_rules` is the extension author's code too, and a name
rule yielding a string failed on `.loc`, as a rule did before `_ruled`.
`_ruled` now takes the call, and reads both through the same checks: what
they yield is checked, and an error one raises carries a note naming the
definition.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(zarr-metadata): a definition filed again is the one filed last

`claimant` asks the definition filed last first, but a name filed again
kept its first place in its table, so extending a scope with a family
it already held did not let the family take a name back from a
definition filed after it. A name filed again now moves to the end.

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(zarr-metadata): codecs say whether their size is static; a shard's index takes static codecs

The sharding spec says codecs that produce a variable-sized encoded
representation, such as compressors, MUST NOT be used for index codecs,
and nothing checked it: a shard with a gzip in `index_codecs` read.

A `CodecDefinition` now says its `size`, `"static"` or `"dynamic"`:
whether the size of what it gives out is fixed by the size of what it is
handed. It is required, and checked when the definition is built, as
`kind` is. The package's codecs say what zarr-python's `is_fixed_size`
says: `bytes`, `crc32c`, `transpose`, `cast_value` and `scale_offset` are
static; `blosc`, `gzip`, `zstd` and `sharding_indexed`, whose empty inner
chunks take no bytes, are dynamic.

A member annotated `StaticCodecField` takes codecs of static size only.
The shard's TypedDict declares `index_codecs: tuple[StaticCodecField,
...]`, so the constraint lives in the one declaration of that JSON, and
any extension's container codec can say the same. Where a nested field
is read in a scope, a codec of dynamic size in such a member is an
`invalid_value` at its place. A name nothing in scope claims is left
unjudged, its size unknown with the rest of it.

Assisted-by: ClaudeCode:claude-opus-5-5

* test(zarr-metadata): the every-definition tests say what they read

The module docstring named the fork's layer, which a reader of this package has no reason to know.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): the definitions' fragment takes this PR's number

Assisted-by: ClaudeCode:claude-opus-5-5

* refactor(zarr-metadata): raw bits read as r* with the size their name carries

`r16` reads as the definition filed under `r*`, the name the spec's data
types table gives raw bits, with `{"bits": 16}` as its configuration; a
size that is not a positive multiple of 8 is a rule over that
configuration, reported at the field. Every name a scope looks up is now
exact, so `Context.claimant` is a dict lookup, and `Definition` loses
`names` and `name_rules`, which only raw bits used. A reader reads raw
bits its own way by defining `r*`; a data type named `r16` is refused,
since that name reads as `r*`. `canonicalize` writes the size back into
the name, in decimal, so `r008` is `r8`.

Assisted-by: ClaudeCode:claude-opus-5-5

* perf(zarr-metadata): resolve judges the envelope without walking the JSON it refined

`resolve` refines the whole field before reading it, yet its envelope
check walked each configuration member as JSON again, and each nested
field's configuration once more. `envelope_problems` judges the envelope
alone, and `resolve` asks it of the field and of each nested field;
`validate_metadata_field_v3`, for a value nothing has refined, is it
plus the JSON check of the configuration's members. For a shard holding
four codecs, a resolve makes 766 Python calls instead of 1,070.

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…s definition (zarr-developers#4436)

* feat(zarr-metadata): the model reads each extension point through its definition

`validate_array_metadata_v3` judged an array document's structure and
left every configuration unread: a gzip `level` of 99, or a key a codec
does not declare, passed. It now reads each extension point -- the data
type, the chunk grid, the chunk key encoding, each codec and each
storage transformer -- with `resolve`, in a scope,
`CORE_AND_EXTENSIONS` unless a `context` is passed: the envelope judged,
`must_understand: false` refused at each, and the configuration read
against the definition that claims its name. A name nothing in scope
claims is left unjudged, which keeps the format open.

So do the `is_*` and `parse_*` beside it and the v3 group validators,
with each array an inline `consolidated_metadata` holds, and the v3
model classes' `from_json` and `from_key_value` take the same
`context`, so a reader that substitutes its own reading of a codec
builds the model from a document its scope accepts. The pydantic types
read in `CORE_AND_EXTENSIONS`, since a field type holds no scope; the
docstrings and the definition guide say so, and say that no rule here
reads one field against another.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): the validation boundary says what the validators read

The README and the docs index said the model validators do not
interpret extension names or configurations. In a v3 document they now
read each extension point through its definition in a scope, refuse
what the definition refuses and report an undeclared key as
`unknown_key`; they leave names nothing claims unjudged, and do not
judge fields against each other.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): the fragment for the model reading extension points through definitions

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(zarr-metadata): a v3 model writes in the scope it reads in

`to_key_value` validates what it writes with its reader's `parse_*`,
and at this layer the reader reads each extension point in a scope. The
v3 array and group `to_key_value` take the same `context` as `from_json`
and `from_key_value`, so a model read with a reader's own definitions is
written with them, and the default scope still refuses to write what it
would refuse to read.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): the fragment takes this PR's number and says what breaks

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): the must_understand fragment names the PR that merged it

The change merged with zarr-developers#4434, which carried zarr-developers#4433's commits; towncrier links a fragment to the pull request its name gives.

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…r-developers#4356)

* fix(indexing): make sparse selections O(npoints) instead of O(nchunks)

CoordinateIndexer (general path and sorted-1D fast path) and
IntArrayDimIndexer built a dense per-chunk histogram via
np.bincount(..., minlength=nchunks) / np.zeros(nchunks) plus a
full-length cumsum. For arrays with very many chunks this allocates
memory proportional to the total chunk count regardless of how few
points are selected — a 3-point write to an array with 1.4e11 chunks
tried to allocate 1 TiB and raised MemoryError.

Replace the dense histogram with run boundaries computed directly on
the sorted raveled chunk ids (sorted_run_ends), storing a compressed
cumsum aligned with the occupied chunks, and index it positionally in
__iter__. Memory and time now scale with the number of selected
points.

Fixes zarr-developers#4174

Assisted-by: ClaudeCode:claude-fable-5

* refactor(indexing): keep dense indexer attributes as deprecated properties

The compressed per-occupied-chunk cumsum introduced for zarr-developersgh-4174 changed
the observable semantics of chunk_nitems_cumsum (and removed
chunk_nitems on IntArrayDimIndexer). Although zarr.core is documented
as private API, external code is known to introspect these indexers, so
be conservative: store the compressed offsets under a new name
(chunk_run_ends, aligned with chunk_rixs / dim_chunk_ixs) and restore
chunk_nitems / chunk_nitems_cumsum as properties that lazily rebuild
the original dense arrays, warning with ZarrDeprecationWarning. The
O(nchunks) cost is now only paid if someone actually accesses them —
which was the status quo before the fix.

Assisted-by: ClaudeCode:claude-fable-5

* fix(indexing): exact ceildiv everywhere and sparse boolean-axis selections

Review follow-ups for the sparse-selection change:

- Fix ceildiv itself rather than bypassing it at one call site. It went
  through float division, so ceildiv(2**62 - 1, 1) returned 2**62; four
  other callers (slice arithmetic, the regular-grid check, dask-style
  chunk sizes) had the same latent error. Integers now divide exactly;
  floats keep the ceil-of-quotient path. FixedDimension goes back to
  calling it.

- BoolArrayDimIndexer still allocated a dense per-chunk count array and
  ran a Python loop over every chunk, so an orthogonal boolean selection
  on a finely chunked axis paid O(nchunks) in time and memory on top of
  the mask. It now derives the occupied chunks and run ends from the
  selected positions with sorted_run_ends, like the other two indexers,
  and exposes the same deprecated dense properties. A boolean axis with
  2**22 chunks goes from a multi-second loop to ~2 ms.

- Changelog: state precisely which selection kinds are covered, that
  reading the deprecated properties rebuilds the dense array, and the
  ceildiv correction.

Assisted-by: ClaudeCode:claude-fable-5-1

* fix(indexing): defer boolean-axis allocation changes

Retain sparse coordinate and integer indexing plus exact ceildiv, while restoring the existing boolean-axis implementation to avoid dense-mask regressions.

Assisted-by: Codex:GPT-6

* docs: describe current ceildiv behavior

Assisted-by: Codex:GPT-6

* fix(indexing): lazily cache legacy dense attributes

Preserve dense attribute identity, mutation behavior, and dataclass fields without deprecation warnings while keeping normal indexing sparse.

Assisted-by: Codex:GPT-6

* fix(indexing): use a dedicated integer ceiling division helper

Restore the original ceildiv behavior and exports, and use ceildiv_int for integer-only chunk and slice calculations without type-based dispatch.

Assisted-by: Codex:GPT-6

* refactor: remove unnecessary ceildiv re-exports

Assisted-by: Codex:GPT-6

* test: use Expect cases for integer ceiling division

Assisted-by: Codex:GPT-6

* test(indexing): restore the sparse projection property test

The test was added in a merge commit, which the linear rebase onto main dropped.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs: number the changelog fragment after the merging PR

Towncrier renders fragment names as pull-request links, so the fragment
takes zarr-developers#4356 rather than issue zarr-developers#4174. The paragraph describing zarr-developers#4218 is
dropped: it shipped in the 3.4.0 release notes.

Assisted-by: ClaudeCode:claude-opus-5-5
… hosts (zarr-developers#4435)

* fix: byte-order bugs and little-endian test assumptions on big-endian hosts

Running the suite on s390x (QEMU, Debian sid) gave 110 failures on main.
Most came from one asymmetry: V3 data types without an explicit byte
order defaulted to little-endian, while NumPy dtype names mean host order.
On a big-endian host `dtype="float64"` and `dtype=np.float64` produced
different data types, and a reopened array changed dtype.

- V3 data types default to the host byte order (`HasEndianness`), because
  V3 metadata carries none. Stored chunks stay little-endian by default.
- `ShardingCodec` defaults its inner and index `bytes` codecs to
  little-endian, so sharded output no longer depends on the host.
- `scale_offset` computes in native byte order and restores the input's
  byte order; `>f8` and `>u8` arrays failed on every host.
- Base64 fill values of structured data types in V3 metadata are
  little-endian bytes in both directions.
- Tests no longer assume a little-endian host: explicit `<` dtypes and
  `endian="little"` where the expectation is little, and a big-endian case
  for migration and pipeline parity.

Refs zarr-developers#3438

Assisted-by: ClaudeCode:claude-opus-5-5

* docs: name the changelog fragment after the PR

Assisted-by: ClaudeCode:claude-opus-5-5

* ci: run byte-order-sensitive tests on s390x under QEMU

A weekly and path-filtered job that runs the data type, codec and metadata
tests on an emulated big-endian host, in a Debian sid image that takes numpy
and numcodecs from Debian packages so nothing heavy compiles under emulation.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(codecs)!: BytesCodec defaults to little-endian on every host

`BytesCodec()` defaulted to `sys.byteorder`, so the same code wrote
big-endian chunks on s390x and little-endian chunks elsewhere. The bytes
codec originally defaulted to "little"; the host default came in as a side
effect of replacing attrs with dataclasses (zarr-developers#1660), and was later pinned
by a test that only restated it. `"little"` also matches
`default_serializer_v3`.

Chunks written on big-endian hosts with a bare `BytesCodec()` are now
little-endian. Chunks written before this change remain readable, because
the codec records its byte order in the metadata.

Refs zarr-developers#3438

Assisted-by: ClaudeCode:claude-opus-5-5

* revert: keep the BytesCodec default out of this PR

This reverts commit 8dd33e3. Changing the default of `BytesCodec()`
changes what existing code writes on big-endian hosts, so it needs a
deprecation cycle and will land in its own PR.

Assisted-by: ClaudeCode:claude-opus-5-5
* chore(zarr-indexing): render misc fragments and link entries to pull requests

Towncrier's built-in misc type sets showcontent = false, so the package's
misc fragments (zarr-developers#4346, zarr-developers#4364, zarr-developers#4406) would render as bare links. Restate
the five fragment types as zarr-metadata does, with misc showing its
content. Fragments are numbered by the merging PR, so link them under
/pull/ as zarr-metadata does.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-indexing): backfill the 0.1.0, 0.2.0 and 0.2.1 release notes

The three releases were tagged without running towncrier, so CHANGELOG.md
stayed empty and their fragments stayed in changes/, where the next build
would have announced them again as new. Build each release from the
fragments its tag shipped: zarr-developers#3906's (renumbered zarr-developers#4196, the PR that merged
it) for 0.1.0, zarr-developers#4222's for 0.2.0, and a new zarr-developers#4252 entry for 0.2.1, whose
only change was the docs build fix. Dates are the tag dates.

Assisted-by: ClaudeCode:claude-opus-5-5

* chore(zarr-indexing): build 0.3.0 changelog

Consume the pending fragments into CHANGELOG.md for the
zarr_indexing-v0.3.0 release.

Minor, not patch: zarr-developers#4350 makes LazyArray indexing lazy by default, so
iterating a view yields views rather than values, and views keep their
literal domain instead of re-zeroing after each selection; zarr-developers#4310 rejects
hand-built diagonal transforms with ValueError.

Assisted-by: ClaudeCode:claude-opus-5-5

* chore(zarr-indexing): date the 0.3.0 release 2026-09-29

Assisted-by: ClaudeCode:claude-opus-5-5
d-v-b and others added 22 commits November 4, 2026 11:35
…add definitions with union (zarr-developers#4598)

* feat(zarr-metadata)!: replace scope update with copy(update=...) and add definitions with union

`ZarrV3Context.update(**slots)` and `ZarrV2Context.update(**slots)` read
as a merge, but replace each slot whole, so passing one new definition
silently dropped every default. They become `copy(*, update=None)`,
after pydantic's `model_copy(update=...)`, whose replace-whole meaning
pydantic users already know. Adding definitions is `union`, which keeps
every definition the scope has and refuses a conflicting one; the docs,
docstrings and call sites now use it instead of splicing a slot's
definitions back in.

Fixes zarr-developers#424

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): number the scope copy changelog fragment after its PR

Assisted-by: ClaudeCode:claude-opus-5-5

* test(zarr-metadata): check copy refuses another format's definition and name copy in scope docstrings

Assisted-by: ClaudeCode:claude-opus-5-5
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.16.10 → v0.17.3](astral-sh/ruff-pre-commit@v0.16.10...v0.17.3)
- [github.com/DavidAnson/markdownlint-cli2: v0.23.3 → v0.24.0](DavidAnson/markdownlint-cli2@v0.23.3...v0.24.0)
- [github.com/zizmorcore/zizmor-pre-commit: v1.30.1 → v1.31.1](zizmorcore/zizmor-pre-commit@v1.30.1...v1.31.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
* feat(zarr-metadata): draw whole v3 documents

Add `array_documents`, `group_documents` and
`consolidated_group_documents`. An array's members are drawn to fit each
other: the chunk grid for the shape, the fill value for the data type,
and the codecs for the grid's chunks of that data type. A consolidated
listing holds each node's parent, as a group, before the node.

`pipelines` takes `spellings`, as `declarations` does. A drawn document
its definitions refuse raises a ValueError, and strategies with nothing
to draw some member from raise a LookupError. `Spellings` and
`CHARACTERS` move to `_strategy` so the new module can share them.

Assisted-by: ClaudeCode:claude-opus-5-5

* chore(zarr-metadata): number the document strategies changelog fragment after zarr-developers#439

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(zarr-metadata): sample document shapes, listings and data types evenly

Shapes capped axes at 2**16 and rank at 5, with a quarter of documents
rank 0 and few holding a zero-length axis. Draw each rank about as often,
up to 8, and axes that are zero, short, or past 32 bits. Draw a document's
data type first: drawn after the shape, the first in the list was a fifth
of all documents. A listed group now sometimes holds the empty listing
the reference implementation writes, a fresh one for each group. New
tests bound these shares.

Assisted-by: ClaudeCode:claude-opus-5-5

* chore(zarr-metadata): number the document strategies changelog fragment after zarr-developers#4602

Assisted-by: ClaudeCode:claude-opus-5-5
)

Bumps the actions group with 3 updates: [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv), [scientific-python/upload-nightly-action](https://github.com/scientific-python/upload-nightly-action) and [zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action).

Updates `astral-sh/setup-uv` from 10.3.2 to 10.3.3
- [Release notes](https://github.com/astral-sh/setup-uv/releases)
- [Commits](astral-sh/setup-uv@07a047e...68559e9)

Updates `scientific-python/upload-nightly-action` from 0.6.5 to 0.6.6
- [Release notes](https://github.com/scientific-python/upload-nightly-action/releases)
- [Commits](scientific-python/upload-nightly-action@16fa02e...5a74a2a)

Updates `zizmorcore/zizmor-action` from 0.7.1 to 0.8.0
- [Release notes](https://github.com/zizmorcore/zizmor-action/releases)
- [Commits](zizmorcore/zizmor-action@85b2b9f...53290ba)

---
updated-dependencies:
- dependency-name: astral-sh/setup-uv
  dependency-version: 10.3.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: scientific-python/upload-nightly-action
  dependency-version: 0.6.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: zizmorcore/zizmor-action
  dependency-version: 0.8.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
…dices (zarr-developers#4603)

* perf(zarr-indexing): skip the sort in _last_occurrences for sorted indices

When the flat in-hull positions are non-decreasing (the usual C-order
case), repeats are adjacent and the last occurrence of each can be found
in O(n) without np.unique. When there are no repeats at all, return a
full slice so callers index without a gather copy.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-indexing): add changelog fragment for zarr-developers#442

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-indexing): number the changelog fragment for zarr-developers#4603

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* test: fix race condition in test_sync_timeout

* chore: add release notes for zarr-developers#4596

* chore: drop changelog fragment for test-only change

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
…r-developers#4595)

* fix: allow Ellipsis after an index array in orthogonal selection

replace_ellipsis looked up the Ellipsis with tuple.index and removed it
with !=, which compare with ==. When an integer or boolean array comes
before the Ellipsis, the comparison is elementwise and raises
"The truth value of an array ... is ambiguous", so z.oindex[[1, 2], ...]
failed. Compare by identity instead.

* Add changelog entry

---------

Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
…pers#4506)

* fix(metadata): read Zarr V3.1 short-hand extension names

Zarr V3.1 lets an extension definition that needs no configuration be
written as a bare name: `"crc32c"` is equivalent to `{"name": "crc32c"}`.
Reading such a document raised `TypeError: Expected dict, got <class 'str'>`.

`expand_short_hand_name` expands a bare name at the parser of each array
extension point that took only the object form: codecs (including codecs
nested in a sharding codec), chunk_grid, chunk_key_encoding and
storage_transformers. data_type already accepted a bare name. A bare name
for an extension that requires a configuration (`"regular"`, `"gzip"`) is
still rejected, with the missing-configuration error.

Metadata is still written in the object form, which Zarr V3.0 readers
require.

Refs zarr-developers#3188

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(changes): add changelog fragment for short-hand extension names

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(changes): renumber short-hand names fragment to the upstream PR

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(chunk-key-encoding): accept a bare encoding name in ChunkKeyEncodingLike

parse_chunk_key_encoding now expands short-hand names, so array creation
functions accept `chunk_key_encoding="v2"`. Declare `str` in the type,
drop the type ignore it made unnecessary, and test the chunk keys each
short-hand name produces. Correct the fragment: a short-hand storage
transformer was kept as a bare string on main, not rejected.

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…cannot open (zarr-developers#4604)

* feat(zarr-metadata): add a reader that reports what a reader cannot open

`read_openable_node_metadata_v3` reads a v3 `zarr.json` as
`read_node_metadata_v3` does and adds a problem of the new kind
`unclaimed_declaration` for each declaration a reader must understand
that nothing in scope claims: an unknown codec, data type or chunk grid,
or an unknown top-level member without `"must_understand": false`. Its
reading has no problems exactly when a reader that understands the scope
can open the node.

The other readers keep accepting unclaimed declarations, so the format
stays open; their docstrings and the parsing guide now point to
`unclaimed_declarations` and the new reader. Prompted by refkv's report
that an unknown v3 member parses without error.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): number the changelog fragment for zarr-developers#440

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): number the unopenable-declarations fragment after upstream PR 4604

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… each spec claim (zarr-developers#4605)

* docs(zarr-metadata): split the landing page into guide pages and link each spec claim

Shrink index.md to a short pitch, one example and a reader-by-reader list
of where to go. Move the rest into guide pages: models and readers, what
the readers check, consolidated metadata, repairing known writer bugs,
writing an extension, JSON Schema and Pydantic. Each claim backed by a
Zarr spec links to the spec section that makes it; the consolidated
metadata page says what the specs do and do not settle and links the
zarr-specs PRs and issues and the original zarr-python implementation.
Trim the README so it no longer mirrors the landing page, and say
"context" where the pages said "scope".

Assisted-by: ClaudeCode:claude-fable-5-1

* docs(zarr-metadata): number the guide-pages fragment after its fork PR

Assisted-by: ClaudeCode:claude-fable-5-1

* docs(zarr-metadata): say "member" for a JSON name/value pair in the guide pages

The rename branch keeps "member" for a name/value pair of a metadata
object, so the new pages follow: "a top-level member that the spec does
not define is an extra field". "Extra field" and "extension field" stay,
after the names extra_fields and ZarrV3ExtensionField.

Assisted-by: ClaudeCode:claude-fable-5-1

* docs(zarr-metadata): say "member" for a JSON name/value pair on every page

Sweep the parsing-validation and context pages, which said "field" for a
name/value pair of a metadata object, and state the one exception on the
models page: "extra field" follows the spec's "additional fields" and
the names extra_fields, ExtraFieldDefinition and must_understand_fields;
"field" otherwise means a field of a Python class, or a part of a
structured data type.

Assisted-by: ClaudeCode:claude-fable-5-1

* docs(zarr-metadata): say "member" in the two must_understand_fields sentences

The models page said "each unclaimed field" and "any such field" where the
landing page and every neighboring sentence say "member". Roborev flagged
the mismatch.

Assisted-by: ClaudeCode:claude-fable-5-1

* docs(zarr-metadata): say why the additional-fields link points at the latest spec

v3.1.0 has no "Additional fields" heading; PR 373 added it after the
release, so the link cannot be pinned. Say so beside the link.

Assisted-by: ClaudeCode:claude-fable-5-1

* docs(zarr-metadata): split the additional-fields sentence and date its claim

Roborev found the three-clause sentence hard to parse and its "no tagged
release yet" unanchored in time. Two sentences now, anchored to v3.1.0,
with a note to pin the link once a release carries the heading.

Assisted-by: ClaudeCode:claude-fable-5-1

* docs(zarr-metadata): fix six wording and example issues roborev found on the guide pages

The pydantic example now builds the manifest with model_validate, so it
type-checks as the next sentence claims. The consolidated page says three
other readers take a context, not two. The equality section quotes the v2
spec on a missing .zattrs in two sentences. The two numbered Sphinx
anchors are replaced by line ranges in the spec source at the v3.1.0 tag.
The landing page says once that the library does no chunk or store I/O.
The extensions page example and the zarr_metadata.definition docstring
example are pinned to each other by a test.

Assisted-by: ClaudeCode:claude-fable-5-1

* test(zarr-metadata): make the example-drift test say what it could not find

Roborev asked for diagnostics: the test now asserts there is exactly one
extensions-session block and exactly one marker line in the docstring,
each with a message, and compares line lists so a mismatch points at the
differing line.

Assisted-by: ClaudeCode:claude-fable-5-1

* docs(zarr-metadata): build the extension example with union and say "context" throughout

On main a Context has no update method, so the acme.lz4 example on the
extensions page now adds its definition with union, as the definition
module docstring does. Two leftover "scope"s in the parsing page say
"context", and the models page says "member" for an extra field. The
example-drift test imports at module level.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): number the guide-pages fragment after upstream PR 4605

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): fence the module docstring examples as python so the API pages highlight them

The examples in the definition, json_schema, pydantic and typed_json
module docstrings were indented code blocks. An indented block names no
language and pymdownx.highlight does not guess one, so the API reference
rendered them as plain text. Each is now a ```python fence, and the
example-drift test reads the definition docstring's fence.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): write the guide pages in short sentences and lists

Long comma-chained sentences on the guide pages, README and landing page
are split into short sentences, and enumerations become bulleted or
numbered lists. models, validation-rules, consolidated-metadata, repair,
extensions, json-schema and pydantic are restructured; context and
parsing-validation keep their narrative voice and only have their long
sentences split. No link, claim or code block changes.

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
…velopers#4521)

* Remove zarr.tree and the Array.compressor properties

Both were deprecated in 3.0.0 and were scheduled for removal in 3.2.0
by zarr-developers#3325. The rest of that PR shipped in 3.2.0 through zarr-developers#3900-zarr-developers#3903.

Removed:
- zarr.tree, zarr.api.synchronous.tree, zarr.api.asynchronous.tree.
  Use Group.tree / AsyncGroup.tree.
- Array.compressor and AsyncArray.compressor. Use Array.compressors.

The warning-only test for zarr.tree is gone, and the v2 compressor
assertions in tests/test_v2.py now use `compressors`.

The zarr.storage.default_compressor shim from the same zarr-developers#3325 list is
left alone; zarr-developers#4505 removes it.

---------

Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
…arr-developers#4504)

* fix: reset the codec-pipeline thread pool after fork

A forked child inherits codec_pipeline._pool pointing at threads that
do not exist in the child, plus the parent's idle-semaphore permits.
Submissions up to the permit count are consumed without spawning a
thread, so small FusedCodecPipeline reads hang forever.

Add an after_in_child hook that drops the inherited pool, size, and
lock. The lock is recreated because it may have been held by a thread
that no longer exists in the child.

* docs: add changelog entry for zarr-developers#4483

* test(codec_pipeline): pin pool size in the fork regression test

Move the zarr-developers#4478 regression test next to the other FusedCodecPipeline
pool tests and pin `codec_pipeline.max_workers` to 4 through the shared
`_FUSED_POOL_CONFIG`. With the default, a 1-CPU host resolves
`max_workers` to 1, never creates the pool, and passes the test without
exercising the bug. The test now asserts that the parent created the
pool before forking, and it runs on macOS, where the fork start method
is available.

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: barlowa124 <barlowa124@users.noreply.github.com>
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat: read only the needed rows of uncompressed chunks

BytesCodec now implements partial decoding. An uncompressed chunk is
stored in C order, so each row along its first axis is a contiguous run
of bytes; for a selection that does not touch every row, the rows from
the first to the last one it touches are fetched with a single range
request and the selection is applied to them. The pipeline already
uses partial decoding when the array-to-bytes codec supports it and
there are no array-to-array or bytes-to-bytes codecs, so this applies to
uncompressed arrays only. Reading 100 rows of a single-chunk 20 MB
array now fetches the bytes of those rows instead of the whole chunk.

* Fix boolean masks and stores that ignore ranges in BytesCodec partial reads

A boolean mask on the first axis, as from arr.oindex[mask], was trimmed to
start at the first selected row but not to end at the last, so its length
no longer matched the rows fetched and numpy raised an IndexError. The row
window and the shifted selection are now computed together in _row_window,
which trims the mask at both ends. This also gives mypy the narrowing it
needs.

FsspecStore over HTTP returns the whole object when a server ignores the
Range header. The partial read then failed to reshape a chunk that the full
read would have decoded, so a read that worked before this branch raised an
error. A response longer than the requested range is now sliced to it.

* Add sync partial decode to BytesCodec and check the length of ranged reads

Add _decode_partial_sync so FusedCodecPipeline reads only the needed rows
of an uncompressed chunk, sharing the decode step with the async method.

Decide what a store sent for a range request by its exact length: the
requested range, the whole chunk, or everything from the range start.
Any other length raises instead of returning wrong data.

Run the partial read tests on both codec pipelines and add a changelog
entry.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
…4522)

* Deprecate the ignored Zarr-Python 2 keyword arguments

`synchronizer`, `chunk_store`, `cache_metadata`, `cache_attrs`,
`object_codec`, `read_only` and `meta_array` are accepted by `create`,
`group` and `open_group` (and by everything that wraps them, such as
`zeros`) but have never done anything in Zarr-Python 3. Passing one
used to emit a `ZarrRuntimeWarning` saying "not yet implemented", which
read as a promise to implement it.

Emit a `ZarrDeprecationWarning` instead, saying the argument is ignored
and will be removed in a release after April 2027, and say the same in
the docstrings and the v3 migration guide. Calls that do not pass these
arguments are unaffected.

First step of the plan for zarr-developers#3976.

---------

Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
…ers#4612)

Python shows a DeprecationWarning by default only when it is attributed
to __main__, so warnings that pointed at zarr internals were hidden
from users running scripts:

- `ArrayV2Metadata.chunk_grid` is a cached_property, which adds a frame;
  stacklevel 2 pointed at functools. Now 3.
- Setting `zarr.storage.default_compressor` used stacklevel 1, which
  pointed at zarr itself. Now 2.
…velopers#4610)

* feat(zarr-metadata)!: write store bytes through a JSONWriter

`to_key_value` takes a writer instead of an `indent` keyword. A
`JSONWriter` owns how a document becomes JSON bytes: it holds the
settings (`indent`, `sort_keys`, `ensure_ascii`, `trailing_newline`)
and its `encode` method does the writing, so the separators, the bare
non-finite tokens and the surrogate escapes are no longer split off in
a private helper. `to_key_value` also accepts a mapping of the settings,
`JSONWriterSchema`, so callers need not import the class:
`to_key_value({"indent": 2})`.

The defaults are those of `json.dumps`, so a bare `to_key_value()` writes
the same bytes as before. A setting `json.dumps` would misread raises,
and so does a mapping key that is not a setting.

Rebased onto main as one commit, replacing the JSONWriterConfig design.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): number the changelog fragment for zarr-developers#4610

Assisted-by: ClaudeCode:claude-opus-5-5
…developers#4608)

* docs(zarr-metadata): say that to_json returns arrays as tuples

The guide said `to_json` returns plain containers, while another section
said it returns tuples. Each model's `to_json` docstring now says that
every JSON array is a tuple, as the package's JSON types spell one, so
the result does not compare equal to `json.loads` output, and points to
comparing models instead. Prompted by refkv's report.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): number the changelog fragment for zarr-developers#441

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): number the changelog fragment for zarr-developers#4608

Assisted-by: ClaudeCode:claude-opus-5-5

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…initions (zarr-developers#4609)

* feat(zarr-metadata): export base64_fill_value_rules for data type definitions

Export the rule that rejects a fill value string that is not
standard-alphabet base64, so a data type defined outside the package can
pass it as `fill_value_rules` or yield from it. `bytes` and
`variable_length_bytes` now share it. The parsing and validation guide
shows a data type that defines `fill_value_rules`, built with `union`.

Rebased onto main as one commit; the earlier history carried the merged
ZARR_PYTHON_CONTEXT branch.

Assisted-by: ClaudeCode:claude-opus-5-5

* docs(zarr-metadata): number the changelog fragment for zarr-developers#4609

Assisted-by: ClaudeCode:claude-opus-5-5
…arr-developers#4614)

* fix(zarr-metadata): accept the generic time unit in v2 time dtypes

NUMPY_TIME_UNITS gains "generic", NumPy's unit-less unit, which NumPy
parses in brackets (<M8[generic]) though its own dtype.str omits it, so
the v2 reader accepts the bracketed generic spellings zarr-python
writes (<M8[generic], <m8[2generic]). The v3 unit tuple already carried
generic and now reuses the shared tuple unchanged. A unit is still
required: the unitless <M8 stays refused, as the v2 spec demands.

Refs zarr-developers#4580

Assisted-by: ClaudeCode:claude-fable-5

* docs(zarr-metadata): changelog fragment for zarr-developers#422

Assisted-by: ClaudeCode:claude-fable-5

* docs(zarr-metadata): number the generic time unit fragment after its PR

Assisted-by: ClaudeCode:claude-opus-5-5
The Zarr format reserves node names beginning with '__' and the name
'zarr.json'. create_group('__a') wrote the reserved name, and
create_group('a/zarr.json') wrote a directory that shadows the parent's
metadata document, orphaning the whole subtree from members(). Both are
now refused with MetadataValidationError before anything is stored.

The check validates each '/'-separated segment in AsyncGroup.create_group,
AsyncGroup.create_array, and the module-level create_array/create_group
'name'/'path' arguments. Empty segments pass through because leading and
repeated slashes have long been normalized away by path joining.
@barlowa124
barlowa124 force-pushed the reserved-node-names-4453 branch from 7d90be3 to 748abd0 Compare November 11, 2026 05:38
barlowa124 added a commit to barlowa124/zarr-python that referenced this pull request Nov 11, 2026
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@barlowa124 barlowa124 closed this Dec 4, 2026
@barlowa124
barlowa124 force-pushed the reserved-node-names-4453 branch from 748abd0 to d27cd76 Compare December 4, 2026 22:04
barlowa124 added a commit to barlowa124/zarr-python that referenced this pull request Dec 4, 2026
barlowa124 added a commit to barlowa124/zarr-python that referenced this pull request Dec 4, 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.