Skip to main content

Module constants

Module constants 

Source
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 / EMBEDDING_LOAD_EXPECTED_RSS_MB) * 0.5

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

Constants§

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.
BUSY_TIMEOUT_MILLIS
PRAGMA busy_timeout value applied on every connection.
CACHE_SIZE_KB
PRAGMA cache_size value 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_FILE
Filename used for the advisory exclusive lock that prevents parallel invocations.
CLI_LOCK_POLL_INTERVAL_MS
Polling interval in milliseconds used by --wait-lock between try_lock_exclusive attempts.
CURRENT_SCHEMA_VERSION
Current schema version, equal to the highest migration number in migrations/Vnnn__*.sql.
DAEMON_AUTO_START_INITIAL_BACKOFF_MS
Initial polling interval to check whether the daemon became healthy.
DAEMON_AUTO_START_MAX_BACKOFF_MS
Ceiling on backoff between automatic daemon spawn attempts.
DAEMON_AUTO_START_MAX_WAIT_MS
Maximum wait time for the daemon to become healthy after auto-start.
DAEMON_IDLE_SHUTDOWN_SECS
Idle duration in seconds before the daemon shuts itself down.
DAEMON_PING_TIMEOUT_MS
Timeout in milliseconds for a single ping probe against the daemon socket.
DAEMON_SPAWN_BACKOFF_BASE_MS
Base backoff used after daemon spawn/health failures.
DAEMON_SPAWN_LOCK_WAIT_MS
Maximum wait time to acquire the daemon spawn lock.
DB_BUSY_EXIT_CODE
Exit code para DbBusy em v2.0.0 (migrado de 13 para liberar 13 para batch failure).
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_K_RECALL
Default k used by recall when the caller omits --k.
DEFAULT_MAX_HOPS
Default traversal depth for related when --hops is omitted.
DEFAULT_MIN_WEIGHT
Default minimum weight filter applied during graph traversal.
DEFAULT_RELATION_WEIGHT
Default weight assigned to newly created relationships.
EMBEDDING_DIM
Embedding vector dimensionality produced by multilingual-e5-small.
EMBEDDING_LOAD_EXPECTED_RSS_MB
Expected RSS in MiB for a single instance with the ONNX model loaded via fastembed.
EMBEDDING_MAX_TOKENS
Maximum tokens accepted by an embedding input before chunking.
FASTEMBED_BATCH_SIZE
Batch size for fastembed encoding calls.
FASTEMBED_MODEL_DEFAULT
Default fastembed model identifier used by remember and recall.
K_ENTITIES_SEARCH
Default k for entity KNN searches during graph expansion.
K_GRAPH_ENTITIES_DEFAULT_LIMIT
Default --limit para graph entities quando omitido.
K_GRAPH_MATCHES_LIMIT
Maximum result count from the recursive graph CTE in recall.
K_HISTORY_DEFAULT_LIMIT
Default --limit para history quando omitido.
K_LIST_DEFAULT_LIMIT
Default --limit para list quando omitido.
K_MEMORIES_DEFAULT
Default k for memory KNN searches when the caller omits --k.
K_RELATED_DEFAULT_LIMIT
Default --limit para related quando omitido.
LOW_MEMORY_EXIT_CODE
Process exit code returned when available memory is below 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_ENTITIES_PER_MEMORY
Upper bound on distinct entities persisted per memory.
MAX_GRAPH_HOPS
Maximum number of hops allowed in graph traversals.
MAX_MEMORY_BODY_LEN
Hard upper bound on memory body length in bytes.
MAX_MEMORY_DESCRIPTION_LEN
Maximum character length for a memory description field.
MAX_MEMORY_NAME_LEN
Maximum byte length for a memory name field 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_SQLITE_BUSY_RETRIES
Maximum attempts when a statement returns SQLITE_BUSY.
MIN_AVAILABLE_MEMORY_MB
Minimum available memory in MiB required before starting model loading.
MIN_RELATION_WEIGHT
Minimum relationship weight required for traversal inclusion.
MMAP_SIZE_BYTES
PRAGMA mmap_size value 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 purge when --retention-days is omitted.
QUERY_PREFIX
Prefix prepended to queries before embedding as required by E5 models.
QUERY_TIMEOUT_MILLIS
Query timeout applied to statements in milliseconds.
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 k constant used by Reciprocal Rank Fusion in hybrid-search.
SCHEMA_USER_VERSION
Canonical value of PRAGMA user_version written after migrations.
SQLITE_BUSY_BASE_DELAY_MS
Base delay in milliseconds for the first SQLITE_BUSY retry.
SQLITE_GRAPHRAG_VERSION
Crate version string sourced from CARGO_PKG_VERSION at build time.
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 list output.
WAL_AUTOCHECKPOINT_PAGES
PRAGMA wal_autocheckpoint threshold in pages.
WEIGHT_FTS_DEFAULT
Default weight for the BM25 text contribution in the hybrid-search RRF formula.
WEIGHT_VEC_DEFAULT
Default weight for the vector contribution in the hybrid-search RRF formula.

Functions§

max_relationships_per_memory
Resolves the per-memory relationship cap, honouring the env-var override.
ner_batch_size
Batch size for BERT NER forward passes.