feat(storage): BackendSessionStorage — KV-backed SessionStorage#12
Merged
Conversation
Add an optional SessionStorage backed by an injected key/value backend (KVBackend protocol: stash/retrieve), for cross-host session continuity without writing the protocol by hand. Schema, 4h TTL, and legacy migration are shared with LocalFileStorage via extracted _serialize / _deserialize helpers. Backend errors never propagate: reads fall back to defaults, writes log-and-continue. attune-help imports no backend itself — the integrator injects one — so this adds no required dependency (ADR-002 intact). Export KVBackend + BackendSessionStorage from the package root; fix the README protocol example (get_session/set_session, not load/save). Implements specs/help-memory-tool (Option A) tasks 1-4, 6, 7. Task 5 ([memory] extra) dropped: attune_redis is bundled in attune-ai, not a standalone PyPI package, so there is nothing clean to pin — the backend is bring-your-own via injection. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
specs/help-memory-toolOption A (the corrected scope — see that spec's premise-correction note).What
BackendSessionStorage— an optionalSessionStoragebacked by an injected key/value backend (KVBackendprotocol:stash/retrieve). Gives cross-host session continuity without writing the protocol by hand.LocalFileStoragevia extracted_serialize/_deserializehelpers (no duplication).KVBackend+BackendSessionStoragefrom the package root.load/save→get_session/set_session).Dependency stance (ADR-002)
attune-help imports no backend — the integrator injects one — so this adds zero required dependencies.
storage.pyremains stdlib-only.Scope note
Task 5's
[memory]extra was dropped:attune_redisis bundled inside attune-ai, not a standalone PyPI package, so there's nothing clean to pin. The backend is bring-your-own via injection. (The genuine model-driven Anthropic memory tool is split to a separate follow-on spec.)Tests
13 new tests (in-memory fake backend) covering protocol parity with
LocalFileStorage(round-trip, defaults-on-miss, TTL expiry, legacy migration, malformed payload), keying/isolation, and backend error-safety. 315 passed (5 pre-existingensurepipSIGABRT env failures in the isolated-venv tests, unrelated). ruff clean.🤖 Generated with Claude Code