Make versioning backend-agnostic - #179
Open
xxfast wants to merge 1 commit into
Open
Conversation
Move `VersionedCodec` out of `kstore-file` and into `kstore`. It's now a decorator over three codecs: the data, the version, and a stale reader for the old payload. Nothing in it knows about files. `kstore-file` keeps `storeOf(file, version, ...)`, now a thin factory over `FileCodec`. `kstore-storage` gets `storeOf(key, version, ...)` for free. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #179 +/- ##
==========================================
- Coverage 94.35% 93.52% -0.83%
==========================================
Files 8 9 +1
Lines 124 139 +15
Branches 11 12 +1
==========================================
+ Hits 117 130 +13
- Misses 0 2 +2
Partials 7 7
|
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.
VersionedCodeclived inkstore-fileand did its own file IO, sokstore-storagecouldn't have versioned stores.Moved it into
kstoreas a decorator over three codecs:data- the current shape ofTversionCodec- persists the version alongside the datastaleCodec- re-reads the old payload in a raw shape that survives schema changesVersioning is itself just persistence, so it's delegated to codecs. Nothing in
VersionedCodecknows about files or keys.What this gets us
kstore-storagegetsstoreOf(key, version, ...)for free. 48 lines pointingStorageCodecat a"$key@version"sibling record.kstore-filekeepsstoreOf(file, version, ...)unchanged. It's now a thin factory overFileCodec, net -44 lines.Behaviour
0, ie the store predates versioning.versionasnull, the same way an unreadable payload leavespreviousasnull.API
Migration<T, R>is now generic over the raw shape.kstore-filekeeps itsMigration<T>typealias andDefaultMigrationso nothing downstream breaks.apiDumpis committed.Tests
VersionedCodecTests(10) runs the decorator against an in-memoryMapCodec, proving it's backend-agnostickstore-fileKVersionedStoreTests(14), behaviour unchangedkstore-storageKVersionedStoreTests(6), newDocs updated with the storage factory and the custom codec path.
🤖 Generated with Claude Code