Skip to content

feat(session): add storage interface for pluggable session backends#15922

Open
ryanjwong wants to merge 4 commits intoanomalyco:devfrom
ryanjwong:ryan/oc-store-interface
Open

feat(session): add storage interface for pluggable session backends#15922
ryanjwong wants to merge 4 commits intoanomalyco:devfrom
ryanjwong:ryan/oc-store-interface

Conversation

@ryanjwong
Copy link

@ryanjwong ryanjwong commented Mar 4, 2026

Issue for this PR

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This adds a typed storage contract for session persistence, wraps SQLite behind that contract, and makes the contract async-compatible so non-SQLite providers can be added more easily.

Changes included:

  • Added SessionStore + SessionStoreTx interfaces in packages/opencode/src/session/store.ts, with operation groups for sessions/messages/parts/todos/permissions.
  • Added schema-derived insert/select types (SessionInput, SessionRow, etc.).
  • Added Asyncable<T> return support across the store interface (use, transaction, effect, and tx methods).
  • Added SqliteSessionStore adapter in packages/opencode/src/session/store.sqlite.ts that wraps Database.use, Database.transaction, and Database.effect.
  • Routed core write paths through the adapter:
    • Session.updateMessage, Session.removeMessage, Session.removePart, Session.updatePart
    • Todo.update and Todo.get (now async to align with async-capable store)
  • Exported store types and sqlite adapter from packages/opencode/src/session/index.ts.

This remains incremental: runtime behavior should stay equivalent while introducing a real, async-ready boundary for follow-up backends.

How did you verify your code works?

  • Installed Bun (1.3.10) in this environment
  • Ran bun install at repo root
  • Ran bun run typecheck in packages/opencode
  • Pushed branch successfully; pre-push hook ran bun turbo typecheck and passed

Screenshots / recordings

N/A (no UI changes)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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