Skip to content

Claude/read spec n6efu#171

Merged
yellowman merged 8 commits intomainfrom
claude/read-spec-n6efu
Dec 26, 2025
Merged

Claude/read spec n6efu#171
yellowman merged 8 commits intomainfrom
claude/read-spec-n6efu

Conversation

@yellowman
Copy link
Copy Markdown
Owner

@yellowman yellowman commented Dec 26, 2025

Note

Adds a testing-only stub model backend and stabilizes QA and Docker-based workflows.

  • Stub backend: New StubBackend with canned responses and streaming; integrated via LLMService._build_backend and allowed in /admin/settings (model_backend now includes stub).
  • Docker/Bootstrap: docker-compose.test.yml sets MODEL_BACKEND=stub; bootstrap_admin.py syncs MODEL_BACKEND into system_settings for runtime.
  • Smoke & tests: scripts/smoke_test.sh now requires 200 and checks for the stub response; new unit tests in tests/test_stub_backend.py.
  • Makefile reliability: test-pg and docker targets use trap-based cleanup and --wait; adds docker-clean target.
  • Docs/config: Normalize DATABASE_URL scheme to postgresql://; QA runbook updated for Compose --wait; deployment and OpenBSD env examples adjusted accordingly.

Written by Cursor Bugbot for commit 6d4ebe2. This will update automatically on new commits. Configure here.

- Makefile test-pg: use --wait instead of sleep 5
- Makefile docker: use --wait instead of sleep 10
- QA_RUNBOOK.md: update both Docker steps to use --wait

The --wait flag waits for service health checks to pass,
making tests deterministic on slower machines and CI.
- test-pg: wrap in bash with trap to run cleanup on EXIT
- docker: wrap in bash with trap to run cleanup on EXIT
- Add docker-clean target for manual cleanup of leftover containers

The trap pattern ensures docker compose down runs regardless of
whether pytest/smoke tests pass or fail.
- Add StubBackend class that returns canned responses for testing
- Add STUB enum value to ModelBackend in config.py
- Wire stub backend into LLMService._build_backend()
- Update docker-compose.test.yml to use MODEL_BACKEND=stub
- Update smoke_test.sh to require 200 from chat (not 503)

This makes chat smoke tests deterministic without requiring a real LLM.
The runtime resolves model_backend as:
  sys_settings.get("model_backend") or settings.model_backend

This meant DB defaults (which seed "openai") would override the
MODEL_BACKEND env var, causing the stub backend to not be used.

Fix: bootstrap_admin.py now syncs MODEL_BACKEND env to system_settings
if set, ensuring the test stack actually uses the stub backend.
The admin settings validator rejected 'stub' as a model_backend value,
which would prevent setting it via the API. Added to allowed values
with a comment noting it's for testing only.
The Makefile uses `docker compose --wait` which requires Compose v2.1+.
Added version requirements and a note about checking/upgrading.
Tests ensure StubBackend doesn't regress:
- generate() returns canned response with usage stats
- generate_stream() yields tokens then message_done event
@yellowman yellowman merged commit 7b85f53 into main Dec 26, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants