CortexDB · docs

Production Deployment

This guide covers the single-node CortexDB deployment: one server process with one persistent data directory. A cluster (cortexdb node --config, new in 0.11.0) has its own guide, docs/generated/cluster.md; plain cortexdb still refuses the old cluster flags and CORTEX_CLUSTER_* variables at startup.

Production prerequisites

CORTEX_INSECURE_NO_AUTH=1 and mock embeddings are test-only settings. Do not use either for customer data or quality measurements.

Supported Docker Compose start

The repository's docker-compose.yml publishes only 127.0.0.1:3141, requires the CortexDB bearer, and uses a named volume. It runs cortexdb/cortexdb:${CORTEXDB_TAG:-v0.16.1}, the tag the release's image file loads: docker load -i cortexdb-<version>-image-linux-<arch>.tar.gz first, and set CORTEXDB_TAG to run another version you loaded. Create an untracked .env file:

CORTEX_API_KEY=<strong-random-bearer>
OPENAI_API_KEY=<provider-key>
CORTEX_DEPLOYMENT_PRESET=on_prem_enterprise
CORTEX_LICENSE=<your-license>

Then start and verify readiness:

docker compose up -d
curl -fsS http://127.0.0.1:3141/v1/admin/health
curl -fsS http://127.0.0.1:3141/v1/admin/ready

The health endpoints intentionally require no bearer so an orchestrator can probe the process. Memory and administrative routes remain authenticated.

Use the same bearer for a write/read smoke test:

curl -fsS -X POST \
  'http://127.0.0.1:3141/v1/experience?wait=indexed' \
  -H 'Authorization: Bearer <token>' \
  -H 'X-Cortex-Actor: user:local' \
  -H 'Content-Type: application/json' \
  -d '{
    "scope":"ws:smoke",
    "modality":"conversation",
    "content":{"kind":"message","role":"user","text":"deployment smoke marker"},
    "context":{"observed_at":"2026-09-04T00:00:00Z"},
    "idempotency_key":"deployment-smoke-001"
  }'

curl -fsS -X POST \
  http://127.0.0.1:3141/v1/recall \
  -H 'Authorization: Bearer <token>' \
  -H 'X-Cortex-Actor: user:local' \
  -H 'Content-Type: application/json' \
  -d '{"scope":"ws:smoke","query":"deployment smoke marker"}'

Replace <token> with the configured value without recording it in shell history or source control.

Provider configuration

The container image explicitly selects an OpenAI-compatible embedding URL, model, and dimensions. With that remote endpoint selected, a missing usable embedding key is a startup error; CortexDB does not silently persist mock vectors. For another compatible provider set all identity-bearing fields:

CORTEX_EMBEDDING_URL=<https-endpoint>
CORTEX_EMBEDDING_MODEL=<model-id>
CORTEX_EMBEDDING_DIMS=1536
CORTEX_EMBEDDING_API_KEY=<provider-key>

The embedding provider/model/dimensions are pinned to the data directory. Changing them for existing data requires a planned migration or reindex; never mix vectors from different models in one store.

Entity extraction is optional and uses CORTEX_LLM_URL, CORTEX_LLM_MODEL, and preferably CORTEX_ENTITY_API_KEY. Request-time answers are a separate role configured by CORTEX_ANSWER_PROVIDER, CORTEX_ANSWER_URL, CORTEX_ANSWER_MODEL, and CORTEX_ANSWER_API_KEY. /v1/answer and /v1/compose return 503 ANSWER_UNAVAILABLE with retriable: false when no usable answer router is configured - an honest refusal rather than a fabricated 200. Ingestion and recall remain available, and GET /v1/admin/ready reports the live state under checks.answer.

Two knobs are test-only and are recorded here so nobody copies them out of a CI config. CORTEX_ANSWER_STUB=1 opts a deterministic context-echo renderer back in where no answer LLM is configured, so /v1/answer returns 200 instead of the honest 503; a client cannot tell that 200 from a real answer, so it belongs in CI and local development only (a configured answer LLM always wins over it). CORTEX_LIFECYCLE_AUTHORITY_RECHECK_SECS (default 30, floor 1) is how often an idle /v1/lifecycle/stream re-checks the subscriber's credential before closing the stream with a final policy_revoked frame; a stream that is delivering events is re-checked per frame regardless. Leave it at the default in production.

Empty optional environment values are treated as unset, so role-specific keys can fall back according to the documented provider precedence.

Write completion and immediate reads

A single POST /v1/experience with no wait parameter (or wait=accepted) is a durable asynchronous accept. It can return before vector indexing, so an immediate recall can race it.

