Skip to content

kv: add Reader read-only seam interface - #109

Merged
oc-engteam merged 1 commit into
mainfrom
feat/kv-reader
Jul 8, 2026
Merged

kv: add Reader read-only seam interface#109
oc-engteam merged 1 commit into
mainfrom
feat/kv-reader

Conversation

@oc-engteam

Copy link
Copy Markdown
Collaborator

What

Adds kv.Reader { Get; Scan; ScanRange } — the read-only surface shared by kv.Store and kv.Snapshot — plus two compile-time assertions that both satisfy it:

var (
    _ Reader = (Store)(nil)
    _ Reader = (Snapshot)(nil)
)

Why

Store and Snapshot (added in #108) expose the identical read triple, but as distinct types a read helper written against one can't accept the other. Reader names 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, a Store or Snapshot value is already passable where a Reader is 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/documents re-parameterization, no pebblekv change. Wiring the read path onto a snapshot is a separate later change.

Compatibility

Purely additive: Store/Snapshot/Batch/Snapshotter are left byte-identical, so every existing implementer keeps satisfying them. The assertions have teeth — they'd fail to compile if Store or Snapshot ever lost a read method. No on-disk format change.

Verification (go1.24.2)

  • core build green — the var _ Reader = … assertions are the compile-time check.
  • gofmt clean; diff is a pure 18-line addition to core/kv/kv.go, zero deletions.
  • No behavioral test (interface-only).

Built via the SDD flow (spec → review → workflow-driven implementation).

🤖 Generated with Claude Code
via Happy

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>
@oc-engteam
oc-engteam merged commit 8baa383 into main Jul 8, 2026
4 checks passed
@oc-engteam
oc-engteam deleted the feat/kv-reader branch July 8, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants