Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.kaireonai.com/llms.txt

Use this file to discover all available pages before exploring further.

KaireonAI reads ~169 environment variables across the Next.js platform (platform/src/), the BullMQ worker (platform/src/worker/), the MCP server (platform/src/mcp/), the license-generator script (platform/scripts/), and the Python ml-worker (ml-worker/). This page is the canonical index — every variable below was verified by grepping the codebase against the cited file:line.

What it documents

Each variable below has a name, source file:line of its first read, default value (literal ||/?? fallback in the code, or when there is none), and a one-line purpose. Variables are grouped by domain so an operator can configure a single subsystem without scrolling the whole page. Subsystem deep-dives live on /platform/ops/configuration-reference and /deployment/helm-reference; this page indexes everything in one place and cross-links to the deep-dive where one exists.

Quick start

The minimum to boot the platform locally:
DATABASE_URL=postgresql://user:pass@localhost:5432/kaireon
NEXTAUTH_SECRET=<random 32+ char string>
JWT_SIGNING_SECRET=<random 32+ char string>
CONNECTOR_ENCRYPTION_KEY=<random 32+ char string>
WEBHOOK_SIGNING_SECRET=<random 32+ char string>
API_KEY_PEPPER=<random 32+ char string>
DATABASE_URL is the only variable required outside production (platform/src/lib/env-validation.ts:18); the other five become required when NODE_ENV=production (platform/src/lib/env-validation.ts:19-23). Production checklist (in addition to the six above):
  • REDIS_URL — required for caching, rate limiting, and the BullMQ worker queue (platform/src/worker/index.ts:27).
  • CORS_ALLOWED_ORIGINS — must be a non-empty, non-wildcard list in production or validateEnvFormats warns (platform/src/lib/env-validation.ts:91-93).
  • EVENT_PUBLISHER + the matching backend group (KAFKA_*, MSK_*, EVENTBRIDGE_*, KINESIS_*) — defaults to redis (platform/src/lib/infra/container.ts:50).
  • INTERACTION_STORE + the matching backend group (SCYLLA_*, DYNAMODB_*, KEYSPACES_*) — defaults to pg (platform/src/lib/infra/container.ts:123).
  • SEARCH_INDEX + OPENSEARCH_* when running OpenSearch — defaults to pg (platform/src/lib/infra/container.ts:186).
  • OTEL_EXPORTER_OTLP_ENDPOINT — when shipping traces (platform/src/lib/tracing.ts:63).
  • A SIEM block (SIEM_BACKEND + SIEM_ENDPOINT + optional SIEM_API_KEY/SIEM_SOURCETYPE/SIEM_INDEX) — when shipping audit logs to Splunk/Datadog/Elastic (platform/src/lib/audit/sink.ts:48-67).

How it works

platform/src/lib/env-validation.ts:35 runs at process startup (imported eagerly from prisma.ts). Two passes:
  1. PresencevalidateEnv() iterates the REQUIRED_ENV_VARS list at env-validation.ts:17-26. Production-required keys missing → throw. Development-required keys missing → warn-only.
  2. FormatvalidateEnvFormats() at env-validation.ts:72 checks DATABASE_URL starts with postgresql://, REDIS_URL starts with redis:///rediss://, PORT is in [1, 65535], CORS_ALLOWED_ORIGINS is non-empty/non-wildcard in production, and any OPTIONAL_BOOLEAN_VARS are literally "true" or "false".
The build phase (NEXT_PHASE === "phase-production-build") skips validation entirely (env-validation.ts:37) so next build does not need production secrets. Subsystem env reads happen lazily at first use:
  • The DI container at platform/src/lib/infra/container.ts reads EVENT_PUBLISHER, INTERACTION_STORE, and SEARCH_INDEX once-per-process to pick the backend, then reads the backend-group vars to construct the client.
  • The Prisma pool at platform/src/lib/prisma.ts:21 reads PG_POOL_MAX once at module load.
  • Per-request env reads (e.g. process.env.NEGOTIATION_GLOBAL_KILL at negotiate/apply/route.ts:121, process.env.ALLOW_UNSIGNED_WEBHOOKS at webhooks/delivery/route.ts:20) hit process.env on every call. Operators changing those vars need a process restart only when the read is module-scoped, not per-request.
Tier behavior:
NODE_ENVWhat changes
productionRequired keys throw on missing. CORS wildcard rejected. CSP unsafe-eval removed. Encryption fallback key disabled (encryption.ts:36-42).
developmentRequired keys warn-only. CSP allows unsafe-eval for React stack traces. Deterministic encryption fallback key allowed.
testSame as development plus rate limiter is disabled and RLS_AUTO_ENABLE is force-skipped (prisma.ts:81).

Reference

Database and migrations

