Commit 2d7df08
authored
feat(examples): S3, Redis, Postgres SessionStore reference adapters (#842)
Stacked on #837. (Replaces #841, which was merged into #837's branch by
mistake — this re-splits it.)
Three copy-in reference `SessionStore` adapters under
`examples/session_stores/`:
- **S3** (`s3_session_store.py`) — JSONL part files per append; mirrors
`@anthropic-ai/claude-agent-sdk-s3` (TS)
- **Redis** (`redis_session_store.py`) — RPUSH/LRANGE lists + zset
session index; mirrors the TS Redis reference
- **Postgres** (`postgres_session_store.py`) — `asyncpg` + jsonb rows
with bigserial seq; new (no TS equivalent)
Not shipped in the wheel — these live in `examples/`, users copy the
file they need into their project. The sdist does include `examples/` so
the references travel with source releases. Backend deps are in the
optional `[examples]` group only.
**Tests** — 678 passed, 3 skipped (env-gated live suites)
- All test modules `importorskip` on their backend client so default CI
is unaffected.
- S3 unit tests use `moto` in-process; Redis uses `fakeredis`; both pass
the full conformance suite.
- Live e2e modules for all three are env-gated (`SESSION_STORE_S3_*`,
`SESSION_STORE_REDIS_URL`, `SESSION_STORE_POSTGRES_URL`) and skip
otherwise.
- Verified locally against moto, fakeredis, and dockerized
`postgres:16-alpine`.
Zero secrets / internal refs in the diff (scanned).
**Review follow-ups** (9 commits total)
- Docs: Production checklist, Retention → `delete_session_via_store`,
scrubbed internal TS path refs, S3 ref now points at the public TS
example path, README notes Redis key separator + Postgres schema
divergence.
- Build: sdist manifest now includes `examples/`.
- Tests: Redis + Postgres conformance tests swapped `isinstance(store,
SessionStore)` → `_store_implements()` after #837 dropped
`@runtime_checkable` from the base Protocol.1 parent 6e3d54f commit 2d7df08
12 files changed
Lines changed: 2854 additions & 0 deletions
File tree
- examples/session_stores
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
0 commit comments