Skip to content

feat(middleware): implement SessionMap with file-backed session store (#24)#25

Merged
alexey-pelykh merged 1 commit intomainfrom
feat/session-map
Feb 25, 2026
Merged

feat(middleware): implement SessionMap with file-backed session store (#24)#25
alexey-pelykh merged 1 commit intomainfrom
feat/session-map

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

Implements SessionMap class that maps channel conversations to CLI runtime session IDs, enabling session continuity across messaging channels.

  • Exports SessionMap class, SessionKey type, SessionEntry type from src/middleware/session-map.ts
  • Composite key format: {channelId}:{userId}:{threadId ?? "_"}
  • 7-day default TTL with configurable override
  • get() returns undefined for unknown, expired, or corrupted entries
  • set() evicts all expired entries, writes atomically (temp + rename)
  • delete() removes entry, no-op for missing key
  • Corrupted JSON file → graceful recovery (no throw)
  • Missing directory → created on set()
  • No in-memory cache — every operation hits disk
  • 17 tests covering CRUD, persistence, TTL expiration, resilience, and key composition

Closes #24

Test plan

  • npx vitest run src/middleware/session-map.test.ts — all 17 tests pass
  • npx vitest run — full suite passes (pre-existing flaky server.auth timeout unrelated)
  • pnpm check — format, typecheck, lint all clean

🤖 Generated with Claude Code

…#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]>
@alexey-pelykh alexey-pelykh merged commit 2834b1f into main Feb 25, 2026
2 checks passed
@alexey-pelykh alexey-pelykh deleted the feat/session-map branch February 25, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SessionMap

1 participant