innercontext/backend/tests
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
..
validators feat(api): add LLM response validation and input sanitization 2026-03-06 10:16:47 +01:00
__init__.py Initial commit: backend API, data models, and test suite 2026-02-26 15:10:24 +01:00
conftest.py refactor(api): remove MCP server integration and docs references 2026-03-04 12:28:30 +01:00
test_ai_logs.py feat(api): add INCI tool-calling with normalized tool traces 2026-03-04 11:35:19 +01:00
test_health.py feat(repo): expand lab results workflows across backend and frontend 2026-03-05 12:46:49 +01:00
test_inventory.py Initial commit: backend API, data models, and test suite 2026-02-26 15:10:24 +01:00
test_llm_profile_context.py feat(profile): add profile settings and LLM user context 2026-03-05 15:57:21 +01:00
test_product_model.py refactor(products): remove obsolete interaction fields across stack 2026-03-04 12:42:12 +01:00
test_products.py refactor(products): remove usage notes and contraindications fields 2026-03-05 10:11:24 +01:00
test_products_helpers.py feat(backend): include last-used date in product LLM details 2026-03-05 16:48:49 +01:00
test_products_pricing.py feat(backend): move product pricing to async persisted jobs 2026-03-04 22:46:16 +01:00
test_profile.py feat(profile): add profile settings and LLM user context 2026-03-05 15:57:21 +01:00
test_routines.py refactor(backend): consolidate product LLM function tools 2026-03-05 16:44:03 +01:00
test_routines_helpers.py fix(routines): enforce min_interval_hours and minoxidil flag server-side 2026-03-05 23:36:15 +01:00
test_skincare.py feat(profile): add profile settings and LLM user context 2026-03-05 15:57:21 +01:00