Ask::Session
Event-sourced session state for the ask-rb ecosystem.
Overview
Ask::Session provides the foundational value objects and stores for event-sourced
session management in ask-rb: immutable Record and Event envelopes, an
in-memory Store with concurrency guardrails, a durable ProviderStore for
restart-safe sessions, a replayable Host with subscriptions, a
State reducer, and a Sink that records ask-runtime tool lifecycle through
Host#sink. It ships with zero runtime dependencies — durability through
ask-state-providers is an
optional integration.
Task guides live in docs/.
Installation
Requires Ruby 3.2+.
gem "ask-session"Quick start
In-memory, single process:
require "ask-session"
host = Ask::Session::Host.new
host.create(id: "s1", metadata: { user: "alice" })
host.send_message("s1", content: "hello")
host.session("s1").version # => 2
host.close("s1", reason: "done")Invalid transitions (sending to a closed session, closing twice) raise
Ask::Session::InvalidTransitionError.
Guides
- Guides index
- In-memory sessions
- Durable sessions with SQLite (optional ask-state-providers)
- Subscriptions and replay
- Tool lifecycle through Host#sink
- Export and import
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-feature) - Commit your changes (
git commit -am 'Add feature') - Push to the branch (
git push origin my-feature) - Create a Pull Request
License
MIT License. See LICENSE for details.