Skip to content

Commit 85ea094

Browse files
authored
chore(redis): require Redis and remove the no-Redis fallbacks (#10272)
* chore(redis): require Redis and remove the configuration fallbacks * chore(redis): remove the remaining no-Redis paths across the app, realtime, setup and deploy config * fix(redis): resolve rate-limit storage lazily and address review findings * improvement(redis): address review threads and simplify the leftovers of the fallback removal * fix(redis): keep unit tests off a real Redis and update integration tests for lazy channels * chore(redis): drop stale fallback references after rebasing
1 parent 6787693 commit 85ea094

281 files changed

Lines changed: 3435 additions & 6148 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/rules/sim-testing.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ contracts, and demonstrated regressions.
3434
| Suffix | Needs | Run with | In CI |
3535
|--------|-------|----------|-------|
3636
| `*.test.ts(x)` | nothing; global mocks from `vitest.setup.ts` | `bun run --cwd <workspace> test` | `test` jobs |
37-
| `*.integration.ts` | real PostgreSQL (`TEST_DATABASE_URL`), Redis (`TEST_REDIS_URL`; optional locally, required in CI) | `bun run --cwd <workspace> test --mode integration` | `integration` jobs, by glob (sharded per provisioning path) |
37+
| `*.integration.ts` | real PostgreSQL (`TEST_DATABASE_URL`) and Redis (`TEST_REDIS_URL`: required by `apps/sim` and `apps/realtime`; `packages/db` runs without it locally and requires it in CI) | `bun run --cwd <workspace> test --mode integration` | `integration` jobs, by glob (sharded per provisioning path) |
3838
| `*.live.test.ts` | provider APIs, hosted sandboxes, local runtimes, or sibling checkouts | `bun run --cwd apps/sim test --mode live <file>` | never |
3939
| `apps/desktop/e2e/*.spec.ts` | the packaged Electron app | Playwright | desktop E2E workflow |
4040
| `apps/sim/scripts/test-*-e2e.ts` | a running app over HTTP | its `package.json` script when one exists (`bun run test:scim:e2e`; `test:workflow-version-compare:e2e` adds `--no-env-file`), else `bun scripts/test-<suite>-e2e.ts` from apps/sim | `e2e` jobs (`.github/scripts/http-e2e.sh`) |
@@ -46,7 +46,10 @@ contracts, and demonstrated regressions.
4646
`vi.mock` in the file.
4747
- `TEST_DATABASE_URL` must be loopback and its database name must contain a `test` segment
4848
(`sim_test`); `TEST_REDIS_URL` must be loopback. `packages/db/testing/test-infrastructure.ts` owns
49-
those checks. Isolate with a unique schema or generated IDs, and clean up in `afterAll`.
49+
those checks. `apps/sim` integration setup runs `FLUSHDB` before every file, so its
50+
`TEST_REDIS_URL` must also select a non-zero database (`redis://127.0.0.1:6379/15`); never
51+
point it at a Redis holding data you want to keep. Isolate with a unique schema or generated
52+
IDs, and clean up in `afterAll`.
5053
- Integration files run one at a time against one shared database. A new `*.integration.ts` is
5154
picked up by CI with no workflow change, and the run writes the JSON report configured in
5255
`vitest.shared.ts`, which CI uploads. Never exclude a failing suite from the run in

‎.cursor/rules/sim-testing.mdc‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ contracts, and demonstrated regressions.
3131
| Suffix | Needs | Run with | In CI |
3232
|--------|-------|----------|-------|
3333
| `*.test.ts(x)` | nothing; global mocks from `vitest.setup.ts` | `bun run --cwd <workspace> test` | `test` jobs |
34-
| `*.integration.ts` | real PostgreSQL (`TEST_DATABASE_URL`), Redis (`TEST_REDIS_URL`; optional locally, required in CI) | `bun run --cwd <workspace> test --mode integration` | `integration` jobs, by glob (sharded per provisioning path) |
34+
| `*.integration.ts` | real PostgreSQL (`TEST_DATABASE_URL`) and Redis (`TEST_REDIS_URL`: required by `apps/sim` and `apps/realtime`; `packages/db` runs without it locally and requires it in CI) | `bun run --cwd <workspace> test --mode integration` | `integration` jobs, by glob (sharded per provisioning path) |
3535
| `*.live.test.ts` | provider APIs, hosted sandboxes, local runtimes, or sibling checkouts | `bun run --cwd apps/sim test --mode live <file>` | never |
3636
| `apps/desktop/e2e/*.spec.ts` | the packaged Electron app | Playwright | desktop E2E workflow |
3737
| `apps/sim/scripts/test-*-e2e.ts` | a running app over HTTP | its `package.json` script when one exists (`bun run test:scim:e2e`; `test:workflow-version-compare:e2e` adds `--no-env-file`), else `bun scripts/test-<suite>-e2e.ts` from apps/sim | `e2e` jobs (`.github/scripts/http-e2e.sh`) |
@@ -43,7 +43,10 @@ contracts, and demonstrated regressions.
4343
`vi.mock` in the file.
4444
- `TEST_DATABASE_URL` must be loopback and its database name must contain a `test` segment
4545
(`sim_test`); `TEST_REDIS_URL` must be loopback. `packages/db/testing/test-infrastructure.ts` owns
46-
those checks. Isolate with a unique schema or generated IDs, and clean up in `afterAll`.
46+
those checks. `apps/sim` integration setup runs `FLUSHDB` before every file, so its
47+
`TEST_REDIS_URL` must also select a non-zero database (`redis://127.0.0.1:6379/15`); never
48+
point it at a Redis holding data you want to keep. Isolate with a unique schema or generated
49+
IDs, and clean up in `afterAll`.
4750
- Integration files run one at a time against one shared database. A new `*.integration.ts` is
4851
picked up by CI with no workflow change, and the run writes the JSON report configured in
4952
`vitest.shared.ts`, which CI uploads. Never exclude a failing suite from the run in

‎.github/scripts/http-e2e.sh‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#
66
# Usage: http-e2e.sh <scim|cli|stop-after|desktop-inbox|assistant-actions|organization-search|search-permissions|browser-extension|browser-extension-native|browser-extension-navigation|browser-extension-composer|browser-extension-access|project-files|markdown-viewer|workflow-code-ui|mobile|seo> (run from apps/sim)
77
#
8-
# The job provides DATABASE_URL, BETTER_AUTH_SECRET and ENCRYPTION_KEY; each group sets the rest of
8+
# The job provides DATABASE_URL, BETTER_AUTH_SECRET, ENCRYPTION_KEY and a Redis on 127.0.0.1:6379
9+
# (Redis is required, so every app and realtime server gets REDIS_URL); each group sets the rest of
910
# its app's environment here. Reports and server logs land in $RUNNER_TEMP/e2e.
1011
#
1112
# Under `next dev` the first request cold-compiles the app under Turbopack, which takes 60-185s on
@@ -23,6 +24,7 @@ set -euo pipefail
2324
group=${1:?usage: http-e2e.sh <scim|cli|stop-after|desktop-inbox|assistant-actions|organization-search|search-permissions|browser-extension|browser-extension-native|browser-extension-navigation|browser-extension-composer|browser-extension-access|project-files|markdown-viewer|workflow-code-ui|mobile|seo>}
2425
report_dir="$RUNNER_TEMP/e2e"
2526
ready_timeout_seconds=600
27+
export REDIS_URL=${REDIS_URL:-redis://127.0.0.1:6379}
2628
mkdir -p "$report_dir"
2729

2830
server_pid=''
@@ -204,6 +206,7 @@ case "$group" in
204206
export PEOPLE_E2E_SCREENSHOT_DIR="$report_dir/people-ui-report.json.artifacts"
205207
SCIM_E2E_BASE_URL="$local_app_url" \
206208
SCIM_E2E_DATABASE_URL="$DATABASE_URL" \
209+
SCIM_E2E_REDIS_URL="$REDIS_URL" \
207210
SCIM_E2E_AUTH_SECRET="$BETTER_AUTH_SECRET" \
208211
SCIM_E2E_REPORT_PATH="$report_dir/scim-e2e-report.json" \
209212
bun run test:scim:e2e
@@ -238,8 +241,7 @@ case "$group" in
238241
;;
239242

240243
# The search suites serve their own fixtures in-process and need no app. They share this group
241-
# because they finish in seconds. Self-hosted without billing: hosted billing admits runs through
242-
# Redis, which the CLI app is not given.
244+
# because they finish in seconds. Self-hosted, so runs are not admitted through hosted billing.
243245
cli)
244246
for search in google-content lucid zoom google-meet; do
245247
report_var="SEARCH_$(echo "$search" | tr 'a-z-' 'A-Z_')_REPORT_PATH"
@@ -262,7 +264,7 @@ case "$group" in
262264
bun run test:cli-run-latency:e2e
263265
;;
264266

265-
# Self-hosted: hosted billing admits a run only through a Redis usage reservation.
267+
# Self-hosted, so runs are not admitted through hosted billing's usage reservation.
266268
stop-after)
267269
export NEXT_PUBLIC_FORCE_HOSTED=false
268270
export CRON_SECRET=stop-after-e2e-local-cron-secret
@@ -278,7 +280,6 @@ case "$group" in
278280
;;
279281

