Skip to content

Commit ca20f8e

Browse files
committed
Run sequential DEV Supabase DB migration PRs with per-PR validation and cleanup - PR_26166_165-172
1 parent a4b5c6e commit ca20f8e

14 files changed

Lines changed: 2054 additions & 2399 deletions

docs_build/dev/codex_commands.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,3 +1383,39 @@ Required reports:
13831383
- `docs_build/dev/reports/coverage_changed_js_guardrail.txt`
13841384
- `docs_build/dev/reports/codex_changed_files.txt`
13851385
- `docs_build/dev/reports/codex_review.diff`
1386+
1387+
1388+
## PR_26166_165-auth-test-user-cleanup
1389+
1390+
Changes:
1391+
- Read `docs_build/dev/PROJECT_INSTRUCTIONS.md`.
1392+
- Verified the current branch is `main` before edits.
1393+
- Added DEV-only Supabase Auth test-account cleanup for matching `codex-*` and `playwright-*` `@example.test` accounts only.
1394+
- Added server/dev-runtime cleanup operations to delete matching Supabase Auth users, `users` rows, and `user_roles` rows.
1395+
- Added explicit shared account audit-reference reassignment requiring a surviving non-test DEV audit user key.
1396+
- Added reusable cleanup script `npm run cleanup:supabase-dev-auth-test-users`.
1397+
- Added focused cleanup/provider contract tests.
1398+
- Preserved `GAMEFOUNDRY_DB_PROVIDER=local-db` and did not add any product-data cutover.
1399+
- Did not touch UAT/PROD, `.env.local`, secrets, password tables, browser-owned provider logic, or full samples smoke.
1400+
1401+
Validation:
1402+
- `node --check src/dev-runtime/auth/provider-contract-stubs.mjs`
1403+
- `node --check src/dev-runtime/testing/supabase-dev-auth-test-user-cleanup.mjs`
1404+
- `node --check scripts/cleanup-supabase-dev-auth-test-users.mjs`
1405+
- `node --check tests/dev-runtime/SupabaseDevAuthTestUserCleanup.test.mjs`
1406+
- `node --test tests/dev-runtime/SupabaseDevAuthTestUserCleanup.test.mjs`
1407+
- `node --test tests/dev-runtime/SupabaseProviderContractStub.test.mjs`
1408+
- `npm run validate:supabase-dev`
1409+
- `node --use-system-ca ./scripts/cleanup-supabase-dev-auth-test-users.mjs --dry-run --json`
1410+
- `node --use-system-ca ./scripts/cleanup-supabase-dev-auth-test-users.mjs --json --audit-user-key 01KV6R2GKPZDAWNKM1N65SHZY5`
1411+
- `npm run cleanup:supabase-dev-auth-test-users -- --dry-run --json`
1412+
- `npx playwright test tests/playwright/account/SupabaseSignInSession.spec.mjs --project=playwright --workers=1 --reporter=list`
1413+
- Full samples smoke skipped by request and because samples were not in scope.
1414+
1415+
Required reports:
1416+
- `docs_build/dev/reports/PR_26166_165-auth-test-user-cleanup_report.md`
1417+
- `docs_build/dev/reports/PR_26166_165-auth-test-user-cleanup_cleanup_report.md`
1418+
- `docs_build/dev/reports/playwright_v8_coverage_report.txt`
1419+
- `docs_build/dev/reports/coverage_changed_js_guardrail.txt`
1420+
- `docs_build/dev/reports/codex_changed_files.txt`
1421+
- `docs_build/dev/reports/codex_review.diff`

