BrainLayer uses a single-writer arbitration path for background producers that can otherwise fight over SQLite's write lock.
BRAINLAYER_ARBITRATED=1makes producers enqueue writes instead of writing directly to the database. The current launchd templates set this for watch and enrichment.BRAINLAYER_DRAIN_EMBED=0disables post-drain embedding, mainly for tests or emergency operator debugging. Production should leave it enabled so queuedbrain_storechunks reach semantic search.- The unified durable queue lives at
~/.brainlayer/queue/. Each event is one JSONL file named by source, timestamp, and UUID. com.brainlayer.drain.plistrunsscripts/drain_daemon.py, which drains the queue every 500ms underBEGIN IMMEDIATE.- The drain daemon opens SQLite with APSW, loads
sqlite-vec, writes chunks/enrichment updates, and embeds queuedbrain_storechunks intochunk_vectors/chunk_vectors_binarybefore removing their queue files. - Legacy
pending-stores.jsonlis migrated bybrainlayer flush; migration assigns stable chunk IDs so rerunning after a crash isINSERT OR IGNOREsafe.
- Startup no longer performs large synchronous trigram repairs.
- Run
brainlayer repair-ftsfor an explicitchunks_fts_trigramrebuild. scripts/launchd/com.brainlayer.repair-fts.plistschedules that repair weekly.- Set
BRAINLAYER_REPAIR=1only for an operator-controlled process that should run the repair during VectorStore initialization.