280282
desktop-inbox|assistant-actions|organization-search|search-permissions)
281-
export REDIS_URL=redis://127.0.0.1:6379
282283
export NEXT_PUBLIC_FORCE_HOSTED=false
283284
export COPILOT_TOOL_PERMISSIONS_ENABLED=true
284285
export KNOWLEDGE_MEMBER_ACCESS=true CREDENTIAL_GROUPS=true ACCESS_CONTROL_ENABLED=true
@@ -330,7 +331,6 @@ case "$group" in
330331
browser-extension-composer) extension_group=composer ;;
331332
browser-extension-access) extension_group=access ;;
332333
esac
333-
export REDIS_URL=redis://127.0.0.1:6379
334334
export NEXT_PUBLIC_FORCE_HOSTED=false
335335
export KNOWLEDGE_MEMBER_ACCESS=true CREDENTIAL_GROUPS=true ACCESS_CONTROL_ENABLED=true
336336
export SIM_LINKS=true
@@ -358,7 +358,7 @@ JS
358358

359359
project-files)
360360
PROJECT_FILES_E2E_ADMIN_DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:5432/postgres \
361-
PROJECT_FILES_E2E_REDIS_URL=redis://127.0.0.1:6379 \
361+
PROJECT_FILES_E2E_REDIS_URL="$REDIS_URL" \
362362
PROJECT_FILES_E2E_BASE_URL=http://127.0.0.1:3050 \
363363
PROJECT_FILES_E2E_RELAY_URL=http://127.0.0.1:3052 \
364364
PROJECT_FILES_E2E_REPORT_PATH="$report_dir/project-files/orchestration.json" \

‎.github/workflows/checks.yml‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ jobs:
122122
--health-retries 10
123123
env:
124124
TEST_DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:5432/sim_test
125-
TEST_REDIS_URL: redis://127.0.0.1:6379
125+
TEST_REDIS_URL: redis://127.0.0.1:6379/15
126126
DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:5432/sim_test
127127
BETTER_AUTH_SECRET: oauth-postgres-ci-secret-at-least-32-characters
128128
NEXT_PUBLIC_APP_URL: https://test.sim.ai
@@ -236,9 +236,9 @@ jobs:
236236
--health-interval 5s
237237
--health-timeout 5s
238238
--health-retries 10
239-
# Desktop inbox, browser extension, and Project Files use Redis.
239+
# Redis is required: every app server the suites start connects to it.
240240
redis:
241-
image: ${{ (matrix.group == 'desktop-inbox' || matrix.group == 'assistant-actions' || matrix.group == 'organization-search' || matrix.group == 'search-permissions' || startsWith(matrix.group, 'browser-extension-') || matrix.group == 'project-files') && 'redis:8.2-alpine' || '' }}
241+
image: redis:8.2-alpine
242242
ports:
243243
- 6379:6379
244244
options: >-
@@ -408,6 +408,16 @@ jobs:
408408
--health-interval 5s
409409
--health-timeout 5s
410410
--health-retries 10
411+
# Redis is required: the app server refuses to start without it.
412+
redis:
413+
image: redis:8.2-alpine
414+
ports:
415+
- 6379:6379
416+
options: >-
417+
--health-cmd "redis-cli ping"
418+
--health-interval 5s
419+
--health-timeout 5s
420+
--health-retries 10
411421
env:
412422
DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:5432/sim_test
413423
BETTER_AUTH_SECRET: http-e2e-ci-secret-at-least-32-characters

