Skip to content

Runbook: configuration reference (environment variables)

The authoritative reference for every environment variable the app reads — purpose, whether it is required, its default/fallback, and what breaks when it is unset. .env.example is the copy-paste template (the same variables, grouped identically); this page is the prose reference. Keep the two in sync when adding a variable.

  • The backend reads variables through a single readRuntimeEnv(name) helper (Bun/Node env), so any value present in the process environment works — .env* files, the shell, or the Kubernetes deployment.
  • EMERGENT_-prefixed aliases. Several externally-reachable URLs are read as readRuntimeEnv("X") || readRuntimeEnv("EMERGENT_X"), so either name is accepted. The reference lists the short name and marks the alias.
  • Unset is safe. Nothing here is required for the process to start. A missing value either (a) falls back to a https://localhost placeholder (syntactically valid URLs that are simply not externally verifiable) or (b) makes exactly one feature return 503 — never a crash, never silent wrong behavior. Set the relevant group for any real deployment.
  • Secrets (*_SECRET, *_TOKEN_SECRET, *_DATABASE_URL) are environment-owned and never committed. The migrations create signing roles NOLOGIN; their passwords are an operator step (see credential-issuer-keys.md).
Variable Required Notes
DATABASE_URL yes General app connection; also provisioning (encrypt-only Vault writes) and public JWKS/profile reads.
APP_ENV no development / production.

Frontend (Vite, baked at build — resolved at runtime)

Section titled “Frontend (Vite, baked at build — resolved at runtime)”
Variable Required Notes
VITE_SUPABASE_HOST yes Supabase origin, resolved in the browser against the page’s host (ADR-0055). Three forms: contains :// → verbatim URL; contains . → https://<value>; bare label → replaces the current host’s first label.
VITE_SUPABASE_PUBLISHABLE_KEY yes Public routing/anon key. Shared across environments that share the build; secret keys stay per-cluster.

Externally reachable origins embedded in credentials, emails, and OAuth redirects. Unset → https://localhost fallback. (alias = also read from EMERGENT_….)

Variable Alias Notes
API_PUBLIC_URL ✓ API origin; base for canonical images /img/:kind/:id, extracted wallet badge art /img/wallet-credential/:key, and the Badge Connect manifest apiBase.
LEARNER_WEB_PUBLIC_URL ✓ Learner SPA origin; LTI launch redirects and the Badge Connect client redirect_uri (…/wallet/connections/callback).
TEACHER_PORTAL_PUBLIC_URL ✓ Teacher SPA origin.
ADMIN_CONSOLE_PUBLIC_URL ✓ Admin SPA origin.
LRS_PUBLIC_URL ✓ xAPI LRS public base.
H5P_RUNTIME_PUBLIC_URL ✓ H5P runtime origin (cmi5/xAPI launches).
QTI_ITEM_ASSET_BASE_URL — Base for QTI authored-item asset URLs (ADR-0023); falls back to the API origin.
CASE_PROVIDER_BASE_URL — Externally reachable base for exported CASE framework URIs.
ONEROSTER_PROVIDER_BASE_URL — Externally reachable base for the OneRoster provider.

Supabase storage (server-side object storage)

Section titled “Supabase storage (server-side object storage)”

Storage-backed features — entity + wallet badge images (ADR-0035 / ADR-0038), QTI item assets (ADR-0023), learner submissions (ADR-0027), External-Package runtimes — read/write private buckets server-side over the service_role key. The storage endpoint is derived as ${SUPABASE_URL}/storage/v1 unless SUPABASE_STORAGE_URL overrides it. Without a storage URL and a service-role key, those features return 503; the rest of the app is fine.

Variable Required Notes
SUPABASE_URL for storage Supabase base; storage URL derives from it.
SUPABASE_STORAGE_URL no Explicit storage endpoint override.
SUPABASE_SECRET_KEY for storage Server-side bucket read/write key.
SUPABASE_AUTH_ADMIN_URL, SUPABASE_HOST_INTERNAL_URL, SUPABASE_PUBLISHABLE_KEY for admin auth GoTrue admin endpoint + internal host for admin-console user management.

Credential signing & key custody (ADR-0015/0016/0017; capability-b ADR-0038)

