innercontext/backend
Piotr Oleszczyk 2a9391ad32 feat(api): add LLM response validation and input sanitization
Implement Phase 1: Safety & Validation for all LLM-based suggestion engines.

- Add input sanitization module to prevent prompt injection attacks
- Implement 5 comprehensive validators (routine, batch, shopping, product parse, photo)
- Add 10+ critical safety checks (retinoid+acid conflicts, barrier compatibility, etc.)
- Integrate validation into all 5 API endpoints (routines, products, skincare)
- Add validation fields to ai_call_logs table (validation_errors, validation_warnings, auto_fixed)
- Create database migration for validation fields
- Add comprehensive test suite (9/9 tests passing, 88% coverage on validators)

Safety improvements:
- Blocks retinoid + acid conflicts in same routine/day
- Rejects unknown product IDs
- Enforces min_interval_hours rules
- Protects compromised skin barriers
- Prevents prohibited fields (dose, amount) in responses
- Validates all enum values and score ranges

All validation failures are logged and responses are rejected with HTTP 502.
2026-03-06 10:16:47 +01:00
..
alembic feat(api): add LLM response validation and input sanitization 2026-03-06 10:16:47 +01:00
innercontext feat(api): add LLM response validation and input sanitization 2026-03-06 10:16:47 +01:00
tests feat(api): add LLM response validation and input sanitization 2026-03-06 10:16:47 +01:00
.env.example fix: load .env via python-dotenv; SQLite default for local dev 2026-02-26 20:51:13 +01:00
.python-version Initial commit: backend API, data models, and test suite 2026-02-26 15:10:24 +01:00
alembic.ini feat(backend): add Alembic migrations 2026-02-28 20:14:57 +01:00
db.py Initial commit: backend API, data models, and test suite 2026-02-26 15:10:24 +01:00
main.py feat(profile): add profile settings and LLM user context 2026-03-05 15:57:21 +01:00
pyproject.toml chore(backend): enable psycopg binary dependency 2026-03-04 21:46:38 +01:00
README.md Initial commit: backend API, data models, and test suite 2026-02-26 15:10:24 +01:00
skincare.yaml Initial commit: backend API, data models, and test suite 2026-02-26 15:10:24 +01:00
test_query.py refactor(llm): optimize Gemini config profiles for extraction and creativity 2026-03-03 21:24:23 +01:00
uv.lock chore(backend): enable psycopg binary dependency 2026-03-04 21:46:38 +01:00

See the root README for setup and usage instructions.