Skip to content

Rename demo master-switch env var: DEMO_MODE → DEMO#7

Merged
Ho1yShif merged 1 commit into
mainfrom
fix/rename-demo-env-var
Jul 14, 2026
Merged

Rename demo master-switch env var: DEMO_MODE → DEMO#7
Ho1yShif merged 1 commit into
mainfrom
fix/rename-demo-env-var

Conversation

@Ho1yShif

Copy link
Copy Markdown
Collaborator

Why

The demo master switch (the flag that turns on per-IP rate limiting + per-visitor ephemeral chat history for a public demo) is now spelled DEMO instead of DEMO_MODE, adopting DEMO as the convention.

Context: the public demo's Render env var was set as DEMO, but the code read DEMO_MODE, so demo mode silently stayed off (shared, disk-persisted history across visitors). Rather than keep the longer name, we standardize on DEMO.

What changed

  • deeptutor/services/demo/rate_limiter.py — limiter now reads os.environ["DEMO"] (the one behavior change).
  • render.yaml, README.md, .env.example — documented env var name.
  • Docstrings/comments in main.py, routers/auth.py, routers/unified_ws.py, routers/chat.py, and web/lib/demo-visitor.ts.
  • Demo test suite updated to set DEMO.

Left unchanged on purpose: DEMO_RATE_LIMIT_PER_MIN / DEMO_RATE_LIMIT_PER_HOUR (separate, descriptive tuning knobs) and the is_demo_mode() function name.

⚠️ Breaking change

Deployments that set DEMO_MODE must switch the env var to DEMO. The flag is off by default, so local/private forks are unaffected. The public demo service (srv-d9a693…) already has DEMO set, so this rename makes the running code match that key.

Verification

DEMO=true       -> is_demo_mode() == True
DEMO unset      -> is_demo_mode() == False
DEMO_MODE=true  -> is_demo_mode() == False   # old key no longer honored (expected)
  • Demo test suite: pytest tests/services/demo tests/api/test_demo_visitor_isolation.py42 passed.
  • pre-commit on all changed files: ruff, ruff-format, prettier, mypy, bandit, check-yaml, detect-secrets → all pass.

After merge

Deploy, then confirm isolation is live (fresh visitor ids must return an empty session list):

BASE=https://deeptutor-t1z4.onrender.com
curl -s -H "X-Demo-Visitor: probe-$(date +%s)a" "$BASE/api/v1/sessions?limit=5"
curl -s -H "X-Demo-Visitor: probe-$(date +%s)b" "$BASE/api/v1/sessions?limit=5"

🤖 Generated with Claude Code

Adopt DEMO as the convention for the demo master switch (the flag that enables
per-IP rate limiting + per-visitor ephemeral chat history on a public demo).
The limiter now reads os.environ["DEMO"]; DEMO_RATE_LIMIT_PER_MIN/HOUR keep
their names, and the is_demo_mode() function name is unchanged.

Updated the env var name everywhere it appears: rate_limiter.py, render.yaml,
README, .env.example, docstrings/comments across the API routers and main.py,
the frontend comment, and the demo test suite.

BREAKING: deployments that set DEMO_MODE must switch to DEMO. The flag is
off by default, so private/local forks are unaffected.

Verified: DEMO=true -> is_demo_mode() True; DEMO unset -> False; the old
DEMO_MODE key is no longer honored. Demo test suite (42 tests) passes; ruff,
ruff-format, prettier, mypy, bandit all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Ho1yShif Ho1yShif merged commit 4c95e73 into main Jul 14, 2026
11 checks passed
@Ho1yShif Ho1yShif deleted the fix/rename-demo-env-var branch July 14, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant