Skip to content

feat: disk-backed primitives — skipLoad, getManifest, streamSnapshot, getWalOps#11

Merged
mbocevski merged 6 commits into
mainfrom
feat/disk-backed-primitives
Apr 11, 2026
Merged

feat: disk-backed primitives — skipLoad, getManifest, streamSnapshot, getWalOps#11
mbocevski merged 6 commits into
mainfrom
feat/disk-backed-primitives

Conversation

@mbocevski

@mbocevski mbocevski commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • skipLoad optionstore.open(dir, { skipLoad: true }) opens the store for writes without loading snapshot or replaying WAL into memory. Guards compact() to prevent writing empty snapshots.
  • store.getManifest() — returns read-only ManifestInfo with snapshot/WAL paths and stats
  • store.streamSnapshot() — async generator yielding [id, record] pairs with true streaming via readline (JSONL format)
  • store.getWalOps(sinceTimestamp?) — async generator yielding WAL operations for incremental replay. Multi-writer ops merge-sorted by Lamport clock.
  • JSONL snapshot format — snapshots now written as JSONL (header + one record per line) instead of monolithic JSON. Enables true streaming reads. Legacy JSON snapshots auto-detected and read correctly.
  • ManifestInfo type — read-only facade for manifest data

These primitives enable AgentDB v1.2.0 to build a Parquet-backed disk storage mode on top of opslog.

Breaking

  • Snapshot file extension changed from .json to .jsonl. Existing .json snapshots still readable. Custom StorageBackend implementations may need updating (see opslog-s3 task).

Test plan

  • skipLoad: records Map empty, writes work, lock acquired, compact() guarded
  • getManifest: null before open, read-only fields, no internal fields exposed
  • streamSnapshot: all records, empty snapshot, excludes deleted, true streaming
  • getWalOps: all ops, sinceTimestamp filter, empty WAL
  • JSONL snapshots: write/read round-trip, legacy JSON backward compat
  • Error handling: streamSnapshot/getWalOps throw before open
  • skipLoad + archive: returns 0

… getWalOps

- skipLoad option: open store for writes without loading snapshot/WAL into memory
- getManifest(): public accessor for current manifest (snapshot/WAL paths)
- streamSnapshot(): async generator yielding [id, record] from snapshot
- getWalOps(since?): async generator yielding WAL ops for incremental replay
- skipLoad disables checkpointOnClose (empty Map would overwrite real data)
- 12 new tests in disk-primitives.test.ts
…ation, test coverage

- Return read-only ManifestInfo from getManifest() instead of raw Manifest
- Single-writer getWalOps yields directly without intermediate allOps array
- Add JSDoc noting streamSnapshot memory characteristics
- Add 6 tests: error-before-open, snapshot-after-delete, read-only manifest,
  skipLoad+archive, covering all reviewer gaps
Snapshots now written as JSONL: header line with version/timestamp,
followed by one {id, data} line per record. Enables streamSnapshot()
to use readline for true streaming — one record in memory at a time.

Legacy monolithic JSON snapshots auto-detected and read correctly.
Snapshot file extension changed from .json to .jsonl.
@mbocevski
mbocevski merged commit a7f0cd6 into main Apr 11, 2026
3 checks passed
@mbocevski
mbocevski deleted the feat/disk-backed-primitives branch April 11, 2026 11:44
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.

1 participant