Skip to main content

Module brain

Module brain 

Source
Expand description

Brain (oxibrain) memory backend.

BrainMemoryBackend is the only durable-memory authority under the Oxi Foundation v1 host. The legacy local memory backends (memory_sqlite, memory_summary, memory_mnemopi, memory_workers, mnemopi) stay compilable during the migration window but are no longer durable: they are read-only mirrors, never write targets.

§Wire protocol

oxibrain exposes its memory.* tool surface over a Unix-domain socket via the JSON-RPC client in oxibrain-client. The backend translates every MemoryBackend method into one oxibrain tool call:

MemoryBackend methodoxibrain toolargs shape
putmemory.put{"content": ..., "kind": ..., "subject": ...}
searchmemory.search{"query": ..., "k": N}
listmemory.list{"subject": ...}
deletememory.delete{"id": ...}

§Degraded mode

When the daemon is unreachable, every mutation returns ToolError(String) carrying "backend unavailable: oxibrain daemon unreachable". The local file store is never consulted as a fallback, because doing so would silently duplicate memory across two authorities and break the Foundation contract. Tools surface degraded to the user instead of pretending the store succeeded.

§Unix-only

oxibrain-client uses Unix-domain sockets. On non-Unix targets this module compiles to a stub that returns BackendUnavailable for every call. The same memory_info constant is used in both targets so the TUI’s health banner reads “degraded” identically.

Structs§

BrainMemoryBackend
Brain memory backend. The Arc<Mutex<Option<…>>> wrapper yields interior mutability on the optional client while keeping the MemoryBackend trait object signature (Arc<…>, no &mut).

Enums§

BrainHealth
Health of the Brain connection. Surfaced via memory_info so the TUI health banner reports the state without leaking the underlying transport.
MigrationError
Migration-specific error type. Distinguishes the cases the migration core cares about: backend offline, write failure, runtime failure.

Constants§

DEFAULT_BRAIN_SCOPE
Default scope identifier passed to oxibrain when one is not provided. oxicode uses the project working directory when known; the fallback is the literal "default" so the daemon can route to a project bucket.

Functions§

default_socket_path
Resolves the default socket path for the oxibrain daemon. Honors OXIBRAIN_SOCKET if set; otherwise $XDG_RUNTIME_DIR/oxibrain.sock (Linux) or ~/.oxi/run/oxibrain.sock (macOS).