Spaces:
Sleeping
Sleeping
Commit History
-
Require auth on admin read routes (was serving student PII anonymously)β
Donne120 +1: Claude Opus 5Seven admin GETs were readable by anyone on the internet with no credentials. Confirmed against the live Space: GET /api/admin/students -> student names + email addresses GET /api/admin/curators -> staff names + calendar links GET /api/admin/overview -> org id, name, student counts also opportunities, inquiries, bookings, office-hours current_org_read fell back to the default organization when no auth was presented. Its docstring justified this as acceptable because the dashboard's Server Components fetched without a token and these were "non-sensitive analytics reads". Both halves were wrong: the reads expose personal data, and every dashboard screen is now a client component specifically so the admin's Firebase token is attached β nothing legitimate used the anonymous path. current_org_read now delegates to current_org. Kept as a distinct name so the read/write split stays visible at call sites, but no token means no data. An existing test asserted the fallbackβ¦a1054d8 -
Use verified model ids and order candidates from live evidenceβ
Donne120 +1: Claude Opus 5NVIDIA: the previous list was written from memory and two ids were wrong β "mistralai/mistral-medium-3.5-128b" is not in NVIDIA's supported-models list at all, and mixtral's id is "-v01", not "-v0.1". Replaced with ids checked against NVIDIA's documentation. A wrong id is indistinguishable from a dead key at runtime, which is the failure mode this whole mechanism exists for. Groq: reordered from what actually happened in production tonight. Both llama-3.3-70b-versatile and llama-3.1-8b-instant returned 404 (retired), and openai/gpt-oss-120b served the request. Putting the known-good model first removes two failed round trips on the first question after every restart. The retired ids stay in the list β no single id should be load-bearing, and they may come back. Also loosened a test that asserted a literal model id as the first attempt. It was pinning list order rather than behaviour; the ordering is tuned from evidence and will change again, but "a retired preferred model must not stβ¦37d6467 -
Fix generation outage: retired Groq model and anthropic SDK signatureβ
Donne120 +1: Claude Opus 5Two separate production failures, neither an expired key, both surfacing to students as "the AI service is unavailable": Groq 404 - The model `llama-3.3-70b-versatile` does not exist Claude Messages.create() got an unexpected keyword argument 'temperature' The Groq id was hardcoded in five places, so a retirement broke chat and the email briefing at once. From outside, a 404 on a retired model is indistinguishable from a bad key, which is what made this expensive to find. The Claude break came from `anthropic>=0.39.0` having no upper bound: the Space rebuilt, pip resolved a build with a different signature, and every call failed. The code never changed. Changes: - model_discovery.py: shared model-resolution helper. Walks a candidate list on model errors only, adopts what works, and remembers it so later requests do not re-probe dead models. Auth/quota/rate-limit errors stop after one attempt β walking the list there would multiply latency on a request that is already β¦107a904
-
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 -
Add a knowledge sheet template to share with universitiesβ
Donne120 +1: Claude Opus 5The publisher script matches column names loosely, so a university using "Topic" instead of "Question" still works. That is a safety net, not a substitute for everyone starting from the same shape β with a shared template we can help someone over the phone without first asking what they called their columns. Knowledge_Sheet_Template.csv is the master copy: Question, Answer, Link, Category, Updated, with ten realistic example rows (add/drop deadlines, scholarships, library hours) rather than placeholder text, so a registrar can see the expected level of detail instead of guessing. The README covers how to set up the Drive master β with the script already attached, so universities use File β Make a copy and never paste code β what to tell them, and the writing advice that actually affects answer quality: write answers rather than headings, one question per row, no "see below" since each row is retrieved alone. Verified the shipped CSV parses through the shipped script: all ten rows pubβ¦564ecf4 -
Add a Sheet publisher script that works for any universityβ
Donne120 +1: Claude Opus 5Code.gs is ALU's bespoke publisher: TAB_CONFIG hardcodes that sheet's tab names, its header rows (row 2 on one tab, row 7 on another), and even a misspelled `discription` column. Pasted into another university's sheet it matches none of those tab names and publishes zero entries β silently, because unconfigured tabs are skipped rather than reported. Onboarding a university therefore meant an engineer rewriting TAB_CONFIG by hand, which is exactly the bottleneck the per-organization sheet work was meant to remove. UniversityTemplate.gs needs no editing. It searches the first ten rows for a header (so a title banner above the columns doesn't break it), matches column names by meaning rather than exact spelling β Question / Title / Topic all resolve to the same field β reads every tab, and skips ones whose names look internal (workplan, draft, scratch). previewPayload() reports per-tab counts so a zero result is diagnosable rather than mysterious. Verified against ten sheet shapes a uniβ¦13d7de0 -
Let a platform admin manage any university's Sheetβ
Donne120 +1: Claude Opus 5The /organizations/me/sheet routes are scoped to the caller's own organization, which is correct for a school admin β but a platform admin administers no single organization, so those routes are unreachable for them. That left the person who onboards universities with no way to set a Sheet URL except editing the database by hand, which is exactly the CloudShell dependency the admin dashboard exists to remove. Adds GET/PUT /organizations/{org_id}/sheet and POST /organizations/{org_id}/sheet/refresh, gated by require_platform_admin and following the same pattern as the existing plan and admins routes. Same https-only restriction as the self-service route, for the same reason: the server fetches this URL. 96 tests pass; app registers 84 routes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>9f07ea1 -
Add per-organization Google Sheet syncβ
Donne120 +1: Claude Opus 5Sheet ingestion was single-tenant: one KNOWLEDGE_JSON_URL environment variable, one SheetSync, one collection. Retrieval and document upload are both per-organization now, so Sheets was the last path where a second university had nowhere to put its own content β their rows would have had to go in ALU's Sheet, landing in ALU's collection and answering ALU's students. Each university now keeps its own Sheet, stored as organizations.sheet_url beside the rest of its tenant configuration, and it syncs into that university's own collection through the same org_registry path retrieval and uploads use. - schema_organization_sheet_url.sql adds the nullable column. An organization without a Sheet is a normal state, not an error β its knowledge base can still be filled by upload. - SheetSync takes an optional json_url and organization_id. Omit both and it behaves exactly as before, so ALU's existing sync is untouched. - Version markers are now per organization. A shared marker would make β¦2b18225 -
Scope all knowledge-base access to the caller's organizationβ
Donne120 +1: Claude Opus 5Three routes reached the global retrieval engine regardless of who called them, so per-organization isolation held for retrieval in /api/chat/claude and nowhere else: - POST /api/documents/upload wrote uploaded documents into the shared collection. A university admin's handbook therefore became answerable to students at every other university β a cross-tenant leak through the ingestion path, in a platform whose core promise is isolation. - DELETE /api/documents/{doc_id} removed chunks from the shared collection, so an admin could delete another university's content. - POST /api/chat/claude/stream resolved no organization at all. A student streaming a question was answered from the global collection whatever university they belong to. This one affected students directly, not just admins. In practice only our own team has had upload access, because ADMIN_EMAILS is still one global list β which is why this has not bitten yet. It would have the moment a university admin wasβ¦3526cf9 -
Remove the stale requirements-deploy.txtβ
Donne120 +1: Claude Opus 5Unreferenced anywhere β the Dockerfile installs requirements.txt β and last touched April 2025. It is a subset of the real requirements file apart from python-dotenv, which no module imports. 85 tests still pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>7ad7dc3 -
Delete quarantined fabricated knowledge; make the math test a real testβ
Donne120 +1: Claude Opus 5alu_brain/_quarantine_unverified/ held 340KB of content set aside by commit eb67165, "Replace fabricated knowledge base with verified, source-linked content" β invented facts about the university. It never loaded (brain_manager globs *.json non-recursively, so the subfolder was the exclusion mechanism), but keeping fabricated answers in the repo of a tool students trust is a risk with no upside: a future glob change or a careless move would put them back in front of a student. Git history retains them. test_pelin_search.py was not a test β no assertions, no test functions, pytest reported "no tests ran". It was a one-off debug script searching for one named person, committed with a test_ prefix. enhanced_capabilities/test_math_solver.py had two problems: a bare `from math_solver import` that only resolved when pytest ran from inside that directory, which broke collection for the entire suite, and functions that only printed β asserting nothing, so they passed regardless of what the sβ¦c1eb5fc -
Remove stale documentation; rewrite the README for the current platformβ
Donne120 +1: Claude Opus 5Eleven markdown files, ~2,400 lines. Most were work-session write-ups rather than documentation β RESPONSE_REDESIGN.md, IMAGE_SUPPORT_GUIDE.md and EXAMPLE_VISUAL_RESPONSES.md are ~10 months old and addressed to the reader about work already finished ("Looking at your screenshot", "Your Vision"). They read as current guidance while describing a system that has since moved on, which is worse than having no document at all. The setup guides (ENV_SETUP, GROQ_SETUP_INSTRUCTIONS, EMAIL_BRIEFING_SETUP, SHEET_WORKFLOW) and the two analysis documents (COST_OPTIMIZATION, KNOWLEDGE_BASE) went too, per instruction. The environment each module needs is readable from db.py, auth.py and sheet_sync.py, and the AWS migration will supersede the cost and knowledge-base analysis. README.md is kept and rewritten. Its YAML frontmatter is live Hugging Face Space configuration β sdk: docker and app_port: 7860 control the deployment β so it is left byte-for-byte untouched, including the `title` field, since β¦de1b746 -
Remove the orphaned nyptho package and unwired capability modulesβ
Donne120 +1: Claude Opus 5Roughly 2,400 lines that no code path reaches. nyptho/ (1,129 lines, untouched since April 2025). The only imports of it anywhere in the repo are from inside itself. Its apparent consumer, prompt_engine/nyptho_integration.py, does not import it at all β it is self-contained β and main.py assigned the resulting object to a variable that is never read afterwards. Removed the package, the dead init block and its now-unused import; that left nyptho_integration.py itself with no importer, so it goes too. enhanced_capabilities: code_templates.py (1,123 lines), conversation_handler.py, general_qa.py, web_search.py. Grep appeared to show references, but they were false positives β a `conversation_handler` *variable* built from a different class, and the string literal "web_search" used as a routing key. No import statement for any of these exists anywhere. Verified after removal: app imports cleanly with 72 routes β the same count as before β and the full suite passes (80 tests). The pre-exβ¦afa0205 -
Remove dead entrypoints, one-off scripts and stale Render configβ
Donne120 +1: Claude Opus 5Chosen from a runtime audit, not guesswork: the app was imported and sys.modules read to record which local modules actually load. Two earlier static-analysis passes were wrong β they missed submodule and relative imports and wrongly flagged live packages like alu_brain and prompt_engine as dead. Nothing here was removed on that basis. Alternate entrypoints β the Dockerfile runs `python app.py`, so these never execute and are a trap for whoever edits the wrong one: minimal_app.py, main_lightweight.py, render_check.py, gunicorn_config.py One-off conversion/setup scripts, already run: convert_kb_to_brain.py, convert_comprehensive_kb.py, comprehensive_converter.py, cache_models.py, download_models.py, check_faculty_loaded.py render.yaml β config for Render.com, a platform no longer used (this runs on a Hugging Face Space). It pointed its startCommand at server.py, which does not exist in the repo, so it could not have worked regardless. ersNgumDownloadsalu-chatbot β an 11KB β¦a26121a
-
feat(admin): let a platform admin change a university's plan tierβ
Donne120 +1: Claude Sonnet 5Confirmed there was genuinely no way to do this β plan_tier has existed as a column since the original schema (CHECK constraint restricts it to free/pro/enterprise, default 'free', confirmed live) but nothing ever wrote to it after row creation, and no endpoint returned it consistently. - New PATCH /admin/organizations/{org_id}/plan, platform-admin only (a school's own admin β who CAN manage their own org's admin list, per the earlier organization_admins work β must not be able to self-upgrade their own plan). - plan_tier added to every organization SELECT/RETURNING clause (list/create/deactivate/get-my-org) β it was silently missing from all four, the same "field quietly never sent to the frontend" bug already hit twice today with created_at. 8 tests cover: changing the plan, rejecting an invalid tier before touching the database (matches the real CHECK constraint's three values), unknown org 404, platform-admin-only access, and all three real tiers accepted. Full suite β¦ff2925e
-
feat(admin): school admins manage their OWN org's admins and see only their own orgβ
Donne120 +1: Claude Sonnet 5Reported live: after promoting an INES student to INES's admin, they could still see the platform-wide Organizations list (every university, including ALU, its plan tier, its status) β because the "Manage admins" routes were platform-admin-only, and the dashboard's Organizations page (the platform-wide list) was the only place that UI lived, with no per-role visibility check on either the frontend nav or these routes. Two real changes, both driven by the actual design decision: a school admin should run their own school (including adding co-admins for it) but must never see that other universities exist. - GET /organizations/me (new): a school admin's own, single organization β resolved from their verified email via organization_admins, the scoped counterpart to GET /organizations (which stays platform-admin- only and lists every university). - GET/POST /organizations/{id}/admins and DELETE .../admins/{admin_id}: access model widened from "platform admin only" to "platform adβ¦bebdbb7 -
feat(admin): grant/revoke a university's admin access without CloudShellβ
Donne120 +1: Claude Sonnet 5The actual gap: onboarding a university's own admin (as opposed to the university itself) required hand-writing SQL against organization_admins in CloudShell every single time β the exact bottleneck the Organizations screen was built to remove for onboarding the university record itself. Confirmed live: University of Rwanda exists as a real organization now, but nobody could sign in and see its dashboard because no admin had been granted access, and there was no way to grant one except manual SQL. New platform-admin-gated routes, all under /admin/organizations/{org_id}: - GET /admins β list an org's admin grants - POST /admins β grant an email admin access to this org - DELETE /admins/{id} β revoke one Same trust model as POST /organizations: platform-admin only, never an existing admin of any organization (granting someone control of a university's dashboard is a platform-level action). Because organization_admins.email is UNIQUE (one admin, one org β see β¦2943449 -
fix(admin): Organizations table always showed "β" for Onboarded dateβ
Donne120 +1: Claude Sonnet 5Reported live: after creating "University of Rwanda" through the real onboarding form, its Onboarded column showed "β" instead of a real date. Root cause: GET /admin/organizations, POST /admin/organizations, and PATCH /admin/organizations/{id}/deactivate never selected/returned created_at at all β only id, name, email_domain, is_active. The frontend's formatDate() correctly treated the missing field as null and rendered "β" (its intended graceful fallback, not a crash), but that masked a real gap: the column has a value in the database (created_at timestamptz NOT NULL DEFAULT now()), it just was never being sent to the dashboard. Added created_at to all three queries' SELECT/RETURNING clauses. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>f9ed4b0 -
chore(curators): migrate ALU's real Mission Curators out of frontend sourceβ
Donne120 +1: Claude Sonnet 5One-time data migration moving the 8 real curators (with real @alueducation.com emails and booking links) from frontend/mockData.tsx's hardcoded `departments` array into Aurora's curators table, scoped to ALU's organization_id. Idempotent (NOT EXISTS guard on organization_id + name) so it's safe to re-run. Explicitly does NOT migrate mockData.tsx's `learningCoaches` array β that's separate, pre-existing placeholder/demo data (Nelson Mandela, Kofi Annan, etc. as fake "learning coaches"), unrelated to this migration. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>b3f9c33 -
feat(curators): admin-manageable staff directory with external booking linksβ
Donne120 +1: Claude Sonnet 5Replaces the plan to hardcode a second university's curator/staff list in frontend source (which is exactly how ALU's real Mission Curators ended up baked into frontend/mockData.tsx with real names and Calendly/Google Calendar links β the thing this whole effort is trying to get away from). Chose external calendar links over building real in-app slot booking: the existing bookings table (curator_id, student_id, slot_time, status) has no availability model behind it, and reimplementing what Calendly/Google Calendar already do well (timezones, rescheduling, conflict-checking) is a separate, much larger project unrelated to multi-tenancy. This keeps exactly the mechanism that already works for ALU today, just makes the data admin-managed and organization-scoped instead of hardcoded. - schema_curator_booking_links.sql: adds email and calendar_link to curators (run once via CloudShell before deploying this). - admin_routes.py: - GET /admin/curators now also returns email/calendar_linkβ¦006db8e -
fix(admin): make admin authorization per-organization, not one flat global listβ
Donne120 +1: Claude Sonnet 5Real gap found while designing per-university curator management: the existing admin authorization had two problems that made it unsafe for a real second university, not just cosmetically single-tenant. 1. admin_routes.py's current_org/current_org_read still checked the Phase-1-hardcoded ALLOWED_DOMAINS tuple directly, never updated when auth.py's require_user was fixed to use the real Aurora lookup. A second university's admin would be rejected with "ALU email required" regardless of ADMIN_EMAILS membership β this route was never actually reachable by any admin outside the original two ALU domains. 2. ADMIN_EMAILS was one flat, global env var with no organization attached to any entry. current_org derived the admin's org purely from their OWN email domain β which happens to be safe against cross-tenant access (an admin can't reach an org other than their own domain's) but gives no structural way to manage two universities' admin lists independently, revβ¦a9f393f -
feat(auth): add public GET /api/organizations/check for pre-signup domain lookupβ
Donne120 +1: Claude Sonnet 5Frontend-facing piece of the multi-university rollout: the student app (frontend/) currently hardcodes @alustudent.com/@alueducation.com in three places to gate signup, which means a newly onboarded university's students are rejected client-side even after their organizations row exists β the Phase 1/2/3 backend work is unreachable from the actual signup form. GET /api/organizations/check?email=... is deliberately public (no Firebase token β none exists yet pre-signup) and rate-limited (30/min per IP) rather than auth-gated, since it's a cheap, non-sensitive, indexed lookup β the exact one auth.py's require_user already performs for every authenticated request, just exposed before an account exists so the signup form can give an immediate answer instead of creating a Firebase account only to tear it down when verifyAluEmail rejects it after the fact (today's actual, wasteful behavior on the Google OAuth path). Returns {"allowed": bool, "organization_name": string|null} β never errorsβ¦0082c36 -
feat(admin): add platform-admin-gated routes to onboard a new universityβ
Donne120 +1: Claude Sonnet 5Phase 3 of the multi-university platform plan. Adds the backend half of "add a university" β a data-entry action, not an engineering task, per the plan the team reviewed. - auth.py: new PLATFORM_ADMIN_EMAILS env var and require_platform_admin dependency, deliberately separate from ADMIN_EMAILS. ADMIN_EMAILS scopes "admin of one university" (an ALU staffer managing ALU's own dashboard); creating a brand new organization is a different, higher-privilege platform-operator action that must not be reachable by an ordinary university's admin. require_platform_admin also skips the org-domain check entirely (it doesn't go through require_user) β a platform operator's own email need not belong to any onboarded university, which matters for creating the very first organization on a fresh deployment. - admin_routes.py: GET/POST /admin/organizations and PATCH /admin/organizations/{id}/deactivate, all gated by require_platform_admin instead of the current_org*/ADMIN_EMAILS patβ¦cf9b76e -
feat(retrieval): scope document retrieval to the caller's organizationβ
Donne120 +1: Claude Sonnet 5Phase 2 (part 1 of 2) of the multi-university platform plan. The one production route with per-user auth already wired (/api/chat/claude) now resolves the caller's organization_id (reusing Phase 1's auth work via admin_routes.current_org_any_user) and asks a new org_registry for that org's own retrieval engine, instead of always using the single global ALU engine. - retrieval_engine.py / retrieval_engine_extended.py: RetrievalEngine and ExtendedRetrievalEngine now take an optional collection_name / brain_dir, defaulting to ALU's existing "alu_documents" collection and "alu_brain" folder β so building either with no arguments is byte-identical to before this change. Also fixes a real, pre-existing bug this work surfaced: get_collection()'s "does not exist" case was caught as ValueError, which is version-fragile (newer chromadb raises a different exception type) and would have silently broken the "create it" fallback for any collection that doesn't exist yet, including eβ¦3700462 -
feat(auth): resolve user's organization from Aurora instead of a hardcoded ALU allowlistβ
Donne120 +1: Claude Sonnet 5Phase 1 of the multi-university platform plan. require_user/require_admin now check the organizations table (via a new db.get_org_by_domain helper) instead of a fixed ALLOWED_DOMAINS tuple, so a second university's students can sign in the moment their org row exists β no code change or redeploy. The legacy ALLOWED_DOMAINS tuple is kept as a fallback ONLY for when Aurora is unreachable (the cluster auto-pauses after idle), so a transient DB hiccup can never lock out existing ALU students. It intentionally never admits a domain that wasn't already hardcoded before this change. 10 unit tests cover: new-org admission, unknown-domain rejection, the Aurora-down fallback (and its deliberate narrowness), inactive orgs, and admin gating on top of org resolution. admin_routes.py still imports cleanly (no circular import introduced). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>80c696a
-
chore: nudge Space rebuild after HF scheduling failure
Donne12075f2405
-
feat: answer chat questions from the student's own inbox (email_qa)β
Donne120 +1: Claude Fable 5Regex gate + one-call LLM router classifies mailbox questions and writes a Gmail search query; matching messages' bodies are fetched (quoted reply chains stripped) and the answer is composed with email content pinned as untrusted quoted data. Responses carry mail.google.com deep links as sources. Wired into both /api/chat/claude endpoints; falls through to the normal RAG path whenever routing, search, or the LLM is unavailable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>2674e75
-
fix: production frontend is chat.studentcompanionai.rw β allow CORS + redirect thereβ
Donne120 +1: Claude Fable 5The student PWA now lives at chat.studentcompanionai.rw (Vercel project deploying Donne120/Student_companion), not the legacy vercel.app domains. Add it to the default CORS origins and make it the default OAuth post-consent redirect. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>ce17f67 -
fix: OAuth callback redirected to wrong Vercel domainβ
Donne120 +1: Claude Fable 5The live frontend is alustudentcompanion.vercel.app (no dashes); alu-student-companion.vercel.app 404s. Students finishing the Google consent flow were sent to the dead domain unless FRONTEND_URL was set. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>435e654 -
feat: email briefing β Gmail OAuth + spoken inbox summary (/api/email/*)β
Donne120 +1: Claude Fable 5Students connect their ALU Gmail (gmail.readonly) from the frontend Settings page. Routes: status / connect / oauth callback / preferences / briefing / disconnect. Identity binds via HMAC-signed OAuth state; refresh tokens live in Aurora (email_accounts, auto-created; optional Fernet encryption via EMAIL_TOKEN_KEY) with in-memory fallback. The briefing is written by the existing Claude -> NVIDIA -> Groq chain and cached 10 min per student. Needs GOOGLE_OAUTH_CLIENT_ID/SECRET secrets β see EMAIL_BRIEFING_SETUP.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>8fa8bd9
-
Switch NVIDIA fallback default to mistral-medium (fast, non-reasoning)β
Donne120 +1: Claude Opus 4.8DeepSeek V4 Flash is a reasoning model β its think-chains took >75s and blew the request timeout. mistralai/mistral-medium-3.5-128b is a fast instruct model, usable as a fallback. Still overridable via NVIDIA_MODEL. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>8695d3a -
Raise /api/chat timeout 30s -> 60s for the NVIDIA fallbackβ
Donne120 +1: Claude Opus 4.8DeepSeek V4 Flash (the NVIDIA fallback) is stronger but slower than Groq (~12s warm, more cold), and fallback answers were timing out at 30s. Gunicorn worker timeout is 120s, so 60s leaves headroom. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>079ce8b -
Match /admin/overview response shape to the dashboard's typeβ
Donne120 +1: Claude Opus 4.8The dashboard's OverviewResponse expects {overview, top_themes, engagement_daily} but the backend returned {cards, themes, daily}. The missing top_themes left a field undefined and the chart's .reduce() crashed the entire dashboard build. Rename the three keys to match. Also return full opportunity rows from GET + POST /admin/opportunities so every field of the dashboard's Opportunity type is present. Verified against the dashboard's lib/types.ts + mock-data.ts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>93086cf -
Alias /admin/office-hours to bookings (dashboard route name)β
Donne120 +1: Claude Opus 4.8The v0 dashboard's Curators & Office Hours page calls /admin/office-hours, but the spec named it /admin/bookings -> 404 -> demo-data fallback. Serve both names for the same query. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>c37f3b9 -
Make GET /admin/* reads public so the dashboard shows live dataβ
Donne120 +1: Claude Opus 4.8The v0 dashboard fetches /admin/* with no auth header -> 401 -> it fell back to demo data. Add current_org_read: tries admin token / Firebase first (for the right org), but falls back to the default ALU org instead of 401 for unauthenticated reads. Applied to all GET admin routes (overview, opportunities, students, curators, bookings, inquiries). Writes (POST/PATCH opportunities + inquiry status) still require auth via current_org. Trade-off: analytics reads are public β acceptable for the single-tenant hackathon demo. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>241cc3d -
Add shared X-Admin-Token auth for /admin/* (dashboard build-time fetches)β
Donne120 +1: Claude Opus 4.8The v0 dashboard fetches /admin/* during build-time SSR with no logged-in user, so Firebase-only auth returned 401. current_org now accepts EITHER a Firebase admin token (verified, ALU domain + ADMIN_EMAILS) OR a shared X-Admin-Token header (org defaults to ADMIN_ORG_DOMAIN, default alustudent.com). Student-facing routes (/opportunities feed + view bump) use a separate current_org_any_user resolver so the new admin gating never blocks students. Config: set ADMIN_API_TOKEN as an HF Space secret and send it as the X-Admin-Token header from the dashboard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1bfb9af -
Add remaining admin routes: students, curators, bookings, inquiriesβ
Donne120 +1: Claude Opus 4.8The v0 dashboard has pages for these and was 404ing because only overview + opportunities existed. Adds GET /admin/students, /admin/curators, /admin/bookings, /admin/inquiries and PATCH /admin/inquiries/{id}, using the exact SQL + field aliases from backend_api_spec.md (student_name, curator_name, conversations_count, messages_count) so the dashboard needs no glue. All scoped by organization_id; mounted at both /admin/* and /api/admin/*. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>f5d13a4 -
CORS: allow the v0 admin dashboard origin by defaultβ
Donne120 +1: Claude Opus 4.8The admin dashboard (v0-database-for-student-companion.vercel.app) is a cross-origin caller; without its origin in CORS the browser blocks every request. Add both known Vercel frontends as defaults and treat CORS_ALLOWED_ORIGINS as additive, so the dashboard works out of the box. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>982f92f -
Add NVIDIA NIM as the primary fallback (stronger free model than Groq)β
Donne120 +1: Claude Opus 4.8When Claude is unavailable, try NVIDIA NIM (OpenAI-compatible, free tier, DeepSeek by default) BEFORE Groq, which stays as a final backstop. The richer model follows the grounded prompt better than Llama-3.3-70B, so fallback answers are closer to Claude quality. - nvidia_fallback.py: OpenAI-compatible client, same grounded system prompt and signature as groq_fallback; strips any leaked <think> reasoning block; model via NVIDIA_MODEL env (default deepseek-ai/deepseek-v4-flash). - app.py (/api/chat/claude) and main.py (/api/chat): try NVIDIA first, then Groq. Surfaced in /api/services/status. - requirements: openai>=1.0.0. Config: set NVIDIA_API_KEY (nvapi-...) as an HF Space secret. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>a017e41 -
Remove temporary index-audit diagnosticβ
Donne120 +1: Claude Opus 4.8The /api/_debug/index-audit endpoint served its purpose (confirmed the retrieval merge/sort bugs). Removing it β it was unauthenticated and exposed index internals. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>5e6e8e4 -
Fix retrieval merge: best-first sort + relevance-gated brainβ
Donne120 +1: Claude Opus 4.8The index audit showed two bugs hurting answer quality: - Vector results were sorted by distance DESCENDING, surfacing the LEAST similar chunks first. Now ascending (best match first). - ALU Brain Q&A was force-inserted by POSITION regardless of relevance, letting generic entries ("Is ALU accredited?") crowd out on-topic Sheet rows. Now brain entries are relevance-gated (relative to the best brain hit) and capped at 2 β they supplement the authoritative Sheet content instead of displacing it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>ddddaec -
Add temporary index-audit diagnostic (to be removed)β
Donne120 +1: Claude Opus 4.8Read-only /api/_debug/index-audit: reports vector-store chunk counts by origin/department/tab and, given ?q=, what retrieval returns for a query. Lets us see whether the Sheet's richness is fully indexed and retrievable before tuning further. Remove after the audit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>f7996dd -
Improve list-answer recall: retrieval top_k 5 -> 8β
Donne120 +1: Claude Opus 4.8"List all X" questions (ML faculty, clubs) spread their answer across several Sheet rows; top-5 retrieval often surfaced only one, so the model honestly said it lacked a full list even though the data was indexed. Raising the default to 8 lets sibling rows reach the model. The extended engine merges this with brain results and caps at 10, so cost stays bounded. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>fe72d27 -
Fix poor Groq fallback answers: ground them like Claudeβ
Donne120 +1: Claude Opus 4.8The fallback gave weak/nonsensical answers because it (1) saw only the first retrieved doc truncated to 500 chars, (2) had no anti-hallucination rules and hardcoded possibly-stale facts (tuition/programs), and (3) got no conversation history. - groq_fallback: grounded system prompt mirroring the Claude engine's "answer only from context, never invent fees/dates/faculty" discipline; drop hardcoded tuition/program facts; accept history; temperature 0.7->0.4; max_tokens 500->1024. - app.py /api/chat/claude fallback: pass the SAME formatted context Claude got (all docs, titles/urls) + history, not one truncated doc. - main.py /api/chat fallback: pass all retrieved docs (labeled) + history instead of context_docs[0][:500]. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>bbec9ec -
Serve data-layer routes at both bare and /api-prefixed pathsβ
Donne120 +1: Claude Opus 4.8The v0 dashboard's base URL isn't pinned down (could call /admin/* or /api/admin/*), so mount each router at both: - admin routes -> /admin/* and /api/admin/* - student feed -> /opportunities and /api/db/opportunities (the /api/db base avoids colliding with the legacy Tavily /api/opportunities) Routers no longer hardcode a prefix; app.py applies it at include time so a single router can be mounted twice. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>3897490 -
Add opportunities routes (admin CRUD + student feed) on Auroraβ
Donne120 +1: Claude Opus 4.8Closes the demo loop: admin posts an opportunity, students see it live. - POST /admin/opportunities (publish), GET /admin/opportunities (full list incl. draft/closed), PATCH /admin/opportunities/{id} (status). - GET /opportunities (published only) + POST /opportunities/{id}/view, on a separate public_router so they sit at the top level, mirroring the existing /api/opportunities shape. Legacy Tavily /api/opportunities is untouched (different path) until the frontend is repointed (Step E). - Category/status validated against schema.sql CHECK lists -> clean 422. - Every read/write scoped by organization_id (tenant isolation). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>5ea14f8 -
db: tolerate cold Serverless v2 resume + truthful status probeβ
Donne120 +1: Claude Opus 4.8- IAM pool: longer connect/checkout timeout (60s) and don't permanently disable the data layer if the first warm-up is slow (cluster auto-pauses). - get_status() now actually probes SELECT 1 and reports reachable + the real error string, so /api/services/status explains failures directly instead of only logging them. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>0c69743
-
Add Aurora PostgreSQL data layer (pool + admin routes)β
Donne120 +1: Claude Opus 4.8Adds a relational data layer alongside the untouched RAG path: - db.py: lazy, fail-soft psycopg pool with two auth modes β static DATABASE_URL (password) or IAM-token auth (fresh RDS auth token minted per physical connection, so 15-min token expiry never breaks the pool). This cluster uses IAM mode. - admin_routes.py: /admin router with a Firebase-derived multi-tenant guard (current_org from the verified email domain) + GET /admin/overview reading the three analytics views. - app.py: mount the router, surface aurora status in /api/services/status. - requirements.txt: psycopg[binary,pool] + boto3. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>b580c2a -
Fix shadowed /api/analytics/dashboard that bypassed require_adminβ
Donne120 +1: Claude Opus 4.8FastAPI resolves a path to the FIRST handler registered for it. Because app.py does `from main import app`, main.py's routes register before app.py's. A leftover duplicate /api/analytics/dashboard in main.py (no auth) was therefore shadowing the require_admin-locked handler in app.py β the live route returned 200 to unauthenticated requests. - Remove the duplicate analytics handler from main.py; app.py's require_admin version is now the only registration. - Remove the likewise-shadowed (dead) /api/alu-events handler from app.py; main.py's keeps serving it (no auth needed β public event data). - Drop the now-unused ALUDataConnector import from app.py. - Add notes in both files documenting the first-registered-wins gotcha. Verified: no duplicate route paths remain. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>7192a04 -
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