docs_build/dev/commit_comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fix live Supabase sign-in session resolution - PR_26166_164-live-sign-in-runtime-fix
1+
Add DEV Supabase auth test user cleanup - PR_26166_165-auth-test-user-cleanup
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# PR_26166_165 Auth Test User Cleanup Report
2+
3+
## Summary
4+
5+
PASS
6+
7+
- Created test records during PR_165: none.
8+
- Dry-run before cleanup: 7 matching Supabase-auth test-account candidates.
9+
- Delete run: 7 matching test records deleted from the app identity table.
10+
- Final dry-run after cleanup: 0 matching candidates.
11+
- Non-test users were skipped and not deleted.
12+
- UAT/PROD were not touched.
13+
14+
## Matching Rule
15+
16+
The cleanup only targets users that satisfy all of these conditions:
17+
18+
- `authProvider` is `supabase-auth`.
19+
- `authProviderUserId` is present.
20+
- Email matches `codex-*` or `playwright-*` at `example.test`.
21+
- User key is not one of the static DEV user exceptions.
22+
23+
## Created Test Records
24+
25+
None.
26+
27+
## Pre-Cleanup Dry-Run Candidates
28+
29+
- `codex-pr156-1781555647052-44df0842@example.test` userKey=`01KV6FVNXBGQWRMAHAT994S4CW`
30+
- `codex-pr156-session-1781555681463-772702@example.test` userKey=`01KV6FWQ35QBXT2CXPR0TKANFN`
31+
- `codex-pr157-160-1781557811826-cbba99@example.test` userKey=`01KV6HXRBKW27SB3Y9PCZVZ5JP`
32+
- `codex-pr157-160-1781557880857-f21b68@example.test` userKey=`01KV6HZV2GW5K5428TP9NSHKE5`
33+
- `codex-pr161-create-1781560208113-777e5d@example.test` userKey=`01KV6M6VSGH4N1PF02NE2P1ZW4`
34+
- `codex-pr26166-mqftqbp8@example.test` userKey=`01KV6RNFD2VNF5SMK6Z7PW5J04`
35+
- `codex-pr26166-live-mqfue66y@example.test` userKey=`01KV6SQE8XWCATB1TPQNW2STH0`
36+
37+
## Audit Dependency Handling
38+
39+
- One shared account audit dependency was found before cleanup.
40+
- Table: `roles`
41+
- Row key: `01KV6FVP0ASR2RRR9WXCBKTV6C`
42+
- Fields: `createdBy`, `updatedBy`
43+
- Reassigned to explicit surviving DEV audit user key: `01KV6R2GKPZDAWNKM1N65SHZY5`
44+
- Reassigned fields: 2
45+
46+
## Deleted Test Records
47+
48+
- `codex-pr156-1781555647052-44df0842@example.test` userKey=`01KV6FVNXBGQWRMAHAT994S4CW`; Auth deleted=false; Auth not found=true; role audit refs reassigned=2; user_roles deleted=0; users deleted=1
49+
- `codex-pr156-session-1781555681463-772702@example.test` userKey=`01KV6FWQ35QBXT2CXPR0TKANFN`; Auth deleted=true; Auth not found=false; role audit refs reassigned=0; user_roles deleted=1; users deleted=1
50+
- `codex-pr157-160-1781557811826-cbba99@example.test` userKey=`01KV6HXRBKW27SB3Y9PCZVZ5JP`; Auth deleted=true; Auth not found=false; role audit refs reassigned=0; user_roles deleted=1; users deleted=1
51+
- `codex-pr157-160-1781557880857-f21b68@example.test` userKey=`01KV6HZV2GW5K5428TP9NSHKE5`; Auth deleted=true; Auth not found=false; role audit refs reassigned=0; user_roles deleted=1; users deleted=1
52+
- `codex-pr161-create-1781560208113-777e5d@example.test` userKey=`01KV6M6VSGH4N1PF02NE2P1ZW4`; Auth deleted=true; Auth not found=false; role audit refs reassigned=0; user_roles deleted=1; users deleted=1
53+
- `codex-pr26166-mqftqbp8@example.test` userKey=`01KV6RNFD2VNF5SMK6Z7PW5J04`; Auth deleted=true; Auth not found=false; role audit refs reassigned=0; user_roles deleted=1; users deleted=1
54+
- `codex-pr26166-live-mqfue66y@example.test` userKey=`01KV6SQE8XWCATB1TPQNW2STH0`; Auth deleted=true; Auth not found=false; role audit refs reassigned=0; user_roles deleted=1; users deleted=1
55+
56+
## Final Cleanup Confirmation
57+
58+
- Command: `npm run cleanup:supabase-dev-auth-test-users -- --dry-run --json`
59+
- `testDataCandidates`: 0
60+
- `testDataCreated`: 0
61+
- `testDataDeleted`: 0 in final dry-run mode
62+
- `auditReassignmentRequired`: false
63+
- `status`: PASS
64+
65+
## Non-Test Records Skipped
66+
67+
Six users were skipped because they did not match the DEV test-account pattern. They were not deleted.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# PR_26166_165-auth-test-user-cleanup
2+
3+
## Branch Validation
4+
5+
PASS
6+
7+
- Current branch: `main`
8+
- Expected branch: `main`
9+
- Local branches found: `main`
10+
- `docs_build/dev/PROJECT_INSTRUCTIONS.md` read before execution.
11+
12+
## Scope Summary
13+
14+
PASS
15+
16+
- Added DEV-only Supabase Auth test-account cleanup.
17+
- Cleanup is limited to Supabase-auth users whose email matches `codex-*` or `playwright-*` at `example.test`.
18+
- Cleanup deletes Supabase Auth users, matching `users` rows, and matching `user_roles` rows.
19+
- Added explicit audit-reference reassignment guard for shared account rows that still reference a test user as `createdBy` or `updatedBy`.
20+
- Added reusable cleanup script: `npm run cleanup:supabase-dev-auth-test-users`.
21+
- No UAT or PROD enablement was added.
22+
- No product-data provider cutover was added; product data remains Local DB.
23+
- No password tables were added.
24+
- No browser-owned auth/provider logic was added.
25+
- No silent fallback was added.
26+
- No `.env.local` or secret values were changed or committed.
27+
28+
## Requirement Checklist
29+
30+
- PASS - Treat PR_165 as one separate BUILD unit only.
31+
- PASS - Main branch only; current branch was `main`.
32+
- PASS - Read `docs_build/dev/PROJECT_INSTRUCTIONS.md` before work.
33+
- PASS - Add DEV-only auth test user cleanup.
34+
- PASS - Delete Supabase Auth user, `users` row, and `user_roles` rows for matching test accounts only.
35+
- PASS - Add reusable DEV cleanup pattern for later PRs.
36+
- PASS - No UAT/PROD enablement.
37+
- PASS - Do not commit secrets or `.env.local`.
38+
- PASS - Clean up Codex-created test data before packaging.
39+
- PASS - Run `npm run validate:supabase-dev`.
40+
- PASS - Run targeted auth/session validation.
41+
- PASS - Playwright impacted: targeted auth/session Playwright run completed.
42+
- PASS - Do not run full samples smoke.
43+
- PASS - Create `codex_review.diff`, `codex_changed_files.txt`, PR-specific report, validation notes, and cleanup report.
44+
45+
## Validation Lane Report
46+
47+
Executed lanes:
48+
49+
- contract: `node --check` for changed runtime/script/test files.
50+
- contract: `node --test tests/dev-runtime/SupabaseDevAuthTestUserCleanup.test.mjs`
51+
- contract: `node --test tests/dev-runtime/SupabaseProviderContractStub.test.mjs`
52+
- integration/runtime: `npm run validate:supabase-dev`
53+
- targeted Playwright auth/session: `npx playwright test tests/playwright/account/SupabaseSignInSession.spec.mjs --project=playwright --workers=1 --reporter=list`
54+
- cleanup/live DEV: dry-run, delete with explicit audit user, final dry-run confirmation.
55+
56+
Skipped lanes:
57+
58+
- Full samples smoke: SKIP by request and no samples were in scope.
59+
- Admin DB Viewer validation: SKIP for PR_165 because no Admin DB Viewer behavior changed.
60+
- Targeted provider/API validation for migrated product areas: SKIP for PR_165 because no product areas were migrated.
61+
- `npm run test:workspace-v2`: SKIP because no Project Workspace, toolState, or workspace runtime behavior changed. The command name is legacy; user-facing language remains Project Workspace.
62+
63+
## Validation Results
64+
65+
- PASS - `node --check src/dev-runtime/auth/provider-contract-stubs.mjs`
66+
- PASS - `node --check src/dev-runtime/testing/supabase-dev-auth-test-user-cleanup.mjs`
67+
- PASS - `node --check scripts/cleanup-supabase-dev-auth-test-users.mjs`
68+
- PASS - `node --check tests/dev-runtime/SupabaseDevAuthTestUserCleanup.test.mjs`
69+
- PASS - `node --test tests/dev-runtime/SupabaseDevAuthTestUserCleanup.test.mjs` (5 tests passed)
70+
- PASS - `node --test tests/dev-runtime/SupabaseProviderContractStub.test.mjs` (29 tests passed)
71+
- PASS - `npm run validate:supabase-dev` (overall PASS; DEV direct PostgreSQL TLS warning remains advisory: `SELF_SIGNED_CERT_IN_CHAIN`)
72+
- PASS - `npx playwright test tests/playwright/account/SupabaseSignInSession.spec.mjs --project=playwright --workers=1 --reporter=list` (1 test passed)
73+
- PASS - `npm run cleanup:supabase-dev-auth-test-users -- --dry-run --json` after cleanup confirmed zero candidates.
74+
75+
## Manual Validation Notes
76+
77+
- Confirmed live DEV cleanup dry-run found seven matching Supabase-auth test accounts and one shared account audit dependency.
78+
- Confirmed delete mode required an explicit surviving non-test DEV audit user key before reassignment.
79+
- Confirmed delete mode removed seven matching test `users` rows and six matching `user_roles` rows.
80+
- Confirmed one older candidate had an already-missing Supabase Auth account; cleanup reported `authUserNotFound=true` and still removed the matching `users` row after audit reassignment.
81+
- Confirmed the final dry-run returned `testDataCandidates: 0`.
82+
- Confirmed skipped non-test users were not deleted.
83+
- Confirmed targeted Playwright sign-in still resolves Supabase-backed auth/session through the local API with `GAMEFOUNDRY_DB_PROVIDER=local-db`.
84+
85+
## Playwright V8 Coverage
86+
87+
- Report: `docs_build/dev/reports/playwright_v8_coverage_report.txt`
88+
- Guardrail: `docs_build/dev/reports/coverage_changed_js_guardrail.txt`
89+
- Runtime JS changes were server/dev-runtime oriented and were not collected by browser V8 coverage; missing changed runtime JS coverage is WARN/advisory per project instructions.
90+
91+
## Required Artifacts
92+
93+
- `docs_build/dev/reports/PR_26166_165-auth-test-user-cleanup_report.md`
94+
- `docs_build/dev/reports/PR_26166_165-auth-test-user-cleanup_cleanup_report.md`
95+
- `docs_build/dev/reports/codex_review.diff`
96+
- `docs_build/dev/reports/codex_changed_files.txt`
97+
- `tmp/PR_26166_165-auth-test-user-cleanup_delta.zip`
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
# git status --short
2-
M docs_build/dev/codex_commands.md
2+
M docs_build/dev/codex_commands.md
33
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
4+
A docs_build/dev/reports/PR_26166_165-auth-test-user-cleanup_cleanup_report.md
5+
A docs_build/dev/reports/PR_26166_165-auth-test-user-cleanup_report.md
6+
M docs_build/dev/reports/coverage_changed_js_guardrail.txt
77
M docs_build/dev/reports/playwright_v8_coverage_report.txt
8-
M src/dev-runtime/server/local-api-router.mjs
8+
M package.json
9+
A scripts/cleanup-supabase-dev-auth-test-users.mjs
10+
M src/dev-runtime/auth/provider-contract-stubs.mjs
11+
A src/dev-runtime/testing/supabase-dev-auth-test-user-cleanup.mjs
12+
A tests/dev-runtime/SupabaseDevAuthTestUserCleanup.test.mjs
913
M tests/dev-runtime/SupabaseProviderContractStub.test.mjs
10-
A tests/playwright/account/SupabaseSignInSession.spec.mjs
1114

1215
# git ls-files --others --exclude-standard
1316
(no output)
1417

1518
# git diff --stat
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(-)
19+
docs_build/dev/codex_commands.md | 36 +++
20+
docs_build/dev/commit_comment.txt | 2 +-
21+
...66_165-auth-test-user-cleanup_cleanup_report.md | 67 +++++
22+
.../PR_26166_165-auth-test-user-cleanup_report.md | 97 ++++++++
23+
.../dev/reports/coverage_changed_js_guardrail.txt | 2 +
24+
.../dev/reports/playwright_v8_coverage_report.txt | 5 +
25+
package.json | 1 +
26+
scripts/cleanup-supabase-dev-auth-test-users.mjs | 110 +++++++++
27+
src/dev-runtime/auth/provider-contract-stubs.mjs | 84 +++++++
28+
.../supabase-dev-auth-test-user-cleanup.mjs | 232 ++++++++++++++++++
29+
.../SupabaseDevAuthTestUserCleanup.test.mjs | 272 +++++++++++++++++++++
30+
.../SupabaseProviderContractStub.test.mjs | 78 +++++-
31+
12 files changed, 983 insertions(+), 3 deletions(-)

0 commit comments

Comments
 (0)