Repository navigation
feat(cloud): enable the fork-owned Connect relay and release config - #476
Merged
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
…reflight Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Problem
The vendored Connect relay (
infra/relay) unconditionally refused deployment, release workflows could not wire fork-owned Connect configuration (including the fork's pinnedT3CODE_CLOUD_MINT_PUBLIC_KEY) into desktop and CLI builds, and client/server code paths still assumed a hosted web origin or upstream PlanetScale/Axiom accounts.How this fixes it
infra/relay/alchemy.run.tswithassertForkRelayDeploymentEnv(infra/relay/src/forkOwnership.ts), running beforeAlchemy.Stackconstructs providers or state: pinsCLOUDFLARE_ACCOUNT_IDonCloudflare.state({ accountId }), rejects upstream domains and RFC 2606 placeholders (example.com,.example,.invalid,.test), validatesCLERK_PUBLISHABLE_KEY, and fails closed if neither external Postgres (RELAY_DB_HOST) nor PlanetScale (PLANETSCALE_ORGANIZATION) is configured.CloudMintKeyPairfrominfra/relay/src/worker.ts, includedcloudMintPublicKeyin stack outputs, and updatedPublishClientConfig(infra/relay/src/clientConfig.ts) to write single-line\n-escapedT3CODE_CLOUD_MINT_PUBLIC_KEY.infra/relay/src/db.ts/dbConfig.ts(RELAY_DB_CLUSTER_SIZEdefaultPS_5,RELAY_DB_REPLICASdefault0instead ofPS_160/ 2 replicas) and added external Postgres mode selected byRELAY_DB_HOSTsupporting both Cloudflare Access + Tunnel (AccessOrigin) and public (PublicOrigin) Hyperdrive origins with configurableRELAY_DB_CONNECTION_LIMIT(default20for external,40for PlanetScale). External mode fails clearly on non-prodstages.infra/relay/src/postgresMigrations.ts,infra/relay/scripts/migrate-postgres.ts,vp run --filter t3code-relay migrate:postgres) writing the exactrelay_migrationsschema and SHA-256 bookkeeping so databases stay portable between external Postgres and PlanetScale.AXIOM_TOKENis unset, no Axiom datasets/tokens/views/monitors or mobile source-map R2 bucket/credentials are created (infra/relay/src/observability.ts,alchemy.run.ts,worker.ts), mobile observe routes respond503 mobile_telemetry_not_configured(MobileTelemetry.layerDisabled), andPublishClientConfigwrites onlyT3CODE_RELAY_URLandT3CODE_CLOUD_MINT_PUBLIC_KEY.Alchemy.Telemetry.layerOtlpwhenRELAY_OTLP_TRACES_URL(and optionalRELAY_OTLP_TRACES_TOKEN) is configured. WithAXIOM_TOKENset, upstream Axiom behavior stays intact..github/workflows/deploy-relay.ymlforshuv1337/s2coderefs/heads/mainonubuntu-24.04insideenvironment: productionwithconcurrency(cancel-in-progress: false), path-filteredpush(skipping cleanly whilevars.RELAY_API_ZONE_NAMEis empty), external Postgres migration step overcloudflared access tcpbefore deploy,APNS_ENABLEDdefaulting tofalse, no APNs/FCM/T3Chat secrets, and a final step writing only publicT3CODE_RELAY_URLand single-lineT3CODE_CLOUD_MINT_PUBLIC_KEYto$GITHUB_STEP_SUMMARY..github/workflows/relay-preview.ymland.github/workflows/relay-preview-cleanup.ymlongithub.repository == 'shuv1337/s2code' && vars.RELAY_PREVIEWS_ENABLED == 'true'..github/workflows/web-preview.ymlremains notice-only.release.yml(preflight,build_bundle, and all fourrelease-desktop.ymlcallers),release-desktop.yml(newcloud_mint_public_keyandhosted_app_urlinputs for CLIbuild-exe), andencrypted-windows-build.yml, without enteringenvironment: production.CLOUD_MINT_PUBLIC_KEYtoPUBLIC_CONFIG_KEYS(packages/shared/src/productIdentity.ts) and mappedT3CODE_CLOUD_MINT_PUBLIC_KEY+T3CODE_HOSTED_APP_URL->VITE_HOSTED_APP_URLinscripts/lib/public-config.ts.hasCloudPublicConfig(apps/server/src/cloud/publicConfig.ts) to require a pinned mint public key instead ofT3CODE_HOSTED_APP_URL, and updatedauthorizeCli(apps/server/src/cli/connect.ts) to fall back to Clerk's device-authorization flow when no hosted app URL is configured.scripts/build-desktop-artifact.ts) onT3CODE_MACOS_PROVISIONING_PROFILEorT3CODE_CLERK_PASSKEY_RP_DOMAINSso signed macOS builds withT3CODE_CLERK_PUBLISHABLE_KEYdo not fail without a provisioning profile.HOSTED_UNAVAILABLE_MESSAGE,binCli.ts), added browser-origin guidance on web when apk_live_build runs on a private origin (SavedEnvironmentRows.tsx+ all 10 locale catalogs), and updateddocs/operations/hosted-fork.md,docs/operations/connect-setup.md,infra/relay/.env.example, and.env.example.What stays off
web-preview.ymlstays notice-only), relay PR previews (RELAY_PREVIEWS_ENABLEDunset), APNs/FCM push (APNS_ENABLED=false), T3 Chat account linking, mobile store builds, and Axiom paging monitors remain off.Operator variables and secrets
GitHub Environment:
production(used only bydeploy-relay.yml)CLOUDFLARE_API_TOKEN,CLERK_SECRET_KEYCLOUDFLARE_ACCOUNT_ID,RELAY_API_ZONE_NAME(also set as a repository variable to enable path-filteredpushdeploys onmain; keeping it only inproductionrestricts deploys toworkflow_dispatch),RELAY_TUNNEL_ZONE_NAME,CLERK_PUBLISHABLE_KEY,CLERK_JWT_AUDIENCE(t3-code-relay), optionalRELAY_DOMAIN,APNS_ENABLED(false),RELAY_TUNNEL_CLEANUP_MODE,RELAY_LEGACY_TUNNEL_CLEANUP_MODERELAY_DB_HOSTis set):RELAY_DB_HOST,RELAY_DB_NAME,RELAY_DB_USER, optionalRELAY_DB_PORT(public origin only), optionalRELAY_DB_CONNECTION_LIMIT(default20)RELAY_DB_PASSWORD, plusRELAY_DB_ACCESS_CLIENT_IDandRELAY_DB_ACCESS_CLIENT_SECRET(both set for Cloudflare Tunnel + AccessAccessOrigin, or both unset forPublicOrigin)AXIOM_TOKENis unset): variableRELAY_OTLP_TRACES_URL, optional secretRELAY_OTLP_TRACES_TOKENPLANETSCALE_ORGANIZATION,RELAY_DB_CLUSTER_SIZE(defaultPS_5),RELAY_DB_REPLICAS(default0),AXIOM_ORG_ID; secretsPLANETSCALE_API_TOKEN_ID,PLANETSCALE_API_TOKEN,AXIOM_TOKENGitHub Repository Variables (public build config read by
release.ymlandencrypted-windows-build.yml)Validated all-or-nothing (all five required, or all unset for cloudless builds):
T3CODE_RELAY_URLT3CODE_CLOUD_MINT_PUBLIC_KEY(single-line\n-escaped PEM from thedeploy-relay.ymlsummary)T3CODE_CLERK_PUBLISHABLE_KEYT3CODE_CLERK_JWT_TEMPLATE(t3-relay)T3CODE_CLERK_CLI_OAUTH_CLIENT_IDT3CODE_HOSTED_APP_URL(optional)Refs #331
Rat-stack pages followed
ratstack://lore/testing-ladderratstack://skills/security-auditratstack://lore/agent-source-first-workflowratstack://skills/learn-alchemyVerification
nice -n 19 vp test run --maxWorkers=4across 14 changed test files, including PGlite migration tests): 14/14 files, 213/213 tests passed.node --test .github/scripts/encrypted-windows-delivery.test.cjs): 7/7 passed.vp run i18n:check): passed forapps/web,apps/mobile,apps/desktop.t3code-relay,@t3tools/shared,t3,@t3tools/web,@t3tools/scripts): 5/5 passed.nice -n 19 node scripts/check-changed.ts --concurrency 2: passed (unused patches,format,lint,knip 1/2,knip 2/2,graphql,typecheck43/43,test18 files / 234 tests,react compiler2 files).Implemented by
gemini-4-neon(Cursor harness via T3 Code).