Spaces:
Running
Running
Commit History
-
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
-
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(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
-
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