Expand description
Compile-time constants: embedding dimensions, limits and thresholds. Compile-time constants shared across the crate.
Grouped into embedding configuration, length and size limits, SQLite
pragmas and retrieval tuning knobs. Values are taken from the PRD and
must stay in sync with the migrations under migrations/.
§Dynamic concurrency permit calculation
The maximum number of simultaneous instances can be adjusted at runtime using the formula:
permits = min(cpus, available_memory_mb / LLM_WORKER_RSS_MB) * 0.5where available_memory_mb is obtained via sysinfo::System::available_memory()
converted to MiB. The result is capped at MAX_CONCURRENT_CLI_INSTANCES
and floored at 1.
§Layout
The constants live in themed submodules and are re-exported here, so every
crate::constants::X path in the crate keeps resolving unchanged. The split
happened in v1.2.5, when the single file had reached 960 lines against the
project’s own 800-line ceiling (GAP-SG-89).
Constants§
- AGENT_
SURFACE_ ALIAS_ ARRAYS - GAP-SG-142: derived result arrays suppressed once the agent-native surface reshapes their canonical source.
- AGENT_
SURFACE_ FIELD_ SYNONYMS - GAP-SG-230: field spellings the agent-native surface treats as ONE key.
- AGENT_
SURFACE_ RESULT_ KEYS - GAP-SG-142: envelope members searched, in order, for the primary result
array reshaped by
crate::agent_surface. - AUTOSPLIT_
PARTITION_ MAX_ BYTES - Byte budget for one auto-split partition (sub-memory) in
ingest(GAP-SG-04/07). - BACKUP_
BUSY_ RETRY_ DELAY_ MS - Pause, in milliseconds, between
sqlite3_backup_stepretries after a transientBusy/Locked. - BATCH_
PARTIAL_ FAILURE_ EXIT_ CODE - Exit code for partial batch failure (PRD line 1822). Conflicts with DbBusy in v1.x; in v2.0.0 DbBusy migrates to 15 and this code takes 13 per PRD.
- BROKEN_
PIPE_ EXIT_ CODE - Process exit code returned when stdout is a closed pipe.
- BUSY_
TIMEOUT_ MILLIS PRAGMA busy_timeoutvalue applied on every connection.- CACHE_
SIZE_ KB PRAGMA cache_sizevalue in kibibytes (negative means KiB).- CHUNK_
OVERLAP_ TOKENS - Token overlap between consecutive chunks.
- CHUNK_
SIZE_ TOKENS - Chunk size expressed in tokens for body splitting.
- CLI_
LOCK_ DEFAULT_ WAIT_ SECS - Maximum time in seconds an instance waits to acquire a concurrency slot.
- CLI_
LOCK_ EXIT_ CODE - Process exit code returned when the lock is busy and no wait was requested (EX_TEMPFAIL).
- CLI_
LOCK_ POLL_ INTERVAL_ MS - Polling interval in milliseconds used by
--wait-lockbetweentry_lock_exclusiveattempts. - COOPERATIVE_
YIELD_ SLEEP_ MS - Pause, in milliseconds, appended to a cooperative yield between enrich batches (PRIO-05).
- CURRENT_
SCHEMA_ VERSION - Current schema version, equal to the highest migration number in
migrations/Vnnn__*.sql. - DB_
BUSY_ EXIT_ CODE - Exit code for DbBusy in v2.0.0 (migrated from 13 to free 13 for batch failure).
- DEADLOCK_
CHECK_ INTERVAL_ SECS - Poll interval, in seconds, of the
deadlock-detectionwatchdog thread. - DEDUP_
FUZZY_ THRESHOLD - Jaccard threshold above which two memories are considered fuzzy duplicates.
- DEDUP_
SEMANTIC_ THRESHOLD - Cosine distance threshold below which two memories are semantic duplicates.
- DEFAULT_
AGENT_ SURFACE_ MAX_ ITEMS - Default cap on emitted result elements (
--max-items).0means no cap, preserving the pre-GAP-SG-142 envelope byte for byte. - DEFAULT_
AGENT_ SURFACE_ MAX_ OUTPUT_ BYTES - Default cap on the serialized envelope in bytes (
--max-output-bytes).0disables the ceiling. - DEFAULT_
AGENT_ SURFACE_ TRUNCATE_ CONTENT - Default cap on string length in characters (
--truncate-content).0disables content truncation. - DEFAULT_
EMBEDDING_ DIM - Default embedding vector dimensionality for a NEWLY created database.
- DEFAULT_
EMBEDDING_ HTTP_ TIMEOUT_ SECS - Default total per-request budget, in seconds, for an OpenRouter embeddings
HTTP call when neither
--openrouter-timeoutnor XDGembedding.timeout_secssupplies a value (GAP-SG-141 B3). - DEFAULT_
ENRICH_ CIRCUIT_ BREAKER_ RESET_ SECS - Cooldown, in seconds, before a tripped per-worker circuit breaker allows the
next attempt (
enrichparallel drain). - DEFAULT_
ENRICH_ LLM_ PARALLELISM - Default subprocess worker count for
enrichwhen--llm-parallelismis omitted (GAP-SG-141). - DEFAULT_
ENRICH_ MAX_ RUNTIME_ SECS - Default wall-clock budget, in seconds, for one
enrichrun when--max-runtimeis omitted. - DEFAULT_
ENRICH_ REST_ CONCURRENCY - Default REST fan-out for
enrich --mode openrouterwhen--rest-concurrencyis omitted (GAP-SG-141). - DEFAULT_
ENRICH_ SCAN_ PAGE_ SIZE - GAP-SG-185 / v1.2.4: default keyset page size for enrich scan collectors.
- DEFAULT_
HYBRID_ MAX_ GRAPH_ RESULTS - DEFAULT cap on
hybrid-search --with-graphgraph matches. - DEFAULT_
K_ RECALL - Default
kused byrecallwhen the caller omits--k. - DEFAULT_
LLM_ PROBE_ TIMEOUT_ MS - Fail-fast probe budget for LLM backends before spawning (ms).
Override via XDG
llm.probe_timeout_ms. - DEFAULT_
LOG_ LEVEL - Default tracing filter level when neither CLI
-v/-qnor XDGlog.levelis set (GAP-SG-93). - DEFAULT_
MAX_ HOPS - Default traversal depth for
relatedwhen--hopsis omitted. - DEFAULT_
MAX_ RSS_ MB - Maximum process RSS in MiB before aborting embedding operations.
Users can override via
--max-rss-mb. Set to 8 GiB by default. - DEFAULT_
MIN_ WEIGHT - Default minimum weight filter applied during graph traversal.
- DEFAULT_
OPENROUTER_ CHAT_ TIMEOUT_ SECS - Default per-item budget, in seconds, for an OpenRouter chat-completion when
--openrouter-timeoutis omitted. - DEFAULT_
OPENROUTER_ CHAT_ URL - Default OpenRouter chat completions endpoint (override via XDG
network.openrouter.chat_urlor aliasnetwork.chat_url). - DEFAULT_
OPENROUTER_ EMBEDDINGS_ URL - Default OpenRouter embeddings endpoint (override via XDG
network.openrouter.embeddings_urlor aliasnetwork.embed_url). - DEFAULT_
RATE_ LIMIT_ DEADLINE_ SECS - Deadline, in seconds, a drain keeps absorbing provider rate limits before giving up on the run.
- DEFAULT_
RAYON_ THREADS - Default worker count for the global Rayon pool.
- DEFAULT_
REEMBED_ CLAIM_ BATCH - GAP-SG-141 (B1): how many
ReEmbedqueue rows a single claim takes. - DEFAULT_
RELATION_ WEIGHT - Default weight assigned to newly created relationships.
- DEFAULT_
STDIN_ READ_ TIMEOUT_ SECS - Deadline, in seconds, for reading a memory body from stdin.
- DERIVED_
NAME_ MAX_ LEN - Maximum byte length for an
ingest-derived kebab-case name. - DUPLICATE_
EXIT_ CODE - Process exit code returned when a duplicate memory or entity is detected (exit 9).
- EMBEDDING_
DIM_ RANGE - Accepted range for any embedding dimensionality, override or recorded.
- EMBEDDING_
MAX_ TOKENS - Maximum tokens accepted by an embedding input before chunking.
- EMBEDDING_
REQUEST_ MAX_ TOKENS - Maximum token count for a SINGLE embedding request input (GAP-SG-02).
- EMBED_
RUNTIME_ MAX_ WORKER_ THREADS - Upper bound on Tokio worker threads for the shared embedding runtime (GAP-SG-141 B2).
- EMBED_
RUNTIME_ MIN_ WORKER_ THREADS - Lower bound on Tokio worker threads for the shared embedding runtime (GAP-SG-141 B2).
- EMBED_
SLOT_ RETRY_ DELAY_ MS - Pause, in milliseconds, before retrying a query embedding that lost the race for an LLM slot.
- EMBED_
TIMEOUT_ PER_ EXTRA_ BATCH_ ITEM_ SECS - Extra timeout, in seconds, granted per item beyond the first in a batched embedding call (GAP-4).
- ENRICH_
BACKOFF_ CEILING_ SECS - Ceiling, in seconds, on the exponential backoff a rate-limited drain waits between attempts.
- ENRICH_
BODY_ LOG_ PREVIEW_ CHARS - Number of chars of a memory body kept in a LOG or diagnostic line.
- ENRICH_
BODY_ PREVIEW_ CHARS - Number of chars of a memory body shown to the model as a PREVIEW.
- ENRICH_
BODY_ SUBJECT_ CHARS - Number of chars of a memory body sent when the body ITSELF is the subject.
- ENRICH_
GENERIC_ DESCRIPTION_ MAX_ CHARS - Minimum description length, in chars, below which a description is judged generic and eligible for rewriting.
- ENRICH_
HIGH_ WEIGHT_ THRESHOLD - Relationship weight at or above which an edge counts as HIGH weight.
- ENRICH_
INITIAL_ MAX_ TOKENS - Initial
max_tokensbudget sent on anenrichchat-completion request (GAP-SG-70/71). - ENRICH_
MAX_ LENGTH_ RETRIES - Maximum number of
max_tokens-growth re-attempts after a truncated (finish_reason: "length")enrichchat-completion, before giving up and returning the truncation as an error (GAP-SG-70/71). - ENRICH_
MAX_ TOKENS_ CEILING - Upper bound on
max_tokensgrowth for anenrichchat-completion (GAP-SG-70/71). - ENRICH_
MAX_ TOKENS_ GROWTH_ FACTOR - Multiplier applied to
max_tokenseach time OpenRouter reportsfinish_reason: "length"on anenrichchat-completion (GAP-SG-70/71). - ENRICH_
QUALITY_ ACCEPT_ RATE_ WEIGHT - Weight given to the accept rate when blending it with mean grounding score into a single quality figure.
- ENRICH_
QUALITY_ MEAN_ SCORE_ WEIGHT - Weight given to the mean grounding score in the same blend.
- ENRICH_
SCAN_ PAGE_ SIZE_ RANGE - Accepted range for
enrich.scan_page_size/--scan-page-size. - ENRICH_
SCAN_ WATCHDOG_ POLL_ MS - Poll interval, in milliseconds, of the watchdog that interrupts an over-budget enrich scan.
- ENRICH_
UNTIL_ EMPTY_ IDLE_ NAP_ SECS - Nap, in seconds, taken by an
--until-emptydrain when every remaining item is still serving its backoff. - ENTITY_
EMBED_ CACHE_ MAX_ ENTRIES - DEFAULT entry ceiling for the process-wide entity-embedding cache.
- ENTITY_
EMBED_ CACHE_ TTL_ SECS - DEFAULT time-to-live, in seconds, of one entity-embedding cache entry.
- FASTEMBED_
BATCH_ SIZE - Batch size for
fastembedencoding calls. - HEALTH_
SUPER_ HUB_ DEGREE_ THRESHOLD - Degree above which
healthreports an entity as a super-hub. - HEALTH_
SUPER_ HUB_ SAMPLE_ LIMIT - How many super-hubs
healthnames in its warning string. - JOB_
SINGLETON_ POLL_ INTERVAL_ MS - G28-B (v1.0.68): polling interval in milliseconds used by
acquire_job_singletonbetween retry attempts when another invocation already holds the singleton for(job_type, namespace). - K_
DEEP_ RESEARCH_ GRAPH_ EDGES_ LIMIT - Maximum edges pulled when
deep-researchexpands the graph around its hits. - K_
ENRICH_ BODY_ CONTEXT_ ENTITIES_ LIMIT - Linked entities pulled into the prompt context when enriching a body.
- K_
ENTITIES_ SEARCH - Default
kfor entity KNN searches during graph expansion. - K_
GRAPH_ ENTITIES_ DEFAULT_ LIMIT - Default
--limitforgraph entitieswhen omitted. - K_
GRAPH_ MATCHES_ LIMIT - Maximum result count from the recursive graph CTE in
recall. - K_
HISTORY_ DEFAULT_ LIMIT - Default
--limitforhistorywhen omitted. - K_
LIST_ LIMIT_ MAX - Inclusive upper bound for
--limiton commands that page over stored rows. - K_
LIST_ TEXT_ DEFAULT_ LIMIT - Default
--limitforlistin a HUMAN format, when the caller omits it. - K_
MAX_ HOPS_ CEILING - Inclusive upper bound for
--max-hopsand--depthon graph traversal. - K_
MAX_ SUB_ QUERIES_ CEILING - Inclusive upper bound for
deep-research --max-sub-queries. - K_
MEMORIES_ DEFAULT - Default
kfor memory KNN searches when the caller omits--k. - K_
QUERY_ RANGE_ MAX - Inclusive upper bound for
-k/--kon every retrieval command. - K_
RELATED_ DEFAULT_ LIMIT - Default
--limitforrelatedwhen omitted. - K_
VOCABULARY_ MAX_ KEYS - Hard ceiling on distinct key names collected for a suggestion.
- K_
VOCABULARY_ MAX_ SUGGESTIONS - Alternatives named in a refusal message.
- K_
VOCABULARY_ SAMPLE_ ELEMENTS - Elements sampled when the surface builds the key vocabulary for a SUGGESTION.
- LLM_
SLOT_ ASSUMED_ AVAILABLE_ MB - Memory assumed available when the LLM slot default is computed without
sysinfoat hand. - LLM_
SLOT_ POLL_ INTERVAL_ MS - How long the LLM slot acquirer sleeps between polls while every slot is busy.
- LLM_
WORKER_ RSS_ MB - DEFAULT expected RSS, in MiB, budgeted for one LLM/REST worker.
- LOW_
MEMORY_ EXIT_ CODE - Process exit code returned when available memory is below
crate::constants::MIN_AVAILABLE_MEMORY_MB. - MAX_
BODY_ CHARS_ BEFORE_ CHUNK - Body character count above which the body is split into chunks.
- MAX_
CONCURRENT_ CLI_ INSTANCES - Maximum number of CLI instances running simultaneously.
- MAX_
EMBED_ PASSAGE_ FAN_ OUT - Highest REST fan-out width the batched passage embedder will use (v1.2.8, plan step 6).
- MAX_
ENRICH_ REST_ CONCURRENCY - Highest REST fan-out
enrich --mode openrouteraccepts (GAP-SG-266). - MAX_
ENTITIES_ PER_ MEMORY - Default upper bound on distinct entities persisted per memory.
- MAX_
ENTITY_ TYPE_ LEN - Maximum length, in characters, of an
entities.typelabel. - MAX_
GRAPH_ HOPS - Maximum number of hops allowed in graph traversals.
- MAX_
MEMORY_ BODY_ LEN - Hard upper bound on memory
bodylength in bytes. - MAX_
MEMORY_ DESCRIPTION_ LEN - Maximum character length for a memory
descriptionfield. - MAX_
MEMORY_ NAME_ LEN - Maximum byte length for a memory
namefield in kebab-case. - MAX_
NAMESPACES_ ACTIVE - Maximum number of simultaneously active namespaces (deleted_at IS NULL). Exit 5 when exceeded.
- MAX_
RELATIONSHIPS_ PER_ MEMORY - Upper bound on distinct relationships persisted per memory.
- MAX_
RETRY_ AFTER_ SECS - Ceiling, in seconds, on a single
Retry-Aftersleep inside the HTTP retry loops ofcrate::chat_apiandcrate::embedding_api. - MAX_
SQLITE_ BUSY_ RETRIES - Maximum attempts when a statement returns
SQLITE_BUSY. - MAX_
TOTAL_ LLM_ WORKERS - DEFAULT joint ceiling on
max_concurrency × llm_parallelismfor one host. - MIN_
AVAILABLE_ MEMORY_ MB - Minimum available memory in MiB required before starting model loading.
- MIN_
EMBED_ PASSAGE_ FAN_ OUT - Lowest REST fan-out width the batched passage embedder will use (v1.2.8, plan step 6).
- MIN_
ENRICH_ REST_ CONCURRENCY - Lowest REST fan-out
enrich --mode openrouteraccepts (GAP-SG-266). - MIN_
RELATION_ WEIGHT - Minimum relationship weight required for traversal inclusion.
- MMAP_
SIZE_ BYTES PRAGMA mmap_sizevalue in bytes applied to each connection.- NAME_
SLUG_ REGEX - PRD-canonical regex that validates names and namespaces. Allows 1 char
[a-z0-9]OR a 2-80 char string starting with a letter and ending with a letter/digit, containing only[a-z0-9-]. Rejects the__prefix (internal reserved). - OMP_
NUM_ THREADS_ DEFAULT - Default value injected into OMP_NUM_THREADS when not set by the user.
- ORT_
INTRA_ OP_ NUM_ THREADS_ DEFAULT - Default value injected into ORT_INTRA_OP_NUM_THREADS when not set.
- ORT_
NUM_ THREADS_ DEFAULT - Default value injected into ORT_NUM_THREADS when not set by the user.
- PASSAGE_
PREFIX - Prefix prepended to bodies before embedding as required by E5 models.
- PURGE_
RETENTION_ DAYS_ DEFAULT - Default retention period (days) used by
purgewhen--retention-daysis omitted. - QUERY_
PREFIX - Prefix prepended to queries before embedding as required by E5 models.
- QUERY_
TIMEOUT_ MILLIS - Query timeout applied to statements in milliseconds.
- REEMBED_
CLAIM_ BATCH_ RANGE - Accepted range for
enrich.reembed_claim_batch. - REMEMBER_
MAX_ CONTROLLED_ BATCH_ CHUNKS - Ceiling on chunks per controlled micro-batch in
remember. - REMEMBER_
MAX_ CONTROLLED_ BATCH_ PADDED_ TOKENS - Maximum padded-token budget per controlled micro-batch in
remember. - REMEMBER_
MAX_ SAFE_ MULTI_ CHUNKS - Explicit operational guard for multi-chunk documents in
remember. - RRF_
K_ DEFAULT - Default
kconstant used by Reciprocal Rank Fusion inhybrid-search. - SCHEMA_
USER_ VERSION - Canonical value of
PRAGMA user_versionwritten after migrations. - SHUTDOWN_
EXIT_ CODE - Process exit code returned when shutdown is requested via SIGINT/SIGTERM/SIGHUP (v1.0.82, GAP-002 final).
- SQLITE_
BUSY_ BASE_ DELAY_ MS - Base delay in milliseconds for the first SQLITE_BUSY retry.
- SQLITE_
BUSY_ MAX_ DELAY_ MS - Ceiling on ONE busy-retry sleep, in milliseconds.
- SQLITE_
GRAPHRAG_ VERSION - Crate version string sourced from
CARGO_PKG_VERSIONat build time. - SYSTEM_
LOAD_ REFRESH_ INTERVAL_ SECS - Minimum interval, in seconds, between two
/proc/loadavgreads. - TEXT_
BODY_ PREVIEW_ LEN - Character size of the body preview emitted in text/markdown formats.
- TEXT_
DESCRIPTION_ PREVIEW_ LEN - Character length of the description preview shown in
listoutput. - USAGE_
EXIT_ CODE - Process exit code returned when the argv is a valid parse but an invalid
combination (
EX_USAGEin spirit,2by this project’s contract). - VOCABULARY_
SUGGESTION_ MIN_ SIMILARITY - Jaro-Winkler similarity below which a candidate is not offered as a fix.
- WAL_
AUTOCHECKPOINT_ PAGES PRAGMA wal_autocheckpointthreshold in pages.- WEIGHT_
FTS_ DEFAULT - Default weight for the BM25 text contribution in the
hybrid-searchRRF formula. - WEIGHT_
VEC_ DEFAULT - Default weight for the vector contribution in the
hybrid-searchRRF formula.
Functions§
- agent_
surface_ field_ synonym_ groups - GAP-SG-274: the synonym groups that apply to
command, in table order. - clamp_
retry_ after_ secs - Clamps a server-advised
Retry-AftertoMAX_RETRY_AFTER_SECS, warning when the cap actually bites. - embedding_
dim - Resolves the active embedding dimensionality (single source of truth).
- embedding_
dim_ from_ runtime - Reads the CLI
--embedding-dimflag or the XDG keyembedding.dim. - entity_
embed_ cache_ max_ entries - Entity-cache entry ceiling: XDG
embedding.entity_cache_max_entriesorENTITY_EMBED_CACHE_MAX_ENTRIES.0falls back to the default. - entity_
embed_ cache_ ttl_ secs - Entity-cache TTL in seconds: XDG
embedding.entity_cache_ttl_secsorENTITY_EMBED_CACHE_TTL_SECS.0falls back to the default. - hybrid_
search_ max_ graph_ results - Graph-match ceiling for
hybrid-search: the--max-graph-resultsflag, then XDGsearch.hybrid.max_graph_results, thenDEFAULT_HYBRID_MAX_GRAPH_RESULTS. - joint_
parallelism_ ceiling - Joint fan-out ceiling in force for this process.
- joint_
parallelism_ ceiling_ for - Per-process fan-out width still allowed once
max_concurrencyprocesses are counted againstmax_total_llm_workers. - llm_
worker_ rss_ mb - Per-worker RSS budget in MiB: XDG
llm.worker_rss_mborLLM_WORKER_RSS_MB. - max_
entities_ per_ memory - Resolves the per-memory entity cap (flag/XDG/
runtime_config). - max_
relationships_ per_ memory - Resolves the per-memory relationship cap (flag/XDG/
runtime_config). - max_
total_ llm_ workers - Joint worker ceiling: XDG
parallelism.max_total_workersorMAX_TOTAL_LLM_WORKERS.0falls back to the default. - name_
slug_ regex - Returns a reference to the compiled
NAME_SLUG_REGEXpattern. Compiled once on first call, cached viaOnceLock. - set_
active_ embedding_ dim - Records the dimensionality found in the opened database (
schema_meta.dim). - set_
joint_ parallelism_ ceiling - Publishes the joint fan-out ceiling derived from the resolved
--max-concurrency(called once, frommain).