cultcache-py: export CultCacheError from the package root (py-cultcacheerror-not-exported)
Some checks failed
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Failing after 19m53s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Libby 2026-11-17 02:00:21 +00:00
commit b53bb45844
4 changed files with 19 additions and 1 deletions

View file

@ -8,6 +8,7 @@
### Added
- `CultCacheError` is exported from the package root (`from cultcache_py import CultCacheError`); it was reachable only from the private `cultcache_py.cache` module.
- `CultCache.update` and `update_global` return `UpdateResult(outcome, document)`; `UpdateOutcome` is `UPDATED`, `DECLINED` or `LOST_RACE`. The single-file store gains `read(key)` (the record and its content version, the SHA-256 C# computes) and `commit_if(envelope, expected)`, the version is the SHA-256 of the record re-encoded as `[key, schemaId, storedAt, payload]` with minimal MessagePack encodings, which is the SHA-256 of the record's stored bytes exactly when the writer encoded it minimally (every writer in this library does; a record another writer encoded with a wider-than-needed length or integer has the version of its minimal form, not of its bytes). Both looked up by the cache and not `BackingStore` protocol members (variants:cut_spec:cut-update-with-retry-py).
- `read_payload_tree(type_name, payload, decoder=None)`: the exported owner of the one-value, depth-first payload read that `decode_payload` uses, for payloads read outside a definition (`cultnet-py`'s witness bundle decode needs it, so `cultnet-py` now requires `cultcache-py>=0.4.0`). The manifest version is 0.4.0, the minor these Unreleased breaking changes imply, set in this change so the workspace install resolves the new bound; the `## Unreleased` heading becomes `## [0.4.0]` when it is tagged.

View file

@ -69,6 +69,7 @@ store.
## Public Surface
- `CultCacheError` (a `RuntimeError`, exported from the package root): the cache's refusals (a duplicate registration, a unique-index violation, a key held by two types). Import it from `cultcache_py`, not from the private `cache` module. Any `convert` refusal raised as a `CultCacheError` is caught by it too, once `convert` lands.
- `define_document_type(...)`
- `define_database_entry_type(...)`
- `database_entry_field(...)`

View file

@ -1,7 +1,7 @@
from .backing_store import BackingStore, CultCacheEnvelope
from .backing_store import CultCacheSchemaCatalogEntry, CultCacheSchemaCatalogMember
from . import leaves
from .cache import CultCache, CultCacheBuilder, ForeignRecord, UpdateOutcome, UpdateResult
from .cache import CultCache, CultCacheBuilder, CultCacheError, ForeignRecord, UpdateOutcome, UpdateResult
from .documents import (
MAX_PAYLOAD_DEPTH,
MAX_SLOT_KEY,
@ -25,6 +25,7 @@ __all__ = [
"BackingStore",
"CultCache",
"CultCacheBuilder",
"CultCacheError",
"CultCachePayloadDepthError",
"CultCacheEnvelope",
"CultCacheSchemaCatalogEntry",

View file

@ -93,5 +93,20 @@ class FirstCallTests(unittest.TestCase):
self.assertIn("```python\n" + snippet + "```", docs)
class RootExportTests(unittest.TestCase):
def test_cultcacheerror_is_importable_from_the_root_and_catches_a_cache_refusal(self) -> None:
import cultcache_py
from cultcache_py import CultCache, CultCacheError, define_document_type
from cultcache_py.cache import CultCacheError as private
self.assertIs(CultCacheError, private)
self.assertIn("CultCacheError", cultcache_py.__all__)
document = define_document_type("tests.root_export")
cache = CultCache.builder().register_document_type(document).build()
with self.assertRaises(CultCacheError):
cache.get_required(document, "absent")
if __name__ == "__main__":
unittest.main()