Configuration
Both processes' settings — brain-db's TOML with environment overrides, brain-edge's pure-environment config, and the choices pinned at creation.
Two processes, two config styles
brain-db uses two underscores to descend a TOML level
(BRAIN__LLM__BROKER__URL). brain-edge's names are flat and use one
(BRAIN_EDGE_POOL_SIZE). Mixing them is the most common configuration
mistake here, and it fails quietly: an unrecognised variable is simply
ignored, so the setting you believe you changed keeps its default.
brain-db
The override mechanism
Any key is overridable: uppercase it, join levels with __, prefix BRAIN.
[server]
listen_addr = "0.0.0.0:8080"BRAIN__SERVER__LISTEN_ADDR=0.0.0.0:9090That is the mechanism you want in containers — keep the baked file and override the handful of things that differ per environment.
Required
BRAIN__LLM__BROKER__URL=http://edge:8080 # where credentials resolve from
BRAIN__LLM__BROKER__SERVICE_KEY=… # Brain's identity TO the broker
BRAIN__ADMIN__TOKEN=… # gates the admin planeThe server refuses to start without BRAIN__LLM__BROKER__URL and
BRAIN__ADMIN__TOKEN. The service key is not part of that gate — validation
only checks that the broker URL is present and non-empty — but without it every
resolve call is unauthenticated, so the LLM tier is degraded for every
namespace. Set all three.
The same fields in TOML, with the one tunable:
[llm.broker]
url = "http://edge:8080"
service_key = "…"
ttl_secs = 300 # resolved-credential cache lifetimeBRAIN__LLM__BROKER__SERVICE_KEY authenticates Brain to the broker, so
the broker will swap a grant for the tenant's real key on the way upstream.
Provider keys are registered per namespace through the broker — see
Credentials. Setting [llm] api_key
satisfies neither the boot gate nor any namespace.
`[llm] api_key` is optional, and setting it adds a boot probe
It is the shard-wide fallback, not the serving credential — see what it refuses to start without. When it is set, the server makes one 1-token completion at boot and exits if the provider rejects it; when it is unset, that probe never runs. Prefer leaving it unset to leaving an expired key in the environment.
What a broker has to serve
In production the broker is the Arc gateway. Self-hosting, it is brain-edge:
the same binary that serves /v1/* also serves the broker, which is why
BRAIN__LLM__BROKER__URL points at the edge (see
splitting the planes for running it as its
own process). Anything else standing in has to answer two routes, authenticated
with the service key as a bearer:
| Route | Returns |
|---|---|
GET /llm/ns/{namespace}/resolve | 200 with { "provider": …, "model": … } — no key material. 409 means that namespace has registered no key |
POST /llm/ns/{namespace}/{provider}/v1/… | The provider's own completions response, proxied upstream with the real key — /v1/chat/completions for openai, /v1/messages for anthropic |
Resolve carries no key because completions go through the broker: Brain
builds a provider client whose base URL is {broker}/llm/ns/{namespace}/{provider}
and whose bearer is the service key, so the provider credential is applied at
the broker and never arrives here. A resolve result is cached for ttl_secs,
which is what bounds how long a revoked key keeps working.
Listeners
[server]
listen_addr = "0.0.0.0:8080" # wire protocol
metrics_addr = "0.0.0.0:9091" # health + metrics — public, no auth
admin_addr = "127.0.0.1:9092" # admin plane — keep it loopbackAll three default to loopback in the source config (config/dev.toml, with the
wire protocol on 9090); the image binds the wire and metrics listeners to
0.0.0.0 so peers on a container network can reach them, and leaves the admin
listener on loopback. Leave admin_addr on loopback unless you have put a
token-checking proxy in front of it — see Security.
Storage
[storage]
data_dir = "/var/lib/brain/data"
shard_count = 1
[shard]
arena_capacity_bytes = "1GiB"
wal_segment_size_bytes = "64MiB"
wal_retention_segments = 16 # ≈1 GiB of WAL retained per sharddata_dir must be a persistent volume. shard_count is a decision you make
once — see Scaling.
The arena is a fixed-size mapped file. Running out of slots is a hard wall, not
a gradual slowdown, which is why
brain_arena_slots_free is the metric to
alert on earliest.
Index and embedding
[hnsw]
m = 16
ef_construction = 200
ef_search = 64
[embedder]
model = "bge-small-en-v1.5"
cache_size = 10000
batch_size = 32
batch_window_ms = 5ef_search is the one worth tuning at runtime: higher buys recall and costs
read work, roughly in proportion. The rest are sensible defaults you should have
a measurement before changing.
There is no in-place migration. Changing [embedder] model means standing up
a fresh deployment and re-ingesting everything, because the vectors already
on disk were produced by a different model and cosine distance between two
models' vectors is meaningless. Decide before you load data, not after.
Optional capabilities
[rerank]
enabled = false # ships disabled
[summarizer]
backend = "disabled" # consolidation summaries, off
[extractors.classifier]
model_path = "/opt/brain/models/gliner-small-v2.1"The reranker is off because it only reorders already-retrieved candidates and cannot surface what retrieval and grounding missed — solve recall upstream, and flip it on only to A/B the cross-encoder's ordering. Enabling it without the model on disk is a boot failure, deliberately: a silently-degraded reranker would make two shards with identical config return different orderings. See Policies.
Background workers
[workers]
decay_interval_sec = 3600
consolidation_interval_sec = 600
hnsw_maintenance_interval_sec = 1800
idempotency_cleanup_interval_sec = 3600
slot_reclamation_interval_sec = 3600
wal_retention_interval_sec = 600
edge_scrub_interval_sec = 86400
counter_reconciliation_interval_sec = 86400
statistics_update_interval_sec = 60
snapshot_interval_sec = 21600 # 6 hoursThese are maintenance cadences, not feature flags.
Several workers have their own blocks — [workers.auto_edge],
[workers.temporal_edge], [workers.causal_edge] and [workers.extractor] —
each with an enabled flag, a cycle interval, a batch size and a channel
capacity. Two worth knowing:
[workers.extractor]
llm_budget_per_cycle_micro_usd = 50000 # the spend ceiling per cycle
skip_already_extracted = true
[workers.temporal_edge]
window_seconds = 300
cross_session = false # temporal edges stay inside a sessionsnapshot_interval_sec is not your backup schedule
The periodic snapshot worker captures the HNSW graph so a restart does not have to rebuild it. It is not a full backup. Read Backups before you treat this number as your RPO.
Logging and tracing
[monitoring.logging]
level = "info"
output = "stdout"
format = "json" # Loki / Elastic / CloudWatch ingest cleanly
[monitoring.tracing]
enabled = false
sampler = "ratio"
sample_ratio = 0.01
endpoint = ""
service_name = "brain-server"Keep format = "json" anywhere you ship logs. Tracing is off by default; point
endpoint at your OTLP collector to turn it on.
brain-edge
Environment only — there is no file.
BRAIN_ADDRhost:portoptionalThe database's wire address — ip:port or a DNS host:port, resolved
once at startup. Defaults to 127.0.0.1:7878, which is almost never right
in a container. Set it. Note the name: it is not prefixed like the
others, and BRAIN_EDGE_BRAIN_ADDR is simply ignored — the default stands
and every data request fails.
BRAIN_EDGE_LISTENip:portoptionalHTTP listen address. Defaults to 0.0.0.0:8080.
BRAIN_EDGE_PLANEboth | data | credentialoptionalWhich plane this process serves. Defaults to both. See
Security.
BRAIN_EDGE_POOL_SIZEintegeroptionalPooled wire connections per credential. Defaults to 4.
BRAIN_EDGE_MAX_CREDENTIALSintegeroptionalCap on cached credentials. Defaults to 256. Each one holds a pool, so
this times the pool size bounds total sockets.
BRAIN_EDGE_IDLE_TTL_SECSintegeroptionalIdle-sweep TTL for cached credentials and their pools. Defaults to 900.
BRAIN_EDGE_REQUEST_TIMEOUT_SECSintegeroptionalPer-request timeout. Defaults to 30. Exceeding it is a 408, produced by
middleware before a handler runs.
BRAIN_EDGE_MAX_BODY_BYTESintegeroptionalRequest body cap. Defaults to 1048576 (1 MiB). Enforced twice — once on
Content-Length, once on the streamed body — so a chunked request is
refused too.
BRAIN_EDGE_WIRE_LISTENip:portoptionalOpt-in wire proxy: lets wire-protocol clients reach the database through the edge. Unset means off, which is the default.
BRAIN_EDGE_WIRE_RATE_CAPACITYintegeroptionalPer-credential burst for the wire proxy. Defaults to 0 — off.
BRAIN_EDGE_WIRE_RATE_REFILL_PER_SECintegeroptionalPer-credential refill rate for the wire proxy. Defaults to 0.
An unparseable address, a malformed number, or a zero where a positive value is required is a startup error, not a fallback to the default.
Reloading
There is an admin config surface for inspecting and reloading configuration at
runtime — GET /v1/config, POST /v1/config and POST /v1/config/reload on
the same loopback listener as the rest of the admin plane.
Listener addresses, data_dir, shard_count and the embedding model are not
things to expect a reload to change. Treat those as restart-or-rebuild.
Was this page helpful?