Skip to content

refactor(relay): retire Clerk authentication compatibility - #1704

Draft
incognitojam wants to merge 7 commits into
mainfrom
styal/remove-clerk-relay
Draft

incognitojam wants to merge 7 commits into
mainfrom
styal/remove-clerk-relay

Conversation

@incognitojam

@incognitojam incognitojam commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Note

Draft: merging this PR to main is a production cutover. It automatically triggers the production relay deployment, then development; hosted web and mobile production pipelines also run. Keep this draft until all three owners have confirmed relay sessions on every device and server home, and the Fable review is complete. GUI Clerk removal has landed in #1703.

Clerk compatibility remains after email sign-in is live. This retires bearer verification, both legacy exchange routes, obsolete OAuth discovery, external user/email validation and deletion, the completed import tooling, and Clerk bindings/inputs in relay deployment workflows. It also removes server/CLI startup adoption, deferred here so #1703 cannot silently disconnect a headless server upgrading from a pre-email build. Stored accounts, ids, email mappings, relay sessions, mobile registrations and environment links remain. No relay database migration or schema is edited.

Situation Result
Current relay session and matching DPoP proof Continues with the same account, session and machines.
Clerk bearer credential Authentication fails.
Old signed access token without a relay session Authentication fails, even before its JWT expiry.
/v1/client/dpop-token or /v1/auth/clerk-exchange 404. Neither route is mounted.
Relay OAuth discovery Both well-known discovery routes return 404. The existing private JSON refresh API is unchanged.
Pre-email mobile/store binary or another Clerk-only client Cannot establish new authenticated control-plane connections. It needs an update and email sign-in. An already-open tunnel is not proof of conversion.
Transition build already converted to a relay session Works even if its binary still contains the Clerk SDK.
Account deletion / T3 Chat linking Uses relay account data only. T3 Chat's existing clerkUserId JSON field retains its protocol spelling and carries the stable relay id.

The accompanying client release performs one-time cleanup of named desktop Clerk token files, the mobile SecureStore client JWT, and same-origin Clerk browser storage. Relay credentials, proof keys and unrelated data remain. Failures retry. #1703 deliberately retains these old credentials for downgrade; deleting them here is not undone by reverting code. HttpOnly/cross-origin cookies require Clerk session retirement later.

No transition exchange contract or client adapter remains. The desktop cleanup runs in the SDK-free app-link startup; server refresh configuration, public build inputs, and the shared publishable-key helper are removed.

Validation: local HTTP tests accept a live account-scoped DPoP session and reject missing proof, wrong scope, revoked sessions, bearer credentials and a correctly signed sessionless legacy token. Both retired exchange routes return 404. Local HTTP composition also confirms both obsolete OAuth discovery routes return 404. Email verification keeps an imported account id; deletion still waits for successful environment teardown; T3 Chat uses the stored relay email and refuses a missing mapping. Cleanup tests cover exact-file deletion, symlink refusal, preservation of unrelated/current relay storage, retry after a locked keychain and idempotence. No production data, settings or credentials were accessed, no import was run, and no deployment was requested.

Merge-triggered deployments and publication:

  • deploy-relay.yml deploys production (prod) first, then shared development (dev) after production succeeds, subject to the existing environment approvals. Its path filter includes infra/relay, packages/client-runtime, packages/contracts, packages/shared, patches, the lockfile and root package/workspace/deployment files. refactor(auth): remove Clerk from styal clients #1703 also triggered a production relay deployment through these shared-path rules; a client-only title does not prevent one.
  • deploy-web.yml independently deploys the hosted production web app, because this PR changes apps/web and shared packages. It does not wait for the relay workflow.
  • mobile-eas-production.yml starts production mobile reconciliation. With its configured credentials, matching native runtimes can receive production OTAs; missing fingerprint/version builds can start iOS TestFlight and Android APK releases. Public App Store release remains manual.
  • Successful main Fork CI can feed automatic desktop/CLI nightly publication through fork-nightly.yml. Stable promotion remains manual. Main may also warm development-client and Android-preview caches.

