Skip to content

Commit 1e1a62b

Browse files
committed
Sync DEV Creator identities and remove duplicate test accounts - PR_26167_185-dev-creator-identity-seed-sync
1 parent ca49623 commit 1e1a62b

52 files changed

Lines changed: 121196 additions & 117269 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs_build/database/dml/DML_INDEX.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
This index classifies each grouped DEV/review DML file.
44

5-
Direct SQL setup is intentionally narrow. Account DEV users are SQL-executable so local sign-in scripts can target stable seeded users. Non-user setup is server-seed-owned so direct SQL does not bypass server/API key generation or audit ownership.
5+
Direct SQL setup is intentionally narrow. Account DEV users now require server-side Supabase Auth synchronization so `users.authProviderUserId` matches real `auth.users.id` values. Non-user setup is server-seed-owned so direct SQL does not bypass server/API key generation or audit ownership.
66

77
| Group | File | Status | Owner |
88
| --- | --- | --- | --- |
9-
| Account | `account.sql` | SQL-executable | DEV static user seed only |
9+
| Account | `account.sql` | Review-only | DEV static user shape; execute through server-side sync only |
1010
| Admin | `admin.sql` | Server-seed-owned | Admin Site Setup/server-side seed API |
1111
| Asset | `asset.sql` | Server-seed-owned | Server-side seed API |
1212
| Controls | `controls.sql` | Server-seed-owned | Server-side seed API |
@@ -29,7 +29,7 @@ Static ULIDs are allowed only for these DEV user records and required user-role
2929
- User 1
3030
- User 2
3131
- User 3
32-
- DavidQ admin
32+
- DavidQ
3333

3434
All non-user records must use server/API-generated ULID-style keys.
3535

docs_build/database/dml/account.sql

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
-- Group: Account
33
-- Ownership: docs_build/database/dml/account.sql
44
-- DEV review only. Codex may execute DEV database setup only.
5-
-- DML status: SQL-executable DEV static user seed.
5+
-- DML status: review-only DEV static user shape.
66
-- UAT and production SQL execution is user-controlled.
77
-- Runtime reseed/setup must be called through Admin-owned server-side APIs.
8+
-- Supabase Auth identity sync must use scripts/sync-supabase-dev-creator-identities.mjs.
89
-- Target DEV database: gamefoundry_dev
910
-- Temporary DEV static user ULID exception:
10-
-- Static ULIDs are allowed only for User 1, User 2, User 3, and DavidQ admin.
11+
-- Static ULIDs are allowed only for User 1, User 2, User 3, and DavidQ.
1112
-- Static ULIDs are allowed for user_roles only to bind these DEV users to existing roles.
1213
-- Non-user records, including roles, must use real server/API-generated keys.
1314
-- No passwords, password hashes, password reset tokens, or authProvider='mock' records are defined here.
15+
-- authProviderUserId values must be replaced by the server-side sync with real auth.users.id values before runtime validation.
1416

1517
INSERT INTO users (
1618
key,
@@ -29,7 +31,7 @@ VALUES
2931
'01K2GFSJ0Y0000000000000051',
3032
'User 1',
3133
'user1@example.invalid',
32-
'dev-static-seed',
34+
'supabase-auth',
3335
'user-1',
3436
true,
3537
now(),
@@ -41,7 +43,7 @@ VALUES
4143
'01K2GFSJ0Y0000000000000052',
4244
'User 2',
4345
'user2@example.invalid',
44-
'dev-static-seed',
46+
'supabase-auth',
4547
'user-2',
4648
true,
4749
now(),
@@ -53,7 +55,7 @@ VALUES
5355
'01K2GFSJ0Y0000000000000053',
5456
'User 3',
5557
'user3@example.invalid',
56-
'dev-static-seed',
58+
'supabase-auth',
5759
'user-3',
5860
true,
5961
now(),
@@ -63,10 +65,10 @@ VALUES
6365
),
6466
(
6567
'01K2GFSJ0Y0000000000000054',
66-
'DavidQ admin',
67-
'admin@example.invalid',
68-
'dev-static-seed',
69-
'davidq-admin',
68+
'DavidQ',
69+
'qbytes.dq@gmail.com',
70+
'supabase-auth',
71+
'davidq',
7072
true,
7173
now(),
7274
now(),
@@ -92,8 +94,7 @@ BEGIN
9294
VALUES
9395
('admin'),
9496
('creator'),
95-
('guest'),
96-
('user')
97+
('guest')
9798
) AS required_roles(role_slug)
9899
LEFT JOIN roles ON roles."roleSlug" = required_roles.role_slug
99100
WHERE roles.key IS NULL;
@@ -105,11 +106,10 @@ END $$;
105106

