Repository navigation
Per-user health data and authenticated API (Step 0) - #1
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…heck Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- api/auth.py verify_token: guard against non-dict JSON responses using isinstance check - api/supabase_http.py http_get_json: catch OSError and http.client.HTTPException to ensure no exceptions escape (ConnectionResetError, RemoteDisconnected, IncompleteRead, etc) - add tests for edge cases: non-dict/empty responses, network errors Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…fallback Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…pi/chat Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Adds build_demo_health_data() and build_seed_sql() in scripts/make_demo_seed.py to generate a deterministic, synthetic demo dataset for testing and seeding. The generated supabase/seed_demo.sql provides an idempotent upsert of the demo row that works across environments. Features: - 120 days of plausible health data (steps, sleep, HRV, etc.) from Gaussian distributions - Deterministic generation (seed=42) for reproducible testing - Summary statistics auto-calculated from daily data - Sample event (exam week) included in the demo - Idempotent SQL upsert with on conflict clause Includes: - scripts/__init__.py (empty package marker) - scripts/make_demo_seed.py (generator code) - tests/scripts/test_make_demo_seed.py (6 tests covering shape, determinism, plausibility, and SQL format) - supabase/seed_demo.sql (generated seed data) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…_demo Only fall through to the demo row when the own-row query returned 200 with no rows; any other status returns None. Demo data now carries is_demo: true so the client can tell the truth. Adds URL-shape tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… extend RLS checks Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Step 0 of the Somada modernization (
docs/superpowers/specs/2026-10-03-somada-modernization-design.md). Today every user shares one publicly readablehealth_datarow (id = 1), so the last upload overwrites everyone else's data and anyone can read it. This PR fixes that.user_idunique) with RLS scoped toauth.uid(), plus one read-only synthetic demo row (is_demo). The legacyid = 1row is left in place but becomes invisible. Migration0002is idempotent;supabase/rollback/0002_down.sqlrestores the old app for the legacy row only./api/healthand/api/chatverify the Supabase JWT (401otherwise) and query PostgREST with the caller's own JWT, so RLS decides visibility. No anon-key reads, nolimit=1fallback, no local-file fallback when Supabase is configured. Demo data is markedis_demoby the server.index.html: minimal patch: sends the token, upserts byuser_id, syncs the "demo data" flag from the server.scripts/make_demo_seed.py->supabase/seed_demo.sql).NOT verified yet
The SQL (
supabase/) has never been executed against a database. Before merging:supabase/migrations/0001then0002, runsupabase/tests/rls_check.sql(expectALL RLS CHECKS PASSED), then re-apply0002and re-run it.docs/superpowers/plans/2026-10-03-step0-per-user-privacy-fix.md(preview deploy against the scratch project, then a back-to-back migration + deploy window for production; existing users must re-upload).Do not merge until the deploy checklist is ready: the new schema and the old frontend/API are not compatible, so the migration and this deploy must go out together.
Test plan
python -m pytest -v(54 passed)rls_check.sqlon a scratch project🤖 Generated with Claude Code