Skip to content

Add SqliteBackend::from_connection — incremental-adoption seam (0.1.1)#1

Merged
hartsock merged 1 commit into
mainfrom
feat/from-connection
Jun 14, 2026
Merged

Add SqliteBackend::from_connection — incremental-adoption seam (0.1.1)#1
hartsock merged 1 commit into
mainfrom
feat/from-connection

Conversation

@hartsock

Copy link
Copy Markdown
Member

Summary

Adds the seam both consumers need to adopt agent-store without opening a second connection to the same DB or rewriting all their domain SQL at once:

  • SqliteBackend::from_connection(Connection) — wrap a connection the consumer already owns.
  • SqliteBackend::connection() -> &rusqlite::Connection — escape hatch so the consumer keeps its existing rusqlite domain SQL while the agent-store primitives (Generation, WriterLog) run on the same database via the Backend trait.

newt-agent's ConversationStore and modulex-mcp's Store each hold a live rusqlite::Connection; this keeps the first integration PRs small. Bumps 0.1.0 → 0.1.1.

Test plan

  • just check green locally (fmt + clippy -D warnings + tests).
  • New regression test from_connection_wraps_and_shares_the_database.
  • 16 unit tests + 1 doctest pass.

risk:low — additive API, no CI/hook/build changes, regression test included.

WHAT: SqliteBackend::from_connection(Connection) wraps a connection a consumer
already owns; SqliteBackend::connection() lends it back for domain-table SQL.
Bump 0.1.0 -> 0.1.1.

WHY: newt-agent's ConversationStore and modulex-mcp's Store each own a live
rusqlite::Connection. Without this seam, adopting agent-store would mean either
a second connection to the same file or rewriting all domain SQL at once. This
lets a consumer hand over its connection, keep its existing rusqlite code via
connection(), and gain the agent-store primitives on the same database — so the
first integration PRs stay small.

Regression test: from_connection_wraps_and_shares_the_database asserts Backend
trait writes and connection() escape-hatch writes hit the same database.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hartsock hartsock added the risk:low Scoped, tested, no CI/build changes label Jun 14, 2026
@hartsock hartsock merged commit 047c7c1 into main Jun 14, 2026
1 check passed
@hartsock hartsock deleted the feat/from-connection branch June 14, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Scoped, tested, no CI/build changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant