Skip to content

Commit a4b5c6e

Browse files
committed
Fix live Supabase sign in session creation and role resolution - PR_26166_164-live-sign-in-runtime-fix
1 parent 4beb913 commit a4b5c6e

9 files changed

Lines changed: 2887 additions & 1177 deletions

docs_build/dev/codex_commands.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,35 @@ Required reports:
12341234
- `docs_build/dev/reports/codex_changed_files.txt`
12351235
- `docs_build/dev/reports/codex_review.diff`
12361236

1237+
## PR_26166_164-live-sign-in-runtime-fix
1238+
1239+
Changes:
1240+
- Read `docs_build/dev/PROJECT_INSTRUCTIONS.md`.
1241+
- Verified the current branch is `main` before edits.
1242+
- Kept `GAMEFOUNDRY_DB_PROVIDER=local-db` and product data on Local DB.
1243+
- Added safe structured operator diagnostics for `POST /api/auth/sign-in`.
1244+
- Reused the resolved auth readiness status for sign-in and create-account auth adapter checks.
1245+
- Kept Sign In owned by the server API and Supabase Auth provider.
1246+
- Added targeted account Playwright validation for Create Account -> Sign In -> `/api/session/current`.
1247+
1248+
Validation:
1249+
- `node --check src/dev-runtime/server/local-api-router.mjs`
1250+
- `node --check tests/playwright/account/SupabaseSignInSession.spec.mjs`
1251+
- `node --test tests/dev-runtime/SupabaseProviderContractStub.test.mjs`
1252+
- `npx playwright test tests/playwright/account/SupabaseSignInSession.spec.mjs --project=playwright --workers=1 --reporter=list`
1253+
- `npm run validate:supabase-dev`
1254+
- `npm run dev:local-api`
1255+
- Manual live validation through `/account/create-account.html` and `/account/sign-in.html`.
1256+
- `/api/session/current` authenticated user and `user` role check.
1257+
- `git diff --check`
1258+
- Full samples smoke skipped because samples were not in scope.
1259+
1260+
Required reports:
1261+
- `docs_build/dev/reports/PR_26166_164-live-sign-in-runtime-fix_report.md`
1262+
- `docs_build/dev/reports/playwright_v8_coverage_report.txt`
1263+
- `docs_build/dev/reports/codex_changed_files.txt`
1264+
- `docs_build/dev/reports/codex_review.diff`
1265+
12371266

12381267
## PR_26161_008
12391268