‎.github/workflows/docs-negotiation.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,17 @@ jobs:
334334
--health-interval 5s
335335
--health-timeout 5s
336336
--health-retries 10
337+
# The platform consumer runs the app's docs search in-process, and its provider admission
338+
# needs Redis.
339+
search-redis:
340+
image: ${{ (matrix.group == 'http' || matrix.group == 'platform') && 'redis:8.2-alpine' || '' }}
341+
ports:
342+
- 6379:6379
343+
options: >-
344+
--health-cmd "redis-cli ping"
345+
--health-interval 5s
346+
--health-timeout 5s
347+
--health-retries 10
337348
env:
338349
DATABASE_URL: postgresql://docs_test:docs_test@127.0.0.1:1/docs_test
339350
DOCS_E2E_BASE_URL: http://127.0.0.1:3001
@@ -348,6 +359,7 @@ jobs:
348359
DOCS_SAMPLES_SYNTAX_LANGUAGES: javascript,python,bash,go,java,csharp
349360
DOCS_SAMPLES_HTTP_BASE_URL: http://127.0.0.1:3001
350361
DOCS_PROVIDER_E2E_DATABASE_URL: postgresql://docs_test:docs_test@127.0.0.1:5432/docs_search_test
362+
DOCS_PROVIDER_E2E_REDIS_URL: redis://127.0.0.1:6379
351363
DOCS_PROVIDER_E2E_BASE_URL: http://127.0.0.1:3001
352364
DOCS_PROVIDER_E2E_REPORT_PATH: ${{ github.workspace }}/apps/docs/test-results/platform-consumer/report.json
353365
steps:

‎README.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ npx sim-setup add email
112112
npx sim-setup add storage
113113
npx sim-setup add sandbox
114114
npx sim-setup add jobs
115-
npx sim-setup add cache
116115
npx sim-setup add knowledge
117116
npx sim-setup add chat
118117
npx sim-setup add llm

