Spaces:
Running
Running
Commit History
-
Give every module one definition of the data directory
Donne120 +1: Claude Opus 5Three modules worked out where to put files independently and disagreed. retrieval_engine.py honoured the DATA_DIR environment variable — but only when DEPLOYMENT_ENV was "huggingface". document_processor.py and prompt_engine/templates.py hardcoded Path("./data") and ignored it. Nothing sets DATA_DIR in production, so all three resolved to the same directory by coincidence and the split was invisible. Set it — which is the obvious thing to do when mounting persistent storage during the AWS migration — and uploads write to ./data while retrieval searches somewhere else. Nothing raises: the upload reports success and the document simply never becomes answerable. paths.py now owns DATA_DIR, DOCUMENTS_DIR, METADATA_FILE, VECTOR_DB_DIR, PROMPTS_DIR and ALU_BRAIN_DIR; the three modules import from it. Also removed retrieval_engine's DEPLOYMENT_ENV branch, whose non-Hugging-Face path preferred ./backend/data when it existed — verified it does not exist in this repo, so that branch never ran…c8527f1
-
Auth, rate limiting, upload hardening, and error hygiene on all routes
Donne120 +1: Claude Opus 4.8Closes the remaining audit findings beyond the admin lock: - require_user on student-facing routes: /api/chat/claude, /chat/claude/stream, /coach/essay, /api/opportunities (was unauthenticated paid-LLM/Tavily access). - require_admin on /api/documents/upload, DELETE /api/documents/{id}, GET /api/documents, /api/analytics/dashboard (were open: KB poisoning, IDOR delete, analytics leak). - slowapi rate limiting keyed by client IP: chat 20/min, upload 5/min, opportunities 10/min, essay 5/min. Clean 429 on limit. - ClaudeChatRequest.message capped at 4000 chars, history at 40 turns; essay capped at 12000 chars — bounds single-request LLM cost. - Upload hardening: 10 MB size cap enforced while streaming to disk; saved-file extension derived from validated content-type, never the client filename. - Stop returning str(e) to clients (analytics, upload, deep-query, events, health) — log server-side, return a generic message. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.c…b76768d
-
best move
Donne120f4cfd3f