Skip to content

refactor(search): split the session store into Redis and in-memory stores - #3896

Merged
Quick104 merged 1 commit into
mainfrom
refactor/search-session-store-split
Nov 9, 2026
Merged

Quick104 merged 1 commit into
mainfrom
refactor/search-session-store-split

Conversation

@Quick104

@Quick104 Quick104 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #3699
Validation tasks: none (search continuation paths behind #1143 C2 and #1144 C3 run this code; behavior is unchanged)

After #3699, searchSessionStore in internal/catalog/search_session.go holds both a Redis client and a mutex-guarded in-memory map, and put and get choose the backend by checking whether the client is nil. This PR splits the two backends into separate types. It is a refactor with no behavior change.

Approach

searchSessionStore is now an unexported interface with put and get, implemented by two types:

  • redisSearchSessionStore: the existing Lua script path, unchanged.
  • memorySearchSessionStore: the existing map, cross-account expiry sweep, and earliest-expiry eviction, unchanged.

Session ID generation (24 random bytes, hex) and the ID-format check that returns invalid_cursor are shared helpers that both stores call. NewMeilisearchSearchProvider still installs the in-memory store, and CatalogSearchService.WithSearchSessionStore still swaps in the Redis store when the router has a Redis client.

A nil *searchSessionStore used to return ErrSearchContinuationUnavailable. A nil interface would panic instead, so the Meilisearch cursor path now checks for a missing store before each call and returns the same error. Production always installs a store; tests that build the provider directly rely on this.

Validation

  • Build, go vet, and make lint-changed: clean.
  • go test ./internal/catalog/ ./internal/api/: pass, including the existing in-memory store test, which now runs against memorySearchSessionStore.
  • The Redis store has no test in the repository, because CI has no Redis. A scratch test against an in-process Redis checked eviction at 16 sessions, account isolation, malformed IDs, the 15-minute TTL, expiry, and ErrSearchContinuationUnavailable wrapping for an unreachable server. It passed. The test is not committed, because it would add a dependency to check code this PR only moves.

Evidence

No user-visible change. The page below records the checks.

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3896/

Risks

None identified. Session keys, TTL, eviction, and error codes are unchanged, so continuation cursors issued before a deploy keep working after it.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code in T3 Code, /silo skill
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: low-level code review (a single pass over the diff). It found that a nil store would now panic instead of returning ErrSearchContinuationUnavailable; fixed with the guards described above. A simplify pass ran and changed nothing. The plan round was skipped because the requester specified the design. The background adversarial review was skipped because the PR changes no behavior.

🤖 Generated with Claude Code

Note

Split search session store into redisSearchSessionStore and memorySearchSessionStore

Replaces the combined session store struct with a searchSessionStore interface and two concrete implementations in search_session.go. The Redis and in-memory put/get paths are moved into their respective types, sharing new helpers newSearchSessionID and validSearchSessionID plus the searchSessionIDBytes constant.

  • The provider's session-store field now uses the interface; NewMeilisearchSearchProvider defaults to the in-memory store, and WithSearchSessionStore configures the Redis store (search_meilisearch_provider.go, search_service.go).
  • searchCursorPage now checks for a missing session store before both session get and put, returning the continuation-unavailable error.
  • Tests instantiate the concrete in-memory store; pruning, expiry, and eviction behavior is unchanged.

Macroscope summarized c6121ae.

@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 9, 2026
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 136a4e45-9208-4c72-8a33-c6c7f13b727f
Commits

Reviewing files that changed from the base of the PR and between 5f6223e and c6121ae.

Files selected for processing: 5

  • internal/catalog/search_meilisearch_cursor.go
  • internal/catalog/search_meilisearch_provider.go
  • internal/catalog/search_service.go
  • internal/catalog/search_session.go
  • internal/catalog/search_session_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-kody

silo-kody Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T18:22:33.921084Z c6121ae New commits
🔒 Security Review ✅ Completed 2026-11-09T18:25:01.021038Z c6121ae New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-triage silo-triage Bot added go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish triaged High-confidence review completed; does not mean fixed, validated, or accepted for release. labels Nov 9, 2026
…ores

searchSessionStore held a Redis client and an in-memory map and branched on
a nil client in put and get. Make it an interface with two implementations:
redisSearchSessionStore (the Lua script path, unchanged) and
memorySearchSessionStore (the map, sweep, and eviction, unchanged). Session
ID generation and the ID-format check are shared helpers.

The provider used to get ErrSearchContinuationUnavailable from a nil store
pointer; the Meilisearch cursor path now checks for a nil store before each
call so a provider built without one still returns that error.

No behavior change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 force-pushed the refactor/search-session-store-split branch from f2bd9ae to c6121ae Compare November 9, 2026 18:21
@silo-kody

silo-kody Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit 35c3634 into main Nov 9, 2026
23 of 24 checks passed
@Quick104
Quick104 deleted the refactor/search-session-store-split branch November 9, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority. triaged High-confidence review completed; does not mean fixed, validated, or accepted for release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant