plans/2026-05-06-redis-dependency-strategy.md
Date: 2026-05-06
Make BullMQ the queue engine, but do not treat Redis like a user-managed global service. Treat it like part of claude-mem's runtime.
Best fit for the "auto-install / it just works" product energy:
In settings and docs, call the capability redis-compatible queue store, but keep env names familiar:
CLAUDE_MEM_QUEUE_ENGINE=bullmq
CLAUDE_MEM_REDIS_MODE=managed|external|docker
CLAUDE_MEM_REDIS_URL=redis://127.0.0.1:<allocated-port>
Valkey is a Redis-compatible fork under the Linux Foundation ecosystem, has current releases, Homebrew/package-manager install paths, Docker images, and Linux binary artifacts. It also gives claude-mem a cleaner dependency story for a managed local queue store.
Redis itself is still viable. Redis Open Source 8 has changed licensing over time, while Valkey keeps the local managed dependency straightforward for "we run a Redis-compatible queue store locally."
BullMQ's own docs say BullMQ is Redis-compliant with Redis 6.2+ but warns that not all Redis alternatives work properly. So this needs CI coverage. Dragonfly is officially called out by BullMQ as a supported/tested Redis-compatible alternative, but Dragonfly's own local install path is Docker-first, which is heavier than Valkey for claude-mem's installer.
Probe for external config:
CLAUDE_MEM_REDIS_URL exists, test PING, INFO, BullMQ Lua/script compatibility, and maxmemory-policy.Probe for local compatible binaries:
valkey-serverredis-server/opt/homebrew/bin, /usr/local/bin/usr/bin, /usr/local/binIf a binary exists, create claude-mem's own config and data dir:
~/.claude-mem/redis/redis.conf~/.claude-mem/redis/data/~/.claude-mem/redis/redis.pid~/.claude-mem/logs/redis-YYYY-MM-DD.logIf no binary exists:
valkey with brew install valkey.valkey using apt/dnf/yum/apk/pacman when available.~/.claude-mem/bin/valkey/<version>/.Start the managed sidecar, then start the worker.
Default should not block on prompts:
CLAUDE_MEM_REDIS_URL works, use it.valkey-server or redis-server exists, manage it.--install-redis was passed, attempt platform install.Do not surprise-run sudo apt install or install Docker in non-interactive mode.
Use a private port, not global 6379.
Allocate and persist a queue-store port the same way claude-mem persists the worker port:
CLAUDE_MEM_REDIS_HOST=127.0.0.1
CLAUDE_MEM_REDIS_PORT=<free-port>
CLAUDE_MEM_REDIS_URL=redis://127.0.0.1:<free-port>
Suggested config:
bind 127.0.0.1 ::1
protected-mode yes
port <allocated-port>
dir ~/.claude-mem/redis/data
daemonize no
appendonly yes
appendfsync everysec
save 60 1
maxmemory-policy noeviction
BullMQ specifically requires maxmemory-policy=noeviction for correct queue behavior and recommends AOF persistence for production durability.
Do not use the user's global Redis config. Generate a claude-mem config so the queue store has the settings BullMQ needs.
Add RedisManager / QueueStoreManager alongside the worker supervisor:
ensureQueueStoreStarted()stopQueueStore()queueStoreStatus()PINGINFO serverCONFIG GET maxmemory-policyCONFIG GET appendonlyWorker startup sequence:
Shutdown sequence:
Avoid making the installer do this as the default:
brew services start redissystemctl enable redissystemctl start valkeyThose mutate the user's machine globally, conflict with existing Redis installs, require sudo/admin flows, and make uninstall messy.
The better UX is a private local sidecar owned by claude-mem. It starts when claude-mem starts, stores data in ~/.claude-mem, and is removed by npx claude-mem uninstall.
Best path:
brew install valkey.valkey-server directly with claude-mem's generated config.brew services.Redis official macOS install now uses brew tap redis/redis and brew install --cask redis, but Redis notes that this cask is not integrated with brew services. For claude-mem, that's fine because we should not rely on brew services anyway.
Best path:
apt install valkey; Ubuntu also has valkey-redis-compat for redis-* symlinks.~/.claude-mem/bin.Hardest platform.
Redis official docs say Windows Redis Open Source requires Docker, with Memurai as a Windows compatibility partner. Valkey docs say Windows is not officially supported and suggest WSL for development.
Pragmatic options:
valkey/valkey:<pinned> or redis:<pinned> with a named volume.CLAUDE_MEM_REDIS_URL or use temporary SQLite fallback until native Windows support is chosen.Do not auto-install Docker Desktop. It is too invasive for an "it just works" CLI installer.
Interactive:
Queue engine
BullMQ needs a local Redis-compatible queue store.
claude-mem can manage one for you under ~/.claude-mem.
[recommended] Manage local Valkey for me
Use existing Redis URL
Keep SQLite queue for now
Non-interactive:
npx claude-mem install --queue bullmq --install-redis
npx claude-mem install --queue bullmq --redis-url redis://127.0.0.1:6379
Status:
npx claude-mem status
Worker: running on 127.0.0.1:37777
Queue: BullMQ
Store: managed Valkey 9.0.3 on 127.0.0.1:39241
Persistence: AOF everysec
Policy: noeviction
Uninstall:
--purge-data.QueueStoreManager with process spawn, PID validation, port allocation, and probes.For claude-mem's desired UX, the winning approach is:
BullMQ + claude-mem-managed Valkey sidecar by default, external Redis URL as an escape hatch, SQLite as short-term fallback only.
This gives the speed and correctness of Redis/BullMQ without making users become Redis operators.