Env VarDefaultRead FromPurpose
DATABASE_URLplatform/src/lib/prisma.ts (via prisma.config.ts); also platform/src/app/api/v1/cron/cleanup/route.ts:105PostgreSQL connection string. Required in all tiers.
PG_POOL_MAX50platform/src/lib/prisma.ts:21pg pool max connection count.
RLS_AUTO_ENABLEenabled (skipped only when "false")platform/src/lib/prisma.ts:82Auto-enable Postgres Row-Level Security on all tenant tables at boot. Set to "false" to skip; never disable in production.

Auth and MFA

Env VarDefaultRead FromPurpose
NEXTAUTH_URLhttps://playground.kaireonai.complatform/src/app/api/v1/auth/verify/route.ts:6; also platform/src/lib/email.ts:19Public canonical URL for NextAuth callbacks and outbound email links.
NEXTAUTH_SECRETplatform/src/middleware.ts:200NextAuth.js session-cookie signing secret. Required in production.
JWT_SIGNING_SECRETplatform/src/lib/oauth.ts:17HMAC key for OAuth2 JWT issue + verify. Required in production. Falls back to NEXTAUTH_SECRET when unset.
API_KEY_PEPPERplatform/src/lib/oauth.ts:39HMAC pepper for client-secret hashing. Required in production.
AUTH_URLhttp://localhost:3000platform/src/lib/auto-seed.ts:42Auth.js base URL used by the auto-seed dispatcher when NEXTAUTH_URL is unset.
GOOGLE_CLIENT_IDplatform/src/lib/auth.ts:34Google OAuth client id (sign-in via Google).
GOOGLE_CLIENT_SECRETplatform/src/lib/auth.ts:34Companion to GOOGLE_CLIENT_ID.
MFA_ENFORCEMENT_DISABLEDplatform/src/middleware.ts:196Test-only flag. Disables MFA gate so integration tests can write without TOTP. Never set in production.
CONNECTOR_ENCRYPTION_KEY— (required in prod)platform/src/lib/settings/platform-settings.ts:12AES-256 raw key for encrypting connector secrets at rest. SHA-256 derived to a 32-byte AES key (encryption.ts:26).
CONNECTOR_ENCRYPTION_KEY_VERSION1platform/src/lib/encryption.ts:30Versioned-secret rotation pointer for the active key.
CONNECTOR_ENCRYPTION_KEY_PREVIOUSplatform/src/lib/encryption.ts:31Previous key, used to decrypt rows still tagged with the prior version.
CONNECTOR_ENCRYPTION_KEY_PREVIOUS_VERSION0platform/src/lib/encryption.ts:32Version number paired with CONNECTOR_ENCRYPTION_KEY_PREVIOUS.
WEBHOOK_SIGNING_SECRET— (required in prod)platform/src/app/api/v1/journeys/callback/[token]/route.ts:77HMAC-SHA256 secret for outbound + inbound webhook signature verification. Also gates the delivery webhook endpoint.
ALLOW_UNSIGNED_WEBHOOKSplatform/src/app/api/v1/webhooks/delivery/route.ts:20Dev-only override. When "true" and NODE_ENV !== "production", accepts unsigned webhooks. Hard-blocked in production.

Network, CORS, and CSP

Env VarDefaultRead FromPurpose
NODE_ENVplatform/src/middleware.ts:47Standard Node runtime tier (production / development / test). Drives env-validation strictness, CSP, encryption fallback.
NEXT_PHASEplatform/src/lib/env-validation.ts:10Next.js framework env. phase-production-build skips env-validation so next build does not need secrets.
NEXT_RUNTIMEplatform/src/instrumentation.ts:16Next.js framework env. Differentiates Edge runtime vs Node runtime when wiring instrumentation.
NEXT_PUBLIC_APP_URLhttp://localhost:3000platform/src/lib/ai/tools/studio-tools.ts:8Public app URL exposed to the browser bundle. Used by Studio AI tools for internal fetch base.
NEXT_PUBLIC_BASE_URLhttp://localhost:3000platform/src/lib/ai/tools/data-tools.ts:15Companion to NEXT_PUBLIC_APP_URL used by Data AI tools.
PORT— (Next.js default 3000)platform/src/lib/env-validation.ts:85HTTP listen port. Validated as integer in [1, 65535].
CORS_ALLOWED_ORIGINS— (deny all cross-origin)platform/src/middleware.ts:33Comma-separated allowlist of cross-origin domains. Wildcard * rejected in production (middleware.ts:46-50).
CSP_DISABLEDplatform/src/middleware.ts:79Set to "true" to skip CSP header (dev only).
CSP_POLICYcomputed defaultplatform/src/middleware.ts:82Override the default Content Security Policy string.
INTERNAL_SERVICE_SECRETplatform/src/middleware.ts:227Shared secret for service-to-service requests inside the cluster.
INTERNAL_API_URLplatform/src/lib/seed-executor.ts:64Base URL for service-to-service API calls from the worker back into the platform. Falls back to NEXTAUTH_URL, then http://localhost:3000.
API_KEYplatform/src/middleware.ts:235Outbound system API key used by internal jobs that talk to themselves over HTTP.

