Use shared toolhive-core redis client for session storage#5324
Merged
reyortiz3 merged 1 commit intoMay 19, 2026
Merged
Conversation
pkg/transport/session carried its own Redis connection layer (RedisConfig, SentinelConfig, RedisTLSConfig, validateRedisConfig, buildRedisClient, buildRedisTLSConfig, timeout defaults). The auth-server migration in #5318 demonstrated the pattern for replacing that duplicated code with toolhive-core/redis; vmcp session storage and the proxy-runner session storage are the remaining consumers in this repo. Replace the local RedisConfig/SentinelConfig/RedisTLSConfig types and the validate/build helpers with tcredis.Config and tcredis.NewClient. NewRedisStorage and NewRedisSessionDataStorage now take (ctx, tcredis.Config, keyPrefix, ttl); the constructors keep the session-specific invariants (key prefix required, must end with ':', ttl > 0) and delegate connection-mode validation, timeout defaults, TLS plumbing, and Ping verification to the shared package. NewManagerWithRedis grows the same keyPrefix parameter so the wrapper matches the underlying storage signature. The vmcp server and proxy runner call sites build tcredis.Config in place (Addr, Password, DB) and pass keyPrefix separately; RedisPasswordEnvVar stays in the session package because pkg/runner reads it. Tests: TestValidateRedisConfig is removed (topology checks now live in tcredis); TestNewRedisStorageInvariants replaces it with the session-specific cases (key-prefix and ttl). TestNewRedisStorageACLAuth keeps its coverage but uses the new signature. The "invalid TLS CA cert" manager subtest is dropped (now exercising tcredis code). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5324 +/- ##
==========================================
- Coverage 68.35% 68.34% -0.01%
==========================================
Files 620 620
Lines 63316 63255 -61
==========================================
- Hits 43278 43230 -48
+ Misses 16808 16798 -10
+ Partials 3230 3227 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ChrisJBurns
approved these changes
May 19, 2026
1 task
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
pkg/transport/sessioncarried its own Redis connection layer (RedisConfig,SentinelConfig,RedisTLSConfig,validateRedisConfig,buildRedisClient,buildRedisTLSConfig, timeout default constants) that duplicated what toolhive-core v0.0.21 ships. PR #5318 migrated the auth server onto the shared package; vmcp session storage and the proxy-runner session storage are the remaining in-repo consumers, so this PR finishes that migration.RedisConfig/SentinelConfig/RedisTLSConfigtypes and thevalidate*/build*helpers withtcredis.Configandtcredis.NewClient.NewRedisStorageandNewRedisSessionDataStoragenow take(ctx, tcredis.Config, keyPrefix, ttl); they keep the session-specific invariants (key prefix required, must end with:,ttl > 0) and delegate connection-mode validation, timeout defaults, TLS plumbing, and Ping verification to the shared package.NewManagerWithRedisgains the samekeyPrefixparameter so the wrapper matches the underlying storage signature. The vmcp server and proxy runner call sites build atcredis.Configin place and passkeyPrefixseparately;RedisPasswordEnvVarstays in the session package becausepkg/runnerreads it.TestValidateRedisConfigis removed (topology checks now live in tcredis) and replaced byTestNewRedisStorageInvariants, which covers the session-specific cases (key prefix and ttl).TestNewRedisStorageACLAuthis preserved with the new signature. The "invalid TLS CA cert" manager subtest is dropped — it now exercises tcredis code.Net result: -298 / +165 lines across 9 files; one source of Redis-connection truth shared with the auth server.
Type of change
Test plan
go test ./pkg/transport/session/... ./pkg/vmcp/server/... ./pkg/vmcp/server/sessionmanager/... ./pkg/runner/retriever/...— all pass.golangci-linton the changed packages reports 0 issues.pkg/runner'sTestRunConfigBuilder_MetadataOverridesfailure reproduces onmainwithout this diff, so it is pre-existing and unrelated.🤖 Generated with Claude Code