Bulk ingestion has its own batching path. Use the SDK's bulk wait option instead of assuming the single-write timing contract; wait=captured is the explicit early-return/deferred-indexing mode.

Optional enrichment and artifacts

Every feature below is domain-general and opt-in. Enabling a profile name does not itself start work.

Legacy enrichment/fact extraction requires:

CORTEX_ENRICHMENT_MODEL=<model-id>
CORTEX_ENRICHMENT_API_KEY=<provider-key>
CORTEX_ENRICHMENT_DELAY_SECONDS=5

CORTEX_ENRICHMENT_URL may override the general LLM URL. An unset delay keeps the scanner off; 0 requests the minimum five-second polling interval.

Artifact compilation and artifact-backed retrieval are separately gated:

CORTEX_ARTIFACT_DUAL_WRITE=1
CORTEX_ARTIFACT_WORKERS=1
CORTEX_ARTIFACT_PIPELINE=full
CORTEX_ARTIFACT_SEARCH=1
CORTEX_ARTIFACT_SEARCH_SEMANTIC=1

Start with lexical artifact search, observe backlog and provider health, then enable semantic search after its embedding cost and latency are understood.

Operations and health

Monitor:

Since 0.15.0 both also report what the derivation gate decided about each candidate memory that enrichment extracted: cortexdb_derivation_verdicts_total{verdict, family} on GET /metrics, and the derivation block of GET /v1/admin/metrics (verdicts, one count per verdict and rule family, and the accepted, held and rejected totals). verdict is accepted, held (kept for review) or rejected; family is the first part of the rule that decided (accept, topic, detector, settings, suppression, writer, review, ...). The counts carry no scope and start at zero with each process; rate() and increase() read through a restart. On a cluster every replica of a shard counts the same candidates.

Alert on a sudden rise in the share of rejected candidates: a derivation policy that suddenly rejects everything (a deny list wider, or an allow list narrower, than meant) otherwise shows only as memory that stops growing. This rule fires when the share over the last 30 minutes stands 30 points above the share over the day before, on real volume:

groups:
  - name: cortexdb-derivation
    rules:
      - alert: CortexDBRejectedCandidatesRose
        expr: |
          (
              (sum(rate(cortexdb_derivation_verdicts_total{verdict="rejected"}[30m])) or vector(0))
            / sum(rate(cortexdb_derivation_verdicts_total[30m]))
          )
          > 0.3 + (
              (sum(rate(cortexdb_derivation_verdicts_total{verdict="rejected"}[1d] offset 30m)) or vector(0))
            / sum(rate(cortexdb_derivation_verdicts_total[1d] offset 30m))
          )
          and sum(increase(cortexdb_derivation_verdicts_total[30m])) > 20
        for: 15m
        annotations:
          summary: The share of rejected derivation candidates rose sharply

sum by (family) (rate(cortexdb_derivation_verdicts_total{verdict="rejected"}[30m])) shows which rules reject them, and GET /v1/derivation/policy?scope= what is in force at a scope. The alert stays silent until candidates were judged in the day before the window, and wherever nothing is extracted (enrichment off).

Drain traffic before stopping the process and allow a graceful shutdown. Back up the complete data directory with a filesystem/storage snapshot that preserves a consistent point in time, then regularly restore it into an isolated instance and exercise authenticated write/recall checks.

Before enabling the artifact plane or upgrading the binary, take a verified snapshot. Feature rollback within the same compatible binary can disable optional readers/workers. Binary rollback to a pre-artifact release should restore the pre-upgrade snapshot rather than opening data modified by the new binary.

Backup and restore

The server binary carries a cold backup (since 0.12.2): stop the server, back up its data directory, start it again. The archive holds everything the server needs to come back as itself: the memories and their indexes, the license (license.json), the token minter's keys (minter-keys/, so credentials it issued keep working), the generated API key and the console's settings. Every file is recorded with its SHA-256, and a restore writes nothing into place until every byte verifies.

With Docker (the image needs nothing else; -t 120 lets the server finish its shutdown):

docker stop -t 120 cortexdb
docker run --rm -v cortexdb-data:/data -v "$PWD":/backup --entrypoint cortexdb \
  cortexdb/cortexdb:v0.16.1 backup /data /backup/cortexdb-$(date +%F).tar.gz
docker start cortexdb

Check an archive at any time without restoring it:

docker run --rm -v "$PWD":/backup --entrypoint cortexdb \
  cortexdb/cortexdb:v0.16.1 backup-verify /backup/cortexdb-2026-10-16.tar.gz

