feat(middleware): implement SessionMap with file-backed session store (#24)#25
Merged
alexey-pelykh merged 1 commit intomainfrom Feb 25, 2026
Merged
feat(middleware): implement SessionMap with file-backed session store (#24)#25alexey-pelykh merged 1 commit intomainfrom
alexey-pelykh merged 1 commit intomainfrom
Conversation
…#24) Add SessionMap class that maps channel conversations to CLI runtime session IDs, enabling session continuity across messaging channels. - Composite key format: channelId:userId:threadId (or _ sentinel) - File-backed JSON storage with atomic writes (temp + rename) - Lazy TTL eviction on set(), 7-day default - Graceful degradation on corrupted/missing files (including non-object JSON) - No in-memory cache: every operation hits disk - 23 tests covering CRUD, persistence, TTL, resilience, and key composition Co-Authored-By: Claude Opus 4.6 <[email protected]>
3091b40 to
fa76609
Compare
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.
Summary
Implements
SessionMapclass that maps channel conversations to CLI runtime session IDs, enabling session continuity across messaging channels.SessionMapclass,SessionKeytype,SessionEntrytype fromsrc/middleware/session-map.ts{channelId}:{userId}:{threadId ?? "_"}get()returnsundefinedfor unknown, expired, or corrupted entriesset()evicts all expired entries, writes atomically (temp + rename)delete()removes entry, no-op for missing keyset()Closes #24
Test plan
npx vitest run src/middleware/session-map.test.ts— all 17 tests passnpx vitest run— full suite passes (pre-existing flakyserver.authtimeout unrelated)pnpm check— format, typecheck, lint all clean🤖 Generated with Claude Code