Redis, caching, and rate limits

Env VarDefaultRead FromPurpose
REDIS_URL— (cache disabled)platform/src/lib/env-validation.ts:80; also platform/src/worker/index.ts:27 (default redis://localhost:6379)Redis/Valkey connection string. Required for the BullMQ worker; optional for the platform (cache falls back to in-memory).
RATE_LIMIT_TIERplatform/src/lib/api-rate-limit.ts:39Per-tenant rate-limit tier override. Used by the unified sliding-window limiter.
SLOW_API_THRESHOLD_MS150platform/src/lib/api-instrumentation.ts:20Per-route warn threshold in milliseconds. Routes exceeding this log a slow_api warn.

Event publisher (Kafka / MSK / EventBridge / Kinesis / Redpanda)

EVENT_PUBLISHER selects the backend; only the matching group is read.
Env VarDefaultRead FromPurpose
EVENT_PUBLISHERredisplatform/src/lib/infra/container.ts:50Backend selector — redis / kafka / redpanda / msk / eventbridge / kinesis.
KAFKA_BROKERSplatform/src/lib/infra/container.ts:56Comma-separated host:port list.
KAFKA_CLIENT_IDplatform/src/lib/infra/container.ts:57KafkaJS client id.
KAFKA_TLS_ENABLEDplatform/src/lib/infra/container.ts:58"true" to enable TLS.
KAFKA_SASL_MECHANISMplatform/src/lib/infra/container.ts:59plain / scram-sha-256 / scram-sha-512.
KAFKA_SASL_USERNAMEplatform/src/lib/infra/container.ts:60SASL username.
KAFKA_SASL_PASSWORDplatform/src/lib/infra/container.ts:61SASL password.
KAFKA_CONSUMER_GROUP_IDplatform/src/lib/infra/container.ts:62Consumer group id (for inbound consumer wiring).
MSK_BROKERSplatform/src/lib/infra/container.ts:70AWS MSK bootstrap broker list.
MSK_REGIONus-east-1platform/src/lib/infra/container.ts:71AWS region.
MSK_AUTH_MODEiam_roleplatform/src/lib/infra/container.ts:72iam_role / sasl.
MSK_ROLE_ARNplatform/src/lib/infra/container.ts:73IAM role ARN when MSK_AUTH_MODE=iam_role.
MSK_SASL_USERNAMEplatform/src/lib/infra/container.ts:74SASL username when MSK_AUTH_MODE=sasl.
MSK_SASL_PASSWORDplatform/src/lib/infra/container.ts:75SASL password when MSK_AUTH_MODE=sasl.
MSK_CONSUMER_GROUP_IDplatform/src/lib/infra/container.ts:76Consumer group id.
MSK_TOPIC_PREFIXplatform/src/lib/infra/container.ts:77Topic name prefix.
EVENTBRIDGE_AUTH_MODEiam_roleplatform/src/lib/infra/container.ts:85iam_role / access_key.
EVENTBRIDGE_REGIONus-east-1platform/src/lib/infra/container.ts:86AWS region.
EVENTBRIDGE_ROLE_ARNplatform/src/lib/infra/container.ts:87IAM role ARN.
EVENTBRIDGE_ACCESS_KEY_IDplatform/src/lib/infra/container.ts:88Static credentials when auth_mode=access_key.
EVENTBRIDGE_SECRET_ACCESS_KEYplatform/src/lib/infra/container.ts:89Companion to access key id.
EVENTBRIDGE_BUS_NAMEplatform/src/lib/infra/container.ts:90Target event bus name.
EVENTBRIDGE_DETAIL_TYPE_PREFIXplatform/src/lib/infra/container.ts:91Prepended to every emitted detail-type.
KINESIS_AUTH_MODEiam_roleplatform/src/lib/infra/container.ts:99iam_role / access_key.
KINESIS_REGIONus-east-1platform/src/lib/infra/container.ts:100AWS region.
KINESIS_ROLE_ARNplatform/src/lib/infra/container.ts:101IAM role ARN.
KINESIS_ACCESS_KEY_IDplatform/src/lib/infra/container.ts:102Static credentials when auth_mode=access_key.
KINESIS_SECRET_ACCESS_KEYplatform/src/lib/infra/container.ts:103Companion to access key id.
KINESIS_STREAM_NAMEkaireon-eventsplatform/src/lib/infra/container.ts:104Target stream.
KINESIS_PARTITION_KEYplatform/src/lib/infra/container.ts:105Field name extracted from event payload as the partition key.

AI providers

The platform uses generic env keys AI_PROVIDER / AI_MODEL / AI_API_KEY / AI_BASE_URL rather than vendor-native keys (OPENAI_API_KEY, ANTHROPIC_API_KEY). The vendor-native keys are not read directly — apiKey is passed into the SDK constructor. Tenant-level overrides in the Settings UI take precedence over env (platform/src/lib/ai/provider.ts:20-23).
Env VarDefaultRead FromPurpose
AI_PROVIDERgoogleplatform/src/lib/ai/provider.ts:20-23, 46-49 (via AI_ENV.PROVIDER at types.ts:15)Provider selector — google / anthropic / openai / ollama / lm_studio / bedrock.
AI_MODELgemini-2.5-flashplatform/src/lib/ai/provider.ts:20-23, 46-49 (via AI_ENV.MODEL at types.ts:16)Model id passed to the provider SDK.
AI_API_KEYplatform/src/lib/ai/provider.ts:20-23, 46-49 (via AI_ENV.API_KEY at types.ts:17)API key for the selected provider.
AI_BASE_URL— (Ollama default http://127.0.0.1:11434/api)platform/src/lib/ai/provider.ts:20-23, 46-49 (via AI_ENV.BASE_URL at types.ts:18)Override base URL — required for Ollama and LM Studio.
ML_WORKER_URLplatform/src/app/api/v1/ai/analyze/[type]/route.ts:68Python ml-worker base URL (FastAPI service hosting ONNX scoring + LightGBM training).
ML_WORKER_API_KEYplatform/src/lib/ml-worker-client.ts:95Bearer token for ml-worker requests.
ML_WORKER_TIMEOUT_MSplatform/src/lib/ml-worker-client.ts:86Request timeout for ml-worker calls.

Scoring and ONNX

Env VarDefaultRead FromPurpose
ONNX_BLOB_STORE_URLplatform/src/lib/scoring/onnx-blob-store.ts:161ONNX BYO model store URL. Supports file:// and s3:// schemes. Unset = inline storage in modelState JSON. Throws on unrecognized schemes.
ONNX_INLINE_BYTES_LIMIT10485760 (10 MB)platform/src/lib/scoring/onnx-blob-store.ts:187Threshold above which model bytes are offloaded to the blob store rather than inlined into modelState.
RETRAIN_EVERY_N100platform/src/app/api/v1/respond/route.ts:48Per-tenant outcome-debounce. Bayesian, Thompson, epsilon-greedy, and online-learner models recompute every Nth outcome. Set to 1 for true real-time.
ATTRIBUTION_TIMEOUT_MS5000platform/src/app/api/v1/respond/route.ts:647Timeout for the recommendation lookup that backs outcome attribution.

Interaction store (Postgres / DynamoDB / Keyspaces / ScyllaDB)

INTERACTION_STORE selects the backend; only the matching group is read.
Env VarDefaultRead FromPurpose
INTERACTION_STOREpgplatform/src/lib/infra/container.ts:123Backend selector — pg / dynamodb / keyspaces / scylla / cassandra.
SCYLLA_CONTACT_POINTSlocalhostplatform/src/lib/infra/container.ts:129Comma-separated host list.
SCYLLA_LOCAL_DATACENTERdatacenter1platform/src/lib/infra/container.ts:130Local datacenter for token-aware routing.
SCYLLA_KEYSPACEkaireonplatform/src/lib/infra/container.ts:131Target keyspace name.
SCYLLA_USERNAMEplatform/src/lib/infra/container.ts:132Auth username.
SCYLLA_PASSWORDplatform/src/lib/infra/container.ts:133Auth password.
SCYLLA_TLS_ENABLEDplatform/src/lib/infra/container.ts:134"true" to enable TLS.
SCYLLA_REPLICATION_FACTORplatform/src/lib/infra/container.ts:135Keyspace replication factor (integer).
SCYLLA_CONSISTENCY_LEVELplatform/src/lib/infra/container.ts:138e.g. LOCAL_QUORUM.
SCYLLA_POOL_SIZEplatform/src/lib/infra/container.ts:139Driver connection pool size.
SCYLLA_REQUEST_TIMEOUT_MSplatform/src/lib/infra/container.ts:142Per-request timeout.
DYNAMODB_TABLE_NAMEkaireon-interactionsplatform/src/lib/infra/container.ts:151Target DynamoDB table.
DYNAMODB_AUTH_MODEiam_roleplatform/src/lib/infra/container.ts:152iam_role / access_key.
DYNAMODB_REGIONus-east-1platform/src/lib/infra/container.ts:153AWS region.
DYNAMODB_ROLE_ARNplatform/src/lib/infra/container.ts:154IAM role ARN.
DYNAMODB_ACCESS_KEY_IDplatform/src/lib/infra/container.ts:155Static credentials.
DYNAMODB_SECRET_ACCESS_KEYplatform/src/lib/infra/container.ts:156Companion to access key id.
KEYSPACES_KEYSPACEkaireonplatform/src/lib/infra/container.ts:164AWS Keyspaces target keyspace.
KEYSPACES_USERNAMEplatform/src/lib/infra/container.ts:165Service-specific credentials username.
KEYSPACES_PASSWORDplatform/src/lib/infra/container.ts:166Service-specific credentials password.
KEYSPACES_REGIONus-east-1platform/src/lib/infra/container.ts:167AWS region.
KEYSPACES_AUTH_MODEaccess_keyplatform/src/lib/infra/container.ts:168access_key / iam_role.
KEYSPACES_REQUEST_TIMEOUT_MSplatform/src/lib/infra/container.ts:169Per-request timeout.

Search index (Postgres / OpenSearch)

Env VarDefaultRead FromPurpose
SEARCH_INDEXpgplatform/src/lib/infra/container.ts:186Backend selector — pg / opensearch.
OPENSEARCH_NODE_URLhttps://localhost:9200platform/src/lib/infra/container.ts:191OpenSearch node URL.
OPENSEARCH_USERNAMEplatform/src/lib/infra/container.ts:192Basic auth username.
OPENSEARCH_PASSWORDplatform/src/lib/infra/container.ts:193Basic auth password.
OPENSEARCH_TLS_ENABLEDenabled (skip when "false")platform/src/lib/infra/container.ts:194TLS toggle.
OPENSEARCH_TLS_REJECT_UNAUTHORIZEDenabled (skip when "false")platform/src/lib/infra/container.ts:195Cert-validation toggle.
OPENSEARCH_INDEX_PREFIXkaireon-platform/src/lib/infra/container.ts:196Prepended to every index name.
OPENSEARCH_REQUEST_TIMEOUT_MSplatform/src/lib/infra/container.ts:197Per-request timeout.
OPENSEARCH_MAX_RETRIESplatform/src/lib/infra/container.ts:200SDK-level retry count.
OPENSEARCH_AUTH_MODEbasicplatform/src/lib/infra/container.ts:203basic / iam_role.
OPENSEARCH_REGIONplatform/src/lib/infra/container.ts:204AWS region (for iam_role mode against AWS-managed OpenSearch).
OPENSEARCH_ROLE_ARNplatform/src/lib/infra/container.ts:205IAM role ARN.
OPENSEARCH_ACCESS_KEY_IDplatform/src/lib/infra/container.ts:206Static credentials.
OPENSEARCH_SECRET_ACCESS_KEYplatform/src/lib/infra/container.ts:207Companion to access key id.

Storage and attachments

Env VarDefaultRead FromPurpose
STORAGE_BACKENDlocalplatform/src/lib/ai/import/storage/factory.ts:15AI-import attachment backend — local or s3. Unrecognized values throw.
ATTACHMENT_S3_BUCKETplatform/src/lib/ai/import/storage/factory.ts:18S3 bucket for attachments when STORAGE_BACKEND=s3. Required when backend is s3.
ATTACHMENT_STORAGE_PATH/var/kaireon/attachmentsplatform/src/lib/ai/import/storage/factory.ts:38Local filesystem base path when STORAGE_BACKEND=local.
AWS_REGIONus-east-1platform/src/lib/email.ts:14Default AWS region for SES + S3 SDK clients.

Email and outbound

Env VarDefaultRead FromPurpose
SES_FROM_EMAILsupport@kaireonai.complatform/src/lib/email.ts:17From-address used by all SES-sent transactional emails.

Governance, approvals, and license

Env VarDefaultRead FromPurpose
APPROVAL_MAX_AGE_HOURS168 (7 days)platform/src/app/api/v1/cron/approvals-expire/route.ts:91Pending approvals older than this are auto-expired by the cron sweep. Falls back on invalid input rather than failing.
NEGOTIATION_GLOBAL_KILLplatform/src/app/api/v1/decisions/[id]/negotiate/apply/route.ts:121Global kill switch for the agent-negotiation apply path. Set to "true" to reject every apply across all tenants.
KAIREON_LICENSE_PRIVATE_KEY— (auto-generates RSA pair when unset)platform/scripts/generate-license.mjs:67RSA private key (PEM, PKCS8) for signing customer licenses. The matching public key ships embedded in the platform for verification.

Worker, outbox, and seed

Env VarDefaultRead FromPurpose
WORKER_CONCURRENCY5platform/src/worker/index.ts:28BullMQ worker concurrency per process.
WORKER_METRICS_PORT9091platform/src/worker/index.ts:29Worker Prometheus exporter listen port.
WORKER_SECRETworker-internalplatform/src/lib/seed-executor.ts:71Worker→API shared secret (X-Worker-Secret header). The default is a known string — override in production.
_SEED_FROM_WORKERplatform/src/lib/seed-executor.ts:60Internal flag the seed-executor sets at :60 and deletes at :100. Currently has no reader — reserved for future API-side reentrancy detection. Operators should not set this.
OUTBOX_LIVENESS_FILE/tmp/outbox-publisher.aliveplatform/src/worker/outbox-publisher.ts:58Liveness file the outbox publisher touches each loop. K8s liveness probe reads its mtime.
OUTBOX_POLL_INTERVAL_MS2000platform/src/worker/outbox-publisher.ts:53Outbox polling interval in ms.
OUTBOX_SHUTDOWN_DRAIN_TIMEOUT_MS15000platform/src/worker/outbox-publisher.ts:54-57Max time to wait for in-flight publishes to drain on shutdown.
OUTBOX_REAPER_STALENESS_SECONDS300platform/src/app/api/v1/cron/outbox-reaper/route.ts:74Outbox rows older than this are reset by the reaper sweep. Falls back on invalid input.

Cron tier

Env VarDefaultRead FromPurpose
CRON_SECRETplatform/src/app/api/v1/cron/siem-ship/route.ts:18Bearer token gating /api/v1/cron/* endpoints (k8s CronJobs).
CRON_TOKENplatform/src/app/api/cron/tick/route.ts:62Bearer token gating the legacy single /api/cron/tick endpoint. Distinct from CRON_SECRET.

Observability — tracing, metrics, logs

Env VarDefaultRead FromPurpose
LOG_LEVELinfoplatform/src/lib/logging.ts:13Log level threshold for the structured logger (silent / error / warn / info / debug).
OTEL_EXPORTER_OTLP_ENDPOINTplatform/src/lib/tracing.ts:63OTLP traces+metrics exporter endpoint. Tracing disabled when unset.
The structured logger pairs with the logError(context, err, meta?) helper at platform/src/lib/api-error.ts:118. logError mints a per-call UUID errorId, sanitizes the error message, attaches the meta block, and returns the errorId for the caller to surface (HTTP response body, downstream worker telemetry, audit row). Use it for any caught error a SIEM or operator may need to correlate later. Adoption is incremental — the API-route layer and the Outbox publisher worker already mint errorId per failed tick (platform/src/worker/outbox-publisher.ts:92); other workers still emit bare getLogger().error() calls and are tracked in .planning/RESIDUALS_2026-04-29.md residual #18 for migration.

Audit + SIEM

Env VarDefaultRead FromPurpose
SIEM_BACKENDplatform/src/lib/audit/sink.ts:49SIEM target — splunk / datadog / elastic. Unset = no SIEM ship-out. Unknown values warn-and-disable.
SIEM_ENDPOINTplatform/src/lib/audit/sink.ts:55SIEM ingest endpoint URL. Required when SIEM_BACKEND is set.
SIEM_API_KEYplatform/src/lib/audit/sink.ts:63Bearer token for SIEM ingest (Splunk HEC token, Datadog API key, etc.).
SIEM_SOURCETYPEplatform/src/lib/audit/sink.ts:64Splunk-only sourcetype name.
SIEM_INDEXplatform/src/lib/audit/sink.ts:65Elastic-only index name (Splunk uses sourcetype).

Provenance, supply chain, and signing

Env VarDefaultRead FromPurpose
GIT_SHAplatform/src/app/api/v1/decisions/[id]/provenance/route.ts:148Build-time git SHA stamped into Decision Provenance Bundles. SLSA attestation skipped when missing.
GIT_REPOplatform/src/app/api/v1/decisions/[id]/provenance/route.ts:149Build-time git repo URL.
IMAGE_NAMEplatform/src/app/api/v1/decisions/[id]/provenance/route.ts:150Container image name (e.g. ghcr.io/kaireonai/platform).
IMAGE_DIGESTplatform/src/app/api/v1/decisions/[id]/provenance/route.ts:151Container image digest (sha256:…).
SBOM_DIGEST_SHA256platform/src/app/api/v1/decisions/[id]/provenance/route.ts:152Hex digest of the published SBOM. Pinned into the SLSA statement.
BUILDER_IDkaireon.platform.runtimeplatform/src/app/api/v1/decisions/[id]/provenance/route.ts:164SLSA builder.id.
BUILDER_VERSIONunknownplatform/src/app/api/v1/decisions/[id]/provenance/route.ts:165SLSA builder.version.
BUILD_STARTED_ONrequest-time fallbackplatform/src/app/api/v1/decisions/[id]/provenance/route.ts:166SLSA metadata.buildStartedOn.
BUILD_FINISHED_ONrequest-time fallbackplatform/src/app/api/v1/decisions/[id]/provenance/route.ts:167SLSA metadata.buildFinishedOn.
GITHUB_RUN_IDrequest id fallbackplatform/src/app/api/v1/decisions/[id]/provenance/route.ts:168SLSA invocationId.
COSIGN_BINARYcosignplatform/src/lib/supply-chain/cosign-sign-blob.ts:43Cosign CLI binary path. Override when not on PATH.
COSIGN_KEYplatform/src/lib/supply-chain/__tests__/cosign-sign-blob.test.ts:65Cosign signing-key file path.

Webhooks and inbound channels

Env VarDefaultRead FromPurpose
WHATSAPP_APP_SECRETplatform/src/app/api/v1/webhooks/whatsapp/route.ts:87Meta WhatsApp app secret used to verify the X-Hub-Signature-256 header on inbound.
WHATSAPP_WEBHOOK_VERIFY_TOKENplatform/src/app/api/v1/webhooks/whatsapp/route.ts:32Token returned during the Meta hub.verify_token handshake.

Multi-region and tenant routing

Env VarDefaultRead FromPurpose
KAIREON_REGIONus-east-1platform/src/lib/tenant/region-router.ts:28Region binding for the running process (e.g. us-east-1). Used by the multi-region router to decide whether a tenant request is local or must redirect.
MULTI_REGION_ENABLEDplatform/src/lib/tenant/region-router.ts:32"true" enables multi-region routing.
PLATFORM_OWNER_TENANT_IDplatform/src/app/api/v1/platform-settings/route.ts:10Tenant id treated as the platform owner — gates write access to platform-wide settings.
SINGLE_TENANT_MODEplatform/src/lib/tenant.ts:18Single-tenant build mode toggle (test-asserted; production semantics depend on caller).

MCP server (CLI / SDK side)

Env VarDefaultRead FromPurpose
KAIREON_API_URLhttp://localhost:3000platform/src/mcp/auth.ts:5KaireonAI API base URL the MCP tools call.
KAIREON_API_KEYplatform/src/mcp/auth.ts:6API key used by the MCP server when calling v1 routes.
KAIREON_TENANT_IDdefaultplatform/src/mcp/auth.ts:7Tenant id sent in the X-Tenant-Id header by MCP tool calls.
MCP_ALLOW_WRITESplatform/src/mcp/tools/types.ts:28Set to "true" to enable write-mode MCP tools. Read-only by default. See /integrations/mcp for the full tool list.

Flow streaming

Env VarDefaultRead FromPurpose
FLOW_STREAMING_ENABLEDplatform/src/lib/flow/runtime/streaming/feature-flag.ts (also asserted in __tests__/feature-flag.test.ts)Feature flag for Flow streaming consumers (Kafka / Kinesis / Pulsar). Phase 6.4 — disabled by default; enable only on self-host with a running broker.

External AI/transform endpoints (Flow runtime)

These four endpoint names are declared as the registry the external-model-call transform consults at runtime (lib/flow/runtime/transforms/external-model-call.ts:47-59). The actual process.env lookup happens inside the call helper. Operators must set the corresponding env var before invoking the transform; if unset, the transform throws MissingExternalModelEndpointError.
Env VarDefaultRead FromPurpose
GEO_RESOLVE_ENDPOINTplatform/src/lib/flow/runtime/transforms/external-model-call.ts:51External geo-resolution model URL.
LANGUAGE_DETECT_ENDPOINTplatform/src/lib/flow/runtime/transforms/external-model-call.ts:59External language-detection model URL.
SENTIMENT_SCORE_ENDPOINTplatform/src/lib/flow/runtime/transforms/external-model-call.ts:55External sentiment scoring URL.
VECTOR_EMBED_ENDPOINTplatform/src/lib/flow/runtime/transforms/external-model-call.ts:47External embedding-vector URL.

Playground and demo

Env VarDefaultRead FromPurpose
PLAYGROUND_MODEplatform/src/lib/auto-seed.ts:17"true" triggers Starbucks auto-seed for new tenants on registration.
DEMO_MODEplatform/src/app/api/v1/tenant/status/route.ts:19Demo-environment toggle. Validated as boolean by validateEnvFormats (env-validation.ts:29).

Python ml-worker

The Python FastAPI service under ml-worker/ reads only two env vars (ml-worker/app/config.py lines 6-7).
Env VarDefaultRead FromPurpose
DATABASE_URLpostgresql://localhost:5432/kaireonml-worker/app/config.py:6Postgres connection string for the ml-worker process. Distinct from the platform’s DATABASE_URL only in that it can be overridden per-process.
ML_WORKER_PORT8000ml-worker/app/config.py:7FastAPI listen port.

Test-only

These keys are read only by the test runner. Operators should not set them in production.
Env VarDefaultRead FromPurpose
TEST_API_KEYtest-ch7-keyplatform/src/__tests__/integration/block4-decision-flow.integration.test.tsIntegration-test API key.
TEST_TENANT_ID5a9904b9-4f75-4c4b-a04d-ff826…platform/src/__tests__/integration/block4-decision-flow.integration.test.tsIntegration-test tenant id.
TEST_BASE_URLhttp://localhost:3000platform/src/__tests__/integration/sample-data-e2e.integration.test.tsBase URL used by integration test HTTP calls.
VITESTplatform/src/lib/connector-executors/types.ts:75Set by Vitest. Production code branches on it to skip side effects in tests.

Configuration

Loading order

Next.js picks up env files in this order, last-write-wins (per Next.js framework defaults):
  1. .env
  2. .env.local (gitignored — local overrides)
  3. .env.${NODE_ENV} (e.g. .env.production)
  4. .env.${NODE_ENV}.local
  5. Process environment (process.env)
platform/.env.example is the template. Copy it to .env.local for local dev and to a secret manager (Kubernetes Secret, AWS SSM, etc.) for production.

Kubernetes — ConfigMap vs Secret

In the Helm chart at helm/kaireon/:
  • Non-secret runtime config (NODE_ENV, LOG_LEVEL, EVENT_PUBLISHER, INTERACTION_STORE, SEARCH_INDEX, RLS_AUTO_ENABLE, WORKER_CONCURRENCY, OUTBOX_*, SLOW_API_THRESHOLD_MS, RETRAIN_EVERY_N, OPENSEARCH_INDEX_PREFIX, OPENSEARCH_TLS_ENABLED) lives in helm/templates/configmap.yaml.
  • Secrets (DATABASE_URL, REDIS_URL, NEXTAUTH_SECRET, JWT_SIGNING_SECRET, CONNECTOR_ENCRYPTION_KEY*, WEBHOOK_SIGNING_SECRET, API_KEY_PEPPER, WORKER_SECRET, INTERNAL_SERVICE_SECRET, CRON_SECRET, CRON_TOKEN, KAFKA_SASL_PASSWORD, MSK_SASL_PASSWORD, *_SECRET_ACCESS_KEY, *_PASSWORD, SIEM_API_KEY, WHATSAPP_APP_SECRET, KAIREON_LICENSE_PRIVATE_KEY, COSIGN_KEY) live in helm/templates/secrets.yaml.
See /deployment/helm-reference for the full chart values map.

Rotation guidance

VariableRotation strategy
CONNECTOR_ENCRYPTION_KEYSet the new key as CONNECTOR_ENCRYPTION_KEY + bump CONNECTOR_ENCRYPTION_KEY_VERSION. Keep the old key as CONNECTOR_ENCRYPTION_KEY_PREVIOUS + matching _PREVIOUS_VERSION until all rows are re-encrypted by a background sweep.
JWT_SIGNING_SECRETRotate inside a maintenance window. All issued tokens become invalid the moment the new secret takes effect.
API_KEY_PEPPERCannot be rotated without invalidating every stored API-key hash. Plan for a hard cutover.
WEBHOOK_SIGNING_SECRETRotate by overlapping — accept either old or new for the rotation window via a transitional verifier (currently single-key; overlap window is an open op).
NEXTAUTH_SECRETLogs out every active session. Rotate during low traffic.
Cloud provider keys (AWS_*, *_ACCESS_KEY_ID)Rotate through the cloud provider’s secret manager; pod restart picks up the new value (no in-process rotation).

Honest limits

  • TS-only vs Python ml-worker — Of the documented variables, only DATABASE_URL is read by both the TypeScript platform and the Python ml-worker. ML_WORKER_PORT is Python-only. The platform talks to the ml-worker via ML_WORKER_URL + ML_WORKER_API_KEY (HTTP); the two processes do not share env vars beyond DATABASE_URL.
  • Once-at-boot vs per-request reads — Most env vars are read once during module load (DI container, Prisma pool, AI provider config, encryption keys). A handful are read per-request: NEGOTIATION_GLOBAL_KILL (negotiate/apply/route.ts:121), ALLOW_UNSIGNED_WEBHOOKS (webhooks/delivery/route.ts:20). For the rest, a process restart is required after changing the value.
  • Deprecated / soft-deprecatedCRON_TOKEN is the legacy auth token for /api/cron/tick. New cron endpoints under /api/v1/cron/* use CRON_SECRET; both are kept until the legacy tick is removed.
  • Internal-only flags — operators should not set_SEED_FROM_WORKER is set by the seed-executor itself before its internal HTTP call. Setting it manually breaks reentrancy detection.
  • Test-only flags in productionMFA_ENFORCEMENT_DISABLED, ALLOW_UNSIGNED_WEBHOOKS, VITEST, TEST_API_KEY, TEST_BASE_URL, TEST_TENANT_ID must not appear in any production environment. ALLOW_UNSIGNED_WEBHOOKS is hard-blocked when NODE_ENV=production (webhooks/delivery/route.ts:20); the others are not enforced — operator discipline only.
  • KAIREON_LICENSE_PRIVATE_KEY is script-side — Read only by platform/scripts/generate-license.mjs:67, never by the running platform. The platform verifies licenses with the matching public key embedded in source. When unset, the script auto-generates a fresh RSA key pair on each run rather than failing.
  • AI provider env keys are tenant-overridable — Tenant-level AI settings in the Settings UI take precedence over AI_PROVIDER / AI_MODEL / AI_API_KEY / AI_BASE_URL (provider.ts:20-23). The env vars are only the fallback when no DB-level setting is configured.
  • Environment variables not yet wired for the AI sidebar metadataAI_SIDEBAR_ENABLED and AI_RATE_LIMIT_PER_MINUTE are declared in AI_ENV at types.ts:19-20 but no process.env[AI_ENV.ENABLED] or process.env[AI_ENV.RATE_LIMIT] read currently exists in the platform. They are reserved keys.