Restore into a new, empty volume (a restore never writes over data), then run the server on it:

docker volume create cortexdb-restored
docker run --rm -v cortexdb-restored:/data -v "$PWD":/backup --entrypoint cortexdb \
  cortexdb/cortexdb:v0.16.1 restore /backup/cortexdb-2026-10-16.tar.gz /data
docker run -d --name cortexdb … -v cortexdb-restored:/data … cortexdb/cortexdb:v0.16.1

The restored files take the owner of the directory restored into (the image's cortex user for a volume), so the server can open them. Without Docker the commands are the same on the binary: cortexdb backup DATA_DIR ARCHIVE, cortexdb restore ARCHIVE NEW_DIR, cortexdb backup-verify ARCHIVE.

Exit codes: 0 done, 2 refused (a target that is not empty, a symbolic link in the data dir, one replica of a cluster group), 3 the data dir is live (stop the server first), 4 the archive is damaged or fails verification.

Keep separately, because no data-directory backup holds them: the environment the server runs with (provider keys, CORTEX_API_KEY, CORTEX_LICENSE is optional as the license is in the archive), keys kept outside the data dir (CORTEX_V1_MINTER_KEY_DIR, CORTEX_ICE_KEY_FILE) and, with the segment store on, the bucket itself. Archives are cold and complete: an online backup or point-in-time recovery is not part of this release.

The archive is the same as scripts/cold_backup.py's, and either tool restores the other's. The script keeps two operator extras: prune (delete archives older than N days) and restore --reincarnate (a cluster shard that lost its quorum, docs/generated/cluster.md).

Generic systemd unit

Store credentials in /etc/cortexdb/cortexdb.env, owned by root with mode 0600. Run the service as a dedicated unprivileged account:

CORTEX_API_KEY=<strong-random-bearer>
CORTEX_DEPLOYMENT_PRESET=on_prem_enterprise
CORTEX_API_ADDR=127.0.0.1:3141
CORTEX_EMBEDDING_API_KEY=<provider-key>
[Unit]
Description=CortexDB single-node service
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=cortexdb
Group=cortexdb
EnvironmentFile=/etc/cortexdb/cortexdb.env
ExecStart=/usr/local/bin/cortexdb 3141 /var/lib/cortexdb
Restart=on-failure
RestartSec=5
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ReadWritePaths=/var/lib/cortexdb

[Install]
WantedBy=multi-user.target

Bind locally behind a TLS proxy unless there is an explicit, reviewed network exposure design.

Restart policies

The admin console's Restart button (POST /internal/ui/restart) persists snapshots and then exits with code 75 (EX_TEMPFAIL) so the new settings and feature toggles take effect when the process starts again. Relaunching it is the supervisor's job, and because the code is non-zero every restart policy does it:

SupervisorRelaunched after a console restart
Docker --restart unless-stopped or always (Compose restart: unless-stopped, as in the repository's docker-compose.yml)yes
Docker --restart on-failureyes
systemd Restart=on-failure (the unit above) or Restart=alwaysyes
No restart policy (docker run without --restart, a foreground shell)no: the server stays stopped

A deliberate stop (docker stop, systemctl stop, SIGTERM) still exits 0, so on-failure policies leave it stopped. Do not add 75 to systemd's RestartPreventExitStatus= (or to SuccessExitStatus= under Restart=on-failure): either stops systemd from relaunching after a console restart. Expect a console restart to look like a failed exit for a moment: systemd reports the unit as failed with exit-code until RestartSec passes, Kubernetes counts a container restart, and alerting on non-zero exits fires once per restart. Releases before this change exited 0, which on-failure policies never relaunched.

One-click updates (opt-in)

The admin console's Updates page can install a new release itself when an updater sidecar runs next to CortexDB. The sidecar (deploy/updater) is a small standard-library Python service and the only container that mounts the Docker socket; CortexDB never does. It manages a single-node Docker Compose deployment only: it replaces the one cortexdb server container, and refuses a container whose command is cortexdb node (a cluster node) or another subcommand (admin, migrate, migrate-unified-wal, native-host). A cluster is upgraded node by node, one binary per shard (docs/generated/cluster.md); its ingress does not route /internal/ui/*, and a data node refuses it. Start both with the overlay:

echo "CORTEX_UPDATER_TOKEN=$(openssl rand -hex 32)" >> .env
docker compose -f docker-compose.yml -f docker-compose.updater.yml up -d

The overlay sets CORTEX_UPDATER_URL=http://cortexdb-updater:8090 and the shared CORTEX_UPDATER_TOKEN on CortexDB, and publishes no port for the sidecar, so only services on the compose network can reach it. When the Updates page reports a newer release, it shows Update to vX.Y.Z now. After the operator confirms, the sidecar:

  1. refuses a version older than the running one. CortexDB checks against its own version; the sidecar checks the running tag, or for a :latest container the image's version stamp. Going back is a restore (below). It also refuses a container that is not the single-node server (above), and, for 0.11.0 or later, one that still runs the retired dual WAL (CORTEX_UNIFIED_WAL=0, or v1_wal/ in the data directory), which 0.11.0 refuses at its first start (LEGACY_WAL_RETIRED, exit 78): run cortexdb migrate-unified-wal first. And it refuses a one-way upgrade without the operator's consent and the backup ("One-way upgrades" below);
  2. refuses a container that keeps its data directory inside itself rather than on a volume or bind mount, or that runs with --rm: replacing it would lose the data;
  3. pulls cortexdb/cortexdb:vX.Y.Z (the repository the container already runs; nothing else is accepted) while CortexDB keeps serving;
  4. checks, still while CortexDB serves, that the backup can be written: the data volume is mounted at /source-data, and the backup volume has room for it. When the sidecar can inspect its own container, it also checks that /source-data is the volume CortexDB uses at /data. A failed check stops the update with CortexDB untouched;
  5. sets CortexDB's restart policy to no, so nothing can restart it during the backup, and stops it gracefully (CORTEX_UPDATER_STOP_TIMEOUT_SECS, default 120, the same grace period as stop_grace_period), so the snapshots are persisted;
  6. writes a cold backup of the data volume to the cortexdb-backups volume (cortexdb-data-<time>-<old tag>.tar.gz, the newest three kept; CORTEX_UPDATER_BACKUP=off skips it). If the backup fails, the old container gets its restart policy back and is started again, and nothing is swapped;
  7. renames the old container to cortexdb-previous and creates the new one with the same settings: command, mounts (including a volume Docker created for /data without a name), ports, networks, and the environment and labels you set. Environment variables and labels whose value is the old image's default are dropped so the new image's defaults apply, as docker compose up would, except the embedding settings (CORTEX_EMBEDDING_PROVIDER, _MODEL, _DIMS, _URL), which are always kept because the data directory is pinned to them;
  8. starts it with restart policy no, so a crash is seen at once instead of hidden by a restart, and waits up to CORTEX_UPDATER_HEALTH_TIMEOUT_SECS (default 900) for Docker to report it healthy and then stay up for CORTEX_UPDATER_SETTLE_SECS (default 20). Only then does it get the old restart policy; the old container is removed;
  9. if the new container exits, restarts or reports unhealthy, stops and removes it, restores the old container under its name and restart policy, starts it and waits for it to be healthy.

One-way upgrades

Some releases change the data directory so that the version before them can no longer open it. 0.11.0 is one: its first start copies the event log into pre_stage2/, moves it into a replicated shard (shard/, derived_wal/) and runs four one-time migrations before it serves (RELEASE_NOTES_0.11.0.md, "Before you upgrade"); a 0.10.x binary cannot open the result. 0.14.0 and 0.15.0 are two more: the first start of each arms the data directory for a newer format (10 and 11), which no older binary opens (RELEASE_NOTES_0.15.0.md, "Upgrade (one-way)").

The updater does not upgrade 0.10.x to 0.11.0: do that upgrade by hand (RELEASE_NOTES_0.11.0.md, "Upgrade"). A one-way update needs the operator's consent, which the console of the running CortexDB sends, and a 0.10.x server's update route sends the version alone. So a sidecar from 0.11.0 or later refuses the job (ONE_WAY_CONSENT_REQUIRED) before CortexDB stops and changes nothing, and a sidecar built from a 0.10.x checkout knows no boundary and must not be used for it (it would start 0.10.x again on the migrated data if 0.11.0 failed).

From 0.11.0 on, the sidecar knows the boundaries a release image declares (the io.cortexdb.one-way-below label, read after the pull; a release that changes the data directory one way raises it). 0.14.0's image declares 0.14.0, whose first start arms the data directory for format 10; 0.15.0's declares 0.15.0, whose first start arms it for format 11. 0.15.0's sidecar has 0.11.0, 0.14.0 and 0.15.0 built in. It also treats an unstamped image on a data directory without shard/ as older than 0.11.0, on one without format_armed.json as older than 0.14.0, and on one whose format_armed.json names a format below 11 as older than 0.15.0. Whatever the labels say, it never rolls an update back onto a data directory the new version armed (the format_armed.json it mounts naming a newer format than before CortexDB stopped), and it refuses a downgrade below the release that introduced the directory's armed format, 0.14.0 for format 10 and 0.15.0 for format 11, even with CORTEX_UPDATER_ALLOW_DOWNGRADE=on (ARMED_DATA_DIRECTORY). Run 0.15.0's sidecar for the update to 0.15.0: an older one sees that boundary only in the image's label.

To upgrade to 0.15.0 and arm later, set CORTEX_FORMAT_CEILING=10 in CortexDB's environment before its first start of 0.15.0: the directory stays at format 10, and what needs 11 answers 503 FORMAT_UPGRADE_PENDING until the ceiling is raised. The update still crosses 0.15.0's boundary, so it still asks for the consent and the backup below, and holding at 10 is no way back to 0.14.x either: the backup is. RELEASE_NOTES_0.15.0.md ("Holding the ceiling at 10") has the steps.

For an update across a boundary:

The job's progress is saved in the backup volume. A sidecar that is itself restarted mid-update picks the job up when it comes back: a new container that is still running gets the same health wait and is kept if it passes; otherwise the old container is put back; an update interrupted before CortexDB stopped is reported as having changed nothing. After a one-way upgrade's new version has started, the sidecar never puts the old container back (above), restarted or not. If a rollback itself fails, the job's message gives the commands that bring the old container back by hand (docker rename cortexdb-previous cortexdb, docker update --restart ..., docker start cortexdb) and names the backup.

The console follows the job (GET /internal/ui/update/status), reports a failure or rollback with its reason, and calls the update done only once the job succeeded and the new version answers /v1/admin/health and /v1/admin/ready; docker logs cortexdb-updater has the full log. An automatic rollback restores the old container, not old data, which is why a one-way upgrade has none. To restore the backup: docker compose stop cortexdb, empty the data volume (files the new version wrote must not stay mixed in), extract the archive into it (tar -xzf), and start the old version. The sidecar's archive is a plain tar of the data directory; a cold backup archive (cortexdb backup, or scripts/cold_backup.py) is restored with cortexdb restore ARCHIVE NEW_DIR (or cold_backup.py restore ARCHIVE NEW_DIR --cortexdb PATH), which runs cortexdb restore-check on it (RELEASE_NOTES_0.11.0.md, "Downgrade to 0.10.1 through 0.10.5"). With the segment store on (CORTEX_ICE_URL), run the restore with the server's CORTEX_ICE_* variables and key file in the environment: restore-check then checks every segment object the archive's log names, brings back one a later rewrite deleted from its bucket version, and marks the directory so its first boot applies every erasure journaled since the backup before it serves (docs/ICE_TIER_PLAN.md, "Copies and restores"). Read the release notes, and the upgrade checklist below, before clicking.

When CortexDB runs a latest tag, the sidecar re-points the local latest tag at the new image, so a later docker compose up keeps the new version. If you pin a version (the compose file runs CORTEXDB_TAG, v0.16.1 by default), update the pin afterwards: the next docker compose up would otherwise recreate the container on the old version, over data the new one may have migrated. The sidecar pulls the new version from the repository the container runs, without registry credentials. Docker Hub holds no current release and the customer portal's registry needs credentials, so an install from the customer portal is upgraded by hand: load the new release's image file, then recreate the container on its tag, after the backup and the release notes' steps. It speaks whatever Docker Engine API version the daemon reports. Without the sidecar the Updates page shows the manual steps only.

Sidecar settings beyond the overlay's: CORTEX_UPDATER_REPOSITORY (refuse any other repository), CORTEX_UPDATER_TAG_TEMPLATE (default v{version}), CORTEX_UPDATER_KEEP_BACKUPS (default 3), CORTEX_UPDATER_SOURCE_DATA and CORTEX_UPDATER_TARGET_DATA (the data mount inside the sidecar and inside CortexDB, default /source-data and /data), CORTEX_UPDATER_ONE_WAY_HEALTH_TIMEOUT_SECS (default 3600), and CORTEX_UPDATER_ALLOW_DOWNGRADE=on (the sidecar's own guard only).

Upgrade checklist

  1. Pin the exact image digest or release artifact and verify its adjacent SHA-256 file.
  2. Review the release notes and current configuration lint output.
  3. Snapshot and restore-test the whole data directory.
  4. Preserve the pinned embedding identity or plan a reindex.
  5. Upgrade one isolated instance, wait for readiness, then run authenticated write, recall, and enabled-pipeline health checks.
  6. Promote traffic only after backlog and provider health are stable.