Skip to content

feat(session): implement Redis storage backend (RC-6)#4233

Merged
yrobla merged 1 commit intomainfrom
issue-4205
Mar 20, 2026
Merged

feat(session): implement Redis storage backend (RC-6)#4233
yrobla merged 1 commit intomainfrom
issue-4205

Conversation

@yrobla
Copy link
Copy Markdown
Contributor

@yrobla yrobla commented Mar 19, 2026

Summary

Add RedisStorage as a distributed Storage implementation for the transport/session package, enabling horizontal scaling of the vMCP component by externalising session state to a shared Redis/Sentinel backend.

  • Add RedisConfig, SentinelConfig, and RedisTLSConfig structs with configurable timeouts (defaults: dial 5s, read 3s, write 3s)
  • Implement RedisStorage with Store (SET+EX TTL refresh), Load (ErrSessionNotFound on miss), Delete (no-op on missing key), DeleteExpired (no-op; Redis TTL handles expiry), and Close
  • Support standalone and Sentinel modes; optional TLS with system or custom CA roots
  • Add unit tests using miniredis covering all methods, TTL refresh, idempotent upsert, key format, and all three session types
  • Remove nolint:unused annotations from serializeSession/deserializeSession now that they are consumed by RedisStorage

Fixes #4205

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Changes

File Change

Does this introduce a user-facing change?

Special notes for reviewers

@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Mar 19, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 358e8a194e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 43.92523% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.22%. Comparing base (a881814) to head (e290678).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
pkg/transport/session/storage_redis.go 43.92% 56 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4233      +/-   ##
==========================================
+ Coverage   68.82%   69.22%   +0.39%     
==========================================
  Files         468      471       +3     
  Lines       47087    47300     +213     
==========================================
+ Hits        32407    32742     +335     
- Misses      11996    12019      +23     
+ Partials     2684     2539     -145     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yrobla yrobla requested a review from Copilot March 19, 2026 12:18
@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Mar 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a Redis-backed Storage implementation for pkg/transport/session to externalize session state (enabling horizontal scaling), including configuration structs and unit tests.

Changes:

  • Added RedisConfig/SentinelConfig/RedisTLSConfig (with default timeout constants) for configuring Redis connectivity.
  • Implemented RedisStorage with Redis TTL-based expiry and standalone/Sentinel support (plus optional TLS).
  • Added miniredis unit tests covering CRUD behavior, TTL refresh/expiry, key format, and multiple session types; removed now-unneeded nolint:unused in serialization helpers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
pkg/transport/session/storage_redis.go Adds Redis-backed Storage implementation and TLS helper.
pkg/transport/session/redis_config.go Introduces Redis configuration structs and default timeout constants.
pkg/transport/session/storage_redis_test.go Adds miniredis-based unit tests for RedisStorage.
pkg/transport/session/serialization.go Removes obsolete “unused” annotations/comments now that serialization is exercised.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yrobla yrobla requested a review from Copilot March 19, 2026 12:24
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/M Medium PR: 300-599 lines changed labels Mar 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Redis-backed Storage implementation to pkg/transport/session so session state can be shared across replicas (supporting horizontal scaling), with configuration structs and unit tests.

Changes:

  • Introduces RedisConfig / SentinelConfig / RedisTLSConfig with defaulted timeouts.
  • Implements RedisStorage (standalone + Sentinel, optional TLS) plus constructor(s).
  • Adds miniredis-backed unit tests and removes now-unneeded nolint:unused annotations from session serialization helpers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
pkg/transport/session/redis_config.go Adds Redis configuration structs and default timeout constants.
pkg/transport/session/storage_redis.go Implements the Redis-backed Storage plus config validation and TLS builder.
pkg/transport/session/storage_redis_test.go Adds unit tests for Redis storage behavior using miniredis.
pkg/transport/session/serialization.go Removes “unused” comments/linters now that serialization is used by Redis storage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Mar 19, 2026
@yrobla yrobla requested a review from Copilot March 19, 2026 14:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a Redis-backed Storage implementation to pkg/transport/session, enabling session state to be shared across vMCP replicas for horizontal scaling (RC-6 / Fixes #4205).

Changes:

  • Introduces RedisStorage with standalone + Sentinel support, TTL-based expiry, and TLS options.
  • Adds Redis configuration structs and default timeout constants for consistent client behavior.
  • Adds unit tests using miniredis to cover storage operations, TTL refresh behavior, and round-trips across session types.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/transport/session/redis_config.go Adds Redis/Sentinel/TLS config structs and default timeout constants.
pkg/transport/session/storage_redis.go Implements the Storage interface backed by Redis, including TTL refresh on Load via GETEX.
pkg/transport/session/storage_redis_test.go Adds miniredis-based unit tests for Redis storage behavior and config validation.
pkg/transport/session/storage.go Clarifies Load semantics around backend TTL refresh vs. UpdatedAt.
pkg/transport/session/serialization.go Removes now-unneeded nolint:unused annotations since serialization is used by Redis storage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add RedisStorage as a distributed Storage implementation for the
transport/session package, enabling horizontal scaling of the vMCP
component by externalising session state to a shared Redis/Sentinel
backend.

- Add RedisConfig, SentinelConfig, and RedisTLSConfig structs with
  configurable timeouts (defaults: dial 5s, read 3s, write 3s)
- Implement RedisStorage with Store (SET+EX TTL refresh), Load
  (ErrSessionNotFound on miss), Delete (no-op on missing key),
  DeleteExpired (no-op; Redis TTL handles expiry), and Close
- Support standalone and Sentinel modes; optional TLS with system
  or custom CA roots
- Add unit tests using miniredis covering all methods, TTL refresh,
  idempotent upsert, key format, and all three session types
- Remove nolint:unused annotations from serializeSession/deserializeSession
  now that they are consumed by RedisStorage

Closes #4205
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Mar 19, 2026
@yrobla yrobla merged commit 4d4fbe2 into main Mar 20, 2026
42 checks passed
@yrobla yrobla deleted the issue-4205 branch March 20, 2026 08:48
Sanskarzz pushed a commit to Sanskarzz/toolhive that referenced this pull request Mar 23, 2026
Add RedisStorage as a distributed Storage implementation for the
transport/session package, enabling horizontal scaling of the vMCP
component by externalising session state to a shared Redis/Sentinel
backend.

- Add RedisConfig, SentinelConfig, and RedisTLSConfig structs with
  configurable timeouts (defaults: dial 5s, read 3s, write 3s)
- Implement RedisStorage with Store (SET+EX TTL refresh), Load
  (ErrSessionNotFound on miss), Delete (no-op on missing key),
  DeleteExpired (no-op; Redis TTL handles expiry), and Close
- Support standalone and Sentinel modes; optional TLS with system
  or custom CA roots
- Add unit tests using miniredis covering all methods, TTL refresh,
  idempotent upsert, key format, and all three session types
- Remove nolint:unused annotations from serializeSession/deserializeSession
  now that they are consumed by RedisStorage

Closes stacklok#4205

Co-authored-by: taskbot <taskbot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large PR: 600-999 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Redis Storage Backend for transport/session (RC-6)

4 participants