## Implementation Plan ### 1. Commit the Unstaged Fix **File:** `devplacepy/database/schema.py` Lines 1206–1208 are unstaged in the working tree: ```python if not get_setting("gateway_embed_key", "") and openrouter: set_setting("gateway_embed_key", openrouter) logger.info("Migrated gateway embed key from environment") ``` **Action:** Stage these three lines and commit with message `fix: migrate gateway_embed_key from env on first boot` ### 2. Update Documentation **File:** `devplacepy/services/openai_gateway/CLAUDE.md` Line 66 currently reads: > migrates `DEEPSEEK_API_KEY`/`OPENROUTER_API_KEY` env into `gateway_api_key`/`gateway_vision_key` **Action:** Append `and gateway_embed_key` to the existing line so it reads: > migrates `DEEPSEEK_API_KEY`/`OPENROUTER_API_KEY` env into `gateway_api_key`/`gateway_vision_key` and `gateway_embed_key` ### 3. Add Unit Tests (Low Risk, High Value) **New test file:** `tests/unit/services/openai_gateway/schema_test.py` One test: `test_migrate_embed_key_populates_db` – verify that `migrate_ai_gateway_settings()` sets `gateway_embed_key` from `OPENROUTER_API_KEY` env var when the DB value is empty. **Existing test file:** `tests/unit/services/openai_gateway/service_test.py` One test: `test_effective_config_fallback_embed_key` – verify that `effective_config()` returns `gateway_vision_key` when `gateway_embed_key` is empty and vision key is set. Use existing `conftest.py` fixture that creates a clean in-memory DB. ### 4. Verify Run the project’s verification commands: ```bash pip install -e '.[dev]' -q && make test-unit pip install -q ruff && ruff check . ``` --- ## Definition of Done - [ ] `git log` shows a new commit with message `fix: migrate gateway_embed_key from env on first boot` that touches `devplacepy/database/schema.py` - [ ] `grep -c 'gateway_embed_key' devplacepy/services/openai_gateway/CLAUDE.md` returns a positive count and the line includes the appended text - [ ] All existing unit tests pass: `pip install -e '.[dev]' -q && make test-unit` exits with code 0 - [ ] Linting passes: `pip install -q ruff && ruff check .` exits with code 0 - [ ] (If tests added) The two new tests are present and green in the test output