‎apps/desktop/e2e/desktop-tools-live-sim.spec.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ import {
3030
* what the user or the model would observe: the result the model is resumed with, what landed in
3131
* the workspace, what Sim persisted, and which requests reached Sim.
3232
*
33-
* Sim runs the background executor wherever it has Redis, as it does here. Most tests cover the
34-
* chat view running desktop tools itself, as on an install without Redis: the proxy answers the
35-
* app's registration as such an install does, so the app stays dormant and no turn binds to it.
33+
* Sim runs the background executor for a registered desktop app, as it does here. Most tests cover
34+
* the chat view running desktop tools itself: the proxy answers the app's registration with the
35+
* executor off (as servers predating required Redis did), so the app stays dormant and no turn
36+
* binds to it.
3637
* The tests marked as running in the background let Sim's own answer through.
3738
*/
3839

‎apps/docs/MACHINE_ACCESS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The suite exercises real HTTP and the official MCP client, including discovery p
7979

8080
The PostgreSQL suite uses a new, empty, loopback database and no embedding key. It verifies real keyword search, citation freshness, graceful database failure, repeated index publication, retirement and failed-publication preservation. It refuses databases containing existing tables. CI provisions its own `pgvector/pgvector:pg17` service and uploads the report with the other docs checks.
8181

82-
The platform consumer harness also uses an empty loopback database and the running docs build. From `apps/sim`, run `bun --no-env-file scripts/test-docs-search-provider-e2e.ts` with `DOCS_PROVIDER_E2E_DATABASE_URL`, `DOCS_PROVIDER_E2E_BASE_URL` and `DOCS_PROVIDER_E2E_REPORT_PATH`. Its default mode uses the existing Azure endpoint configuration with a local HTTP fixture, deterministic vectors and the real PostgreSQL provider-admission store. It verifies the platform's direct-table search, scope exclusions, VFS reads and public citations, with no paid requests. This verifies the transport and consumer contract, not semantic relevance.
82+
The platform consumer harness also uses an empty loopback database and the running docs build. From `apps/sim`, run `bun --no-env-file scripts/test-docs-search-provider-e2e.ts` with `DOCS_PROVIDER_E2E_DATABASE_URL`, `DOCS_PROVIDER_E2E_REDIS_URL` (a loopback Redis), `DOCS_PROVIDER_E2E_BASE_URL` and `DOCS_PROVIDER_E2E_REPORT_PATH`. Its default mode uses the existing Azure endpoint configuration with a local HTTP fixture, deterministic vectors and the real Redis provider-admission store. It verifies the platform's direct-table search, scope exclusions, VFS reads and public citations, with no paid requests. This verifies the transport and consumer contract, not semantic relevance.
8383

8484
Live provider verification is opt-in: set `DOCS_PROVIDER_E2E_ALLOW_LIVE=1` and supply `OPENAI_API_KEY`, using a fresh database named `docs_search_provider_test`. The harness limits publication to the introduction page, rejects plans above 15 chunks, and sends at most one batch with up to three attempts. The consumer makes at most one query embedding request, for a total cap of four provider requests. Provider failure stops the run and remains a failed report. The default fixture mode also accepts the empty `docs_search_test` database used by the PostgreSQL suite. Both modes remove their tables when finished.
8585

‎apps/docs/content/docs/platform/self-hosting/architecture.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Sim runs an app, a realtime server, PostgreSQL, Redis, and a scheduler. This pag
1515
| **realtime** | `ghcr.io/simstudioai/realtime` | 3002 | In-flight collaboration state | Yes |
1616
| **migrations** | `ghcr.io/simstudioai/migrations` | — | One-shot schema and data migrations | Yes |
1717
| **postgresql** | `pgvector/pgvector:pg17` | 5432 | Durable application data | Yes |
18-
| **redis** | `redis:7-alpine` | 6379 | Cache, coordination, and live events | Bundled by default; required across replicas |
18+
| **redis** | `redis:7-alpine` | 6379 | Rate limits, coordination, and live events | Yes (bundled by default) |
1919
| **cron** | `ghcr.io/simstudioai/cron` (Compose) / `curlimages/curl` (Kubernetes) | — | None | Required for scheduled work |
2020
| **pii** | `ghcr.io/simstudioai/pii` | 5001 | None | Optional |
2121
| **ollama** | `ollama/ollama` | 11434 | Model cache | Optional |
@@ -36,7 +36,7 @@ The Bun Socket.IO server carries collaborative editing, live execution updates,
3636
Realtime shares PostgreSQL and `BETTER_AUTH_SECRET` with the app, using Better Auth's shared-database-session pattern. It authenticates the same accounts without a separate login.
3737

3838
<Callout type="warn">
39-
More than one realtime replica requires `REDIS_URL`. The Socket.IO Redis adapter carries events between replicas; without it, members connected to different pods do not see each other's edits.
39+
Realtime requires `REDIS_URL`, pointing at the same Redis as the app. The Socket.IO Redis adapter carries events between replicas, so members connected to different pods see each other's edits.
4040
</Callout>
4141

4242
A realtime server must exist for editing and live updates. Set `realtime.enabled: false` in Helm only when `app.env.SOCKET_SERVER_URL` points to a realtime instance you run separately.
@@ -55,7 +55,7 @@ PostgreSQL holds workflows, runs, logs, accounts, organizations, credentials, kn
5555

5656
### Redis
5757

58-
Redis carries live events and stores shared coordination state. Some stores fall back to PostgreSQL or process-local state, but cross-pod collaboration has no local fallback. CLI API-key pairing also requires Redis, even with one replica; OAuth login uses a separate path. See [Redis](/platform/self-hosting/redis) for the full fallback matrix.
58+
Redis is required, even with one replica. It holds rate-limit buckets, one-time passcodes, and shared coordination state, and carries live events between processes. There is no PostgreSQL or process-local fallback, and the app refuses to start without `REDIS_URL`. See [Redis](/platform/self-hosting/redis) for everything it backs.
5959

6060
### Scheduler
6161

‎apps/docs/content/docs/platform/self-hosting/docker.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ curl -fsS http://localhost:3000/api/health
8989
| `simstudio` | 3000 | App; 8G memory limit. |
9090
| `realtime` | 3002 | WebSocket service; 1G memory limit. |
9191
| `db` | Not published | PostgreSQL 17 with pgvector. |
92-
| `redis` | Not published | Shared coordination, pub/sub, and caches. |
92+
| `redis` | Not published | Required. Rate limits, shared coordination, pub/sub, and caches. |
9393
| `cron` | None | Calls background job endpoints. |
9494
| `migrations` | None | Applies migrations once, then exits. |
9595

@@ -238,14 +238,14 @@ Invoke commands as `bunx sim-setup <command>` unless the package is installed gl
238238
| `reset` | Confirms before archiving env files and removing managed Compose/dev data. On Helm it uninstalls the release; PostgreSQL StatefulSet PVCs remain and must be deleted separately to erase data. |
239239
| `config` | Reports configured capabilities and integrations. |
240240
| `doctor` | Checks env files and reachable services. `--fix` writes supported repairs; `--json` emits structured findings. |
241-
| `add <feature>` | Configures `email`, `storage`, `sandbox`, `jobs`, `cache`, `knowledge`, `knowledge-embeddings`, `chat`, `llm`, or `integration <slug>`. Requires one writable configuration; refuses ambiguous destinations and Helm releases. |
241+
| `add <feature>` | Configures `email`, `storage`, `sandbox`, `jobs`, `knowledge`, `knowledge-embeddings`, `chat`, `llm`, or `integration <slug>`. Requires one writable configuration; refuses ambiguous destinations and Helm releases. |
242242
| `desktop` | Prints this deployment's installer/server links. `--url <url>` skips discovery; `--no-open` skips the browser-opening prompt. |
243243

244244
`--dir <path>` works with every command and scopes standalone lifecycle commands to that installation.
245245

246246
For Compose, `reset` archives `.env` beside the Compose file. For dev, Kubernetes, or no detected install, it archives `apps/sim/.env`, `apps/realtime/.env`, `packages/db/.env`, and root `.env`. Preserve any backups before intentionally removing volumes.
247247

248-
`add` writes beside the Compose file or to `apps/sim/.env` on a source checkout. Recreate containers that read the change: `cache` changes `REDIS_URL` for both app and realtime. For a source checkout, mirror shared values into `apps/realtime/.env`. `restart` alone does not apply changed container environment. Desktop discovery refuses configurations naming different origins; pass `--url` to choose.
248+
`add` writes beside the Compose file or to `apps/sim/.env` on a source checkout. Recreate containers that read the change. To point both app and realtime at a different Redis, set `REDIS_URL` in `.env` and recreate both containers. For a source checkout, mirror shared values into `apps/realtime/.env`. `restart` alone does not apply changed container environment. Desktop discovery refuses configurations naming different origins; pass `--url` to choose.
249249

250250
## Back up and update [#commands]
251251

0 commit comments

Comments
 (0)