chore(deploy): gp.nano migration — env-driven kill switches + low-maintenance notices#22
Merged
Merged
Conversation
Move the openai_api_key guard from stream_chat_response (async generator) into send_message (route handler body). An HTTPException raised inside an async generator body is caught by the except-Exception wrapper and emitted as an SSE error event, so the HTTP status was always 200. Placing the guard synchronously before EventSourceResponse is constructed ensures FastAPI returns a real 503. Remove the now-redundant guard and the unused HTTPException import from chat_service.py.
The TFT kill-switch is already controlled by ENABLE_TFT_FORECASTS read directly in ml/training/config.py. The Settings field added in the prior commit was never read and could mislead future maintainers into thinking Settings is the authoritative control point for TFT. Remove the field and update the comment to describe only the scheduler flag that remains.
Drop NODE_OPTIONS max-old-space-size from 384 to 300, keeping the container memory limit at 384M. This reserves ~84 MiB for native Node memory (OpenSSL, buffers, addons) and prevents guaranteed OOM when the heap fills to the container ceiling.
Replace all three hardcoded tracesSampleRate: 0.1 literals with reads from environment variables. Frontend (server, edge, client) reads NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE; backend reads SENTRY_TRACES_SAMPLE_RATE. Both fall back to 0.1 when unset, so behaviour is unchanged without the overlay.
The previous comment claimed NEXT_PUBLIC_DISABLED_FEATURES was set in docker-compose.nano.yml, but that variable doesn't exist yet. Reword to describe the intended behaviour without referencing a future env var.
Introduces NEXT_PUBLIC_DISABLED_FEATURES env var (comma-separated list)
that gates AI-powered features behind a bilingual MaintenanceCard notice
instead of firing requests destined to fail on gp.nano.
- src/lib/feature-flags.ts: build-time feature-flag helper evaluated
from NEXT_PUBLIC_DISABLED_FEATURES
- src/components/ui/maintenance-card.tsx: styled elevated notice using
project brand tokens (bg-card, border-hover, accent-yellow tint);
wrench icon, role=status, tight tracking on title, relaxed leading
on body; supports optional feature-specific copy
- messages/{en,es}.json: adds "maintenance" namespace with title, body,
and featureBody (ICU placeholder for feature name)
- Wraps five host components with the outer/inner pattern so hooks never
fire when the feature is flagged off: AiWeatherSummary, RiskNarrative,
PersonalizedSuggestions, PlanWizard, ChatPage
- Hooks (use-ai-summary, use-narrative, use-personalized-suggestions,
use-emergency-plan) now expose disabled: boolean and set it on HTTP
503, giving a defence-in-depth fallback when the env var is missing
- docker-compose.nano.yml: adds NEXT_PUBLIC_DISABLED_FEATURES to
frontend environment block
- .env.production.nano.example: documents the var and updates the
OPENAI_API_KEY comment to reference it
Owner
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
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.
Summary
ENABLE_SCHEDULERandENABLE_TFT_FORECASTSenv-driven kill switches to backend config, wired into scheduler bootstrap and ML module constantchat_serviceagainst emptyOPENAI_API_KEY(raises 503 before SSE stream construction)docker-compose.nano.ymloverlay for 1vCPU/2GB hosts with memory/CPU caps.env.production.nano.examplereference file for nano deploymentsENABLE_SENTRY_SAMPLE_RATEenv var to make Sentry sample rate configurableNODE_OPTIONS=--max-old-space-size=512)docs/deploy/gp-nano-runbook.md) with migration and revert stepsMaintenanceCardcomponent and wrap disabled-feature pages with low-maintenance notices when kill switches are activeTest plan
npx tsc --noEmit— passesnpx eslint src/— 4 pre-existing warnings (not in our diff), no new warningsruff check .— cleanTypeGuardedTypeinternal crash unrelated to our changes)docker compose -f docker-compose.prod.yml -f docker-compose.nano.yml config— exits 0