Section titled “Credential signing & key custody (ADR-0015/0016/0017; capability-b ADR-0038)”

Full operator procedure (the NOLOGIN → LOGIN PASSWORD step, connection wiring, rotation): credential-issuer-keys.md. The credential_signing_role migration creates the credential_signer / holder_signer roles and their name-scoped decrypted views.

Variable Required Notes
CREDENTIAL_ISSUER_BASE_URL for issuance Issuer URI / JWKS base for issued OB 3.0 / CLR 2.0 credentials. Unset → https://localhost.
VITE_CREDENTIAL_ISSUER_BASE_URL frontend (build-time) The learner wallet reads its list from the sync rail and shows this as the issuer of OUR-issued credential cards (the issuer is server-derived, not a synced column). Mirror CREDENTIAL_ISSUER_BASE_URL — set both together, or issued cards fall back to https://localhost.
SIGNING_DATABASE_URL for issuance KeySigner connection as credential_signer — the only decrypt path for issuer Ed25519 secrets. Same DB as DATABASE_URL, different user. Unset → credential export cannot sign.
HOLDER_SIGNING_DATABASE_URL for presentations KeySigner holder path as holder_signer — the only decrypt path for per-learner VP keys. Separate user from the issuer signer. Unset → Verifiable Presentations cannot be signed.

Badge Connect host & client (capability-b; ADR-0038)

Section titled “Badge Connect host & client (capability-b; ADR-0038)”

emergent both hosts a Badge Connect / CLR API (OAuth2 authorization-server) and acts as a client pulling a learner’s credentials from an external host.

Variable Required Notes
BADGE_CONNECT_TOKEN_SECRET for host and client Dual role: the HS256 secret the OAuth2 AS host mints/verifies access tokens with, and the AES-256-GCM key the wallet client uses to seal its PKCE authorization-flow state. Long random value. Unset → the host returns 503 and the wallet cannot start an external-host pull.
BADGE_CONNECT_AUTHORIZATION_URL no The learner-web consent page the host manifest advertises as authorizationUrl. Falls back to ${API_PUBLIC_URL}/oauth/authorize.

Each signs the short-lived capability token for one feature’s serve proxy. Long random values; unset → only that feature returns 503.

Variable Feature
WEB_CONTENT_DELIVERY_TOKEN_SECRET web-content delivery (ADR-0022)
PACKAGE_RUNTIME_TOKEN_SECRET static-package runtime serving, cmi5 Captivate (ADR-0032)
ONEROSTER_PROVIDER_TOKEN_SECRET OneRoster provider OAuth2 token endpoint
Variable Required Notes
EMAIL_SENDER_TYPE no mailgun (default) or console (dev).
MAILGUN_BASE_URL, MAILGUN_REGION for mailgun Mailgun endpoint config.
SEND_EMAIL_HOOK_SECRETS for auth emails Verifies the Supabase auth “send email” webhook signature; strict mode throws without it (so auth emails are never sent unverified).
Variable Required Notes
CIRCUITS_ENGINE_URL for sync Circuits engine control API (in-cluster), e.g. http://common-data-circuits-engine:7010. The control plane posts each compiled shape here.
DURABLE_STREAMS_URL for sync durable-streams base URL, e.g. http://common-data-durable-streams:8791. The /stream/* edge proxies its bytes.
STREAM_TOKEN_SECRET for sync HMAC key shared by the control plane (mints stream tokens) and the edge (verifies them). Cluster secret stream-token-secret.
EMERGENT_SYNC_MUTATION_RLS_ENABLED no Defaults to enabled; "false" bypasses RLS on sync mutations (dev only).
EMERGENT_SYNC_MUTATION_REQUEST_PATH no Override the in-DB mutation request path (default /api/mutations, the canonical batch-write path).

The three read-path variables are required together: with any of them unset the api logs a warning at boot and both the control plane (/sync/v1/subscribe|refresh|release|barrier) and the stream edge (/stream/*) answer 503 READ_PATH_UNCONFIGURED until it is restarted with all three set.

Language event consumer worker (lang-event-consumer)

Section titled “Language event consumer worker (lang-event-consumer)”

A worker host, not the api: apps/api/src/lang-event-consumer.ts runs as its own single-replica Deployment (the chart’s services.lang-event-consumer, strategy: Recreate, port 3014), draining the language Event-lane queues into the projector and running the merge-touched sweep on a cadence of its own. The “unset is safe” rule above does not apply to it: DATABASE_URL is required, and a malformed value for any knob below (0, -1, 1.5, ten) fails the boot with a LangEventConsumerConfigError rather than silently falling back — a chart value that does not do what it says is the fault nobody notices from outside. Unset is still ordinary: everything but DATABASE_URL has a default.

Variable Required Default Notes
DATABASE_URL yes — Injected by the chart (serviceDefaults.injectDatabaseEnv).
LANG_EVENT_CONSUMER_VISIBILITY_TIMEOUT_SECONDS no 120 Redelivery delay of a sub-batch whose callback threw, and the crash-recovery bound — not a processing budget (leases are renewed at half of it). Size it above ONE callback’s worst case.
LANG_EVENT_CONSUMER_BATCH_SIZE no 10 Max messages (each one single-stream sub-batch) per queue read.
LANG_EVENT_CONSUMER_SWEEP_LIMIT no 500 Rows one merge-touched sweep pass recomputes before ending; a big merge’s fallout drains over several passes.
LANG_EVENT_CONSUMER_SWEEP_ACTIVE_INTERVAL_MS no 5000 Sleep after a pass that discharged a stamp.
LANG_EVENT_CONSUMER_SWEEP_IDLE_INTERVAL_MS no 60000 Sleep after a pass that discharged nothing (the common case — merges are rare).
LANG_EVENT_CONSUMER_SWEEP_BACKOFF_INTERVAL_MS no 5000 First retry delay after a failing pass; doubles per consecutive failure.
LANG_EVENT_CONSUMER_SWEEP_MAX_BACKOFF_INTERVAL_MS no 300000 Ceiling for that doubling.
PORT no 3014 Heartbeat health server (/health, /ready). The chart always sets it from application.listenPort.
LANG_EVENT_CONSUMER_LIVENESS_STALE_MS no max(poll ceiling, sweep idle) × 3, ≥30s The MERGED heartbeat window: a beat from any source older than this fails liveness (stale). On the defaults that is 3 min; dev’s tighter sweep cadence makes it 45 s.
LANG_EVENT_CONSUMER_POLL_STALE_MS no max(poll ceiling × 3, 30s) The POLL-ONLY window: a last queue read older than this fails liveness (stale-poll) however fresh the merged beat is. 30000 on the library poll ceiling.

There is no consumption-pacing knob: the queue runner’s adaptive poll is @pgxsinkit/server’s internal (ADR-0053 decision 7). Only the sweep’s cadence is the host’s to set. The host passes no poll tuning either, so the runner’s idle ceiling is the library default (5 s) — which is what the liveness staleness default below is derived from.

What the probes actually observe. The process publishes one heartbeat, and its primary source is the queue poll: onPoll fires after every read the runner performs — productive, empty, or faulted — so the beat follows the loop that does the queue’s work and keeps ticking on an idle queue, where the callback is silent by design and the sweep beats only once an idle interval. The sweep loop (every pass, completed or failed) and the consumer callback (every delivered sub-batch) beat as well, because each is real work completed. A faulted read beats like any other, deliberately: the runner backs off and carries on, so a database outage does not restart the pod — it reads as pollFaults / lastPoll.fault in the /health body, alongside polls, the sweep counters and the delivery counters. Readiness is the first fresh beat, which the runner’s first read supplies within milliseconds of start.

Liveness applies two windows, and needs both. One timestamp cannot tell “something is turning” from “everything is turning”, so once a read has ever settled the probe requires the merged beat fresher than LANG_EVENT_CONSUMER_LIVENESS_STALE_MS and the last poll fresher than LANG_EVENT_CONSUMER_POLL_STALE_MS. A runner that stops reading while the sweep keeps passing therefore fails the probe within pollStaleMs (30 s on the defaults) instead of being masked indefinitely. The verdicts:

State /health status
No beat yet (booting) 200 starting
Beat fresh, poll fresh 200 ok
Beat fresh, no poll has ever settled (runner still booting) 200 ok
Beat fresh, last poll older than POLL_STALE_MS 503 stale-poll
Beat older than LIVENESS_STALE_MS (every source stopped) 503 stale

/ready answers the same codes, except that it is 503 rather than 200 before the first beat. ageMs and pollAgeMs are both in the body, so a 503 names the loop that stopped without diffing counters.

Applying it is the maintainer’s. Values live in infra/charts/emergent/values.yaml and infra/helmfile/values/dev/overrides-dev.yaml (dev runs the live source at /apps/api/src/lang-event-consumer.ts and tunes the sweep down to 2 s/15 s); a session never applies to a cluster.

Language enrichment worker (lang-enrichment-worker)

Section titled “Language enrichment worker (lang-enrichment-worker)”

A worker host, not the api: apps/api/src/lang-enrichment-worker.ts runs as its own single-replica Deployment (the chart’s services.lang-enrichment-worker, strategy: Recreate, port 3015), claiming Contents in processing_requested one at a time and running the enrichment engine over them (Phase-4 plan R5). Imports no longer enrich on the request path: the import (and the operator re-run, POST /workflow/lang-enrichment-reruns) marks the Content processing_requested and returns, and this process is what turns that into a processed Content with its enriched-package artifact — the book rewritten in place, plus one models sidecar per part (Phase-4 plan R4). The same “unset is safe” exception applies as to the event consumer: DATABASE_URL is required, and a malformed value for any knob below (0, -1, 1.5, ten) fails the boot with a LangEnrichmentWorkerConfigError rather than silently falling back.

Variable Required Default Notes
DATABASE_URL yes — Injected by the chart (serviceDefaults.injectDatabaseEnv).
SUPABASE_URL + SUPABASE_SECRET_KEY to run — Object storage (<SUPABASE_URL>/storage/v1, or SUPABASE_STORAGE_URL) — the worker READS the import’s bytes and WRITES the artifact. Absent, every pass throws before it claims.
LANG_ENRICHMENT_WORKER_ACTIVE_INTERVAL_MS no 2000 Sleep after a pass that CLAIMED a Content. Only about draining a backlog — a pass that just spent minutes on a book does not care.
LANG_ENRICHMENT_WORKER_IDLE_INTERVAL_MS no 15000 Sleep after a pass that found nothing queued. This is the LATENCY between “the import returned” and “the worker started”.
LANG_ENRICHMENT_WORKER_BACKOFF_INTERVAL_MS no 5000 First retry delay after a pass that THREW (unreachable database, unresolvable storage credentials); doubles per consecutive failure.
LANG_ENRICHMENT_WORKER_MAX_BACKOFF_INTERVAL_MS no 300000 Ceiling for that doubling.
PORT no 3015 Heartbeat health server (/health, /ready). The chart always sets it from application.listenPort.
LANG_ENRICHMENT_WORKER_LIVENESS_STALE_MS no max(idle × 3, 30s) A beat older than this with no pass in flight fails liveness (stale). 45 s on the defaults, 30 s in dev.

The engine’s own configuration is deliberately not part of the host config and is not read at boot. The four variables below are read per pass, by features/lang-enrichment/enrichment-environment.ts:

Variable Required Notes
LANG_ENRICHMENT_CORENLP_URL_ZH to run The Chinese CoreNLP endpoint. Per language: one shared endpoint would parse Chinese with English models.
LANG_ENRICHMENT_CORENLP_URL_EN to run The English one. The suffix is the CATALOG tag upper-cased, never a Bing code or a CoreNLP model name.
LANG_ENRICHMENT_BING_API_HOST to run The translation API host (api.cognitive.microsofttranslator.com), not a URL; a scheme is stripped.
LANG_ENRICHMENT_BING_API_KEY to run Its subscription key. From a secret (lang-enrichment-bing); never a value in a values file.

A deployment with no parser is one that records engines-unavailable on the Contents it claims, which an operator can read and retry; a worker that refused to boot without a translation key would take the queue down with it and could not say why.

Two workloads read all four, not one: this worker (imports) and the api — the paste route (features/lang-enrichment/lang-paste-enrichment-routes.ts) enriches in-request and builds its providers from the same environment. In dev both are set: infra/helmfile/values/dev/overrides-dev.yaml on services.lang-enrichment-worker, and overrides-supabase-dev.yaml on the api’s functions.extraEnvVars. The CoreNLP pair is chart-declared — services.corenlp-zh and services.corenlp-en in infra/charts/emergent/values.yaml, one upstream transcrobes/corenlp-* image per language (per language because one shared server would parse Chinese with English models), addressed as http://emergent-corenlp-zh:9000 and http://emergent-corenlp-en:9000, with heap, thread count, query timeout and the Chinese segmenter under each service’s application. The translation key comes from the lang-enrichment-bing secret (infra/secrets/emergent/lang-enrichment-bing.yaml), whose committed value is a dummy replaced outside the repo at bootstrap like the other external-service keys — until it is, the parsers work, every gloss lookup 401s, and an import attempted in that state records run-failed and spends an attempt, so replace it before the first import. A pdf import still stops at no-text-extractor before the engines are asked for at all (epub and plain text do reach them).

⛔ Never a placeholder URL. An endpoint that resolves and then fails records run-failed, which spends an attempt, where the unconfigured refusal’s engines-unavailable is a plain failure an operator fixes and re-queues.

What the probes actually observe. One work source, so one heartbeat and one window: every settled pass beats — claimed, idle, or failed alike — so an empty queue keeps beating on the idle cadence and a database or parser outage does too (the loop catches, reports, backs off and passes again). The outage reads as passErrors / lastError in the /health body, alongside passes, claims, processed and the last pass’s outcome. Readiness is the first beat, which the loop publishes as it starts its first pass.

⛔ The staleness window is suspended while a pass is in flight (status: "working"), and that is the one place this host differs from every other worker. A pass is a whole book — thousands of parser round trips — so the gap between beats is unbounded by anything the host controls. Failing liveness there would restart the pod mid-book, leaving the Content at processing with its attempt spent and recoverable only by an operator’s breakClaim; three such restarts dead-letter a book that was never broken. So liveness detects the one wedge a restart actually fixes — the loop stopped turning between passes — and a hung pass is reported instead: inFlightMs and the claimed content id are in the body, and the row sits visibly at processing.

State /health status
No beat yet (booting) 200 starting
A pass in flight, however long 200 working
Between passes, beat fresh 200 ok
Between passes, beat older than STALE_MS 503 stale

/ready answers the same codes, except that it is 503 rather than 200 before the first beat.

Operating it. A Content’s state is the whole record (ADR-0061): processing_requested = queued, processing = a worker owns it, failed + processing_reason = it ran and did not publish, processed = terminal and frozen. A row parked at processing with no worker running is a died-mid-run claim: re-queue it with POST /workflow/lang-enrichment-reruns {"contentId": "…", "breakClaim": true} once you have established that no run is live. A failed row re-queues with the same call without breakClaim. At processing_attempts = 3 the row is dead-lettered and the endpoint refuses (409): resurrection is a developer zeroing the counter with direct database access, deliberately.

Applying it is the maintainer’s. Values live in infra/charts/emergent/values.yaml and infra/helmfile/values/dev/overrides-dev.yaml (dev runs the live source at /apps/api/src/lang-enrichment-worker.ts and tightens the cadence to 1 s/5 s); a session never applies to a cluster.

One variable, read by the api at boot (features/lang-dictionary/definition-batch-config.ts, wired in registerLangDictionaryRoutes).

Variable Required Default Notes
LANG_DEFINITION_BATCH_MAX_LEXEMES no 1000 How many lexeme ids one POST /workflow/lang-dictionary-definitions may name (offline plan R7). A positive integer; anything else fails the boot naming the variable and the value. Unset or empty = the default.

What changing it means. The number is not only a request limit: it is what the client chunks at. GET /workflow/lang-dictionaries reports it as batchMaxLexemes, the definition cache stores it (lang_definition_coverage_state.batch_max_lexemes) at each entitlement check, and every later diff/fetch/local-read takes chunks of that size. So a change takes effect on a device at its next entitlement check (once per session), and in between a client keeps chunking at the size it was last told — which is why an over-sized chunk is refused loudly (400, naming the cap) rather than truncated or silently retried smaller: the mismatch belongs to the operator who changed the cap, and the client surfacing it is how they see it. Lower it to cut peak request/response size; raise it to cut the number of round trips a chapter’s backfill takes. A device that has never reconciled uses the compiled-in default (DEFINITION_BATCH_MAX_LEXEMES in @emergent/db/lang-dictionary).

Variable Required Notes
EMERGENT_LTI_TOOL_ENABLED no Enables the LTI tool routes.
LTI_TOOL_KEY_ID no kid for the tool’s signing key (else a default).
EMERGENT_LTI_TOOL_ALLOW_EPHEMERAL_KEYS no Dev only: allow ephemeral (non-persisted) keys.

emergent acting as a platform that launches into external tools (the inverse of the tool role above). The /lti/platform/* endpoints are unset-safe — each returns 503 until configured, so none of these are required to boot.

Variable Required Notes
LTI_PLATFORM_ISSUER for launches The platform iss stamped on every launch, and the base of the JWKS URL. Falls back to API_PUBLIC_URL (then EMERGENT_PUBLIC_API_URL).
LTI_PLATFORM_TOKEN_SECRET for NRPS/AGS Long random HS256 secret; mints and verifies the service (NRPS/AGS) access tokens — emergent is both the authorization server and the resource server.
LTI_PLATFORM_PRIVATE_JWK_JSON / LTI_PLATFORM_PUBLIC_JWK_JSON for launches The RS256 id_token signing keypair (JWK JSON). The public half is served at /lti/platform/jwks for tools to verify launches. Set both together.
EMERGENT_LTI_PLATFORM_ALLOW_EPHEMERAL_KEYS no Dev only: generate an ephemeral RS256 keypair when the JWKs are unset (rotates per restart — fine for a local spike, breaks JWKS caching).

Generate the platform signing keypair (the env values above mirror the tool side’s key custody — no Vault, no DB):

Terminal window
bun -e '
import { generateKeyPair, exportJWK, calculateJwkThumbprint } from "jose";
const { publicKey, privateKey } = await generateKeyPair("RS256", { extractable: true });
const pub = await exportJWK(publicKey), priv = await exportJWK(privateKey);
const kid = await calculateJwkThumbprint(pub);
pub.kid = priv.kid = kid; pub.use = "sig"; pub.alg = "RS256";
console.log("LTI_PLATFORM_PRIVATE_JWK_JSON=" + JSON.stringify(priv));
console.log("LTI_PLATFORM_PUBLIC_JWK_JSON=" + JSON.stringify(pub));
'

For local dev, .env.development.local already ships a stable generated keypair + token secret and an LTI_PLATFORM_ISSUER pointing at the loc API origin, so the platform endpoints work out of the box. In a real deployment, set LTI_PLATFORM_TOKEN_SECRET and the JWK pair from a secret store (the same way the credential-signing keys are handled — see credential-issuer-keys.md); LTI_PLATFORM_ISSUER falls back to API_PUBLIC_URL, so it only needs setting if the platform issuer differs from the API origin.

Variable Required Notes
CMI5_API_INTERNAL_URL, CMI5_LRS_INTERNAL_URL cluster Internal cmi5 fetch/state + LRS endpoints (set by the deploy).
CMI5_LAUNCH_SESSION_TTL_SECONDS no Launch-session lifetime (else a built-in default).
EMERGENT_XAPI_ACTOR_HOME_PAGE no xAPI actor account homePage (default https://emergent.app).
Variable Notes
EMERGENT_SEED_PROFILE Which deterministic seed profile to load.
EMERGENT_SEED_VALUE drizzle-seed RNG seed.
EMERGENT_SMALL_SEED_DEFAULT_PASSWORD / _TEACHER_PASSWORD / _LEARNER_PASSWORD Passwords for seeded accounts (small profile).
  • credential-issuer-keys.md — signing role logins, SIGNING_DATABASE_URL / HOLDER_SIGNING_DATABASE_URL wiring, key rotation.
  • migrations.md — the migration workflow (additive); the credential_signing_role and storage_buckets migrations create the signing roles + storage buckets.
  • consuming-conform-ed-and-pgxsinkit.md — the @conform-ed/* / @pgxsinkit/* dependency channel.