Skip to content

fix(indexing): define an explicit source token contract - #4348

Draft
d-v-b wants to merge 15 commits into
zarr-developers:mainfrom
d-v-b:codex/indexing-token-contract
Draft

fix(indexing): define an explicit source token contract#4348
d-v-b wants to merge 15 commits into
zarr-developers:mainfrom
d-v-b:codex/indexing-token-contract

Conversation

@d-v-b

@d-v-b d-v-b commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Depends on #4345. This draft targets upstream main, so its diff includes the prerequisite audit commits until that PR merges. Follow-up-only diff.

Tokenizing a lazy source previously depended on whether Dask was installed: the fallback could convert and read small remote arrays, hash object references instead of nested values, or return a fresh UUID on every call for large arrays.

Define a conservative source contract: hash plain NumPy arrays without object fields in full; delegate explicit source hooks and propagate their errors; reject other sources without conversion or serialization. Remove generic Dask and UUID fallbacks. Zarr and opaque sources can still be passed to dask.array.from_array with name=False; update and execute the Dask example accordingly.

Hashing has linear time and temporary-memory costs. Hooks own their versioning and I/O semantics. Tokens describe the source at tokenization time, not a snapshot or persistent cache identity, and cannot invalidate keys in graphs already constructed before a mutation. Object arrays, subclasses, and memory-mapped arrays need a source hook or Dask's naming opt-out.

Validation: an initial run passed 1,533 package tests/doctests and Dask example checks with Dask 2026.8 and TensorStore 0.1.84; 23 focused token/Dask checks passed after adding scalar, structured, string, noncontiguous, and mmap-buffer cases. Initial red run reproduced five unsafe/nondeterministic fallback failures. Applicable prek hooks pass; package pyright reports 0 errors (90 warnings).

Contract references: https://docs.dask.org/en/stable/custom-collections.html#implementing-deterministic-hashing and https://docs.dask.org/en/stable/generated/dask.array.from_array.html.

Corresponding fork review: d-v-b#336.

All four final follow-up heads were also combined and verified together: 1,633 package tests/doctests passed, no skips, and the strict documentation build passed.

Correct mathematical API documentation to match supported coordinate, grid, and chunk projection contracts.

Assisted-by: Codex:GPT-6
Retain the existing unsigned selector fix and update the unsupported mixed-dependency error assertion for general intersection routing.

Assisted-by: Codex:GPT-6
Use lexicographic tuple grouping when chunk indices contain negative values. Cover shared one-axis and two-axis array dependencies, repeated points, and extreme signed coordinates.

Assisted-by: Codex:GPT-6
@github-actions github-actions Bot added the needs release notes Automatically applied to PRs which haven't added release notes label Sep 13, 2026
@read-the-docs-community

read-the-docs-community Bot commented Sep 13, 2026

Copy link
Copy Markdown

Remove implementation history and unsupported historical claims from source and test docstrings. Distinguish immutable coordinate mappings from mutable source values.

Assisted-by: Codex:GPT-6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs release notes Automatically applied to PRs which haven't added release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant