Skip to content

relayburn-sdk: implement search + export_ledger + export_stamps verbs#303

Merged
willwashburn merged 1 commit into
mainfrom
claude/sdk-export-search
May 5, 2026
Merged

relayburn-sdk: implement search + export_ledger + export_stamps verbs#303
willwashburn merged 1 commit into
mainfrom
claude/sdk-export-search

Conversation

@willwashburn

Copy link
Copy Markdown
Member

Summary

Fill in `crates/relayburn-sdk/src/export_verbs.rs` with the three new verbs from the #259 redesign:

  • `search(SearchQueryOptions) -> Result` — FTS5 over content blobs, BM25-ranked hits with snippets.
  • `export_ledger(ExportLedgerOptions) -> Result<impl Iterator<Item = serde_json::Value>>` — emits the event stream as JSONL-shaped values for `jq` / audit-trail consumers.
  • `export_stamps(ExportStampsOptions) -> Result<impl Iterator<Item = serde_json::Value>>` — same pattern for the stamps table.

Each verb is callable as a `LedgerHandle` method and as a free function. Exports use the buffered approach (write into a `Vec`, split on newlines, parse each line) — relayburn ledgers are small enough that this is fine, and the iterator surface lets us add a streaming variant later.

Part of #246.

Test plan

  • `cargo test -p relayburn-sdk` — 6 passed (FTS5 hit, session-filter scope, limit cap, free-function ledger open, export turn round-trip, export stamp round-trip)
  • `cargo test --workspace` green
  • `cargo doc --no-deps -p relayburn-sdk` clean

Stacking

Stacked on #300 (module stubs) — base is `claude/sdk-module-stubs` and will rebase to `main` once that lands.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces a new export_verbs.rs module to the relayburn-sdk crate that provides public APIs for searching ledger content via FTS5 and exporting ledger and stamp data as JSONL. The module exports option structs, result types, and both method and free-function variants of search, export_ledger, and export_stamps operations.

Changes

Search and Export Verbs

Layer / File(s) Summary
Data Shapes
crates/relayburn-sdk/src/export_verbs.rs (lines 17–66)
SearchQueryOptions, SearchResult, ExportLedgerOptions, and ExportStampsOptions define the public API contracts for search and export operations, with optional limit, session filtering, and ledger home overrides.
Core Implementation
crates/relayburn-sdk/src/export_verbs.rs (lines 67–179)
LedgerHandle methods and free functions implement search (building a lower-level SearchOptions and delegating to inner.search_content) and export operations (streaming JSONL via inner.export_ledger_jsonl and inner.export_stamps_jsonl).
Helper Utilities
crates/relayburn-sdk/src/export_verbs.rs (lines 180–194)
parse_jsonl_lines splits JSONL buffers and deserializes each line into serde_json::Value objects for consumption by export iterators.
Tests & Documentation
crates/relayburn-sdk/src/export_verbs.rs (lines 195–387)
Comprehensive test suite covers search query execution, limit enforcement, session filtering, and both ledger and stamp export flows via method and free-function variants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through ledgers deep,
With FTS5 secrets to keep,
Search and export, JSONL streams,
Making data dance, or so it seems!
Let the verbs fly, the queries sing—
New SDK powers on the wing!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: implementing three verbs (search, export_ledger, export_stamps) in the relayburn-sdk, which matches the primary purpose of the changeset.
Description check ✅ Passed The description is directly related to the changeset, providing clear details about the three implemented verbs, their signatures, usage patterns, test coverage, and the overall objective of filling in the export_verbs.rs module.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/sdk-export-search

Comment @coderabbitai help to get the list of available commands and usage tips.

Base automatically changed from claude/sdk-module-stubs to main May 5, 2026 21:38
@willwashburn willwashburn deleted the branch main May 5, 2026 21:38
@willwashburn willwashburn reopened this May 5, 2026
Wraps the FTS5 search and JSONL export APIs on relayburn_ledger::Ledger
behind the SDK surface. Each verb appears in two forms:

- LedgerHandle method (sync, anyhow::Result), reusing the open ledger.
- Free function form, which opens its own handle from
  LedgerOpenOptions's ledger_home.

`search` returns a SearchResult that echoes the query alongside
BM25-ranked SearchHits. `export_ledger` and `export_stamps` buffer the
JSONL output into Vec<serde_json::Value> and return an `impl Iterator`
— relayburn ledgers are small enough that buffering is fine for v1; we
can add a streaming variant later without breaking callers.

Includes unit tests against a tempfile-backed ledger covering FTS5
hits, session-filter scoping, and round-tripping a turn / stamp through
the export iterator.

Part of #246
@willwashburn willwashburn force-pushed the claude/sdk-export-search branch from 367d416 to eedd229 Compare May 5, 2026 21:41
@willwashburn willwashburn merged commit 9637850 into main May 5, 2026
2 of 3 checks passed
@willwashburn willwashburn deleted the claude/sdk-export-search branch May 5, 2026 21:43
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