docs_build/dev/commit_comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Display returned Objects render assets - PR_26161_010-objects-asset-return-display
1+
Fix live Supabase sign-in session resolution - PR_26166_164-live-sign-in-runtime-fix
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# PR_26166_164-live-sign-in-runtime-fix Report
2+
3+
## Branch Validation
4+
5+
- Current branch: `main`
6+
- Expected branch: `main`
7+
- Local branches found: `main`
8+
- Branch validation: PASS
9+
10+
## Requirement Checklist
11+
12+
- PASS - Read `docs_build/dev/PROJECT_INSTRUCTIONS.md` before implementation.
13+
- PASS - Main branch only: branch gate passed on `main`.
14+
- PASS - Reproduced Sign In through `/account/sign-in.html` using `npm run dev:local-api`.
15+
- PASS - Captured safe operator diagnostics for `POST /api/auth/sign-in`.
16+
- PASS - Fixed runtime cause by adding sign-in phase diagnostics and using the already resolved auth readiness status for the sign-in action path.
17+
- PASS - Sign In authenticates through Supabase Auth (`authProviderId=supabase-auth`).
18+
- PASS - Sign In resolves the server session after Supabase Auth password grant.
19+
- PASS - Sign In resolves the app `users` row, `roles`, and `user_roles` through the Supabase identity table provider.
20+
- PASS - `/api/session/current` returns an authenticated user and `roleSlugs=["user"]`.
21+
- PASS - `GAMEFOUNDRY_DB_PROVIDER=local-db` remained active.
22+
- PASS - Product data remains Local DB (`databaseProviderId=local-db`, `localDbProductDataActive=true`).
23+
- PASS - No `.env.local` or secret files changed.
24+
- PASS - No password tables were added or modified.
25+
- PASS - No browser-owned auth/provider logic was added.
26+
- PASS - No silent fallback was added; failures return generic browser errors plus safe operator diagnostics.
27+
- PASS - Full samples smoke was not run; samples are out of scope for this auth/session runtime PR.
28+
29+
## Validation Lane Report
30+
31+
- Runtime/auth lane: PASS
32+
- `node --check src/dev-runtime/server/local-api-router.mjs`
33+
- `node --test tests/dev-runtime/SupabaseProviderContractStub.test.mjs`
34+
- Targeted auth/session Playwright lane: PASS
35+
- `npx playwright test tests/playwright/account/SupabaseSignInSession.spec.mjs --project=playwright --workers=1 --reporter=list`
36+
- Supabase DEV lane: PASS with advisory WARN
37+
- `npm run validate:supabase-dev`
38+
- WARN: direct PostgreSQL TLS returned `SELF_SIGNED_CERT_IN_CHAIN`; REST/API identity readiness passed, so the validator classified this as advisory for DEV.
39+
- Local API manual/UAT lane: PASS
40+
- `npm run dev:local-api`
41+
- Server reported `Local API auth provider: supabase-auth` and `Local API product data provider: local-db`.
42+
- Skipped lanes: engine, broad integration, samples, and full samples smoke.
43+
- Reason: changes are scoped to dev-runtime auth/session routing and targeted account Playwright validation.
44+
45+
## Manual Validation Notes
46+
47+
- Started the local API with `npm run dev:local-api`.
48+
- Opened `/account/create-account.html` through Playwright against `http://127.0.0.1:5501`.
49+
- Created a fresh throwaway DEV account through the page.
50+
- Opened `/account/sign-in.html?returnTo=account/achievements.html`.
51+
- Signed in with the newly created account through the page.
52+
- Observed successful redirect to `/account/achievements.html`.
53+
- Called `/api/session/current` after Sign In:
54+
- `authenticated=true`
55+
- `roleSlugs=["user"]`
56+
- `userKey` matched the user key returned by Create Account.
57+
- Observed no page errors, console errors, or failed same-origin browser requests.
58+
59+
## Safe Operator Diagnostics
60+
61+
Captured from the local API stderr log:
62+
63+
```text
64+
[auth/operator] POST /api/auth/sign-in diagnostic phase=start selectedAuthProvider=supabase-auth dbProvider=local-db supabaseConfigured=yes identityTablesReady=yes upstreamStatusCode=none safeErrorCode=none safeMessage=ready-check-complete
65+
[auth/operator] POST /api/auth/sign-in diagnostic phase=success selectedAuthProvider=supabase-auth dbProvider=local-db supabaseConfigured=yes identityTablesReady=yes upstreamStatusCode=200 safeErrorCode=none safeMessage=session-resolved
66+
```
67+
68+
No email, password, access token, refresh token, service role key, anon key, or raw secret value appeared in the captured sign-in diagnostics.
69+
70+
## Playwright V8 Coverage
71+
72+
- Report: `docs_build/dev/reports/playwright_v8_coverage_report.txt`
73+
- Status: generated.
74+
- Notes: Playwright browser V8 coverage exercised the account page scripts. Server-side runtime files are listed as WARN/not collected by browser V8 coverage, which is advisory per project instructions.
75+
76+
## Files Changed
77+
78+
- `src/dev-runtime/server/local-api-router.mjs`
79+
- `tests/dev-runtime/SupabaseProviderContractStub.test.mjs`
80+
- `tests/playwright/account/SupabaseSignInSession.spec.mjs`
81+
- `docs_build/dev/reports/playwright_v8_coverage_report.txt`
82+
- `docs_build/dev/reports/PR_26166_164-live-sign-in-runtime-fix_report.md`
Lines changed: 18 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,25 @@
11
# git status --short
2-
M docs_build/dev/reports/coverage_changed_js_guardrail.txt
3-
M docs_build/dev/reports/dependency_gating_report.md
4-
M docs_build/dev/reports/dependency_hydration_reuse_report.md
5-
M docs_build/dev/reports/execution_graph_reuse_report.md
6-
M docs_build/dev/reports/failure_fingerprint_report.md
7-
M docs_build/dev/reports/filesystem_scan_reduction_report.md
8-
M docs_build/dev/reports/incremental_validation_report.md
9-
M docs_build/dev/reports/lane_compilation_report.md
10-
M docs_build/dev/reports/lane_deduplication_report.md
11-
M docs_build/dev/reports/lane_input_validation_report.md
12-
M docs_build/dev/reports/lane_manifests/workspace-contract.json
13-
M docs_build/dev/reports/lane_runtime_optimization_report.md
14-
M docs_build/dev/reports/lane_snapshot_report.md
15-
M docs_build/dev/reports/lane_snapshots/workspace-contract.json
16-
M docs_build/dev/reports/lane_warm_start_report.md
17-
M docs_build/dev/reports/lane_warm_starts/workspace-contract.json
18-
M docs_build/dev/reports/monolith_trigger_removal_report.md
19-
M docs_build/dev/reports/persistent_lane_manifest_report.md
20-
M docs_build/dev/reports/playwright_discovery_ownership_report.md
21-
M docs_build/dev/reports/playwright_discovery_scope_report.md
22-
M docs_build/dev/reports/playwright_structure_audit.md
2+
M docs_build/dev/codex_commands.md
3+
M docs_build/dev/commit_comment.txt
4+
A docs_build/dev/reports/PR_26166_164-live-sign-in-runtime-fix_report.md
5+
M docs_build/dev/reports/codex_changed_files.txt
6+
M docs_build/dev/reports/codex_review.diff
237
M docs_build/dev/reports/playwright_v8_coverage_report.txt
24-
M docs_build/dev/reports/retry_suppression_report.md
25-
M docs_build/dev/reports/slow_path_pruning_report.md
26-
M docs_build/dev/reports/static_validation_report.md
27-
M docs_build/dev/reports/targeted_file_manifest_report.md
28-
M docs_build/dev/reports/test_cleanup_performance_report.md
29-
M docs_build/dev/reports/test_cleanup_routing_report.md
30-
M docs_build/dev/reports/testing_lane_execution_report.md
31-
M docs_build/dev/reports/validation_cache_report.md
32-
M docs_build/dev/reports/zero_browser_preflight_report.md
33-
M src/dev-runtime/auth/provider-contract-stubs.mjs
348
M src/dev-runtime/server/local-api-router.mjs
35-
?? docs_build/dev/reports/PR_26166_163-create-account-live-diagnostic-fix.md
36-
?? docs_build/dev/reports/PR_26166_163-local-api-console-errors.txt
37-
?? docs_build/dev/reports/PR_26166_163-local-api-console.txt
9+
M tests/dev-runtime/SupabaseProviderContractStub.test.mjs
10+
A tests/playwright/account/SupabaseSignInSession.spec.mjs
3811

