Skip to main content

Crate second_brain_api

Crate second_brain_api 

Source

Modules§

alert
Posts each health state change to [alert] webhook_url, retrying a failed post until it lands or a newer state replaces it.
associate
auth
backfill
eval
file_modes
footprint
health
The daemon’s own view of whether it is capturing and indexing. The watcher, the outbox drain and the repair loop report what they see; each report re-assesses the state, so GET /health only clones the result.
heap
Allocator residency accounting for /v1/status.
ingest
logging
maintenance
The drain thread: applies the index outbox every few seconds and, when the outbox is quiet and the interval has passed, repairs the store with the writable indexes it owns. On-demand repairs arrive over a channel so the same thread services them; two writers never exist.
mentions
models
Startup of the search indexes and the embedding and rerank models, and the timers that unload idle models.
near_duplicates
note_cover
progress
raw_index
repairs
One-off data repairs, each idempotent: a second run finds nothing left to change, so running one again after a partial failure is always safe.
routes
self_update
sources
startup
Answers from the moment the port is bound, so a supervisor sees a starting daemon instead of one that accepts connections and never replies.
store_compaction
The one-time compaction after the stored-content redaction pass. The pass rewrites rows, but SQLite keeps their old bytes in free and split pages and tantivy keeps deleted terms until a segment merges away; a VACUUM and a forced merge are what take that plaintext off the disk.
stored_redaction
sync_loop
value_metrics
Whether second-brain is worth running: how often sessions recall, how often recall finds something, what agents do with what it found, and what the store costs in disk, memory and sync lag. Kept in memory over a rolling window, so a restart starts every window empty and each check waits for enough events before it judges.
vaults
watcher
write_gate
Keeps agent writes off the SQLite writer while store maintenance holds it. A write that arrives then is saved to the write queue and answered 202; once maintenance ends, writes keep queueing behind the saved ones until the replayer has sent them all, so none lands out of order.
write_queue
Replays the writes the MCP server queued under queue/ while this daemon was unreachable. Each entry is the request the MCP server would have sent; it goes through this daemon’s own router, so auth, redaction and every handler apply exactly as for a live call.

Structs§

AppState

Functions§

app
daemon_tunables
The retrieval settings the daemon serves recall with: base from config, with abstention and source order on.
link_query_entities
Extract the entity names a query refers to, using the same gazetteer extraction the ingest path applies to transcripts. Matching extractors on both sides is what lets query entities resolve to stored entity ids, so the graph term in recall is conditioned on the query rather than raw connectedness. Shared by the live recall route and the eval harness so both measure the same ranking.