kv: add Reader read-only seam interface - #109
Merged
Merged
Conversation
Reader { Get; Scan; ScanRange } names the read-only surface shared by Store and
Snapshot, so a read path can be written against either the live Store or a
consistent point-in-time Snapshot. Two compile-time assertions
(var _ Reader = (Store)(nil) / (Snapshot)(nil)) prove both satisfy it — and
would catch a regression that dropped a read method from either.
Purely additive: Store/Snapshot/Batch/Snapshotter method sets are unchanged, so
every existing implementer keeps satisfying them. No consumer yet — this only
adds the seam; wiring the search read path onto a snapshot is a separate change.
go1.24.2: core build green (the assertions are the check); gofmt clean.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
codetrek
approved these changes
Jul 8, 2026
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.
What
Adds
kv.Reader { Get; Scan; ScanRange }— the read-only surface shared bykv.Storeandkv.Snapshot— plus two compile-time assertions that both satisfy it:Why
StoreandSnapshot(added in #108) expose the identical read triple, but as distinct types a read helper written against one can't accept the other.Readernames the shared subset so a read path can be written against either the live store or a consistent point-in-time snapshot. Because Go interface assignability (not embedding) is what applies, aStoreorSnapshotvalue is already passable where aReaderis wanted, with no explicit conversion — so this is the seam the future search-on-a-snapshot wiring will use.Scope
Seam only. No consumer — no
engine/invertedindex/documentsre-parameterization, no pebblekv change. Wiring the read path onto a snapshot is a separate later change.Compatibility
Purely additive:
Store/Snapshot/Batch/Snapshotterare left byte-identical, so every existing implementer keeps satisfying them. The assertions have teeth — they'd fail to compile ifStoreorSnapshotever lost a read method. No on-disk format change.Verification (go1.24.2)
buildgreen — thevar _ Reader = …assertions are the compile-time check.gofmtclean; diff is a pure 18-line addition tocore/kv/kv.go, zero deletions.Built via the SDD flow (spec → review → workflow-driven implementation).
🤖 Generated with Claude Code
via Happy