Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ LLMVAULT_SOLUTION_KEY=
# recoverable from the public source. If set, run: python -m tools.sealtool reseal-flags
# and keep this exported at runtime.
# LLMVAULT_PEPPER=

# Off by default. Opt in to Flask debug mode (the Werkzeug debugger runs arbitrary
# code) on a trusted, local machine only.
# LLMVAULT_DEBUG=1
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ python app.py
# open http://127.0.0.1:5000
```

Flask debug mode is **off by default** (the Werkzeug debugger runs arbitrary code). Only on a
trusted, local machine, opt in with `LLMVAULT_DEBUG=1 python app.py` (`true` also works).

No API key needed, ever. Play Mode's assistants are **scripted**, so flags reproduce reliably and
the whole range runs offline. Live Mode adds a real model, but it runs on your machine too — see
[Live Mode](#-live-mode--a-real-model-no-script) below. Nothing in LLMVault calls a hosted API.
Expand Down
13 changes: 11 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,16 @@ def scoreboard():
return render_template("scoreboard.html", rows=rows, total=TOTAL_LABS)


if __name__ == "__main__":
def main() -> None:
"""Start the local development server.

Debug mode is opt-in via LLMVAULT_DEBUG (see config.DEBUG): the Werkzeug
debugger executes arbitrary code, so it must stay off by default.
"""
if getattr(config, "LIVE_MODE_ENABLED", False):
print(model_registry.startup_banner())
app.run(host="127.0.0.1", port=5000, debug=True)
app.run(host="127.0.0.1", port=5000, debug=config.DEBUG)


if __name__ == "__main__":
main()
12 changes: 12 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,15 @@
# policy before adversarial testing — that obligation sits with the key holder.
OPENAI_API_KEY = _os.environ.get("OPENAI_API_KEY")
OPENAI_MODELS = ["gpt-4o-mini"]


# --- Debug mode --------------------------------------------------------------
# Flask's debug mode enables the Werkzeug interactive debugger, which runs
# arbitrary Python for anyone who can reach the server. It is therefore OFF
# unless the operator explicitly opts in: set LLMVAULT_DEBUG=1 (or true).
def debug_enabled(environ=None) -> bool:
env = _os.environ if environ is None else environ
return env.get("LLMVAULT_DEBUG", "").strip().lower() in ("1", "true")


DEBUG = debug_enabled()
25 changes: 25 additions & 0 deletions tests/test_debug_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Debug mode comes from LLMVAULT_DEBUG and must stay off unless opted in."""
import os
import sys

import pytest

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import config # noqa: E402
import app as server # noqa: E402


@pytest.mark.parametrize("value,expected", [(None, False), ("1", True), ("true", True), ("0", False)])
def test_debug_enabled(value, expected):
env = {} if value is None else {"LLMVAULT_DEBUG": value}
assert config.debug_enabled(env) is expected


@pytest.mark.parametrize("debug", [True, False])
def test_main_forwards_debug_to_app_run(monkeypatch, debug):
monkeypatch.setattr(server.config, "LIVE_MODE_ENABLED", False)
monkeypatch.setattr(server.config, "DEBUG", debug)
captured = {}
monkeypatch.setattr(server.app, "run", lambda **kw: captured.update(kw))
server.main()
assert captured["debug"] is debug