Repository navigation
Brain OS v0.2.0
[0.2.0] — 2026-04-11
First minor release after 0.1.0. Focus: security hardening, resilience,
streaming, and workspace cleanup. Workspace-locked version: all 16 crates
publish at 0.2.0 together.
Added
- Token streaming over WebSocket with cancellation-safe finalization —
live token-by-token chat output; upstream disconnects no longer drop
in-flight responses. - Resilience primitives (
brainos-backends::resilience) — circuit
breaker with half-open probes and exponential-backoff retry for all
external HTTP calls (search, messaging, LLM). 5xx / 408 / 429 /
timeout / connect errors are retried; other 4xx fail fast. - Metrics endpoint (
/metrics) exposes Prometheus counters and
subsystem gauges (fact/episode counts, intent LLM fallback count,
circuit open/reset counters). - Graceful shutdown —
brain servehandles SIGTERM and Ctrl+C,
runs a WAL checkpoint viaSignalProcessor::shutdown()before exit. - CLI chat UX — interactive chat now prints a green
Brain:prefix
before the first streamed token, matching the non-streaming path. brainos-backendscrate — action backends (search, scheduling,
messaging) and resilience primitives extracted frombrainosbinary
into a reusable library crate. Workspace now has 16 crates.
Changed
- SignalProcessor — unified adapter entry point (
AdapterRequest
struct replaces a 10-parameter positional API). - SQLite foreign keys enforced (
PRAGMA foreign_keys = ON) so
futureREFERENCESclauses in migrations are no longer decorative. - Migration version bumped to 17 — adds
notificationsoutbox
table and audit-log schema; idempotent upgrade from v16. - CORS hardened — exact-match origin check (
http://localhost:/
http://127.0.0.1:) replaces prefix check that could match
localhost.attacker.com. - Intent classification prompt injection hardened — user input is
now a separate role-based message, not interpolated into the system
prompt. Same change applied to importance scoring. - Novelty detection bounded — amygdala
seen_topicsreplaced with
a capacity-10 000 LRU cache (was an unbounded HashSet). - HTTP body + frame limits — all three HTTP-based adapters
(http,mcpHTTP,ws) cap request/frame size at 1 MiB and
concurrent in-flight requests at 100. - N+1 query fix in semantic search — batched
WHERE id IN (?…)
lookups replace per-result round trips.
Fixed
- Bridge CLI handshake —
brain bridgenow performs a two-frame
auth-then-signal handshake. Previously merged fields into the auth
frame were silently dropped, causing every bridge invocation to
submit zero content. - Atomic FTS writes — episode insert + FTS insert, episode delete
- FTS delete, and semantic fact insert + RuVector write are now
wrapped in transactions with compensating rollback.
- FTS delete, and semantic fact insert + RuVector write are now
num_predicthonored — removed incorrect#[serde(rename_all = "camelCase")]onOllamaOptionsthat silently renamed the field
tonumPredictand caused every Ollama call to ignoremax_tokens.- Ollama streaming termination — streams now return on
done: trueinstead of waiting for the server to close the socket. - Ebbinghaus retention uses the actual stored importance for BM25
hits (was hardcoded to 0.5, flattening forgetting-curve reranking). - Notification prune age-checks delivered notifications instead of
deleting them immediately. - Consolidation prune-then-promote now
continues after pruning
so pruned episodes don't reappear as promotion candidates. - PID file permissions —
0o600on Unix; no more world-readable
PID files. execute_commandpath restriction — absolute-path arguments
are canonicalized (with parent-dir fallback for non-existent
targets) and must resolve under$HOMEor/tmp...components
rejected in any argument.- LIKE wildcard escape — fact search escapes
%and_in user
queries with an explicitESCAPE '\\'clause. - Fact deduplication race — dedup-check + insert now serialized
under a tokio async mutex. - HTTP gauge cache poison tolerance —
lock().unwrap_or_else(|e| e.into_inner())instead of panicking on mutex poison.
Security
- Constant-time API-key comparison retained (
subtle::ConstantTimeEq). - Default config ships no pre-shared API key —
brain initmints
a random per-installation key on first run. Legacydemokey123
references remain only in test fixtures. - Parameterized SQL everywhere — no string-interpolated queries.
- Supply chain — all external HTTP calls go through the
circuit-breaker / retry layer with timeout budgets.
Documentation
ARCHITECTURE.mdpoints action backends atcrates/backends/src/
(they moved during the refactor) and documents the 408/429 retry
additions to the resilience layer.README.mddocuments proactivity as on-by-default with guardrails
(max 2/day, 14-hour quiet window) instead of labeling it opt-in.
Deferred to 0.2.x
signal/src/lib.rssplit — the 1 786-line file should be
broken intopipeline.rs/recall.rs/streaming.rsfor
maintainability. Structural refactor, not a release blocker.- Thalamus regex
LazyLock— hardcoded patterns still use
unwrap_or_else(panic!). Style-only; patterns are test-verified. - Auth length-mismatch timing leak —
ct_eqis skipped when
key lengths differ. Negligible entropy loss; accepted as a known
limitation until keys are compared as fixed-length hashes.