Repository navigation
Safer install defaults, database timeouts and a cap on model answers - #394
Merged
Merged
Conversation
… logging by default A new install wrote SIGNUP_MODE=open and published the web port on every interface, and the first account to sign up becomes the admin. On a VPS, whoever reached the address first owned the instance, and anyone after them got an approved account spending the operator's provider keys. The installers also turned on LLM_TRACE=logs, which writes every account's transcript excerpts into the logs and the issue-report zips. New installs now write SIGNUP_MODE=approval (the first account is still approved and made admin), BIND_ADDRESS=127.0.0.1 (REELSAW_BIND to choose; the compose template publishes on BIND_ADDRESS, or every interface when it is unset, so existing installs keep listening as before), and LLM_TRACE as a commented-out line. The compose template the installers write no longer falls back to the password 'reelsaw' for Postgres: the installers always generate one. The development compose file publishes MinIO on 127.0.0.1 only; its fallback credentials stay, since a required variable would break compose for every profile. installer-defaults.test.ts reads both scripts and the compose file and fails on any of these regressing. Signed-off-by: dillonstreator <dillonstreator@gmail.com>
No connection set a statement timeout, so a runaway query held one of the pool's connections until it finished. Migrations run at boot took no lock timeout: on a live database, a DDL statement queued behind a long transaction holds every later query on that table behind it for the length of the wait. Every pooled connection now starts with statement_timeout from DB_STATEMENT_TIMEOUT_SECONDS (default 300 s, 0 = never), set the same way as idle_in_transaction_session_timeout. The migrate connection drops that bound (waiting for another process's migration and a long index build are legitimate), takes the migrate advisory lock, then sets lock_timeout to 10 s, and resets both before going back to the pool. A lock timeout fails the boot with a sentence saying what happened; the next start tries again. Historical migrations are unchanged. db-timeouts.test.ts checks the settings on pooled connections, that a long statement is cancelled, and that migrate() restores the pool's settings. Signed-off-by: dillonstreator <dillonstreator@gmail.com>
No model call set maxOutputTokens, so a degenerate answer (a loop, a model that never stops) ran to the provider's own maximum, 64k tokens and more for current models, and was billed for. Every language model handed out by the registry now carries a middleware that sets maxOutputTokens to LLM_MAX_OUTPUT_TOKENS (default 16384, 0 = off) when a call gives none, and lowers a larger one; the model test's 8 stays. Every step's answer is a short JSON object, far under the default. Self- hosted servers (the compatible server, openai with OPENAI_BASE_URL) get no ceiling: vLLM and llama.cpp refuse a max_tokens larger than the context left after the prompt, which would fail long transcripts. The middleware sits outside the trace, so captured calls show the limit sent. llm-output-cap.test.ts covers the middleware against a mock model, which providers it applies to, and the default. Signed-off-by: dillonstreator <dillonstreator@gmail.com>
scripts/unit-tests.mjs handed its test processes the developer's whole environment. A shell exporting ANTHROPIC_BASE_URL (empty) and ANTHROPIC_AUTH_TOKEN, as some local tools do, failed 15 transcription and word-timestamp tests with "baseURL must be a non-empty string"; an exported key or base URL would be used by any test that builds a real provider, and send it requests. scripts/test-env.mjs drops every model-provider key, token and base URL (ANTHROPIC_*, OPENAI_*, GOOGLE_GENERATIVE_AI_*, GROQ_*, DEEPGRAM_*, ASSEMBLYAI_*, AI_GATEWAY_*, OPENCODE_*, LANGFUSE_*, VERCEL_OIDC_TOKEN) from the stack-free run and names what it left out. The --stack run keeps the environment, as the in-process stack tests may need it. test-env.test.ts checks the filter and that unit-tests.mjs uses it. Signed-off-by: dillonstreator <dillonstreator@gmail.com>
Signed-off-by: dillonstreator <dillonstreator@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Nov 28, 2026
Merged
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.
Fixes SEC-002, PRIV-001, SEC-004 (part), CONS-002, LLM-001 and TEST-001 from the 2026-11-28 audit. Companion to #393; the branches are independent.
What was wrong
SIGNUP_MODE=openand published the web port on every interface. The first account to sign up becomes the admin, so on a VPS whoever reached the address first owned the instance, and later strangers got approved accounts that spend the operator's provider keys.LLM_TRACE=logs. That writes every account's prompts, which carry transcript text, into the logs and the "Report an issue" zip.reelsaw.maxOutputTokens. A degenerate answer ran to the provider's maximum and was billed.ANTHROPIC_BASE_URL=exported, 15 transcription tests failed with "baseURL must be a non-empty string".What changed
install.shandinstall.ps1, kept identical where CI compares them):SIGNUP_MODE=approval. The first account is still approved and made admin.BIND_ADDRESS=127.0.0.1(choose withREELSAW_BIND). The compose port is${BIND_ADDRESS:+${BIND_ADDRESS:-}:}${PORT}:3000, so an existing.envwithoutBIND_ADDRESSkeeps listening on every interface as before. The installer readsBIND_ADDRESSback on a re-run.LLM_TRACE=logsbecomes a commented-out line.POSTGRES_PASSWORD:?with no fallback. The installers have always generated one.docker-compose.yml: MinIO is published on127.0.0.1only.db/index.ts):statement_timeoutfrom the newDB_STATEMENT_TIMEOUT_SECONDS(default 300, 0 = off).migrate()turns the statement bound off, takes its advisory lock, then setslock_timeout = '10s', and restores the pool's settings afterwards. A lock timeout fails the boot with a plain sentence.ai/registry.ts):maxOutputTokenstoLLM_MAX_OUTPUT_TOKENS(default 16384, 0 = off) when a call sets none, and lowers a larger one. Smaller requests are kept.openaiwithOPENAI_BASE_URL) get no cap, because vLLM and llama.cpp reject amax_tokenslarger than their remaining context.scripts/test-env.mjsdrops provider keys, tokens and base URLs from the stack-free run.--stackis unchanged.docs:gen. Changeset added (minor).How it was tested
Each new test fails on
origin/mainand passes here:installer-defaults.test.tsreads both scripts and the compose file as text.llm-output-cap.test.tsruns a mock model through the middleware.test-env.test.tsdb-timeouts.test.tsruns against a real Postgres. It checksshow statement_timeoutand thatpg_sleepis cancelled, and runsmigrate()to confirm the settings are restored.Also checked by hand:
docker compose configon the generated compose file. WithBIND_ADDRESSset it giveshost_ip: 127.0.0.1. With it unset it publishes on every interface and prints no warning. WithoutPOSTGRES_PASSWORDit fails with the message..envgeneration section ofinstall.shin a scratch folder.Local gate, with
ANTHROPIC_*unset:pnpm -r typecheck,biome ci(0 errors),pnpm guards,docs:check, andi18n:checkfor server and web.origin/mainon this machine: the bumper crossfade, which depends on the local ffmpeg, andresources"evicts scratch once…".db-timeouts,uow-atomic,lifecycle-order,deleted,stage-seq): 31/31 pass on a temporarypostgrescontainer on port 55433, which has since been removed.Needs manual verification
install.ps1: there was no PowerShell here, so the edits were checked by reading them, plus the compose-template comparison.REELSAW_DRY_RUN=1, then a full one. Re-run the installer over an older install and confirm the port still listens on every interface.For the reviewer to decide
SIGNUP_MODE. Only new installs change.Left out
${VAR:?}breaksdocker composefor every profile, because inactive services are interpolated too. I tested this. Binding to loopback is the mitigation.cap_drop/no-new-privileges: these need entrypoint testing (privilege drop, GPU).create.afterhooks after its own transaction commits, so the sign-up event cannot share the user insert's transaction without replacing Better Auth's adapter path.