3912
# git ls-files --others --exclude-standard
40-
docs_build/dev/reports/PR_26166_163-create-account-live-diagnostic-fix.md
41-
docs_build/dev/reports/PR_26166_163-local-api-console-errors.txt
42-
docs_build/dev/reports/PR_26166_163-local-api-console.txt
13+
(no output)
4314

4415
# git diff --stat
45-
.../dev/reports/coverage_changed_js_guardrail.txt | 2 +
46-
docs_build/dev/reports/dependency_gating_report.md | 2 +-
47-
.../reports/dependency_hydration_reuse_report.md | 4 +-
48-
.../dev/reports/execution_graph_reuse_report.md | 4 +-
49-
.../dev/reports/failure_fingerprint_report.md | 2 +-
50-
.../reports/filesystem_scan_reduction_report.md | 2 +-
51-
.../dev/reports/incremental_validation_report.md | 2 +-
52-
docs_build/dev/reports/lane_compilation_report.md | 2 +-
53-
.../dev/reports/lane_deduplication_report.md | 2 +-
54-
.../dev/reports/lane_input_validation_report.md | 2 +-
55-
.../reports/lane_manifests/workspace-contract.json | 10 +--
56-
.../reports/lane_runtime_optimization_report.md | 2 +-
57-
docs_build/dev/reports/lane_snapshot_report.md | 4 +-
58-
.../reports/lane_snapshots/workspace-contract.json | 22 ++---
59-
docs_build/dev/reports/lane_warm_start_report.md | 4 +-
60-
.../lane_warm_starts/workspace-contract.json | 16 ++--
61-
.../dev/reports/monolith_trigger_removal_report.md | 2 +-
62-
.../dev/reports/persistent_lane_manifest_report.md | 6 +-
63-
.../playwright_discovery_ownership_report.md | 2 +-
64-
.../reports/playwright_discovery_scope_report.md | 2 +-
65-
.../dev/reports/playwright_structure_audit.md | 2 +-
66-
.../dev/reports/playwright_v8_coverage_report.txt | 28 +++++--
67-
docs_build/dev/reports/retry_suppression_report.md | 2 +-
68-
docs_build/dev/reports/slow_path_pruning_report.md | 14 ++--
69-
docs_build/dev/reports/static_validation_report.md | 4 +-
70-
.../dev/reports/targeted_file_manifest_report.md | 4 +-
71-
.../dev/reports/test_cleanup_performance_report.md | 16 ++--
72-
.../dev/reports/test_cleanup_routing_report.md | 2 +-
73-
.../dev/reports/testing_lane_execution_report.md | 18 ++--
74-
docs_build/dev/reports/validation_cache_report.md | 30 +++----
75-
.../dev/reports/zero_browser_preflight_report.md | 2 +-
76-
src/dev-runtime/auth/provider-contract-stubs.mjs | 49 +++++++++--
77-
src/dev-runtime/server/local-api-router.mjs | 96 +++++++++++++++++++++-
78-
33 files changed, 252 insertions(+), 109 deletions(-)
16+
docs_build/dev/codex_commands.md | 29 +
17+
docs_build/dev/commit_comment.txt | 2 +-
18+
...PR_26166_164-live-sign-in-runtime-fix_report.md | 82 +
19+
docs_build/dev/reports/codex_changed_files.txt | 89 +-
20+
docs_build/dev/reports/codex_review.diff | 3473 ++++++++++++++------
21+
.../dev/reports/playwright_v8_coverage_report.txt | 29 +-
22+
src/dev-runtime/server/local-api-router.mjs | 96 +-
23+
.../SupabaseProviderContractStub.test.mjs | 47 +-
24+
.../account/SupabaseSignInSession.spec.mjs | 217 ++
25+
9 files changed, 2887 insertions(+), 1177 deletions(-)

0 commit comments

Comments
 (0)