> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust SDK Storage Configuration

> cognee-rust env vars, config keys and defaults for the vector, graph and relational databases and file storage.

Every value here resolves as `defaults < config.json < .env < env < code`
([precedence](https://docs.cognee.ai/rust/configuration.md#precedence)), and can be set from code with
the [config API](https://docs.cognee.ai/rust/configuration.md#runtime-configuration-api) or
[`cognee-cli config`](https://docs.cognee.ai/rust/configuration#cli-config-subcommand).

## Vector database

The `vector` section is registered by the vector kind. Backend-specific settings
are registered by the backend's factory, for example
[`vector.pgvector`](#pgvector-index-tuning). Flat names are accepted as
aliases, shown in brackets.

| Env var | Key (alias) | Default |
| - | - | - |
| `VECTOR_DB_PROVIDER` | `vector.provider` (`vector_db_provider`) | `lancedb` (embedded, persistent) on non-Android; falls back to `brute-force` (in-memory) on Android |
| `VECTOR_DB_URL` | `vector.url` (`vector_db_url`) | *(empty — defaults to `{system_root_directory}/databases/cognee.lancedb`; set to `:memory:` to force the in-memory brute-force store)* |
| `VECTOR_DB_HOST` / `VECTOR_DB_PORT` | `vector.host` / `vector.port` (`vector_db_host` / `vector_db_port`) | *(empty)* / `1234` |
| `VECTOR_DB_NAME` / `VECTOR_DB_KEY` | `vector.name` / `vector.key` (`vector_db_name` / `vector_db_key`) | *(empty)* |
| `VECTOR_DB_USERNAME` / `VECTOR_DB_PASSWORD` | `vector.username` / `vector.password` (`vector_db_*`) | *(empty)* |
| `VECTOR_DATASET_DATABASE_HANDLER` | `vector.dataset_database_handler` (`vector_dataset_database_handler`) | *(empty — derived from the provider: `lancedb`, `pgvector`, `memory` for `brute-force`/`mock`)*; also `pgvector_shared` (a schema per dataset in the relational database). `pgvector` needs `CREATEDB` on the vector server, `pgvector_shared` `CREATE` on the relational database. Read only with `ENABLE_BACKEND_ACCESS_CONTROL` ([per-dataset storage](https://docs.cognee.ai/rust/configuration/datasets-and-access.md#per-dataset-storage)) |

Supported providers:

> [!NOTE]
>
> This list is the built-in set, not the set of valid values. Any crate can
> register an additional provider under any id on a `ComponentRegistry`, and a
> binary that injects that registry (`ComponentManager::with_registry`, or
> `HandleState::from_settings_with_registry` in the bindings) accepts the id in
> `VECTOR_DB_PROVIDER` / `GRAPH_DATABASE_PROVIDER` — including
> Postgres-backed providers, which receive the assembled `vector_postgres_url` /
> `graph_postgres_url` from the `*_HOST` / `*_PORT` / `*_NAME` / `*_USERNAME` /
> `*_PASSWORD` settings exactly as the built-ins do, whether or not the
> `pgvector` / `pggraph` features are compiled in. Registering over a built-in id
> replaces it. See
> [External providers](https://github.com/topoteretes/cognee-rs/blob/main/docs/guides/external-providers.md).

* `lancedb` — embedded Apache-Arrow / Lance vector store, on disk. The default
  provider, and default-on in `cognee`, `cognee-cli` and every binding; requires
  the `lancedb` Cargo feature (the Arrow/Lance native stack is a large build, so a
  consumer on another vector store can drop it — and must then set
  `vector_db_provider` explicitly). Unavailable on Android, where its native stack
  does not cross-compile. The on-disk layout matches the Python SDK's default
  LanceDB store, so a Rust deployment can be opened from Python and vice versa.
* `brute-force` — pure-Rust in-memory linear scan. Default on Android. Selected
  on any target by setting `vector_db_url = ":memory:"`.
* `pgvector` — Postgres + the `pgvector` extension; requires the `pgvector`
  Cargo feature on the binary build (default-on in `cognee-cli`). See
  [Pluggable Backends](https://docs.cognee.ai/rust/tools/backends.md) for HNSW indexing and
  `cognee-cli vector-reindex`.

Qdrant is not part of OSS. See [Pluggable Backends](https://docs.cognee.ai/rust/tools/backends.md).
Setting `vector_db_provider` to `qdrant` is rejected at component
initialization in OSS (it returns a config error rather than falling back).

### pgvector index tuning

The `vector.pgvector` section, registered by the pgvector factory (`pgvector`
builds only): four optional overrides for the adapter's HNSW build, applied per
adapter and clamped to the range shown. Keys are `vector.pgvector.hnsw_m`,
`.hnsw_ef_construction`, `.maintenance_workers` and `.maintenance_work_mem_mb`,
with aliases `pgvector_hnsw_m` and so on. **Leave them unset** unless a
measurement says otherwise: the defaults are calibrated against a 100k-point
corpus of 384-d embeddings, and the two that cost server resources exist so
they can be turned *down* on a small or shared Postgres without patching the
crate.

| Env var | Default | Range | Effect |
| - | - | - | - |
| `COGNEE_PGVECTOR_HNSW_M` | `24` | 2–100 | `m` of every HNSW index built from now on |
| `COGNEE_PGVECTOR_HNSW_EF_CONSTRUCTION` | `128` | `2 × m` – 1000 | `ef_construction` of those builds |
| `COGNEE_PGVECTOR_MAINTENANCE_WORKERS` | `4` mid-load rebuild / `7` end-of-bulk-load build | 0–64 | `max_parallel_maintenance_workers` for a build; when set, overrides both defaults |
| `COGNEE_PGVECTOR_MAINTENANCE_WORK_MEM_MB` | `2048` | 64–65536 | ceiling of the per-build `maintenance_work_mem` (the adapter sizes each build from the row count and dimension and clamps to this) |

* `m` / `ef_construction` apply to indexes **built after** the change. One
  already on disk keeps the parameters it was built with until it is rebuilt —
  `create_missing_vector_indexes()` (`cognee-cli vector-reindex`) only builds a
  *missing* or invalid index, never a valid one — so raising `m` on an existing
  store is a `DROP INDEX` + reindex, done deliberately.
* `ef_construction`'s floor follows `m` because pgvector requires
  `ef_construction >= 2 × m`; no combination of these two can produce a
  `CREATE INDEX` that fails.
* Asking for more parallel maintenance workers than the server can start is
  **not** an error. Postgres launches as many as the server's
  `max_parallel_workers` / `max_worker_processes` still allow, down to zero (a
  serial build). The only cost of over-asking is a slower build, so no
  server-side configuration is required to adopt the defaults.
* Surrounding whitespace in an env value is ignored. A blank, negative or
  non-numeric env value is ignored and the default applies, as is a value too
  large for the field's integer type; an in-type value above the limit clamps. A typo in a deployment environment should not take the
  store down.

## Graph database

The `graph` section is registered by the graph kind; backend sections such as
`graph.ladybug` are registered by their factory. Flat names are accepted as
aliases.

| Env var | Key (alias) | Default |
| - | - | - |
| `GRAPH_DATABASE_PROVIDER` | `graph.provider` (`graph_database_provider`) | `ladybug` (derived — see below) |
| `GRAPH_FILE_PATH` | `graph.file_path` (`graph_file_path`) | *(empty; defaults under the system root)* |
| `GRAPH_DATABASE_URL` | `graph.url` (`graph_database_url`) | *(empty)* |
| `GRAPH_DATABASE_HOST` / `GRAPH_DATABASE_PORT` | `graph.host` / `graph.port` (`graph_database_host` / `graph_database_port`) | *(empty)* / `123` |
| `GRAPH_DATABASE_NAME` / `GRAPH_DATABASE_KEY` | `graph.name` / `graph.key` (`graph_database_*`) | *(empty)* |
| `GRAPH_DATABASE_USERNAME` / `GRAPH_DATABASE_PASSWORD` | `graph.username` / `graph.password` (`graph_database_*`) | *(empty)* |
| `GRAPH_DATASET_DATABASE_HANDLER` | `graph.dataset_database_handler` (`graph_dataset_database_handler`) | *(empty — derived from the provider: `ladybug`, `kuzu`, `postgres_graph`, `memory` for `mock`)*; also `postgres_graph_shared` (a schema per dataset in the relational database). `postgres_graph` needs `CREATEDB` on the graph server, `postgres_graph_shared` `CREATE` on the relational database. Read only with `ENABLE_BACKEND_ACCESS_CONTROL` ([per-dataset storage](https://docs.cognee.ai/rust/configuration/datasets-and-access.md#per-dataset-storage)) |
| `GRAPH_MAX_DB_SIZE` | section key `graph.ladybug.max_db_size` (alias `graph_max_db_size`; `ladybug` builds only) | `1073741824` (1 GiB) |

Supported providers: `ladybug`/`kuzu` (embedded), `postgres` (feature `pggraph`).
As with the vector store, these are the built-ins; an externally registered
provider id is accepted too (see the note under [Vector database](#vector-database)).

The default is **derived from the graph backends the binary was compiled with**,
not hardcoded. In order:

1. `ladybug`, when that feature is on — every default build;
2. otherwise `postgres`, when `pggraph` is on (e.g. a
   `--no-default-features … pggraph` image), however many other ids are registered;
3. otherwise the single registered backend, when the build has exactly one.

Only a build registering two or more backends of which neither is `ladybug` nor
`postgres` has to set `GRAPH_DATABASE_PROVIDER` explicitly.

When Postgres graph credentials are unset they fall back to the relational `DB_*`
config (see [roadmap/cognify-compatibility-plan.md](https://github.com/topoteretes/cognee-rs/blob/main/docs/roadmap/cognify-compatibility-plan.md)).

## Relational database

The `relational` section is registered by the relational kind. Backends are
`RelationalDbFactory`s on the `ComponentRegistry`, selected by `relational.provider`
(when that is empty, by the scheme of the resolved URL). An external crate adds a
backend with `register_relational`, together with its own config sections; it
implements `cognee_database::RelationalDb`. The built-in SeaORM factory is
registered as `sqlite` (feature `sqlite`) and `postgres` / `postgresql` (feature
`postgres`). An unregistered provider is an error.

| Env var | Key (alias) | Default |
| - | - | - |
| `DB_PROVIDER` | `relational.provider` (`db_provider`) | `sqlite` |
| `DATABASE_URL` | `relational.url` (`relational_db_url`) | `sqlite:./cognee.db?mode=rwc` |
| — | `relational.migration_url` (`migration_db_url`) | *(empty)* |
| `DB_HOST` / `DB_PORT` | `relational.host` / `relational.port` (`db_host` / `db_port`) | `localhost` / `5432` |
| `DB_NAME` | `relational.name` (`db_name`) | `cognee_db` |
| `DB_USERNAME` / `DB_PASSWORD` | `relational.username` / `relational.password` (`db_username` / `db_password`) | *(empty)* |
| `DB_SSLMODE` (else derived from `DATABASE_CONNECT_ARGS`) | `db_sslmode` | *(empty)* |

For `postgres` the URL is built from the connection parts; otherwise `relational.url`
is used verbatim. Each part is percent-encoded, so reserved characters in the
name, username or password (`@`, `#`, `/`, `%`, …) reach the server unchanged
instead of reshaping the URL (a `#` in the name used to drop the `?sslmode=`
that followed it). A part that cannot be encoded is logged (never the password)
and leaves the URL empty, so the connection fails rather than falling back to
another backend. `db_sslmode` stays a cognee-wide `Settings` key: the TLS mode is
appended to every Postgres URL cognee builds (relational, pgvector and the
Postgres graph).

### Serialization and recovery of pipeline runs

Rust uses a per-dataset lock and startup recovery; there is nothing to turn on. The
`single_process` setting (`COGNEE_SINGLE_PROCESS`), the pipeline cache
(`use_pipeline_cache`) and its reset API, the `PipelineAlreadyRunning` error,
the exclusive-run claim and `cognee-cli pipeline-unblock` have all been
removed. Setting `single_process` is now an unknown key: an error under strict config,
otherwise a warning and the value is dropped. `COGNEE_SINGLE_PROCESS` is ignored.

| Env var | Key | Purpose | Default |
| - | - | - | - |
| `COGNEE_STALE_RUN_RECOVERY_MIN_AGE_SECONDS` | `cognify.stale_run_recovery_min_age_seconds` | Startup recovery's age floor: a `STARTED` run younger than this is treated as live | `3600` |

* **No run-history gate.** A `cognify` is never refused or short-circuited
  because of the dataset's `pipeline_runs` rows. Items already processed are
  skipped one by one by the
  [completion markers](https://docs.cognee.ai/rust/configuration/cognify.md#completion-markers-and-incremental-loading).
  A stored `DATASET_PROCESSING_INITIATED` row written by an older version is
  read back as `INITIATED` and gates nothing.
* **A per-dataset lock serializes runs.** `cognify`, `add` and `delete` on one
  dataset take the same in-process lock (`cognee_core::DatasetLocks::global()`),
  so a second `cognify` of a dataset **waits** for the first and then proceeds.
  Different datasets run in parallel. The lock is per process: it does not
  serialize two processes on one database.
* **A killed run is recovered at startup.** A `cognify` or `add` run records
  `{"recovery_lock": "<token>"}` in its `STARTED` row and holds an OS file lock
  on `<system_root>/pipeline_run_locks/<token>/owner.lock`, which the OS drops
  when the process dies, however it dies. Recovery runs on the first operation
  per relational database per process in the bindings. Any other caller (a
  server, say) runs it by calling `cognee_delete::recover_stale_pipeline_runs`;
  `cognee-cli` does not run it. Recovery picks each run whose newest row is
  still `STARTED`, that is older than
  `cognify.stale_run_recovery_min_age_seconds`, whose marker it can claim
  without blocking, whose dataset still exists, and whose dataset lock no run
  of this process holds. It **rolls the run back**
  (a `cognify` run's graph and vector artifacts, scoped to that run in its
  dataset, except what the items it touched that now carry a completion marker
  own) and then **closes** it with an `ERRORED` row whose `run_info` is
  `{"error": "AbandonedPipelineRunError: …"}`. A row without a marker, or one
  whose marker a live process holds, cannot be proven abandoned and is left
  alone, so recovery is safe with any number of processes on the database. If
  the rollback fails, or the run's dataset is gone, the run stays `STARTED`.

Runs write this lifecycle: `DATASET_PROCESSING_STARTED`, then `…_COMPLETED`
or `…_ERRORED`, with no `INITIATED` row. `run_info` no longer lists the run's data
items: `STARTED` is `{}`, or `{"recovery_lock": …}` for a `cognify` or `add` run
(above), `COMPLETED` is `{}`, and `ERRORED` is `{"error": …}`. A
migration strips the `data` key from stored rows. A failed terminal `COMPLETED`
write fails the run, which is then rolled back like any other failed run.
The multi-dataset entry points `cognify_datasets` and `cognify_dataset_refs` add
no row of their own: each dataset they run leaves only that `STARTED` →
`COMPLETED`/`ERRORED` pair. A dataset reached more than once (by name and by
id, or by a repeated ref) runs once, and
`cognify_dataset_refs` given only id refs cognifies just those datasets.

The library runs no periodic re-check (a long-running server calls
`recover_stale_pipeline_runs` itself on an interval), recovery sends no
`Pipeline Run Errored` telemetry event, and the closing `ERRORED` row is always
dated at the time of closing. The closing row therefore becomes the dataset's
newest row, so a dataset whose later run completed reads as `ERRORED` after
recovery.

## File storage

The `storage` section is registered by the storage kind. Backends are factories
(`StorageFactory`) selected by `storage.backend`; an external crate adds one (an
object store, say) with `register_storage`.

| Env var | Key (alias) | Default |
| - | - | - |
| `STORAGE_BACKEND` | `storage.backend` (`storage_backend`) | `local` |
| `STORAGE_BUCKET_NAME` | `storage.bucket_name` (`storage_bucket_name`) | *(empty)* |

Only `local` (files under `data_root_directory`) is built in. An unregistered
backend id is an error. No built-in backend reads `storage.bucket_name`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.