Convex Environments
Event intake adapter configuration
Deploy the web adapters and same-branch Convex intake commands together. Web
requires CONVEX_URL or NEXT_PUBLIC_CONVEX_URL and its existing server-only
CONVEX_ADMIN_TOKEN, CONVEX_DEPLOY_KEY, or CONVEX_SELF_HOSTED_ADMIN_KEY.
Operators own these credentials; recreate or rotate them using the target's
Convex deployment settings and replace the web secret before revoking the old
value. Do not expose an admin credential to MCP clients.
Personal-token validation retains VRDEX_API_TOKEN_PEPPER; hosted OAuth retains
VRDEX_OAUTH_ACCESS_TOKEN_SIGNING_KEY and VRDEX_OAUTH_ACCESS_TOKEN_SIGNING_KID.
The deployment operator maintains and rotates these through the existing API
and OAuth secret configuration. Event contribution adds no separate secret or
verified-email requirement.
Poster operations use the existing private S3 bucket, region, and IAM role.
The local MCP bytes helper additionally requires the non-secret
VRDEX_EVENT_POSTER_UPLOAD_ORIGIN, set to that deployment's exact HTTPS upload
origin. It accepts explicit image bytes, never a path or remote source URL, and
refuses redirects or an origin mismatch.
OPENAI_API_KEY, VRDEX_EVENT_INTAKE_AI_ENABLED, and VRDEX_EVENT_INTAKE_MODEL
settings belong to the web server, and to Convex for Discord intake runs; spam
settings belong to Convex. Both model
paths remain off by default. The private cleanup worker needs its existing
VRDEX_MEDIA_CLEANUP_TOKEN on both ends. Exact defaults, ownership, retention,
and secret recreation are documented in
event intake sources. Self-hosters can
save, edit, and publish manually without model credentials or poster storage.
Event intake tracing uses three Langfuse variables:
LANGFUSE_PUBLIC_KEYLANGFUSE_SECRET_KEY(secret)LANGFUSE_BASE_URL(optional, defaults to Langfuse Cloud)
Scope: the Convex deployment (set with convex env set) and the web app
(Vercel Terraform variables langfuse_public_key, langfuse_secret_key, and
langfuse_base_url in infra/terraform/vercel). Owner: BASIC. Rotation: create
a new key pair in the Langfuse project settings, set it on both, then revoke the
old pair. Missing keys disable tracing and never fail an extraction.
Each extraction run that reaches the model (extraction enabled and
OPENAI_API_KEY set) also records an event_intake_run event. It reaches PostHog
through productAnalyticsOutbox with the existing POSTHOG_PROJECT_API_KEY;
no new PostHog variable is needed.
No hosted write, deployment, migration, model call, or production storage test is implied by the local adapter tests.
Event intake staged release checks
- Deploy the widened schedule schema/indexes and same-branch web/backend adapters with extraction disabled and spam mode off. Keep contribution entry unavailable until the target is ready. There is no dedicated global contribution kill switch in this slice; a deployment rollback or route-level operational restriction must be planned separately from the model switches.
- Run
eventScheduleMigration:backfillin bounded pages, persisting each returned phase/cursor untildone. Replays are safe. Verify indexes are ready, then setEVENT_DATE_ONLY_ENABLED=true. Run timed and date-only public URL, search, community, person/world, ICS, Discord and no-watch checks on that target. - Verify signed-in contribution without staff/email verification and user-scoped
events:contributecredentials. Confirmevents:writestill enforces community authority, stale updates fail, staff takeover locks the contributor, and removal hides public projections. Use deliberately approved staging event data. - Before poster intake, verify the private bucket/CORS/signing origin, upload completion and expiry, private reads, separate artwork choice and deletion worker. Exercise report holds and expired/pending artwork cleanup, including a late storage write. Local fake-storage tests do not establish hosted behavior.
- Keep
VRDEX_EVENT_INTAKE_AI_ENABLED=falseandVRDEX_EVENT_SPAM_MODE=offuntil a consented provider evaluation has measured quality, false matches/blocks, latency, tokens and cost. Set blocking threshold/baseline only after review. Extraction has six turns, five read-only tool calls, 6,000 output tokens per turn and a 20-second timeout per provider request. Classification caps output at 300 tokens. The shared actor allowance is 20 model attempts per rolling day. These caps bound calls. Cost comes from the agent's model price table and isnullonly for unpriced models.
For incident response, disable extraction and/or set spam mode off independently;
manual publication remains available under deterministic preflight. Do not turn
EVENT_DATE_ONLY_ENABLED off after publishing date-only rows without first
restricting new contribution writes and checking how legacy listings will hide
existing date-only rows. Source retention/cleanup must continue during model
shutdown. None of these deployment steps was executed by the local checkpoint.
See source controls and
verification evidence.
Event connectors
VRDEX_EVENT_CONNECTORS_ENABLED turns event connectors on when set to true.
Scope: the Convex deployment environment only. Default: unset, which means off.
Owner: BASIC. It gates the Integrations page, connector creation,
enqueueEventSync, and sync job execution. Turning it off leaves pending jobs in
place; each closes as connectors_disabled when its run claims it. Each kind
also needs its own sync handler: Google Calendar registers one behind
VRDEX_CONNECTOR_GOOGLE_CALENDAR_ENABLED (below). A connector of a kind with no
handler fails every export job and fires the connector failure alarm.
VRDEX_CONNECTOR_VRCHAT_CALENDAR_ENABLED turns the VRChat calendar connector
kind on when set to true. Scope: the Convex deployment environment only.
Default: unset, which means off. Owner: BASIC. Non-secret; rotation does not
apply. While it is off, the Integrations page hides the Connect control and the
group's Calendar feature toggle (the stored feature is untouched), connector
creation throws CONNECTOR_UNAVAILABLE, polls are not enqueued, VRChat calendar
sync jobs fail with CONNECTOR_KIND_DISABLED and enqueue no club operations, and
operations already queued are rejected with connector_inactive. Enable it only after
the collector release-readiness check shows a collector running the worker that
executes calendar operations.
VRDEX_CONNECTOR_DISCORD_BOARD_ENABLED turns on the Discord event board when
set to true: Discord board jobs, the daily board refresh, and the board
Connect button. Scope: the Convex deployment environment only. Default: unset,
which means off; board jobs then fail with CONNECTOR_KIND_DISABLED. It also
needs VRDEX_EVENT_CONNECTORS_ENABLED, DISCORD_BOT_TOKEN, and SITE_URL.
Owner: the deployment operator (BASIC). Not a secret; recreate it with
npx convex env set, and roll back by setting it to false. Pause or
disconnect existing boards first: while it is false, their queued jobs fail
toward the five-failure connector alarm.
VRDEX_CONNECTOR_DISCORD_SCHEDULED_EVENTS_ENABLED: true enables Discord
scheduled event jobs, the relay of scheduled event changes into import jobs,
the daily reconcile, and the Connect button. Scope: the Convex deployment
environment only. Default off: the relay enqueues nothing and scheduled event
jobs fail with CONNECTOR_KIND_DISABLED. Also needs
VRDEX_EVENT_CONNECTORS_ENABLED, DISCORD_BOT_TOKEN, and SITE_URL; the relay
also needs VRDEX_DISCORD_INTAKE_ENABLED. Owner: deployment operator (BASIC).
No secret; recreate it with npx convex env set, and roll back by setting it
to false. Pause or disconnect existing connectors first: while it is false,
their queued jobs fail toward the five-failure connector alarm.
Connector OAuth tokens are stored encrypted with AES-256-GCM in the
v1:iv:tag:ciphertext format, keyed by VRDEX_CONNECTOR_TOKEN_KEY (secret).
Scope: the Convex deployment environment only; never set it on the web app.
Owner: the deployment operator (BASIC). Value: 32 random bytes, base64 encoded,
generated with openssl rand -base64 32 and set with
npx convex env set VRDEX_CONNECTOR_TOKEN_KEY. The value lives only in the
Convex environment, never in git or Terraform state.
Rotation: replacing the value makes every stored connector token unreadable, so
each OAuth connector must be disconnected and connected again from the
Integrations page; Reconnect only shows on a connector in needs_reauth, and
these stay active. The same key signs Google Calendar watch channels, so
existing channels stop authenticating until the new connection opens one. The
v1: prefix leaves room for a dual-key rotation later.
Google Calendar connector
VRDEX_CONNECTOR_GOOGLE_CALENDAR_ENABLED turns the Google Calendar connector on
when set to true, together with VRDEX_EVENT_CONNECTORS_ENABLED. Scope: the
Convex deployment environment only. Default: unset, which means off. Owner:
BASIC. Pause or disconnect every Google Calendar connector before turning it
off: with live connectors their jobs fail and the connector failure alarm fires.
Crons, all inert with either flag off: a 15-minute poll, a daily watch renewal,
and a daily sweep. The sweep queues a reconcile for each active importing
connector, which moves the 60-day recurring import window forward, and marks
revoked any Google credential over a day old with no live connector, which is
what an abandoned Connect leaves. Disconnecting the last connector on a
credential revokes it the same way. Revoking is local: the grant stays live at
Google until the organiser removes it there.
GOOGLE_CONNECTOR_CLIENT_ID and GOOGLE_CONNECTOR_CLIENT_SECRET (secret) are
VRDex's Google OAuth client. Scope: both the Convex deployment (token refresh)
and the web app (the code exchange in /api/connectors/google/callback). Owner:
BASIC, who owns the OAuth client in Google Cloud. Set them on Convex with
npx convex env set, on both the production and the shared development
deployment, and on Vercel through the TERRAFORM_GOOGLE_CONNECTOR_CLIENT_ID
and TERRAFORM_GOOGLE_CONNECTOR_CLIENT_SECRET GitHub secrets, which the
Terraform workflow passes to infra/terraform/vercel.
Rotation: add a new client secret to the OAuth client in the Google Cloud
console, set it on Convex, update the GitHub secret and run the Terraform
workflow for the vercel stack, redeploy the web app, then delete the old
secret in the console. The client ID does not change, so stored
refresh tokens keep working.
The client lives in the vrdex-production Google Cloud project, under the
basicbit.net organization and the basic@basicbit.net identity. It is
VRDex Calendar Connector, separate from the project's existing
VRDex Production client, and was created on 2026-10-30. Its ID and secret are
set on both Convex deployments, in GitHub, and on Vercel through the vercel
stack. The flag is on for both Convex deployments as of 2026-10-30. Google
verification is not done, and nothing has run against real Google yet.
The project's consent screen is External and already published, so no test users
are needed and Testing's seven-day refresh token expiry does not apply. Until
Google verifies calendar.events, a sensitive scope, connecting shows an
unverified app warning and at most 100 users can ever grant it across the
project's lifetime. That cap cannot be reset, so keep connecting limited to
BASIC's own community until verification passes. Verification needs the home page
and privacy policy links on the Branding page, a scope justification on Data
Access, and a demo video recorded against staging.
Bootstrap, once per Google Cloud project:
- Create or choose a Google Cloud project and enable the Google Calendar API.
- Configure the OAuth consent screen as External and declare exactly two scopes
on Data Access,
https://www.googleapis.com/auth/calendar.calendarlist.readonlyandhttps://www.googleapis.com/auth/calendar.events. - Create an OAuth client of type Web application and register one authorized
redirect URI per web origin: the origin followed by
/api/connectors/google/callback. Production ishttps://vrdex.net/api/connectors/google/callback, staging ishttps://staging.vrdex.net/api/connectors/google/callback, and local development ishttp://localhost:3000/api/connectors/google/callback. Vercel preview URLs are not registered, so connecting fails there. - Set the client ID and secret on Convex and in GitHub, as above, then set
VRDEX_CONNECTOR_GOOGLE_CALENDAR_ENABLED.
Ops alerts
VRDEX_OPS_ALERT_EMAIL is the recipient of [VRDex ops] alert emails.
Scope: the Convex deployment environment only. Optional; default
basic@basicbit.net. Owner: BASIC. Change it with
npx convex env set VRDEX_OPS_ALERT_EMAIL; there is no rotation beyond
replacing the address.
Each alert key sends at most one email per six hours while it stays failing,
and one Resolved email when it recovers. A failure after a recovery alerts
again at once. Current alarms:
connector-failures:plus the connector ID: a connector's fifth and every later consecutive finally failed sync job, including jobs failed by recovery aslease_expiredorstalled, so a long streak re-alerts every six hours. Retries, skips, andsupersededcloses do not count. A VRChat calendar job waiting more than six hours on one operation also alerts under this key, at once. The next completed job for that connector, or removing the connector, resolves it, except that abidirectionalconnector'simport_poll,import_item, andreconcilejobs neither clear the count nor resolve the alert: a successful read says nothing about writes.discord-intake:plus the connector ID: a connector's three most recently started intake runs all failed, or the five-minute sweep closed one of its runs asstalledand requeued its posts, a retry that counts against the daily run cap. The email names the connector and community IDs and the failure codes or run ID only. The next finished run, or removing or disconnecting the connector, resolves it.discord-intake-dropped:plus the run ID: the sweep closed a run asstalledand did not requeue its posts, because the retry also stalled or the connector is paused or off. Those posts need a real edit to run again. The key is per run, so it does not resolve automatically.discord-intake-posters: the poster bridge to the web app failed. See Discord intake.product-analytics-delivery: a product analytics outbox row stops retrying after five failed deliveries to PostHog. The email names the row ID, event name, attempt count, and creation time only. The next delivered row resolves it.series_materialize_failed:plus the series ID: the dailymaterialize event seriescron (06:20 UTC) failed to create a recurring series' upcoming nights. The body names the series ID and the error. Each series runs on its own, so the others still materialise. The next successful run for that series resolves it.series_materialize_failed:all: that cron could not list the active series, so no series ran. The body names the error. The next run that lists them resolves it.google_reauth:plus the credential ID: Google refused a credential's grant, so its connectors went toneeds_reauth. The email names the connector and community profile IDs. Reconnecting or removing the last parked connector on that credential resolves it.google_watch_renewal_stale:plus the connector ID: an active importing connector's Google watch has expired or has gone seven days without renewing. The email names the connector and community profile IDs, the watch times, and the last error code. The daily renewal resolves it once the connector is no longer stale.
The Discord gateway's discord_gateway_heartbeat_stale alert and the stalled-run
sweep use the same path; see gateway alarms.
Alerts send through the SES settings in
Transactional Email Environment:
AWS_SES_REGION, AWS_SES_FROM_EMAIL, and the existing SES credential chain.
Without them the internal.opsAlertEmail.send action throws, so a lost alert
shows as a failed function in the Convex logs.
Discord intake
VRDEX_DISCORD_INTAKE_ENABLED turns Discord announcement intake on when set to
true. Scope: the Convex deployment environment only. Default: unset, which
means off. Owner: BASIC. It gates the /discord-intake/* HTTP routes, which
answer 503 while it is off, intake runs, and the Integrations page's Discord
connect flow, which is hidden and refuses while it is off. While it is off the
gateway heartbeat check is silent. Turn it on immediately before creating the
gateway service, as in the bootstrap.
DISCORD_INTAKE_SECRET is the bearer token the Discord gateway presents on
every /discord-intake/* request (secret). Scope: the Convex deployment
environment and the gateway. Owner: BASIC. Value: at least 32 random bytes,
generated with openssl rand -base64 32, set with
npx convex env set DISCORD_INTAKE_SECRET and stored in the gateway's Secrets
Manager entry. With the flag on and no secret set, every route answers 401.
It must match Secrets Manager vrdex/discord-gateway/DISCORD_INTAKE_SECRET.
Rotation: set the new value on Convex and in Secrets Manager in one window, then force a new deployment as in the gateway doc, because ECS injects secrets at task start. Relays and heartbeats fail with 401 until the new task runs, and the gateway does not retry those posts.
VRDEX_DISCORD_POSTER_TOKEN is the bearer token intake runs present to the web
app's internal poster bridge, POST /api/internal/discord-intake/poster, which
copies Discord attachments into private poster storage (secret). Only the web
server holds the bucket role. Scope: the Convex deployment environment and the
web app (GitHub secret TERRAFORM_DISCORD_POSTER_TOKEN, which the Terraform
workflow passes to the Vercel stack as discord_poster_token). Owner: BASIC. Value: at least 32 random bytes,
generated with openssl rand -base64 32. Unset on either side, runs store no
posters and continue with the post text. A run that has posters and stores none
emails the discord-intake-posters ops alert, naming the failure code; the next
run that stores one resolves it. Rotation: write the new value to the web app
first, then to Convex; runs in between store no posters, continue text-only, and
can raise that alert.
DISCORD_APPLICATION_ID is the application ID of the Discord gateway's bot; the
Integrations page builds the bot invite from it. Not secret. Scope: the Convex
deployment environment. Owner: BASIC. Set it with
npx convex env set DISCORD_APPLICATION_ID; it changes only when the gateway
moves to another Discord application.
DISCORD_BOT_TOKEN on Convex must be the token of that same gateway application.
The Integrations page lists channels and proves a channel's guild as this bot,
so a token from another application reports the gateway's bot as missing from
every server. Rotate it with the gateway's token, in one window, as in
the gateway doc. These calls always go to
discord.com: DISCORD_API_BASE_URL does not apply to them.
Staging's DISCORD_BOT_TOKEN is the hosted adapter stub's token (see
Hosted E2E Helpers), which real Discord rejects, and the
stub cannot stand in here. The site channel listing and connect work there only
once DISCORD_REST_BOT_TOKEN holds a real bot token, so
VRDEX_DISCORD_INTAKE_ENABLED stays off on staging until it does.
DISCORD_REST_BOT_TOKEN overrides DISCORD_BOT_TOKEN for
convex/_discordRest.ts only, so the Discord event board, scheduled events,
and announcement connectors' REST calls use a real bot while the hosted stub path in
convex/profileClaims.ts keeps its token (secret). Unset or empty, those calls
fall back to DISCORD_BOT_TOKEN. It must be the token of the same gateway
application. Scope: the Convex deployment environment; currently only needed on
the dev deployment, and production leaves it unset. Owner: BASIC. Rotation:
reset the token in the Discord Developer Portal, then set the new value with
npx convex env set DISCORD_REST_BOT_TOKEN, in one window with the gateway.
Runs reuse SITE_URL as the poster bridge origin. They also read
OPENAI_API_KEY, VRDEX_EVENT_INTAKE_AI_ENABLED, and
VRDEX_EVENT_INTAKE_MODEL from the Convex deployment, so set those on Convex as
well as the web app before turning Discord intake on, plus the Langfuse
variables above when runs should be traced. With extraction off or
OPENAI_API_KEY unset, every run fails with extraction_unavailable, and after
three failed runs in a row the discord-intake: ops alert fires.
The gateway heartbeat check adds no AWS credential on Convex. It emails through the ops alert path.
Recurring events
VRDEX_RECURRING_EVENTS_ENABLED turns recurring events on when set to true.
Scope: the Convex deployment environment, all deployments. Default: unset,
which means off. Owner: BASIC. It is not a secret, so there is nothing to
rotate; change it with npx convex env set VRDEX_RECURRING_EVENTS_ENABLED true.
It gates creating and editing series and the daily materialize event series
cron. Turning it off stops new series and stops the cron. Nights already
created stay in place as events and keep their seriesId and series link.
It also switches connector series import and export, together with the next
flag.
VRDEX_CONNECTOR_SERIES_ENABLED turns on connector series when set to true:
Google Calendar and Discord scheduled event connectors import a recurring item
as one series and export a VRDex series as one recurring item, and the grouping
migration can run. It is read only while VRDEX_RECURRING_EVENTS_ENABLED is on,
through connectorSeriesEnabled(). Scope: the Convex deployment environment,
all deployments. Default: unset, which means off, and it is unset on every
deployment today. Owner: BASIC. It is not a secret, so there is nothing to
rotate; change it with npx convex env set VRDEX_CONNECTOR_SERIES_ENABLED true,
and only after the live checks in
Connector series.
Turning it off returns both kinds to phase-one import and export at once. Series
and series links stay, and a night whose link is none: goes to the phase-one
export: on Google an overridden night then gets a standalone copy beside the
master, and on Discord a night the scheduled event already shows writes nothing.
Locked Decision
VRDex keeps four Convex execution targets separate:
- local development: anonymous local Convex from
pnpm dev:backend:localorpnpm verify:backend:local - pull request preview testing: branch-specific Convex preview deployments when a Vercel preview must exercise same-branch backend functions
- deployed smoke testing: the shared development Convex deployment
- production release: the production Convex deployment
Targeting a deployment from the CLI
Use pnpm cx <local|dev|prod> <convex args>. One optional package-manager
delimiter is also accepted, as in pnpm cx -- dev env list. The target is a required
positional and is never inferred:
pnpm cx -- prod run seedImports:listBatchesForReview
pnpm cx -- dev env list
pnpm cx -- local run health:status
convex --prod does not work in this repository. The repo .env.local sets
CONVEX_DEPLOYMENT=anonymous:anonymous-agent so that local development needs no
cloud project, which leaves --prod with no project to resolve against. The
wrapper supplies CONVEX_DEPLOYMENT and CONVEX_DEPLOY_KEY for the named
target instead.
It also clears CONVEX_URL, CONVEX_DEPLOYMENT, CONVEX_DEPLOY_KEY, and the
self-hosted pair from the child environment before setting the target's own
values. A shell that has run pnpm dev:backend:local keeps CONVEX_URL
pointing at 127.0.0.1:3210, which otherwise silently wins over a command line
that reads prod.
Cloud credentials are read from .env.local in the main checkout — worktrees do
not carry it, and the wrapper locates the main checkout through
git rev-parse --git-common-dir rather than requiring a variable. Exactly one
file is read: when the main checkout has one, a worktree copy is ignored
entirely rather than merged per key, so a credential removed by rotation stays
removed instead of being refilled from a stale worktree. Values are passed to
the Convex CLI through its environment and never printed; the banner names the
deployment and the env file only.
local reverses that order and reads the active worktree first, because
pnpm dev:backend:local writes the running backend's deployment name and port
into that worktree's own .env.local. Reading the main checkout first would
point local at a different instance, or at one that is not running. The banner
names the file it used, so the source is never a guess.
A target that is missing either of its two variables fails and names both, rather than falling back to whichever credentials are present.
The same targeting applies to the seed operations scripts, which take
--target instead of the --prod flag they used to accept:
pnpm ops:seed-publish -- --batch-id <id> --target prod ...
pnpm ops:seed-import:json -- --file <path> --target prod ...
pnpm ops:seed-handoff:create -- --candidate-id <id> --target prod ...
--target defaults to local. The old --prod and --deployment flags are
rejected with an error rather than ignored, since silently falling back to
local would let a leftover --prod invocation report a successful local
publication.
local is pinned to an env file rather than the ambient environment, like the
cloud targets, but to the active worktree's .env.local when it has one,
falling back to the main checkout. It takes CONVEX_DEPLOYMENT and
CONVEX_URL from there, and ambient values are cleared first, so exporting a
worktree-specific CONVEX_URL has no effect. Change whichever file the banner
names, or start the backend with pnpm dev:backend:local — which writes that
worktree's file itself, and which local still expects to be running.
Current Deployments
Do not commit deploy keys. Store them in GitHub/hosting secret stores and local ignored env files only.
Current recommendation: define environment variable names and target scopes in docs or IaC first, then set secret values through provider secret stores. Manual Convex dashboard edits should be treated as bootstrap/emergency changes and followed by a reproducibility update here or in automation.
- development cloud URL:
https://scrupulous-corgi-247.convex.cloud - production cloud URL:
https://superb-pig-954.convex.cloud
GitHub Actions secret names:
CONVEX_DEPLOY_KEY_PREVIEW: preview deployment key used by on-demand Vercel previews that need same-branch backend functionsCONVEX_DEPLOY_KEY_DEV: development deployment keyCONVEX_DEPLOY_KEY_PROD: production deployment key used by the main-branch deploy workflowTERRAFORM_POSTHOG_PUBLIC_KEY: hosted PostHog project key reused by the production workflow for Convex claim analytics; it is required whenever the production Convex deploy gate is enabled
Local ignored env names:
CONVEX_DEPLOY_KEY_PREVIEWCONVEX_DEPLOY_KEY_DEVCONVEX_DEPLOY_KEY_PRODCONVEX_URL_DEVCONVEX_URL_PROD
pnpm cx and the ops:seed-* scripts additionally need the deployment name for
each target they can reach. Both are the deployment's own identifier, not a URL:
CONVEX_DEPLOYMENT_DEV=dev:scrupulous-corgi-247CONVEX_DEPLOYMENT_PROD=prod:superb-pig-954
A target is only usable when both of its variables are present. dev needs
CONVEX_DEPLOYMENT_DEV and CONVEX_DEPLOY_KEY_DEV; prod needs
CONVEX_DEPLOYMENT_PROD and CONVEX_DEPLOY_KEY_PROD. Supplying one without
the other fails naming both, rather than falling back to the other target's
credentials.
The pair is also checked for agreement. A deploy key carries its own deployment
ahead of the |, and the CLI will follow the key rather than
CONVEX_DEPLOYMENT, so a dev deployment name accidentally paired with a
production key would reach production while the banner read "development". A
mismatch fails naming both deployments; the secret after the | is never read
or printed.
Pull Request Preview Backends
Selected same-repository ci:browsers and ci:visuals PR runs call the existing
On-Demand Vercel Preview implementation through Baseline Checks. Manual preview
requests use the same deploy implementation. Both deploy the selected full head
and build Vercel with the matching Convex browser/server URLs. The project-level
CONVEX_DEPLOY_KEY_PREVIEW remains in GitHub Actions and is never injected into
Vercel. It is required for candidate acceptance, optional for a manual shell-only
preview.
CI acceptance serialises and reuses ci-pr-<number> across heads and retries.
Manual previews use pr-<number>; manually requested acceptance has the separate
manual-accept-pr-<number> namespace and concurrency group. A PR with neither
browser selection nor a manual request creates no preview. Retain current PR
backends and reclaim closed PR previews through the exact-name dashboard
procedure in Vercel preview deployment. Run artifacts retain
the full head, preview origin, both backend URLs and executed coverage; an old
preview URL alone does not establish current acceptance.
The Hosted MCP Preview Smoke job runs pnpm smoke:mcp-compat against
the Vercel preview /mcp endpoint in that same on-demand run. CI passes that
target through VRDEX_MCP_SMOKE_URL; local runs can use
pnpm smoke:mcp-compat -- --hosted-url <preview-/mcp-url>. The job is
fail-closed: it requires both a preview deployment URL and a same-branch Convex
preview backend, so a pass covers anonymous hosted Streamable HTTP, OAuth
metadata, bearer challenges, Dynamic Client Registration, and data-backed
vrdex_search plus search/fetch alias checks together. When
CONVEX_DEPLOY_KEY_PREVIEW is absent the job fails and names that prerequisite
rather than reporting reduced coverage as green.
Use the manual Deployed Health Checks workflow target hosted-mcp-smoke when
DCR/CIMD evidence needs to come from a staging, production-like, or otherwise
Convex-backed target. Pass the target /mcp URL as base_url and enable the
mcp_dcr and mcp_cimd inputs for the hosted OAuth compatibility gate.
Do not use production deploy keys for PR previews. Preview deployments are for schema/function compatibility and hosted smoke validation before merge.
For DCR and CIMD preview smoke, the On-Demand Vercel Preview workflow
(.github/workflows/vercel-preview-deploy.yml) enables a narrow persistence
bridge with VRDEX_DEPLOYMENT_ENV=preview,
VRDEX_ENABLE_PREVIEW_PERSISTENCE_BRIDGE=true, and a random
VRDEX_PREVIEW_PERSISTENCE_SECRET shared only with the matching Vercel
deployment. The public bridge mutations reject every other environment and an
incorrect or missing secret. Do not replace this boundary with a preview
CONVEX_ADMIN_TOKEN. When the separately gated hosted E2E developer-credential
flow is enabled, the workflow also sets
VRDEX_ENABLE_PREVIEW_OAUTH_TOKEN_BRIDGE=true on that Convex preview. That flag
permits only client-credentials access-token record issuance and access-token
validation through the same secret-bound bridge. Authorization-code,
refresh-token, revocation, and all other internal operations remain unavailable
to the preview web runtime.
The workflow also sets VRDEX_ENABLE_HOSTED_SMOKE_FIXTURE=true and invokes the
internal hostedSmokeFixtures:ensurePublicSearchFixture mutation through the
Convex CLI admin path. The mutation creates or refreshes one deterministic fake
public community profile for search smoke coverage. Its guard permits only
preview or staging, so production cannot seed the fixture even if the flag
is accidentally present. Staging runs the same internal mutation after its
Convex deploy and before its Vercel deploy.
Transactional Email Environment
The support digest needs these. Clerk sends the verification and password
email this section used to describe, so SES is out of the auth path, but the
hourly internal.supportRequestDigest.sendSupportDigest cron mails new
/support requests through it.
A Convex deployment that sends through SES must set:
AWS_SES_REGIONAWS_SES_FROM_EMAILAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYVRDEX_APP_NAMEoptional display nameVRDEX_SUPPORT_DIGEST_TO: the mailbox the/supportdigest is delivered to. Without it the cron sends nothing and reportsconfigured: false, which is the correct state for a deployment with no operator mailbox. Requests keep their unsetnotifiedAtin the meantime, so setting this later delivers the backlog rather than starting from whatever arrives next.
The hosted SES baseline is documented in docs/deployment/ses-auth-email.md and docs/deployment/aws-baseline.md. Store secret values in Convex env, never in git.
Club operation failure emails reuse the same SES sender, region and credential
chain. They additionally require VRDEX_CLUB_OPERATION_EMAIL_ENABLED=true and
VRDEX_SITE_URL set to the deployment's HTTPS public origin. The flag defaults
off; leave it off until the exact message copy and delivery smoke test are
approved. The five-minute cron claims up to 20 messages per run, rechecks each
recipient's access, and never automatically replays an uncertain send. The
deployment operator owns enabling, recreating and rotating this configuration
through the existing Convex environment and IAM process. See
operation notifications
for exact copy and delivery behavior.
Hosted E2E Helpers
Selected PR acceptance runs real mutation/readback/cleanup and development Clerk auth/account assertions against its same-branch preview. Deployed-health runs retain the shared development/staging target. Neither lane may target production. See candidate acceptance for required switches, matching Clerk instance keys, artifact retention and backend reclamation.
Preview deployments need a project-level default
convex/auth.config.ts reads CLERK_JWT_ISSUER_DOMAIN on every hosted
deployment, and convex deploy --preview-create evaluates it while creating the
deployment. Nothing in CI can set the variable first: convex deploy has no
--env flag, and convex env set needs a deployment that already exists.
Set CLERK_JWT_ISSUER_DOMAIN as a preview environment-variable default on
the Convex project, from the dashboard's project settings. New previews then
inherit it at creation. Without it, Deploy Convex preview functions fails
before any Vercel step runs.
Staging provisions it in the workflow
The shared development/staging deployment already exists, so convex env set
does work there — and staging-deploy.yml runs it from
vars.VRDEX_STAGING_CLERK_JWT_ISSUER_DOMAIN in a Provision Convex auth configuration step placed before convex deploy. Ordering is the point:
auth.config.ts is evaluated at push time and the CLI refuses to push while the
variable is unset, so setting it after the deploy never runs at all.
This used to be a hand-set dashboard value, and that is what failed. Nobody set it when Clerk replaced Convex Auth in #224. Every staging deploy failed from that merge onward with:
✖ Environment variable CLERK_JWT_ISSUER_DOMAIN is used in auth config file
but its value was not set.
Staging kept serving a pre-cutover build — with the removed email/password
sign-in form — for three days while main moved on, and nothing surfaced it
because the failure was inside a workflow nobody was watching.
tests/scripts/staging-runtime-env.test.ts pins the ordering.
An unset variable fails the job; it does not skip it. The other entries in
the gate's missing list mean "this repository is not set up to deploy staging
at all", which is a legitimate skip. This one means staging is set up and is
missing a setting its own auth config requires — so skipping would report a green
workflow while staging silently stopped updating, which is a quieter version of
the same outage.
The issuer is checked against the key Vercel will serve
Convex's issuer and the web publishable key are configured in different places —
a repository variable and the Vercel project — and nothing compared them. A stale
or cross-instance issuer deploys cleanly and then rejects every signed-in
request, because Convex validates the issuer it was told about rather than the
one the browser authenticated against. The Audit Vercel staging runtime variable names step cannot catch it: it reads names, never values.
So the issuer is checked twice, both through
scripts/check-clerk-issuer-match.mjs, plus a format check that runs on every
path. Before the convex env set, the issuer is compared against the key the
current deployment serves; after the Vercel deploy, against what actually
shipped. Both decode the key's base64-encoded host and fail on a mismatch, and
both reject a pk_live_ key outright so the staging and production tenants
cannot be crossed. production-promote.yml does the same for the live tenant.
The format check is separate and unconditional, because auth.config.ts takes
the value verbatim: a bare host or a trailing slash matches no token issuer, and
no path that can write the variable may skip that.
Rotating staging to a different Clerk instance is a manual sequence rather
than a workflow input, documented in
playwright-visual-preview.md. Vercel
is updated and deployed first, then the issuer variable, then a normal staging
deploy — so the pre-deploy comparison agrees by the time it runs and never has
to be skipped. There is a short window between those steps where staging auth is
down, which is inherent to changing two providers that must agree.
A dispatch input that skipped the comparison existed briefly and was removed. Three rounds of review found a fresh hole in it each time: it bypassed the format validation, then left the rollback unreachable on the path it created, and would finally have needed Vercel deployment rollback and repository-variable writes from CI to be correct. That is a two-provider migration system inside a deploy workflow, for an operation performed by hand about once a year.
If a run changes the issuer and then fails, the previous value is restored in two cases, and both mean Convex is ahead of what staging serves: the Vercel deploy did not succeed, or the post-deploy comparison reported a confirmed mismatch — the deployed key naming a different Clerk instance than the issuer just written.
Keyed on that confirmation rather than on the step failing, because a transient fetch error fails the step too and proves nothing about the pairing; rolling back on one would break a pairing that is very likely correct. The script exits 2 for a mismatch and 1 for everything else so the two can be told apart. The pre-deploy comparison can also be inconclusive — a target serving no key at all — so a mismatch reaching the post-deploy check is not unreachable merely because the earlier one passed.
The restore re-pushes functions only when the Convex deploy had itself succeeded. If it had not, nothing carrying the new issuer was ever published, so putting the variable back is the whole repair — and re-pushing there would publish the functions that just failed their typecheck.
The value is not a secret. A Clerk Frontend API origin is public — it is encoded in the publishable key every browser downloads — so it lives in a repository variable rather than a repository secret, where it can be read and audited.
Development/staging Convex env names:
VRDEX_ENABLE_E2E_HELPERS=trueVRDEX_E2E_CONVEX_SECRET: non-empty sentinel also configured in the hosted app environmentVRDEX_ENABLE_E2E_AUTH_HELPERS=true: optional, only when hosted auth/claim E2E is intentionally enabledVRDEX_ENABLE_E2E_ADAPTER_HELPERS=true: optional, only when hosted adapter E2E is intentionally enabledCLERK_JWT_ISSUER_DOMAIN: staging Clerk Frontend API origin, read byconvex/auth.config.ts. Provisioned bystaging-deploy.yml, not by hand — see belowSITE_URL=https://staging.vrdex.net: builds the Discord verification callback URLAUTH_DISCORD_IDandAUTH_DISCORD_SECRET: staging Discord credentials for the purpose-scoped community-verification round-trip. These are not sign-in credentials — Clerk holds those — butconvex/discordVerification.tsstill requires themDISCORD_API_BASE_URL: optional hosted adapter stub base URL, usuallyhttps://staging.vrdex.net/api/e2e/adapters/discordDISCORD_OAUTH_AUTHORIZE_URL: optional consent-screen override, for pointing the OAuth round-trip at a stub instead of Discord. Defaults tohttps://discord.com/oauth2/authorize. The browser follows it carrying thestatethat authorizes the round-trip, so it must be https unless it is loopbackDISCORD_BOT_TOKEN: staging-only adapter token matching the hosted app environment. It is not a real bot token, so the site Discord connect flow needsDISCORD_REST_BOT_TOKENon staging; see Discord intake. The Discord board and scheduled events connectors also use it from Convex in any deployment whereVRDEX_CONNECTOR_DISCORD_BOARD_ENABLEDorVRDEX_CONNECTOR_DISCORD_SCHEDULED_EVENTS_ENABLEDis on, unlessDISCORD_REST_BOT_TOKENoverrides itDISCORD_REST_BOT_TOKEN(secret): optional real bot token forconvex/_discordRest.ts; see Discord intakeVRCHAT_PROOF_ADAPTER_URL: optional hosted adapter stub URL, usuallyhttps://staging.vrdex.net/api/e2e/adapters/vrchat-proofVRCLINKING_PROOF_ADAPTER_URL: optional hosted adapter stub URL, usuallyhttps://staging.vrdex.net/api/e2e/adapters/vrchat-proofVRCHAT_PROOF_ADAPTER_BEARER_TOKEN: staging-only adapter token matching the hosted app environmentVRCLINKING_ADAPTER_CAPABILITY_KEY: staging-only capability signing key, and a different value from the bearer token. Required alongside the two above, not optional with them:getClaimJourneyContexthides the VRCLinking method unless all three are set, so omitting this one leaves the method invisible and the hosted stub unexercised — with nothing reporting a misconfiguration, because hiding is the designed behaviour
The browser-facing token stays in the web host and GitHub Actions as VRDEX_E2E_BROWSER_TOKEN / VRDEX_HOSTED_E2E_BROWSER_TOKEN; it is not needed by Convex.
The shared development deployment scrupulous-corgi-247 is the current hosted E2E backend for Vercel staging. The Staging Deploy GitHub Actions workflow deploys Convex development functions with CONVEX_DEPLOY_KEY_DEV before deploying Vercel staging and running hosted data-flow health.
Production Convex auth env names:
CLERK_JWT_ISSUER_DOMAIN=https://<clerk-frontend-api>: production Clerk Frontend API origin, read byconvex/auth.config.ts. Must match the issuer of theconvexJWT template on the production Clerk instanceSITE_URL=https://vrdex.net: builds the Discord verification callback URLAUTH_DISCORD_IDandAUTH_DISCORD_SECRET: production Discord credentials for the purpose-scoped community-verification round-trip. Still required byconvex/discordVerification.ts; they are no longer sign-in credentialsDISCORD_BOT_TOKEN(secret): bot token of the production Discord application, read byconvex/_discordRest.tsfor the Discord board and scheduled events connectors and byconvex/profileClaims.tsfor the bot claim path. Needed onceVRDEX_CONNECTOR_DISCORD_BOARD_ENABLEDorVRDEX_CONNECTOR_DISCORD_SCHEDULED_EVENTS_ENABLEDis on. Scope: the production Convex environment. Owner: BASIC. Rotate or recreate it by resetting the token in the Discord Developer Portal and setting the new value withnpx convex env set DISCORD_BOT_TOKEN. Resetting the token revokes the old value for every service that uses it, so update each holder
Retired when Clerk replaced Convex Auth, and safe to delete from every Convex deployment once the cutover is verified:
AUTH_GOOGLE_IDandAUTH_GOOGLE_SECRET: Google sign-in now runs through Clerk. Do not delete the Google OAuth client — point it at Clerk's callback URL insteadJWT_PRIVATE_KEYandJWKS: Convex Auth signed its own tokens; Clerk signs them now
The four AWS_SES_* and AWS_* credentials are no longer on that list. They
sent email/password verification codes, which Clerk now handles, but the hourly
support digest has since adopted them. Deleting them stops /support requests
from reaching anyone, and stops it quietly.
Discord community verification needs no additional production Convex environment
variables. It reuses AUTH_DISCORD_ID, AUTH_DISCORD_SECRET, and SITE_URL
through a purpose-scoped OAuth round-trip independent of sign-in; it requires
only that
https://vrdex.net/api/discord/verify/callback is registered as a redirect URI
on the production Discord application.
The VRCLinking claim method needs three, and getClaimJourneyContext hides the
method unless all three are present — a deployment holding only some of them
offers nothing, rather than offering a method that throws:
VRCLINKING_PROOF_ADAPTER_URL: the Function URL output byinfra/terraform/vrclinking-adapterVRCHAT_PROOF_ADAPTER_BEARER_TOKEN: thebearerTokenfield of the shared secret. Also read by the generic VRChat proof adapter seam, so a deployment running both rotates both togetherVRCLINKING_ADAPTER_CAPABILITY_KEY: thecapabilityKeyfield of the same secret, and necessarily a different value from the bearer token — the adapter refuses to start if they match
Both come from one Secrets Manager object, vrdex/vrclinking/shared, holding
{ "bearerToken": …, "capabilityKey": … }. One object rather than two because
two cannot be written atomically, and a cold start landing between the writes
would cache a mismatched pair for its container's life. Provisioning two
single-value secrets instead leaves no ARN for Terraform to take, and pointing
the stack at one of them fails every cold start.
Setting these does not by itself make a claim completable: a community must also
delegate a credential, and until one has, the method is offered and every
attempt returns unavailable. The stack README carries the deployment and
rotation sequence. The optional bot and collector paths, and the exact operator
steps, are documented in
claim-verification-enablement.md.
Session durations are Clerk instance settings, not code and not Convex
environment variables — the constants that once owned them are deleted. Set the
session lifetime and inactivity timeout in each Clerk instance's session
settings, and the token lifetime on its convex JWT template, which is also the
revocation window. Verify by reading the template's lifetime in the Clerk
dashboard; nothing in this repository can assert it. See
docs/backend/auth-sessions.md.
The production authenticated smoke lane does not require Convex E2E helpers and should not enable them in production. It reuses the normal production Auth configuration above and only supplies a pre-authenticated browser storage state from GitHub Actions.
GitHub Actions repository settings for the optional authenticated smoke:
- variable
VRDEX_PRODUCTION_SMOKE_BASE_URL=https://vrdex.net: required so auth cookies target the stable public production domain VRDEX_PRODUCTION_AUTH_SMOKE_PROVIDERis retired: the account page no longer renders linked providers, because Clerk shows them only inside its own profile modal. The smoke asserts the management affordance instead of a provider label- secret
VRDEX_PRODUCTION_AUTH_SMOKE_STORAGE_STATE_B64: base64-encoded PlaywrightstorageStateJSON from a dedicated production test account
The authenticated smoke runs only on an explicit manual dispatch with
production_auth=true. Use target=production-smoke to run this check without
staging mutation checks. Configuring both settings does not enable recurring
authenticated runs. An explicit request fails if either setting is missing.
The deployment operator owns the dedicated account and renewal of its browser
state. The secret contains only that account's Clerk session cookies, including
the HttpOnly __client cookie on the Clerk Frontend API domain. Do not store
account passwords, OAuth credentials, Clerk API keys, or sign-in tickets in this
secret, and do not enable production mutation helper routes. Normal page loading
may provision or refresh the test account's Convex identity row; the smoke makes
no profile edits or other authored data writes.
Follow the production authenticated account smoke runbook for isolated-context capture, fresh-browser verification after the captured JWT expires, the manual dispatch command, and secret renewal. Email or an authorized Clerk sign-in ticket can establish the session; a passing account smoke does not prove OAuth sign-in or provider linkage.
Setting secret values without corrupting them
Do not pipe a secret into convex env set from PowerShell. A PowerShell pipeline
between native commands round-trips the payload through its string pipeline and
appends a platform newline, so the stored value gains a trailing \r. The value
still looks correct in the dashboard and in convex env get, and most consumers
tolerate it, but any provider that compares the secret byte-for-byte rejects it.
This is not hypothetical. On 2026-07-28 production AUTH_GOOGLE_SECRET held a
35-character secret plus a trailing \r. Google sign-in failed at the token
exchange with invalid_client for weeks while consent, Discord, and staging all
worked, because the OAuth authorize step never sends the client secret.
Pass single-line secrets as a positional argument instead, from Git Bash so that
$(...) strips trailing newlines:
SECRET=$(python -c "import json,sys;print(json.load(open(sys.argv[1]))['web']['client_secret'],end='')" ./client_secret.json)
pnpm cx -- prod env set AUTH_GOOGLE_SECRET "$SECRET"
Always verify after writing a secret. len must equal the provider's documented
length and CR must be 0:
pnpm --silent cx -- prod env get AUTH_GOOGLE_SECRET | python -c "
import sys
b = sys.stdin.buffer.read().rstrip(b'\n')
print('CR=%d len=%d' % (b.count(b'\r'), len(b)))"
PEM values are the one case that needs stdin, because they begin with dashes and
would otherwise parse as CLI options. No Convex variable currently holds a PEM —
JWT_PRIVATE_KEY and JWKS were the only ones, and Clerk signs tokens now — so
this is recorded as technique rather than as a step to run. Use cmd /c
redirection rather than a PowerShell pipe, since cmd redirects bytes verbatim,
and substitute the real variable name:
node -e "require('fs').writeFileSync(process.argv[1], process.env.VRDEX_PEM_VALUE)" $env:TEMP\k.pem
cmd /c "pnpm cx -- prod env set SOME_PEM_VARIABLE < $env:TEMP\k.pem"
Remove-Item $env:TEMP\k.pem, Env:\VRDEX_PEM_VALUE -ErrorAction SilentlyContinue
Setting CONVEX_DEPLOYMENT by hand first is no longer needed, and is now
actively counterproductive: cx clears ambient Convex variables before
applying the target's own.
Apply the same CR=0 verification afterwards. A trailing \r is harmless for
some consumers, so check the byte count rather than assuming a working
deployment proves a clean value.
Manual fallback if the workflow is unavailable:
pnpm cx -- dev dev --once --typecheck=try --tail-logs=disable
Custom Domains
Current recommendation: keep client API traffic on the Convex cloud URL unless a separate API custom domain is configured, and use readable Convex Cloud HTTP Actions domains for the HTTP Actions the app still serves.
- development/staging Convex API:
https://scrupulous-corgi-247.convex.cloud - development/staging Convex HTTP Actions:
https://db.staging.vrdex.net - production Convex API:
https://superb-pig-954.convex.cloud - production Convex HTTP Actions:
https://db.vrdex.net
Convex no longer serves sign-in callbacks. convex/http.ts dropped
/api/auth/* when Clerk replaced Convex Auth, so the OAuth redirect URIs below
that name db.vrdex.net/api/auth/callback/... are historical. Following them
during cutover would point a Google or Discord client at a 404. Register Clerk's
callback URLs on those OAuth clients instead — Clerk's dashboard shows the exact
values per instance — and keep the custom domains only for the HTTP Actions the
app still uses.
Convex Cloud custom domains are configured from each deployment's dashboard settings and require a Convex Pro plan. Do not create Route 53 records alone; Convex must first provide the deployment-specific DNS records and certificate binding.
Staging HTTP Actions domain bootstrap, started 2026-06-15:
- In the Convex dashboard for
scrupulous-corgi-247, requestdb.staging.vrdex.netwith request destinationHTTP Actions. - Copy only the exact DNS records Convex provides into Route 53 for the public hosted zone
vrdex.net. - Current Convex-provided records:
db.staging.vrdex.net CNAME convex.domains_convex_domains.db.staging.vrdex.net TXT scrupulous-corgi-247
- Wait for Convex certificate/domain status to become active.
- Historical, do not follow: staging OAuth redirect URIs used to be
https://db.staging.vrdex.net/api/auth/callback/{discord,google}. Those routes no longer exist. Point the staging OAuth clients at the staging Clerk instance's callback URLs. - Historical: the legacy
convex.site/api/auth/callback/...redirects are also gone with Convex Auth. - Override the staging deployment's
CONVEX_SITE_URLtohttps://db.staging.vrdex.netin the Convex custom domain settings. - Rerun staging auth smoke checks from
https://staging.vrdex.net/sign-in.
Current status: db.staging.vrdex.net is configured and verified for the staging deployment and staging CONVEX_SITE_URL is selected as https://db.staging.vrdex.net. The Convex-hosted sign-in callbacks it once served are gone; staging sign-in runs through the staging Clerk instance.
Production HTTP Actions domain bootstrap, completed 2026-06-16:
- In the Convex dashboard/API for
superb-pig-954, requestdb.vrdex.netwith request destinationHTTP Actions. - Copy only the exact DNS records Convex provides into Route 53 for the public hosted zone
vrdex.net. - Current Convex-provided records:
db.vrdex.net CNAME convex.domains_convex_domains.db.vrdex.net TXT superb-pig-954
- Wait for Route 53 to report the change as
INSYNCand for Convex certificate/domain status to become active. - Historical, do not follow: production OAuth redirect URIs used to be
https://db.vrdex.net/api/auth/callback/{google,discord}. Those routes no longer exist. Point the production OAuth clients at the production Clerk instance's callback URLs. - Historical: the legacy
convex.site/api/auth/callback/...redirects are also gone with Convex Auth. - Select
https://db.vrdex.netas the production deployment's canonicalCONVEX_SITE_URL. - Rerun production auth smoke checks from
https://vrdex.net/sign-in.
Current production status: db.vrdex.net is configured and verified for the production deployment and production CONVEX_SITE_URL is selected as https://db.vrdex.net. Sign-in no longer runs through it: the Convex auth callbacks were removed with Convex Auth, and production sign-in is pending the Clerk cutover.
Notes
Resolved 2026-06-15: the duplicate Convex project vrdex-85631 was deleted after confirming the active project is vrdex, the duplicate deployments had no env variables or custom domains, and their profiles tables were empty.