-
Notifications
You must be signed in to change notification settings - Fork 0
Session Store
Session Store extensions are persistence backends. Each store writes session snapshots and reads them back on resume. Exactly one store is active per session; the store owns both write and read.
contractVersion: 1.0.0
A session contains the whole observable state — message history, tool calls, the manifest, every extension's state slot. Persisting it must survive crashes, power loss, and process restarts. The filesystem store ships bundled as the default; other stores plug in through this contract.
Session Stores are extensions because the right backend varies by environment: a laptop uses the filesystem; a team tool might use a database; a Claude-compatible mode might write into Claude's session format.
classDiagram
class SessionStoreContract {
kind : "SessionStore"
contractVersion : SemVer
requiredCoreVersion : SemVerRange
configSchema : JSONSchema
loadedCardinality : unlimited
activeCardinality : one
stateSlot : optional
validationSeverity : critical-when-active
discoveryRules : DiscoveryRules
reloadBehavior : never
capabilities : StoreCapabilities
}
class StoreCapabilities {
journaling : bool
snapshotBytesLimit : int
largeSlotStreaming : bool
concurrentReaders : bool
}
SessionStoreContract --> StoreCapabilities
A Session Store owns both persistence directions:
-
Write — snapshot at turn boundaries, journal between turns if
journaling: true, persist state slots. - Read — resume by session ID, reconstitute the manifest, deliver state slots to their owners with drift handling.
Splitting read and write across separate extensions is not supported. The store that wrote the session is the only store that can read it. See the Persistence and Recovery page.
Every Session Store's configSchema must accept:
| Field | Meaning |
|---|---|
enabled |
Whether this store is loadable. |
active |
Whether this is the active store this session. Exactly one loaded store must have active: true. |
Plus store-specific options (filesystem path, database URL, credentials reference).
| Phase | Store responsibilities |
|---|---|
init |
Validate config; open handles; verify the backend is reachable and writable. |
activate |
If active: true, announce as the session's store and take over the persistence path. |
deactivate |
Drain pending writes; close handles. |
dispose |
Release resources. Idempotent. |
A store that cannot complete init as the active store fails the session with a clear diagnostic. See Validation Pipeline.
Loaded: unlimited. Multiple stores may be loaded (e.g., filesystem + remote backup), but only one writes the session's canonical snapshots.
Active: one. Cross-store resume is not supported. If the session was written by store A, the session must resume against store A.
See Cardinality and Activation.
Optional. A store's own slot typically holds:
- Bookkeeping index (per-slot revisions, summary of what has been written).
- Last successful snapshot offset/pointer.
The store's slot is self-referential — the store reads and writes its own slot like any extension, but it is also the backend that persists every other extension's slot. The store writes its own slot first in a snapshot, then the rest.
See Extension State.
Critical when active. A failed active store fails the session at init; there is no fallback. A loaded-but-inactive store that fails is a warning.
Config cannot relax an active store to optional.
Session Stores live in a session-stores/ folder under each configuration scope layer:
| Layer | Location |
|---|---|
| Bundled | Ships with the package (filesystem store is bundled). |
| Global | ~/.stud/session-stores/… |
| Project | <cwd>/.stud/session-stores/… |
Session Stores are unordered. Only one is active; there is no concept of order across stores.
reloadBehavior: never. Switching the active Session Store mid-session would require migrating the session across backends, which is out of scope for v1.
Changing the active store requires a session end and a new session. This is documented and explicit.
A conforming store provides:
- Atomicity. A snapshot write is all-or-nothing. An interrupted write leaves the previous snapshot intact.
- Consistency. A resume sees a consistent view of the session at the last successfully-acknowledged snapshot.
- Isolation. Concurrent writes (if the backend allows them) do not interleave.
- Durability. After acknowledgement, the snapshot survives crashes.
Different stores implement these differently. The filesystem store uses a journal-plus-snapshot pattern. Remote stores may rely on their backend's guarantees. The contract is durability; the mechanism is not.
A Session Store reads and writes only through the Host API, plus the session persistence surface core exposes to the active store:
-
host.session.persistenceSurface— the interface core uses to hand over serialized snapshots, slot payloads, and to request reads on resume. -
host.env.get(name)— credentials for remote stores (by reference). -
host.audit— every write and resume is audited.
A store never:
- Reads another extension's state slot directly; slots are handed to it as opaque payloads during snapshot.
- Drives the Interaction Protocol outside of trusted-store-setup scenarios.
- Stores must never persist resolved secrets. Session manifests and state slots pass through the store as opaque blobs, but they never contain resolved secrets in the first place — the session manifest and Extension State forbid it. The store's duty is to not introduce secrets of its own (e.g., an access token) into what it persists.
- Stores may be network-attached. A remote store reaches the network at every snapshot. Network failure classes are part of Error Model.
- Resume is a trust event. Resuming a session trusts that the stored manifest matches what core expects. Drift handling (see Session Resume flow) is the safeguard.
- Durability has a cost. A store with synchronous fsync per snapshot is safer but slower. Configuration exposes the tradeoff; defaults favor durability.
- Persistence and Recovery
- Session Lifecycle
- Session Manifest
- Extension State
- Session Resume flow
- Filesystem store reference: reference-extensions/session-stores/Filesystem
- Session Store contract as documented above. Read + write in one contract; exactly one active;
reloadBehavior: never. - Slim manifest shape: stores only message history, attached-SM state reference, security mode, and project root. No extension set, config hashes, or capability probes.
- Resume launched via
stud --continue. On resume, missing or failing extensions are silently absent; core resume (messages + conversation continuation) must never fail due to extension drift. SM backward compatibility is the SM author's responsibility. -
storeIdis stamped on each manifest so resume can verify the originating store before hydration begins. Cross-store resume yieldsSession/ResumeMismatch. - No
validationSeverityfield. A failed Session Store is disabled and surfaced at startup; resume with no available store ends withSession/StoreUnavailable.
- Execution Model
- Message Loop
- Concurrency and Cancellation
- Error Model
- Event and Command Ordering
- Event Bus
- Command Model
- Interaction Protocol
- Hook Taxonomy
- Host API
- Extension Lifecycle
- Env Provider
- Prompt Registry
- Resource Registry
- Session Lifecycle
- Session Manifest
- Persistence and Recovery
- Stage Executions
- Subagent Sessions
- Contract Pattern
- Versioning and Compatibility
- Deprecation Policy
- Capability Negotiation
- Dependency Resolution
- Validation Pipeline
- Cardinality and Activation
- Extension State
- Conformance and Testing
- Providers
- Provider Params
- Tools
- Hooks
- UI
- Loggers
- State Machines
- SM Stage Lifecycle
- Stage Definitions
- Commands
- Session Store
- Context Providers
- Settings Shape
- Trust Model
- Project Trust
- Extension Isolation
- Extension Integrity
- LLM Context Isolation
- Secrets Hygiene
- Security Modes
- Tool Approvals
- MCP Trust
- Sandboxing
- Configuration Scopes
- Project Root
- Extension Discovery
- Extension Installation
- Extension Reloading
- Headless and Interactor
- Determinism and Ordering
- Launch Arguments
- Network Policy
- Platform Integration
Tools
UI
Session Stores
Loggers
Providers
Hooks
Context Providers
Commands
- First Run
- Default Chat
- Tool Call Cycle
- Hook Interception
- Guard Deny Reproposal
- State Machine Workflow
- SM Stage Retry
- Hot Model Switch
- Capability Mismatch Switch
- Session Resume
- Session Resume Drift
- Approval and Auth
- Interaction Timeout
- Headless Run
- Parallel Tool Approvals
- Subagent Delegation
- Scope Layering
- Project First-Run Trust
- Reload Mid-Turn
- Compaction Warning
- MCP Remote Tool Call
- MCP Prompt Consume
- MCP Resource Bind
- MCP Reconnect