> ## 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 Cognify Configuration

> cognee-rust settings for chunking, graph extraction, ontologies, the code graph, cognify failure handling and incremental loading.

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).

## Chunking & tokenizer

Read by [`crates/chunking/src/config.rs`](https://github.com/topoteretes/cognee-rs/blob/main/crates/chunking/src/config.rs).
`chunk_strategy` (default `PARAGRAPH`) selects the chunker cognify cuts
documents with. It has no env binding; set it with
`cognee-cli config set chunk_strategy …`, `ConfigManager::set` or the TypeScript
binding's `setChunkStrategy`, or per run with the CLI's `--chunker`. Names are
case-insensitive, and the chunker class names (`TextChunker`, `LangchainChunker`,
`CsvChunker`, `JsonListChunker`, `TextChunkerWithOverlap`) are accepted too:

| `chunk_strategy` | Class name | `chunker_id` stamped on chunks |
| - | - | - |
| `PARAGRAPH` / `TextChunker` | `TextChunker` | `text_chunker_v1` |
| `RECURSIVE` / `LangchainChunker` | `LangchainChunker` (1024-word splits, `chunk_overlap` words of overlap) | `langchain_chunker_v1` |
| `CSV` / `CsvChunker` | `CsvChunker` | `csv_chunker_v1` |
| `JSON_LIST` / `JsonListChunker` | `JsonListChunker` | `json_list_chunker_v1` |
| `OVERLAP` / `TextChunkerWithOverlap` | `TextChunkerWithOverlap` | `text_chunker_overlap_v1` |

An unknown name logs a warning and keeps `PARAGRAPH`. Under `PARAGRAPH`, CSV
documents are still cut row by row (`csv_chunker_v1`); every other strategy
applies to CSV rows as well. The overlap chunker's ratio
(`CognifyConfig::chunk_overlap_ratio`, default `0.0`, must be in
`[0, 1)`) and a custom `Chunker` (`CognifyConfig::with_chunker`, or
`with_custom_chunker` for a closure, whose chunks carry `custom_chunker`) are
code-only, so `OVERLAP` chosen through config cuts chunks with no overlap (cognify
logs a warning); a custom chunker overrides `chunk_strategy`. `chunk_engine` is stored
and never read.

> [!WARNING]
>
> Before this release every `chunk_strategy` other than `PARAGRAPH` was parsed and
> ignored. `RECURSIVE` now changes behaviour: it fails a document whose 1024-word
> split exceeds `max_chunk_size` tokens — with
> the local embedding engine's \~512-token budget that is most documents over \~400
> words. `JSON_LIST` fails a document that is not a JSON list.

Chunk size and overlap are env-bindable; `chunk_overlap` is read by the
`RECURSIVE` chunker only, in words, and may be at most 1024 there:

| Env var | `Settings` field | Default |
| - | - | - |
| `COGNEE_CHUNK_SIZE` / `CHUNK_SIZE` | `chunk_size` | *(unset — auto)* |
| `COGNEE_CHUNK_OVERLAP` / `CHUNK_OVERLAP` | `chunk_overlap` | `10` |

`chunk_size` unset means "auto-calculate at pipeline time":
`min(<embedding engine limit>, llm_max_completion_tokens / 2)`. The engine limit is
`EMBEDDING_MAX_COMPLETION_TOKENS` (default `8191`) for the OpenAI-compatible and
Ollama engines and `EMBEDDING_MAX_SEQUENCE_LENGTH` (default `512`) for the local
ONNX engine. With OpenAI-compatible embeddings at their defaults that is
`min(8191, 8192) = 8191` tokens; with the local ONNX/BGE engine it is its
512-token sequence limit. Set it explicitly (env, `cognee-cli config set
chunk_size`, or `--chunk-size`) to override — an explicit value is always
honoured. `cognee-cli config set chunk_size null` restores the auto-calculation.

The token counter is chosen by the `cognify` engine section (registered with the
kind sections), resolved when cognee lowers `Settings` into a `CognifyConfig`
(`Settings::cognify_config`; `CognifyConfig::default()` itself reads nothing):

| Env var | Key | Purpose | Default |
| - | - | - | - |
| `COGNEE_TOKEN_COUNTER` | `cognify.token_counter` | `tiktoken` / `word` / `huggingface`(`hf`) | auto from embedding provider |
| `HUGGINGFACE_TOKENIZER` | `embedding.ollama.huggingface_tokenizer` | model id when counter = `huggingface` | *(empty)* |
| `EMBEDDING_TOKENIZER_PATH` | `embedding.onnx.tokenizer_path` | tokenizer file for the `onnx` provider's counter, used when it exists | `<cache_root_directory>/models/bge-small-tokenizer.json` |
| `COGNEE_LEGACY_PER_WORD_TOKEN_COUNT` | `cognify.legacy_per_word_token_count` | restore the legacy per-word token count (`1`/`true`/`yes`/`on`) | `false` |

`Settings::cognify_config` also applies the batch sizes, the graph-extraction
prompt, the extraction strategy and the summary schema:

| Env var | Key (alias) | Purpose | Default |
| - | - | - | - |
| `CHUNKS_PER_BATCH` | `cognify.chunks_per_batch` (`chunks_per_batch`) | chunks of one data item per block the graph is built from; `0` keeps the default. It does not batch or limit the LLM extraction calls: every chunk of the run goes through one stream capped by `max_parallel_extractions` (`LLM_MAX_PARALLEL_REQUESTS`), which is the setting to lower to limit LLM load (it used to cap concurrent calls at min(`chunks_per_batch`, `max_parallel_extractions`), so a lowered `CHUNKS_PER_BATCH` no longer throttles the LLM). A graph backend is still handed `chunks_per_batch` chunks of the run per call, across data items | `2000` |
| `EDGE_EVIDENCE_ENABLED` | `cognify.edge_evidence_enabled` | record which chunk supports which graph edge (`provenance_edge_evidence`) during cognify, so `include_references` can cite edge sources; off only stops new capture, existing rows are still read. See [Edge evidence](#edge-evidence) | `true` |
| `COGNEE_COGNIFY_EXTRACTION_STRATEGY` | `cognify.extraction_strategy` | `single_pass` (one LLM call per chunk) or `cascade` (multi-round: nodes → relationship names → edge triplets, `3 × rounds` calls per chunk, no date hints; ignores a custom prompt). Case-insensitive. An unrecognised value keeps the default, with a warning | `single_pass` |
| `COGNEE_COGNIFY_CASCADE_ROUNDS` | `cognify.cascade_rounds` | rounds per cascade stage; `0` keeps the default | `2` |
| `COGNEE_COGNIFY_CROSS_CHUNK_ENDPOINTS` | `cognify.cross_chunk_endpoints` | the graph is built per data item (or per `chunks_per_batch` block of one), so an extracted edge's endpoint never matches a node of another data item. `true` lets it match a node an earlier chunk of the same block declared, and fall back to a node's name; `false` resolves it only within its own chunk and only by the verbatim node id (node ids `A` and `a` are then two nodes) | `true` |
| `COGNEE_COGNIFY_MAX_UNSAVED_DOCUMENTS` | `cognify.max_unsaved_documents` | how many documents may be in progress and not yet saved at once. cognify saves each document as soon as all its extraction and summary results are in, one at a time and in input order, and sends a document's chunks to the LLM only while fewer than this many documents are waiting to be saved. It bounds the LLM results waiting to be saved; the run's chunk text, merged graph and `CognifyResult` still grow with the run. A slow document holds back the saves behind it and, once the window is full, the dispatch of new documents. `0` counts as `1` | `32` |
| `GRAPH_PROMPT_PATH` | `graph_prompt_path` | graph-extraction system prompt. The default and an empty value use the compiled-in prompt. The names of the other built-in prompts — `generate_graph_prompt_strict.txt`, `generate_graph_prompt_simple.txt`, `generate_graph_prompt_guided.txt`, `generate_graph_prompt_oneshot.txt` — select those prompts, compiled in. Any other value is a file read as the prompt text, a relative path against the working directory. An unreadable file keeps the built-in prompt, with a warning. A file is sent verbatim, not rendered as a template (the built-in prompts contain no template syntax; the default prompt's date-hint block is appended in code, and only to the default prompt). | `generate_graph_prompt.txt` |
| — | `summarization_schema` (no env var: `ConfigManager::set_summarization_schema`, `set`, or a loaded config / settings object; not persisted) | JSON schema of the summary output; must have a string `summary` | *(unset — the built-in `SummarizedContent` shape)* |

`data_per_batch` (`cognify.data_per_batch`, `COGNEE_DATA_PER_BATCH`,
`CognifyConfig::with_data_per_batch`) has been removed: no stage read it once
temporal cognify was gone. Setting the key is now an unknown-key error under
strict config (otherwise a warning, and the value is dropped), and the env var
is ignored.

A `CognifyConfig` built in code with
`ExtractionStrategy::Cascade { rounds: 0 }` fails validation. The strategy is
ignored when a non-`llm` graph backend replaces LLM extraction.

**`COGNEE_LEGACY_PER_WORD_TOKEN_COUNT` restores the legacy per-word count.**
By default a chunk's size is the tokenizer's count of the chunk itself. Before
SDK-632 it was the sum of the counts of its *words, each tokenized in isolation*,
which over-states the span for sub-word tokenizers (measured **1.78x** on *Alice
in Wonderland*: a chunk configured at 8191 tokens held 4,669, and the run made
\~1.8x the LLM calls). The default now fills that budget to 8,188 of 8,191.
Setting `COGNEE_LEGACY_PER_WORD_TOKEN_COUNT=1` restores the per-word count, and
its chunk boundaries, at the cost of the over-count. Only `1`/`true`/`yes`/`on`
enable it. Full measurement record:
[performance/chunk-token-overcount.md](https://github.com/topoteretes/cognee-rs/blob/main/docs/performance/chunk-token-overcount.md).

### Edge evidence

With `EDGE_EVIDENCE_ENABLED` on, each cognify storage batch records which chunk
supports which graph edge in `provenance_edge_evidence`, keyed by the run's
`pipeline_run_id`; a search only cites rows whose run has a `COMPLETED`
`pipeline_runs` row. A run without a user records no evidence (the
ownership ledger, by contrast, falls back to the default user).

A host that records the run in `pipeline_runs` itself, and hands cognify a
no-op run repository, sets `CognifyConfig::with_evidence_pipeline_run_id` (code
only) to the id it marks `COMPLETED`; otherwise the rows carry the executor's
run id, which nothing records, and no search cites them. Only the evidence rows
change: ownership, completion markers and rollback stay keyed on the executor's
run id.

> [!WARNING]
>
> **Postgres: a table Python created is not shared.** The SQLite table is
> byte-compatible with Python's, so one SQLite database serves both SDKs. On
> Postgres it is not: Python's migration declares the id columns as native
> `uuid`, and Rust stores them as text. Rust creates the table with
> `IF NOT EXISTS`, so on a database Python already migrated it leaves Python's
> table untouched, and then every Rust insert fails (`column "id" is of type uuid
>   but expression is of type text`). That fails cognify's storage stage for any run
> that captures evidence, and a search's lookup finds no source evidence. Point
> Rust at a database Python did not migrate, or turn `EDGE_EVIDENCE_ENABLED` off
> there.

## Graph extraction

The `graph_extraction` section is registered by the graph-extraction kind. It
picks the extractor cognify uses to turn chunks into graph facts.

| Env var | Key (alias) | Default |
| - | - | - |
| `GRAPH_EXTRACTOR` | `graph_extraction.backend` (`graph_extractor`) | `auto` |

`llm` is cognify's built-in LLM extractor. `auto`, the default,
picks `llm` when an LLM is usable and `gliner` otherwise (see
[Keyless cognify](#keyless-cognify)). `gliner_demo` means
`gliner`. Other kinds (GLiNER, …) are `GraphExtractorFactory`s that an external
crate registers with `register_graph_extractor`, together with their own config
sections. The setting is overridden per call by
the bindings' `extractor` option and the CLI's `--extractor` flag on `cognify`,
`add-and-cognify` and `remember`. A binding's `graphBackend` cognify option (a
kind string, or `{"kind": …, …tuning}`) overrides both. A kind nothing is
registered under is an error; cognify never falls back to the LLM extractor
silently, and neither does `auto`.

Every operation that cognifies honours the setting: `cognify` and
`add-and-cognify` in the CLI and the bindings, and the operations that cognify as
a sub-step (`remember`, `improve`, and the bindings' `update`). Each one resolves
the extractor before any side effect, so an unregistered kind fails before data is
ingested or deleted. The exception is `cognify` in the CLI and the bindings, and
`add-and-cognify` in the CLI and the bindings: they decide whether a run needs
the extractor (and the LLM) from the items it will actually process, after
items an earlier run completed are skipped, so over items that are all code
they resolve no extractor. They still check a selection nothing is registered
under up front (`--extractor`, the bindings' options, or a configured
`graph_extraction.backend` other than `auto`), so a typo fails even on a
code-only dataset. The exception is the bindings' `cognify`: over code-only
items it checks only an extractor its options name, not the configured
`graph_extraction.backend`. Only the keyless `auto` default that cannot be served is
deferred to an item that needs it (see [Keyless cognify](#keyless-cognify)).
The bindings' `remember`, `improve` and `update` still resolve the extractor up
front, even for a code project.
Library callers that build a `CognifyConfig` themselves get
the configured backend from `ComponentManager::configured_graph_extractor` (or
`graph_extractor` with a per-call selection) and attach it with
`with_graph_backend`; `ComponentManager::resolve_graph_extractor` returns the
resolved kind.

### Keyless cognify

With no usable LLM, cognify switches to local models:

* the `auto` graph extractor resolves to `gliner`. Nothing in cognee-rs
  registers a `gliner` extractor, so a build without one fails cognify with an
  error naming the remedies: set `LLM_API_KEY`, register a `gliner` extractor,
  or set `GRAPH_EXTRACTOR` to a registered kind. Only a run with a document
  to extract needs the extractor: code repositories and code files take the
  LLM-free [code route](https://docs.cognee.ai/rust/core-concepts/main-operations/legacy-operations/cognify.md#code-items),
  and items an earlier run completed are skipped first, so `cognify` and
  `add-and-cognify` (CLI and bindings) of a code project succeed without one.
  An `add-and-cognify` whose every input is a document (text, or existing
  non-code files) is refused before the add, so nothing is stored; one with a
  directory, a code file or a URL among its inputs adds them, and fails only if
  an added item is a document (which stays in the dataset for a retry). A
  selection nothing is registered under (`--extractor` or `GRAPH_EXTRACTOR`)
  is still refused up front, except that the bindings' `cognify` of code-only
  items does not check `GRAPH_EXTRACTOR`. The bindings' `improve` and `update` still fail
  this way, as does `remember` unless `content_type="code"`;
* an embedder with no embedding setting configured (provider and model at the
  stock default, no `EMBEDDING_API_KEY`, no `EMBEDDING_ENDPOINT`) runs on the
  local ONNX model (`onnx`, `BGE-Small-v1.5`, 384 dimensions). The model is
  downloaded on first use. The switch applies to every operation that embeds,
  search included, and follows the LLM: once `LLM_API_KEY` is set, the
  configured embedder is back and no longer matches the vectors stored under
  the local model. Set the embedding settings explicitly to keep one embedder
  either way.

"Usable" is `ComponentManager::llm_available()` (see
[Supported LLM providers](https://docs.cognee.ai/rust/configuration/llm-and-embedding.md#supported-llm-providers)):
the provider needs no key (`LlmFactory::requires_api_key` is `false`, as for
Bedrock; the mock LLM always counts) or `LLM_API_KEY` is set. Without one, setup still
succeeds and only a call that needs the LLM (a completion `search`, the `llm`
extractor chosen explicitly) fails. `recall` routes around the missing LLM
instead, and runs a completion type as `only_context` (see [recall](https://docs.cognee.ai/rust/core-concepts/main-operations/recall.md)).

These settings keep the configuration as given (the LLM extractor and the
configured embedder), for runs with deliberately partial or fake provider
config:

| Env var | Key | Default |
| - | - | - |
| `COGNEE_SKIP_PREFLIGHT` | `skip_preflight` | `false` |
| `COGNEE_SKIP_CONNECTION_TEST` | `skip_connection_test` | `false` |
| `MOCK_EMBEDDING` | `embedding.mock` (`mock_embedding`) | *(empty)* |

Any `MOCK_EMBEDDING` mock mode (`zero`, `deterministic`, …) keeps the
configured embedder. The
configured `embedding.*` values are what `config get` and the telemetry snapshot show,
while `ComponentManager::effective_embedding` (used by `cognee-cli export` to
label the vectors) reports the one in use.

### Custom graph schema (per call)

A custom graph model is a per-call option, not a setting: there is no env var
for it. The same goes for `chunk_attachment`.

**The `graph_model` setting does not select it.** The key registry does carry a
`graph_model` row (`ConfigManager::set_graph_model`, `ConfigManager::set("graph_model", …)`,
`cognee-cli config set graph_model …`, the bindings' config setters), but
nothing reads it: setting it succeeds and has no effect on cognify.
Pass the schema per call instead:

| Entry point | Graph schema | Chunk attachment |
| - | - | - |
| Rust (`cognee` / `cognee-cognify`) | `CognifyConfig::with_graph_schema(value)` (`parse_graph_schema` reads an object or a JSON string; `graph_spec_to_json_schema` compiles a spec) | `with_chunk_attachment(ChunkAttachment::…)` (`ChunkAttachment::parse`) |
| CLI `cognify`, `add-and-cognify` | `--graph-schema <FILE>` or `--graph-spec <FILE>` | `--chunk-attachment direct\|all` |
| Bindings (Python handle, TS, C, Java) | `graphSchema` opt (alias `graphModel`), or `graphSpec`: an object or a JSON string | `chunkAttachment` opt: `"direct"` or `"all"` |
| Python compat `cognify()` / `add_and_cognify()` | `graph_model=`: a Pydantic model class, a dict or a JSON string | `chunk_attachment=` |

`null` and `{}` mean the default `KnowledgeGraph`. The CLI and the bindings
run `CognifyConfig::validate` before any side effect; a Rust caller runs it
itself. An invalid value fails with a validation error: an unknown attachment
(rejected when it is parsed), an attachment without a schema, a
schema that does not compile, or a schema combined with a `graph_backend` or
the `cascade` strategy. The bindings type-check the whole
options object: a wrongly-typed value for any known cognify option is an error,
and an unknown key is logged as a warning. See
[the custom graph schema guide](https://docs.cognee.ai/rust/guides/custom-graph-schema.md#entry-points).

## Ontology

The `ontology` section is registered by the ontology-resolver kind. Resolvers are
factories (`OntologyResolverFactory`) on the `ComponentRegistry`, selected by
`ontology.resolver`; an external crate adds one with `register_ontology_resolver`.
With no file path the no-op resolver is used, whatever the resolver id.

| Env var | Key (alias) | Default |
| - | - | - |
| `ONTOLOGY_FILE_PATH` | `ontology.file_path` (`ontology_file_path`) | *(empty)* |
| `ONTOLOGY_RESOLVER` | `ontology.resolver` (`ontology_resolver`) | `rdflib` |
| `ONTOLOGY_MATCHING_STRATEGY` | `ontology.matching_strategy` (`ontology_matching_strategy`) | `fuzzy` |

Only `rdflib` is built in; an unregistered resolver id with a file path set is an
error. `rdflib` implements only `fuzzy` matching and warns on any other strategy.
The CLI's `--ontology-file` overrides `ontology.file_path` for one run.

## Code graph

The `code_graph` section is an engine section, registered with the kind
sections. It configures the deterministic code graph (`cognee-code-graph`),
which runs the external [enola](https://github.com/enola-labs/enola) binary on
a repository and loads its snapshot as code nodes and typed edges.

| Env var | Key (alias) | Default |
| - | - | - |
| `ENOLA_PATH` | `code_graph.enola_path` (`enola_path`) | *(empty)* |
| — | `code_graph.enola_timeout_secs` | `600` |
| `COGNEE_REPOS_DIR` | `code_graph.clones_dir` (`repos_root_directory`) | *(empty: `~/.cognee/repos`)* |
| `CODE_GRAPH_CACHE_MAX_ENTRIES` | `code_graph.snapshot_cache_max_entries` | `16` |
| `CODE_GRAPH_CACHE_TTL_SECONDS` | `code_graph.snapshot_cache_ttl_secs` | `60` |

Whether remote repositories may be cloned is the cognee-wide
`allow_http_requests` setting, and which local repository paths may be read
is `allowed_local_file_roots`: see
[Outbound requests & local paths](https://docs.cognee.ai/rust/configuration/datasets-and-access.md#outbound-requests--local-paths).

`code_graph.snapshot_cache_max_entries` and `code_graph.snapshot_cache_ttl_secs`
bound the process-wide cache of parsed code graphs the
[`CODE` search type](https://docs.cognee.ai/rust/core-concepts/main-operations/legacy-operations/search#code-search)
reads (one entry per dataset and graph engine; least recently used evicted
first). An entry is served for the time limit unless a code-graph load, or a
delete, forget or graph prune, invalidates it first. A count of `0`, or a time
limit that is not a finite positive number, falls back to the default; a
negative count is not a valid value (`config set` rejects it, and
`CODE_GRAPH_CACHE_MAX_ENTRIES=-1` is ignored without a warning). The
cache is shared by every handle in the process: a handle whose config moves
the bounds off the defaults applies them when its search orchestrator is
built, and a handle left at the defaults does not reset bounds another handle
set.

`code_graph.enola_path` names the enola binary. When it is set, the file must
exist, or the load fails with `EnolaNotInstalledError`; a relative path is
resolved against the process's working directory. When it is empty, `enola` is
looked up on `PATH` each time enola is run, and a missing binary
fails the same way. The Rust crates do not bundle enola: install the
`enola-cli==0.5.1` wheel (`pip install enola-cli==0.5.1`) or the binary, and
put it on `PATH` or in `ENOLA_PATH`, wherever cognify runs.

> [!WARNING]
>
> Source files (`.py`, `.rs`, `.ts`, `.go`, ...) are now stored by `code_loader`
> and cognified through the per-file CODE route, which runs enola. Without enola,
> the first code file fails its item, and under the default fail-fast policy the
> whole cognify run, so the dataset's other documents are not cognified either.
> Install enola, or keep the old plain-text reading with
> `preferred_loaders = ["text_loader"]`. See
> [add: code files](https://docs.cognee.ai/rust/core-concepts/main-operations/legacy-operations/add.md#code-files-and-repositories).

`code_graph.enola_timeout_secs` bounds one `enola --generate` run. A run that
takes longer is killed and fails with `EnolaSnapshotError`. One run over a
dataset's repositories (an enola cluster) gets this budget per repository,
capped at 3600 seconds but never below one repository's budget. It must be a
positive number of seconds: `config set` accepts `0` or a negative number, but
the load then fails with a configuration error. From code, read the section with
`Settings::code_graph()`.

`code_graph.clones_dir` is where remote git repositories are shallow-cloned:
the git URLs of `remember(content_type="code")` and the GitHub/GitLab
repository URLs `add` takes. It is always a local directory, even with S3
storage. Clones are reused across calls and refreshed on each; each branch
gets a directory of its own. An SDK, CLI or binding call reuses a clone whose
refresh failed. Cloning needs `git` on `PATH`.

A request a host serves over HTTP (a `RepoSourceSettings` with
`api_request = true`, `Settings::api_repo_sources`) is stricter: a failed
refresh is an error instead of a stale reuse; the clone directory name carries
an 8-hex hash of the credential-free URL (`github.com-org-repo-1a2b3c4d`), so
URLs that would otherwise map to one name (`github.com/a/b-c` and
`github.com/a-b/c`, or `http://` and `https://`) never share a clone; git
follows no http redirect; and git is pinned (`http.curloptResolve`) to the
addresses the outbound check passed, so a DNS answer that changes after the
check cannot send it elsewhere. That pin needs git 2.37 or later: with an
older git such a clone is refused rather than made unpinned. A code
repository's data id is keyed on its clone directory, so these names give
server rows ids of their own: a repository a server re-adds after upgrading is
a new row, and the old row and its old clone directory stay until the old row
is forgotten.

When a code repository row is forgotten, or its dataset deleted, the
dataset's cluster snapshot (`<repo>/.enola-<dataset_id>`) is removed from the
repository, and a clone no remaining row points at is removed. Removing a
clone also removes the repository's other branch clones beside it that no row
points at: a re-add on another branch moves the URL's one row to that branch's
clone and leaves the old clone in place until then. A re-add itself never
removes a clone.

## Cognify failure handling

Read by [`crates/cognify/src/failure.rs`](https://github.com/topoteretes/cognee-rs/blob/main/crates/cognify/src/failure.rs).
When a stage cannot process one chunk or one file it *records* the failure —
which stage, which file, which chunk, and why — instead of aborting the batch.
The report rides every stage output to `CognifyResult.failures` (on success) or
to `CognifyError::RunFailed` (when the run failed). Whether the run fails is
decided once, at the end, from two independent axes.

Each knob is a `CognifyConfig` builder, and each is also a key of the `cognify`
engine section, which `Settings::cognify_config` applies. They live in the
section, not as `Settings` fields, so `GET /api/v1/settings` keeps the response shape of Python cognee's
settings route.

| Builder | Field | Env var | Key | Default |
| - | - | - | - | - |
| `with_failure_stop` | `failure_stop` | `RAISE_INCREMENTAL_LOADING_ERRORS` / `COGNEE_RAISE_INCREMENTAL_LOADING_ERRORS` | `cognify.raise_incremental_loading_errors` (`raise_incremental_loading_errors`) | `FailFast` (unset) |
| `with_rollback_scope` | `rollback_scope` | `COGNEE_COGNIFY_ROLLBACK_SCOPE` (`whole_run` / `failed_items` only) | `cognify.rollback_scope` | unset: `FailedItems` with `incremental_loading`, `WholeRun` without (`effective_rollback_scope()`) |
| `with_summarization_failure_tolerance` | `tolerate_summarization_failures` | `COGNEE_COGNIFY_TOLERATE_SUMMARIZATION_FAILURES` | `cognify.tolerate_summarization_failures` | `false` |
| `with_chunk_failure_ratio_threshold` | `chunk_failure_ratio_threshold` | `COGNEE_COGNIFY_MAX_CHUNK_FAILURE_RATIO` | `cognify.max_chunk_failure_ratio` | `0.05` — **decides nothing**; still read and validated so existing configuration loads |
| `with_failure_report_cap` | `failure_report_cap` | `COGNEE_COGNIFY_FAILURE_REPORT_CAP` | `cognify.failure_report_cap` | `100` |

`RAISE_INCREMENTAL_LOADING_ERRORS` is Python's own flag (default `true`), so one
`.env` configures both SDKs. Its polarity is Python's: `true` (raise on the first
error) is `FailFast`, `false` is `RunToEnd`. It is a strict boolean:
`true`/`1`/`yes`/`on` is `FailFast`, `false`/`0`/`no`/`off` is `RunToEnd`, and
any other value is ignored with a warning, so a typo such as `ture` keeps the
`FailFast` default rather than silently switching to the costlier run-to-end
mode. Python raises only on a literal `true` (case-insensitive), so in a shared
`.env` use `true` or `false`: `1`/`yes`/`on` (or a typo) mean `FailFast` in Rust
but run-to-end in Python. The other four are Rust-only (`COGNEE_COGNIFY_` prefix). An unset value
leaves the default in place, and out-of-range values are ignored rather than
failing the process: a ratio outside `(0, 1]` or an unknown rollback scope logs a
warning, and a zero cap is dropped silently.

**Axis 1 — when to stop.** `FailFast` stops the failing stage from scheduling
further work once a failure is recorded; files that already completed still
travel down the rest of the pipeline. `RunToEnd` continues past failures and
decides at the end (a full run's LLM cost for the complete failure list). Each
stage stops at its own loop boundary:

| Stage | Stops after | Set by | Default |
| - | - | - | - |
| Chunking | the file that failed | — | one file |
| Graph extraction (standard and custom-graph), LLM | the calls already in flight when the failure came back | `max_parallel_extractions` | **1000 calls** (128 on Android/iOS) |
| Graph extraction, graph backend | the backend call that contained the failure | `chunks_per_batch` | **2000 chunks** |
| Summarization | the calls already in flight when the failure came back | `max_parallel_extractions` | **1000 calls** (128 on Android/iOS) |

Graph extraction and summarization each send every chunk of the run through
one stream, with at most `max_parallel_extractions` calls in flight and no
barrier between `chunks_per_batch` blocks, so they stop at the granularity of
that concurrency window. The two streams share one stop: the first failing
chunk, in either stream, closes the gate for both, so a failed extraction also
stops summary dispatch and vice versa. Undispatched chunks are skipped and
their files recorded as unreached, so a file is complete only when every one
of its chunks was dispatched and none failed. In-flight calls are not
cancelled and their results are collected, failures included, except after a
failed save that fails the run (under `WholeRun` or `Nothing`), which stops
both streams and aborts the calls in flight. Under `FailedItems` a failed save
fails only its file, and stops dispatch only under `FailFast`. On a run with fewer chunks than `max_parallel_extractions`,
every call is already in flight, so `FailFast` saves no calls. Which chunks were sent before the stop depends on timing, so the same
failing input can leave a different set of files unreached. A graph backend
(`CognifyConfig::graph_backend`) is still handed `chunks_per_batch` chunks per
call, one call at a time, and stops after the call that failed. A tolerated
summarization failure does not close the gate.

Under `FailFast` + `FailedItems` that window decides how much survives: a
file is kept only if every one of its calls finished, so every file with a
chunk beyond the window is unreached. Each file is saved — and, with
`incremental_loading`, marked complete — as soon as its last result is in, so
every file that completed before the stop is kept, even though the run then
errors. With 32 calls in flight, a failure at chunk 40 of a 1,500-chunk run
keeps the files whose calls had all come back by then. To keep every file that
succeeded, use `RunToEnd` + `FailedItems`
(`cognify.raise_incremental_loading_errors=false`).

LLM graph extraction no longer logs a `Processed graph extraction batch i/n`
line per batch (a graph backend still does). It logs `graph extraction: N of M
chunks returned` (`custom graph extraction: …` on the custom-graph path) at
most every 30 seconds, and the default path logs one `Extracted graphs from N
of M chunks (K never dispatched)` line at the end.

**Axis 2 — what to sweep.** `WholeRun` removes everything the run created;
`FailedItems` removes only the contributions of the files the run did not
complete and keeps the rest. **An unset `rollback_scope` follows
`incremental_loading`**: `FailedItems` by default, `WholeRun` with
`incremental_loading` off (nothing is marked then, so there is nothing to
keep). Set `COGNEE_COGNIFY_ROLLBACK_SCOPE=whole_run` for the whole-run end
state with incremental loading on. From code, `CognifyConfig::rollback_scope`
is an `Option<RollbackScope>` (`None` follows `incremental_loading`);
`CognifyConfig::effective_rollback_scope()` returns the resolved scope. This
is a breaking change: the default used to be `WholeRun` whatever
`incremental_loading` said, and the field was a plain `RollbackScope`.

Under `FailedItems` each file is **completed as soon as it is saved**: the
document stage saves a file once all its results are in and, with
`incremental_loading`, marks it complete right away; a code item is completed
once its graph is loaded; a DLT row only once the post-run step has written its
foreign-key edges. A completed file is kept whatever happens to the run
afterwards:

* **No item failed**: the run completes and returns `Ok`.
* **An item failed**, or a failure hit outside one file's own work (a failed
  post-run step, a cancellation): the run is recorded `ERRORED` and returns
  `Err` carrying the report, and removes everything it wrote **except** what
  the files it completed own. Run-level rows no kept file stands beside, such
  as a DLT schema node, go too. Select `WholeRun` to remove the completed
  files as well.

A file whose save failed, or was cut off because the run was stopped mid-save,
is not completed and is removed with the rest. Without `incremental_loading`
nothing is marked, so kept files are processed again by the next run. The
removal also takes a type, structural edge or ontology-first entity that only
the removed files declared. It binds no list of files, so it works whatever the
number of kept or removed files: the kept files' rows are set aside under a
holding run id, the run is removed whole, and they are moved back. The edge
evidence of the files an errored run kept is detached from that run, so
`include_references` still cites it.

A third variant, `Nothing`, removes nothing and is **not
selectable from configuration** (`nothing`/`none` are rejected like any unknown
value, from the env var or the `cognify` section key); it is reachable only via
`CognifyConfig::with_rollback_scope(RollbackScope::Nothing)`, because a run that
wrote graph edges and died before the vector stage leaves orphans a retry does
not repair: the retry finds those edges already in the graph and only claims
them (an ownership row, no edge or vector write). Only `cognee-cli edge-reindex --apply`
(`reindex_edge_types`) writes the missing points, or a later run that writes a
new edge with the same text. After a stop — a `FailFast` failure or a failed
save — a `Nothing` run saves nothing more: the files saved before the stop
keep their artifacts and get no completion marker, and complete files waiting
behind the stop are discarded.

| Combination | End state |
| - | - |
| `FailFast` + `WholeRun` *(default without `incremental_loading`)* | Stops dispatching at the first failure, removes everything the run created, marks the run `ERRORED`, returns `Err`. Earlier runs are untouched. |
| `FailFast` + `FailedItems` *(default)* | Stops dispatching at the first failure; the files that completed — before or after it, while their calls were in flight — are kept, indexed and marked as they complete; failed and never-reached ones are removed and left unmarked. The run is `ERRORED` and returns `Err` |
| `RunToEnd` + `WholeRun` | Pays for the whole run to produce the complete failure list, then removes everything the run created |
| `RunToEnd` + `FailedItems` | Every good file is cognified and marked as it completes; only the failed files are removed, and they come back in the report of the `Err` the call returns |
| *either* + `Nothing` *(code only)* | Nothing is removed; partially-cognified files are left in place permanently |

Any combination that sweeps and ends `ERRORED` returns `Err` — every
combination, `FailedItems` included, whenever an item failed.
`CognifyResult.failures` of an `Ok` run lists only tolerated summarization
failures and items left unreached because no document type matches them. A sweep removes an artifact only when nothing outside
the swept scope still claims it (another run, another dataset, a pre-ownership
row, or a surviving file in the same run). **Cancellation is swept** too, though
there is no caller-facing cancel handle yet, and dropping the `cognify()`
future runs no sweep.

**Per-stage policy.**

| Stage | Failure unit | Behaviour |
| - | - | - |
| Chunking | data item | Collected; the item fails and contributes neither chunks nor a `Document` |
| Graph extraction | chunk | Collected; the item fails |
| Summarization | chunk | **Configurable.** Default: the item fails. With tolerance on: recorded separately, never fails the item or the run |
| Code graph | repo item | Collected; the item fails (enola not installed, a timeout, a bad snapshot or manifest). A loaded repo item counts as a survivor |
| Persistence of one file — its graph, vector, ledger and evidence writes, and embeddings | data item under `FailedItems`, else run | Under `FailedItems` the file fails (`FailureStage::Persistence`, shown as `persistence`), is removed, and the run goes on (under `FailFast` it stops dispatching) and errors at the end. Under the other scopes the run fails at once |
| Persistence after the pipeline — the DLT foreign-key step | run | Always fatal; under `FailedItems` the files completed before it are kept |

The **failure ratio** (`FailureReport::chunk_failure_ratio`, failed chunks over
the run's chunks) is still reported but no longer decides anything: every
scope fails the run on any failed item, so a re-run that stops at the same bad
file never reports success. `COGNEE_COGNIFY_MAX_CHUNK_FAILURE_RATIO` is still
read and validated so existing configuration loads. The **report cap** bounds the
individual entries listed (and the error message); totals, the failed-file set and
counters are never capped. A run that dies in a persistence stage loses the
report of failures collected earlier (a persistence error that fails the run
keeps its own `CognifyError` variant). Under `FailedItems` one file's failed
save is not such an error: it is a `FailureStage::Persistence` entry in the
report.

## Completion markers and incremental loading

`incremental_loading` (default **on**) is live. Every data item a run finished
is marked complete on its `Data` row — under `FailedItems` as soon as the item
is saved, under `WholeRun` once the whole run succeeded — under
`pipeline_status["cognify_pipeline"][<dataset id>] =
"DATA_ITEM_PROCESSING_COMPLETED"` — Python's format byte for byte, so the two
SDKs can share a database. The next run reads those markers before it builds a
pipeline and skips items already carrying one: they are not classified, chunked,
or sent to an LLM.

* **Re-cognifying an already-complete dataset is a no-op.** The call returns
  `Ok` with `already_completed = true` and empty payloads, and writes its own
  `STARTED` / `COMPLETED` pair. (Previously every cognify re-processed
  everything.)
* **A failed run keeps only the marks of the items it completed** (none under
  `WholeRun` or `Nothing`), and a sweep clears the markers of every item it
  rolled back, so the next run redoes exactly the work that was lost.
* **A run with failed files leaves them unmarked** (and errors), so the next
  run has exactly the failed files to redo.

**The run trail.** A fully skipped Rust run still writes a `STARTED` /
`COMPLETED` pair (a fresh `pipeline_run_id`; `STARTED` carries only the run's
`recovery_lock`, `COMPLETED` is `{}`). Rust skips the items before it
builds the pipeline, so the cognify entry point writes the pair itself. There is
no pipeline-cache gate any more (`use_pipeline_cache` was removed; see
[Serialization and recovery of pipeline runs](https://docs.cognee.ai/rust/configuration/storage.md#serialization-and-recovery-of-pipeline-runs)).

To reprocess everything on every run, set `with_incremental_loading(false)`.


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