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
WrapperStore didn't forward getsize, getsize_prefix, get_ranges_sync or supports_consolidated_metadata, so wrappers fell back to the Store defaults: getsize read the whole value, and supports_consolidated_metadata was True whatever the wrapped store said. LatencyStore now routes get_ranges_sync through its own get_sync, as it does get_ranges. A new test wraps a store that records every call and checks that each wrapper passes every Store method straight through, apart from the methods a wrapper reroutes on purpose. The conformance ledger now lists latency-local with local for getsize, which it now forwards. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4646 +/- ##
==========================================
+ Coverage 94.90% 94.99% +0.08%
==========================================
Files 96 96
Lines 14055 14096 +41
==========================================
+ Hits 13339 13390 +51
+ Misses 716 706 -10
🚀 New features to boost your workflow:
|
… every platform LoggingStore now logs get_ranges, get_ranges_sync, _get_many, _set_many and supports_consolidated_metadata. A new test checks that it logs every Store method it forwards, and another that each forwarding recipe gives every defaulted argument a non-default value. The conformance test now skips stores per factory instead of per module, so memory, local and zip still run without obstore or fsspec, and fsspec stores skip on fsspec < 2024.12.0. The ledger's below-a-key entries are POSIX-only, and two Windows-only entries record obstore-local raising for a directory. An unmodeled divergence now explains a ledger step only when the steps end with its whole witness. Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s#4646 fragment Assisted-by: ClaudeCode:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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 🤖
WrapperStore, and soLoggingStore, now forwardsgetsize,getsize_prefix,get_ranges_syncandsupports_consolidated_metadatato the store it wraps. Before this change, a wrapper read a whole value to measure its size, and reported support for consolidated metadata even when the wrapped store reported none.LoggingStorenow also logs range reads (get_rangesandget_ranges_sync).What the PR adds
Two tests that check every built-in store against one contract, so a store that drifts fails CI instead of failing a user.
tests/test_store/test_stateful_conformance.py: a HypothesisRuleBasedStateMachinethat runs one sequence ofset,set_if_not_exists,delete,delete_dir,get(with byte ranges),exists,getsize,list,list_prefix,list_dir,getsize_prefixandis_emptyagainst a reference model of the store contract. It runs on ten store configurations: memory, managed-memory, local, zip (append-only), fsspec overfileandmemory, obstore over local and memory, logging and latency wrappers. The contract it checks:"a"≡"a/",""is the root, andlist_prefix("lat")never returnslat_bnds/...;exists,getandgetsizeconcern keys only;The stores disagree in many places today. Each disagreement is an entry in a ledger (
KNOWN_DIVERGENCES, plusUNMODELED_DIVERGENCESfor writes the model cannot follow). Each entry has a short witness program, andtest_divergence_ledger_is_exactruns every witness on every store and requires "diverges ⇔ listed". A store that is fixed, or that starts diverging, fails that test until the ledger is updated. The ledger therefore documents the cross-store behavior as it is now. Entries that come from POSIX filesystem errors (NotADirectoryErrorfor a name below a key) apply only off Windows. Two Windows-only entries record obstore-local raisingGenericErrorforexists/getsizeon a directory. Stores skip one at a time: fsspec stores need fsspec ≥ 2024.12.0 (AsyncFileSystemWrapper), obstore stores need obstore, and the rest always run. This PR made such an update:latency-localnow forwardsgetsizetoLocalStore, so it joins local's twogetsizeentries.test_delete_stays_in_rootrecords, as strict xfails, thatLocalStore.delete/delete_dir(and fsspec overfile, for relative paths) follow..and absolute paths out of the store root. It uses a sentinel directory insidetmp_path. The state machine never generates such paths: during development, an unconfineddelete_dir("/")reachedshutil.rmtree("/").tests/test_store/test_wrapper.py:RecordingStoreoverrides everyStoremember (plusget_sync/set_sync/delete_sync) to record its arguments and return a distinct value. For each wrapper (WrapperStore,LoggingStore,LatencyStore,CacheStore) and each member, the test checks that the wrapped store sees exactly one call of the same method with the same arguments, and that the wrapper returns its result.test_every_store_member_is_checkedfails whenStoregains a member without a recipe here, so a new method can't silently skip the wrappers.REROUTEDlists the methods a wrapper implements itself on purpose (for example,LatencyStorereads ranges through its owngetto add latency), and the test requires each entry to still hold. Every recipe gives each defaulted argument a non-default value, so a wrapper that drops an argument is caught.test_logging_store_logs_every_store_methodchecks thatLoggingStorelogs every method it forwards.Source changes
WrapperStoregainsgetsize,getsize_prefix,get_ranges_syncandsupports_consolidated_metadata. Without them, these fell back to theStoredefaults on the wrapper:getsizeread the whole value throughget;getsize_prefixlisted and then read every value;get_ranges_syncbypassed any override on the wrapped store;supports_consolidated_metadataalways returnedTrue. Wrapping a store that manages its own consolidation (and returnsFalse) inLoggingStorewould therefore letconsolidate_metadatawrite to it.get_ranges_synctakesNonefor the coalescing kwargs to mean "use the wrapped store's default", likeWrapperStore.get_ranges.LoggingStorelogsget_ranges,get_ranges_sync,_get_many,_set_manyandsupports_consolidated_metadata. Before, range reads reached the wrapped store without being logged or counted.CacheStore.getsizenow asks the source store directly, instead of going through the cache-awareget.LatencyStoregainsget_ranges_sync, routed through its ownget_synclike itsget_ranges. Without it, the new forwarding would have removed latency from sync range reads.LatencyStore.getsizeno longer adds latency, because it no longer goes throughget.Found but not fixed here
CacheStoreforwardsdelete_dir,set_if_not_exists,_set_manyandclearto the source store without touching the cache, so later reads can serve stale entries.CacheStore.__enter__raisesNotImplementedError, because_with_storedoes, sowith CacheStore(...)fails. It's inREROUTEDwith that reason.Testing
tests/test_store,tests/test_experimental,tests/test_codecs/test_sharding.py: pass locally on macOS. The fsspec-too-old path was checked by raising the version threshold locally. The Windows entries are confirmed only by CI.max_examples=25) take about 3 s.slow_hypothesisvariants run for about 60 s each underjust hypothesis.getsize,getsize_prefix,get_ranges_syncandsupports_consolidated_metadataon every wrapper.🤖 Generated with Claude Code