106107
WITH user_role_seed (user_role_key, user_key, role_slug) AS (
107108
VALUES
108-
('01K2GFSJ0Y0000000000000082', '01K2GFSJ0Y0000000000000051', 'user'),
109-
('01K2GFSJ0Y0000000000000083', '01K2GFSJ0Y0000000000000052', 'user'),
110-
('01K2GFSJ0Y0000000000000084', '01K2GFSJ0Y0000000000000053', 'user'),
111-
('01K2GFSJ0Y0000000000000085', '01K2GFSJ0Y0000000000000054', 'user'),
112-
('01K2GFSJ0Y0000000000000086', '01K2GFSJ0Y0000000000000054', 'admin')
109+
('01K2GFSJ0Y0000000000000082', '01K2GFSJ0Y0000000000000051', 'creator'),
110+
('01K2GFSJ0Y0000000000000083', '01K2GFSJ0Y0000000000000052', 'creator'),
111+
('01K2GFSJ0Y0000000000000084', '01K2GFSJ0Y0000000000000053', 'creator'),
112+
('01K2GFSJ0Y0000000000000085', '01K2GFSJ0Y0000000000000054', 'creator')
113113
),
114114
resolved_user_roles AS (
115115
SELECT

docs_build/database/seed/account.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@
2121
"key": "01K2GFSJ0Y0000000000000053"
2222
},
2323
{
24-
"displayName": "DavidQ admin",
24+
"displayName": "DavidQ",
2525
"key": "01K2GFSJ0Y0000000000000054"
2626
}
2727
],
2828
"staticUserRoleKeysAllowedOnlyFor": [
2929
"01K2GFSJ0Y0000000000000082",
3030
"01K2GFSJ0Y0000000000000083",
3131
"01K2GFSJ0Y0000000000000084",
32-
"01K2GFSJ0Y0000000000000085",
33-
"01K2GFSJ0Y0000000000000086"
32+
"01K2GFSJ0Y0000000000000085"
3433
]
3534
},
3635
"tables": {
3736
"users": {
3837
"mode": "server-side-upsert",
39-
"authProvider": "dev-static-seed",
38+
"authProvider": "supabase-auth",
4039
"passwordStorage": "none"
4140
},
4241
"roles": {
4342
"mode": "server-api-generated-keys",
44-
"requiredRoleSlugs": ["admin", "creator", "guest", "user"]
43+
"requiredRoleSlugs": ["admin", "creator", "guest"],
44+
"deprecatedRoleSlugs": ["user"]
4545
},
4646
"user_roles": {
4747
"mode": "server-side-upsert",
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Supabase DEV Identity Bootstrap
22

3-
Use this only for the DEV Supabase project while product data remains on Local DB.
3+
Use this only for the DEV Supabase project. Identity seeding is server-side only so app `users.authProviderUserId` values stay synchronized with real Supabase Auth `auth.users.id` values.
44

55
## Bootstrap Order
66

@@ -11,24 +11,29 @@ Use this only for the DEV Supabase project while product data remains on Local D
1111
- `users table`
1212
- `roles table`
1313
- `user_roles table`
14-
4. Keep `GAMEFOUNDRY_DB_PROVIDER=local-db`.
14+
4. Run `node .\scripts\sync-supabase-dev-creator-identities.mjs` against DEV only.
1515

1616
## Seed Rules
1717

1818
- Passwords remain owned by Supabase Auth.
1919
- Do not create password tables.
2020
- Browser JavaScript must not generate authoritative identity keys.
2121
- Create Account provisions app `users`, `roles`, and `user_roles` records server-side.
22+
- Static DEV identity sync provisions only User 1, User 2, User 3, and DavidQ.
23+
- Authenticated users receive the `creator` role by default.
24+
- The `guest` role remains for unauthenticated browsing.
25+
- The `admin` role is preserved only for actual admin assignments.
26+
- The legacy `user` role is deprecated and inactive.
2227
- Static DEV user ULIDs are allowed only for these DEV seed users:
2328
- User 1: `01K2GFSJ0Y0000000000000051`
2429
- User 2: `01K2GFSJ0Y0000000000000052`
2530
- User 3: `01K2GFSJ0Y0000000000000053`
26-
- DavidQ admin: `01K2GFSJ0Y0000000000000054`
31+
- DavidQ: `01K2GFSJ0Y0000000000000054`
2732
- Do not use static keys for games, assets, objects, controls, votes, tickets, tool metadata, tool planning, tool state records, guest seed data, roles, or user_roles.
2833
- Do not use `authProvider: mock` for Supabase account identity records.
2934

3035
## Existing Auth Users
3136

3237
For existing DEV Supabase Auth users, provision app identity through the server/API provisioning path so the `users.authProviderUserId` value matches the real Supabase Auth user id.
3338

34-
Do not commit Supabase Auth user ids, access tokens, service role keys, or database URLs.
39+
Do not commit Supabase Auth user ids, access tokens, service role keys, database URLs, or DEV identity passwords in reports.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# PR_26167_185-dev-creator-identity-seed-sync
2+
3+
## Overall Result
4+
5+
FAIL / blocked.
6+
7+
The implementation was prepared and targeted validation passed, but the live DEV seed/sync could not complete because Supabase Auth rejected the requested User 1/User 2/User 3 password values as shorter than the project minimum password length. Supabase returned HTTP 422: password must be at least 6 characters. Supabase settings were not changed.
8+
9+
## Branch Validation
10+
11+
PASS - current branch was `main` before changes.
12+
13+
## Requirement Checklist
14+
15+
- PASS - Read `docs_build/dev/PROJECT_INSTRUCTIONS.md` first.
16+
- PASS - Hard stop branch check passed on `main`.
17+
- PASS - DEV-only sync path added under server-side scripts/runtime testing code.
18+
- FAIL - Requested User 1/User 2/User 3 passwords could not be applied; Supabase Auth rejected the requested short values.
19+
- PASS - DavidQ seed name is `DavidQ`, not `DavidQ admin`.
20+
- PASS - DavidQ is not statically seeded as admin; explicit existing admin assignments are preserved when present.
21+
- FAIL - Extra codex/qbytes DEV accounts were identified but not deleted because the live sync hard-stopped before cleanup.
22+
- FAIL - Auth users and `public.users` were not fully synced in DEV because the live sync failed.
23+
- PASS - `authProvider="supabase-auth"` and real `auth.users.id` sync behavior is implemented in the server-side sync path.
24+
- PASS - `creator` is the default authenticated Creator role in seed data and create-account provisioning.
25+
- PASS - `guest` remains available for unauthenticated browsing.
26+
- PASS - `admin` is retained only as an explicit assignment.
27+
- PASS - `roleSlug=user` is marked inactive/deprecated in seed data.
28+
- PASS - Dev-static seed docs/data and server-side seed/setup scripts were updated.
29+
- PASS - Seeding remains server-side only.
30+
- PASS - No SQLite/local-db fallback was added.
31+
- PASS - No browser-owned user records were added.
32+
- PASS - Startup wording reports configured account/product-data connections; script name retained as legacy command naming only.
33+
34+
## Before/After Identity Counts
35+
36+
Live sync hard-stopped before mutation. A dry-run snapshot after the failed attempt reported:
37+
38+
| Count | Before | After Dry Run |
39+
| --- | ---: | ---: |
40+
| Supabase Auth users | 12 | 12 |
41+
| `public.users` rows | 12 | 12 |
42+
| Canonical Auth identities | 2 | 2 |
43+
| Canonical `public.users` identities | 3 | 3 |
44+
| Managed extra Auth identities | 10 | 10 |
45+
| Managed extra `public.users` identities | 8 | 8 |
46+
47+
Actual created records: 0.
48+
49+
Actual deleted records: 0.
50+
51+
## Deleted DEV Account List
52+
53+
No live deletions were performed because the sync failed before cleanup.
54+
55+
Dry-run cleanup candidates identified:
56+
57+
- `codex-pr162-1781561056924-35f5412b0f339@example.com`
58+
- `codex-pr162-1781561106580-fe3f2462707fc@example.com`
59+
- `codex-pr163-repeat-1781562780241-ccbc9d07d9f97@example.com`
60+
- `codex-pr163-success-1781562780241-ccbc9d07d9f97@example.com`
61+
- `codex-pr156-missing-identity-1781555713293-c32794@example.test`
62+
- `codex-pr156-admin-probe-1781554902135-23gra6@example.com`
63+
- `qbytes.dq1@gmail.com`
64+
- `qbytes.dq2@gmail.com`
65+
- `qbytes.dq3@gmail.com`
66+
- `qbytes.dq4@gmail.com`
67+
68+
## Auth/Public Users Sync Evidence
69+
70+
Dry-run verification, with Auth IDs omitted:
71+
72+
- `user1@example.invalid`: Auth present, `public.users` present, not synced to real Auth ID yet.
73+
- `user2@example.invalid`: Auth missing, `public.users` present.
74+
- `user3@example.invalid`: Auth missing, `public.users` present.
75+
- `qbytes.dq@gmail.com`: Auth present, `public.users` missing.
76+
77+
Creator role assignments were not present for the four canonical identities in live DEV at dry-run time.
78+
79+
## Validation Lane Report
80+
81+
- PASS - `node --check` for changed JS/MJS files.
82+
- FAIL - `node .\scripts\validate-supabase-dev.mjs`; local TLS trust failed with `UNABLE_TO_VERIFY_LEAF_SIGNATURE` / `SELF_SIGNED_CERT_IN_CHAIN`.
83+
- PASS - `npm run validate:supabase-dev`; REST/API readiness passed, direct PostgreSQL TLS warning remained advisory.
84+
- FAIL - `node --use-system-ca .\scripts\sync-supabase-dev-creator-identities.mjs --json`; Supabase Auth HTTP 422 for requested short passwords.
85+
- PASS - `node --use-system-ca .\scripts\sync-supabase-dev-creator-identities.mjs --dry-run --json`.
86+
- PASS - `node --test tests/dev-runtime/SupabaseDevCreatorIdentitySeedSync.test.mjs`.
87+
- PASS - `node --test tests/dev-runtime/SupabaseProductDataCutover.test.mjs`.
88+
- PASS - Targeted provider contract tests for Auth admin methods, auth routes, create-account provisioning, and Supabase session/product read path.
89+
- TIMEOUT - Full `node --test tests/dev-runtime/SupabaseProviderContractStub.test.mjs` did not complete within 240 seconds; targeted changed cases passed.
90+
- PASS - `npm run dev:local-api` startup check on port 55185 returned HTTP 200 for `/api/auth/status`; startup logs contained no SQLite/local-db/provider-selection wording.
91+
- PASS - `npx playwright test tests/playwright/account/SupabaseSignInSession.spec.mjs --project=playwright --workers=1 --reporter=list`.
92+
- PASS - `npm run test:workspace-v2`.
93+
94+
Playwright V8 coverage report: `docs_build/dev/reports/playwright_v8_coverage_report.txt`.
95+
96+
## Manual Validation Notes
97+
98+
- Live DEV sign-in with the requested canonical short passwords was not validated because Supabase Auth rejected those passwords before sync completed.
99+
- No UAT/PROD resources were touched.
100+
- No `.env.local` or secret files were changed.
101+
- No password values are recorded in this report.
102+
- Startup command remains `scripts/start-local-api-server.mjs`; report and logs treat that as legacy command naming only.

0 commit comments

Comments
 (0)