Maintainer checklist (the detailed read-only SQL, scopes and rollback steps live in the existing operations runbook):

  1. Verify the released refactor(auth): remove Clerk from styal clients #1703 clients while relay compatibility remains. Each owner checks every browser profile, desktop install, store/nightly/spare mobile device and CLI/server home; use email sign-in and verify the same machines and Signed-in devices. A server and CLI sharing a home can share a session.
  2. Confirm aggregate account/email-mapping/session counts and the maintainer's own account's sessions and link count only. Ask friends to confirm their own data privately. Counts alone cannot establish that every device converted. Stop for a missing device, missing mapping or missing machines.
  3. Only then approve this relay merge/deploy. Review the production plan for Worker code and Clerk binding removal, with no data, queue, DNS or tunnel destruction. Smoke-test released clients and CLI, existing sessions, email login, relaunch and sign-out afterward.
  4. Keep the previous revision and its configuration through a chosen rollback window. Reverting before Clerk deletion can restore compatibility; it cannot undo client sign-outs. Choose how long to wait and whether an abandoned device is recovered or deliberately retired.
  5. After that window and all releases, delete the unused Clerk secrets/variables from the repository and production GitHub environment, remove local/EAS Clerk build settings, and confirm Worker bindings are gone. Delete only the styal Clerk application's production and development configuration/instances after confirming no other service uses them. Clerk deletion is irreversible and goes last; keep relay signing keys, email, database, Cloudflare and push credentials. The two previously noted secret rotations still require identification and a separate reviewed plan.

Upstream still uses Clerk at 1ffa099e7fbf0037dbffb6fb72b7585c933be24a. The fork ledger and user overview record the difference; intake must discard upstream bearer verification, exchange handlers, Clerk directory/import tooling and relay bindings.


Written by codex/gpt-6.1-sol, reviewed by codex/gpt-6-astra, in styal 🧵.

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Upstream divergence

Both sides are compared with upstream at the in-order tip 9f4b42e750. Excludes .repos/ and pnpm-lock.yaml.

Measure Base This PR Change
Upstream files the fork changes 2,360 2,358 −2
Lines changed in them 167,672 168,012 +340
Upstream files the fork removes 92 94 +2
Fork-only files 1,052 1,049 −3
Fork-only lines 192,554 190,406 −2,148
Upstream files whose difference changes (40)
File Change Now differs by
packages/shared/src/relayAuth.ts +78 89 lines
infra/relay/src/http/Api.test.ts +70 90 lines
docs/operations/connect-setup.md +67 248 lines
apps/server/src/cloud/publicConfig.ts +48 94 lines
packages/shared/src/relayAuth.test.ts +48 52 lines
packages/contracts/src/relay.ts +38 400 lines
infra/relay/src/t3chat/T3ChatAccounts.ts +27 41 lines
infra/relay/src/t3chat/T3ChatAccounts.test.ts +22 51 lines
apps/server/src/cloud/publicConfig.test.ts +14 43 lines
infra/relay/src/http/Api.ts +13 649 lines
apps/desktop/src/app/DesktopAppLinks.ts +10 132 lines
.github/workflows/relay-preview-cleanup.yml +6 28 lines
apps/server/vite.config.ts +6 54 lines
docs/internals/t3-connect.md −6 58 lines
scripts/lib/public-config.test.ts −6 31 lines
apps/server/src/server.ts −5 282 lines
pnpm-workspace.yaml +4 64 lines
.github/workflows/relay-preview.yml +3 15 lines
infra/relay/README.md +3 108 lines
infra/relay/scripts/android-push-smoke.ts +3 4 lines
infra/relay/scripts/android-push-watch.ts +3 4 lines
infra/relay/src/Config.ts +3 140 lines
infra/relay/src/agentActivity/ApnsDeliveries.test.ts +3 216 lines
infra/relay/src/agentActivity/ApnsDeliveryQueue.test.ts +3 4 lines
infra/relay/src/agentActivity/FcmClient.test.ts +3 4 lines
…and 15 more

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Baseline: e9b1d58 · PR result: 1fe0a3a · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@incognitojam
incognitojam force-pushed the styal/remove-clerk-relay branch 2 times, most recently from e3c0d5a to 71a8bd0 Compare November 22, 2026 22:26
@incognitojam
incognitojam force-pushed the styal/remove-clerk-relay branch from e14170b to 1fe0a3a Compare November 23, 2026 02:31
@incognitojam incognitojam added the preview:android Build an installable Android APK for this PR on every push. label Nov 23, 2026
@github-actions

Copy link
Copy Markdown

Android preview

Download APK

Version: 2.3.0-pr.1704.1658
Commit: 1fe0a3a

Installs as styal Preview, beside the styal app, on arm64 phones. Android will not install an older preview over a newer one, so uninstall styal Preview first when switching back to an earlier build. Push notifications are not set up in preview builds.

No GitHub sign-in is needed. The download stays available until this PR closes or the preview label is removed.

This branch was successfully deployed

1 active deployment
android-preview — 1fe0a3a6 Deployed Nov 23, 2026 by incognitojam via Sign and publish the APK #1658
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview:android Build an installable Android APK for this PR on every push. size:XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant