Repository navigation
Conversation
Add a Hypothesis state machine that applies each Store operation to ten
built-in stores at once (memory, managed memory, local, zip, fsspec over
file and memory, obstore over local and memory, and the logging and
latency wrappers) and compares every result with a reference model.
A disagreement fails the test unless it is in a ledger of known
divergences that records what the store does instead. A witness test
runs each ledger entry against every store, so an entry must name exactly
the stores that diverge: fixing a store, or a store starting to diverge,
fails the test until the ledger is updated.
The ledger starts with 25 entries, among them:
- list_prefix("lat") returns lat_bnds/... on memory, zip and the
managed and logging memory stores (zarr-developers#3773, zarr-developers#4645);
- directories emptied by deletes are still listed by list_dir on the
filesystem stores, and block writing a key of the same name (zarr-developers#4161);
- delete_dir("a") deletes the key "a" on fsspec;
- obstore raises for byte ranges at or past the end of a value, for
zero-length ranges, and for most operations on a name below a key.
delete_dir on LocalStore and fsspec over file reaches outside the store
root for relative paths, and for absolute paths on LocalStore; a
sentinel-directory test records this as strict xfails.
Assisted-by: ClaudeCode:claude-opus-5-5
Owner
Author
|
🤖 AI text below 🤖 Superseded by zarr-developers#4646, which carries this change rebased on upstream main plus a wrapper-forwarding test and fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
This adds a Hypothesis state machine that runs every
Storeoperation against ten built-in stores at once and compares each result with one reference contract. Known disagreements live in a ledger that the tests keep exact, so it doubles as the list of interim store fixes.What the test does
MemoryStore,ManagedMemoryStore,LocalStore,ZipStore,FsspecStoreoverfileand overmemory,ObjectStoreover obstore's local and memory stores,LoggingStore(MemoryStore)andLatencyStore(LocalStore).set,set_if_not_exists,delete,delete_dir,list,list_prefix,list_dir,getsize_prefix,is_empty,exists,get(with range, offset and suffix byte requests) andgetsize."a"and"a/"are the same directory,""is the root, andlist_prefix("lat")never returnslat_bnds/...;exists,getandgetsizeconcern keys only;KnownDivergencerecords what a store does instead, as a predicate. It excuses only that behavior, not the whole operation.UNMODELED_DIVERGENCESholds cases the machine avoids, because a mismatch would leave the stores in different states.test_divergence_ledger_is_exactruns every entry's witness against every store. Fixing a store, or a store starting to diverge, fails until the ledger is updated.slow_hypothesisvariants take about 60 s and are picked up byjust hypothesis(tests/test_store/test_stateful*).Divergences recorded (25 entries)
list_prefix("lat")returnslat_bnds/...onMemoryStore,ZipStore,ManagedMemoryStoreandLoggingStore(MemoryStore)(Divergent behavior of memory store and localstore list prefix zarr-developers/zarr-python#3773, nchunks_initialized and info_complete() raise ValueError when a sibling array's name starts with the array's name zarr-developers/zarr-python#4645).list_prefix,getsize_prefixandis_empty, andlist_diron a top-level key returns the key itself.list_dir, which is where LocalStore listing lists .partial temp files zarr-developers/zarr-python#4161's warnings come from. They also block writing a key of the same name.existsis true for a directory; on fsspec andLocalStore,getsizereturns a number for one.delete_dir("a")deletes the keya.LocalStore:delete_diron a key raisesValueError.GenericError, and zero-length ranges raiseValueError;GenericError.getsizeanddeleteraiseNotADirectoryErroronLocalStore, andgetsizeandlist_diron fsspec overfile.Root escapes
delete_dirreaches outside the store root onLocalStoreandLatencyStore(LocalStore)for both../xand absolute paths, and on fsspec overfilefor../x.test_delete_stays_in_rootrecords these as strict xfails against a sentinel directory inside the test's temporary directory, so an escape can only delete the sentinel.zarr itself can't reach this, because
StorePathrunsnormalize_path, which rejects./..segments and strips a leading/. DirectStoreusers can. During development, a generateddelete_dir("/")madeLocalStorecallshutil.rmtree("/"). Paths that leave the root are no longer generated.Found while building it, not covered here
WrapperStoredoesn't forwardgetsize, so wrapped stores read the whole object to get its size.ObjectStore.list_dirstarts a coroutine when called, so it needs a running event loop at call time.FsspecStore.from_url("file://…")can't write nested keys withoutauto_mkdir=True.Verification
ZipStorecan't delete), 5 xfailed (root escapes).--run-slow-hypothesisruns passed, along with ruff, mypy and pre-commit.laforlat) and names below a key.🤖 Generated with Claude Code