Rename demo master-switch env var: DEMO_MODE → DEMO#7
Merged
Conversation
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>
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.
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
DEMOinstead ofDEMO_MODE, adoptingDEMOas the convention.Context: the public demo's Render env var was set as
DEMO, but the code readDEMO_MODE, so demo mode silently stayed off (shared, disk-persisted history across visitors). Rather than keep the longer name, we standardize onDEMO.What changed
deeptutor/services/demo/rate_limiter.py— limiter now readsos.environ["DEMO"](the one behavior change).render.yaml,README.md,.env.example— documented env var name.main.py,routers/auth.py,routers/unified_ws.py,routers/chat.py, andweb/lib/demo-visitor.ts.DEMO.Left unchanged on purpose:
DEMO_RATE_LIMIT_PER_MIN/DEMO_RATE_LIMIT_PER_HOUR(separate, descriptive tuning knobs) and theis_demo_mode()function name.Deployments that set
DEMO_MODEmust switch the env var toDEMO. The flag is off by default, so local/private forks are unaffected. The public demo service (srv-d9a693…) already hasDEMOset, so this rename makes the running code match that key.Verification
pytest tests/services/demo tests/api/test_demo_visitor_isolation.py→ 42 passed.After merge
Deploy, then confirm isolation is live (fresh visitor ids must return an empty session list):
🤖 Generated with Claude Code