🧠 Zero-Configuration AI Database with Triple Intelligence™ https://soulcraft.com
Find a file
David Snelling a3467e1f9b feat: temporal VFS — file content joins the Model-B immutability model
The temporal model had a hole exactly where files were concerned: every
entity write is an immutable generation with before-images, but VFS content
BYTES lived under an eager refCount GC left over from the pre-8.0 design —
unlink could physically destroy bytes that in-window history still
referenced, and overwrite never released the old hash at all (an unbounded
silent leak whose accidental byproduct was the only thing "preserving"
history). Reading the past could therefore return a stale field, a dangling
hash, or nothing, depending on luck.

Fix: blob reclamation becomes a HISTORY decision instead of a LIVENESS
decision. Each blob's metadata now carries historyRefCount alongside the
live refCount:

- The commit seam counts one history reference per persisted before-image
  record carrying a content hash (commitTransaction staging and the
  group-commit flush), recorded BEFORE the record-set persists and carried
  in the generation delta (blobHashes — always present on new deltas, so
  compaction only falls back to reading records for pre-contract
  generations). An aborted transaction compensates best-effort.
- unlink/rmdir/overwrite drop ONLY the live reference (BlobStorage.delete →
  release; overwrite finally releases the superseded hash — cancelling the
  dedup increment on same-content rewrites and closing the leak), and only
  AFTER the canonical mutation commits, so a failed delete can never leave a
  live file whose bytes compaction might reclaim.
- History compaction is the ONE reclamation point: after deleting a
  generation's record-set it releases that set's references and physically
  reclaims any hash at zero live AND zero history references. Pins are
  exempt automatically. Crash ordering is over-count-only in every path
  (record before persist, release after delete), so a crash can leak until
  the scrub recounts but can never reclaim bytes a retained generation
  needs. scrubBlobHistoryRefCounts() restores exactness; existing stores get
  a one-time marker-gated backfill on open, failing into leak-safe mode
  (reclamation disabled) rather than guessing.

On top of the protected history, the temporal API the generational model
always implied:

- vfs.readFile(path, { asOf }) — the exact bytes as of a generation or Date,
  materialized from the history (pinned view released so compaction is
  never blocked by a read).
- vfs.history(path) — FileVersion[] ascending ({ generation, timestamp,
  hash, size, mimeType? }), the newest entry being the live state.
- Overwrites now refresh the file entity's data/embedding text — semantic
  search and the data field previously served the FIRST version's text
  forever (the stale-field defect a consumer's incident recovery depended
  on by luck).

Integration suite (temporal-vfs.test.ts): per-version exact reads +
history listing, leak-fix + history protection on overwrite, rm keeps bytes
readable, compaction reclaims past-window bytes and preserves in-window
(including the cross-file dedup case where an old file's history and a
newer file's removal share one hash), data freshness, and scrub exactness.
2026-07-10 16:43:48 -07:00
.claude/skills docs(8.0): consistency-model concept + snapshots guide — Db API replaces branching docs 2026-06-11 08:37:26 -07:00
.github/workflows fix(ci): commit the prebuilt wasm pkg + build before test:bun (green CI on fresh clone) 2026-07-01 14:40:11 -07:00
assets/models/all-MiniLM-L6-v2 feat: migrate embeddings to Candle WASM + remove semantic type inference 2026-01-06 12:52:34 -08:00
bin feat: remove legacy ImportManager, standardize getStats() API 2025-10-09 11:40:31 -07:00
docs feat: temporal VFS — file content joins the Model-B immutability model 2026-07-10 16:43:48 -07:00
examples refactor(8.0): remove dead, unreachable, and unwired modules 2026-06-24 15:18:40 -07:00
integrations feat: Integration Hub for external tool connectivity 2026-01-20 16:21:11 -08:00
scripts feat(8.0): id-normalization (#18) + aggregation min/max delete-safety + RC-safe release 2026-06-20 14:46:40 -07:00
src feat: temporal VFS — file content joins the Model-B immutability model 2026-07-10 16:43:48 -07:00
tests feat: temporal VFS — file content joins the Model-B immutability model 2026-07-10 16:43:48 -07:00
.aiignore feat: add distributed scaling and enterprise features for v3 2025-09-08 14:26:09 -07:00
.dockerignore feat: Brainy 3.0 - Production-ready Triple Intelligence database 2025-09-11 16:23:32 -07:00
.gitignore fix(ci): commit the prebuilt wasm pkg + build before test:bun (green CI on fresh clone) 2026-07-01 14:40:11 -07:00
.npmignore chore: Add .npmignore to exclude models from npm package 2025-08-26 13:37:44 -07:00
.nvmrc feat: update Node.js requirements to 22 LTS for ONNX compatibility 2025-08-28 16:05:14 -07:00
brainy.png 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
bun.lock feat: migrate embeddings to Candle WASM + remove semantic type inference 2026-01-06 12:52:34 -08:00
CHANGELOG.md chore(release): 8.1.0 2026-07-10 11:27:20 -07:00
CLAUDE.md docs(8.0): RELEASES.md 8.0.0 release-candidate entry — full breaking-change inventory + upgrade guide 2026-06-11 09:31:07 -07:00
CONTRIBUTING.md feat: migrate embeddings to Candle WASM + remove semantic type inference 2026-01-06 12:52:34 -08:00
docker-compose.yml feat: Brainy 3.0 - Production-ready Triple Intelligence database 2025-09-11 16:23:32 -07:00
Dockerfile feat: Brainy 3.0 - Production-ready Triple Intelligence database 2025-09-11 16:23:32 -07:00
eslint.config.js chore: enforce consistent coding style and semicolon removal 2025-09-29 09:50:59 -07:00
LICENSE 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
package-lock.json chore(release): 8.1.0 2026-07-10 11:27:20 -07:00
package.json chore(release): 8.1.0 2026-07-10 11:27:20 -07:00
README.md feat: guarded plugin auto-detection — installing @soulcraft/cor is the opt-in 2026-07-02 16:19:55 -07:00
RELEASES.md docs: RELEASES.md entry for 8.1.0 (brain.onChange change feed) 2026-07-10 11:24:32 -07:00
tsconfig.cli.json feat: complete CLI with VFS, data management, and Triple Intelligence search 2025-09-29 16:57:14 -07:00
tsconfig.json chore(8.0): ES2023 target + drop DOM lib + downlevelIteration (config truth-up) 2026-07-01 10:58:04 -07:00
vitest.config.memory.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
vitest.config.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00

Brainy

Brainy

Three database paradigms. One API. Zero configuration.
The in-process knowledge database for TypeScript — vector search, graph traversal,
and metadata filtering unified in a single query.

npm version npm downloads CI Documentation MIT License TypeScript

Quick start · One query · Features · Scale with Cor · Docs


Built because we were tired of stitching a vector store to a graph database to a document store — and spending weeks on plumbing before writing a line of business logic. Brainy indexes every fact three ways at once and lets one call query them together:

You write Brainy indexes it as You query it with
data: 'Ada wrote the first program' a 384-dim vector (local embedding — no API key) find({ query: 'computing pioneers' })
metadata: { field: 'CS', year: 1843 } structured fields (O(1) exact, O(log n) range) find({ where: { year: { lessThan: 1900 } } })
relate({ from: ada, to: babbage }) a typed, directed graph edge find({ connected: { to: babbage, depth: 2 } })

It runs inside your process — no server, no Docker, nothing to operate — and persists to plain files you can snapshot with a hard link.

New here?What is Brainy? — plain-language overview, no jargon

Quick start

bun add @soulcraft/brainy        # Bun ≥ 1.1 — recommended
npm install @soulcraft/brainy    # Node.js ≥ 22
import { Brainy, NounType, VerbType } from '@soulcraft/brainy'

const brain = new Brainy()                       // in-memory; one line swaps to disk
await brain.init()

// Text auto-embeds locally; metadata auto-indexes
const react = await brain.add({
  data: 'React is a JavaScript library for building user interfaces',
  type: NounType.Concept,
  subtype: 'library',
  metadata: { category: 'frontend', year: 2013 }
})

const next = await brain.add({
  data: 'Next.js is a React framework with server-side rendering',
  type: NounType.Concept,
  subtype: 'framework',
  metadata: { category: 'frontend', year: 2016 }
})

await brain.relate({ from: next, to: react, type: VerbType.DependsOn, subtype: 'runtime' })

One query, three engines

const results = await brain.find({
  query: 'modern frontend frameworks',           // vector — what it means
  where: { year: { greaterThan: 2015 } },        // metadata — what it is
  connected: { to: react, depth: 2 }             // graph — what it touches
})

Every clause is optional; any combination composes. Under the hood Brainy plans the query across an HNSW vector index, a roaring-bitmap field index, and an adjacency graph index — and re-validates every result against your predicate before returning it, so a corrupt index can never hand you a wrong answer.

Feature tour

The database is a value

Pin it, rewind it, fork it. Snapshot isolation without a server.

const db = brain.now()                           // pin current state — O(1)

await brain.transact([                           // atomic all-or-nothing, CAS-guarded
  { op: 'update', id: order, metadata: { status: 'paid' } },
  { op: 'relate', from: invoice, to: order, type: VerbType.References, subtype: 'billing' }
], { ifAtGeneration: db.generation })

await db.get(order)                              // still 'pending' — pinned forever
await brain.get(order)                           // 'paid' — live

const lastWeek = await brain.asOf(Date.now() - 7 * 86_400_000)   // full query surface, past state
const whatIf = await db.with([{ op: 'remove', id: order }])      // speculative — never touches disk
await brain.now().persist('/backups/today')                      // instant hard-link snapshot

Consistency model · Snapshots & time travel

Local embeddings — no API keys

Strings embed on-device with a bundled MiniLM model (WASM). Semantic search works offline, in CI, and on air-gapped machines, at zero cost per call. Hybrid keyword + semantic ranking is the default:

await brain.find({ query: 'David Smith' })                            // auto: text + semantic
await brain.find({ query: 'AI concepts', searchMode: 'semantic' })    // semantic only

A typed graph, not a bag of edges

42 entity types × 127 relationship types form a shared vocabulary for any domain — healthcare (Patient → diagnoses → Condition), finance (Account → transfers → Transaction), yours. Your own taxonomy layers on with subtype, enforced at write time:

await brain.add({ data: 'Avery Brooks', type: NounType.Person, subtype: 'employee' })

brain.counts.bySubtype(NounType.Person)          // O(1) — { employee: 12, customer: 847 }
brain.requireSubtype(NounType.Person, { values: ['employee', 'customer'], required: true })

Type system · Subtypes & facets

Graph analytics built in

await brain.graph.rank()                          // which entities matter most (centrality)
await brain.graph.communities()                   // natural clusters
await brain.graph.path(a, b)                      // how two things connect
await brain.graph.subgraph([seed], { depth: 2 })  // bounded neighborhood → { nodes, edges }
await brain.graph.export()                        // whole graph, one O(N+E) streaming pass

Write-time aggregations

SUM / COUNT / AVG / MIN / MAX with GROUP BY and time windows, maintained incrementally on every write — reads are O(1) lookups, not scans. Aggregation guide

Import anything

await brain.import('customers.csv')
await brain.import('sales.xlsx')                              // every sheet
await brain.import('research-paper.pdf')                      // tables extracted
await brain.import('https://api.example.com/data.json')

Entities auto-classify on the way in; brain.extractEntities(text) exposes the same NER ensemble directly. Import guide

A filesystem that understands content

await brain.vfs.writeFile('/docs/readme.md', 'Project documentation')
await brain.vfs.search('React components with hooks')          // semantic file search

VFS quick start

Operations-grade by default

  • Single-writer, many-reader — an exclusive lock protects the data directory; Brainy.openReadOnly() and the brainy inspect CLI examine a live brain from another process, safely.
  • Self-upgrading data files — a 7.x brain opens under 8.x and migrates itself behind an observable lock (getIndexStatus().migration), with an automatic pre-upgrade backup. No migration scripts.
  • No silent wrong answers — cold-open guards self-heal or throw typed errors (MetadataIndexNotReadyError, GraphIndexNotReadyError); they never return [] for data that exists.

Multi-process model · Inspection guide

From laptop to hundreds of millions

Brainy's TypeScript engines take you a long way. When you outgrow them, add the native engine — the API doesn't change:

npm install @soulcraft/cor
const brain = new Brainy({ storage: { type: 'filesystem', path: './data' } })
await brain.init()   // @soulcraft/cor detected — same code, native engines underneath

Installing the package is the opt-in: if @soulcraft/cor is present, it loads and announces itself in the init log; if it's present but broken, init() throws — an installed accelerator never silently vanishes behind the JS engines. Opt out with plugins: [], or pin exactly what loads with plugins: ['@soulcraft/cor']. @soulcraft/cor (Brainy 8.x ↔ Cor 3.x, version-matched) registers Rust implementations behind every provider seam: SIMD distance kernels, memory-mapped storage, a disk-native vector index that doesn't need your dataset in RAM, durable LSM field/graph indexes that serve cold opens instantly, and native aggregation. Recall@10 measured 0.99 / 0.96 / 0.96 at 1M / 10M / 100M vectors in Cor's release gate.

Open core, commercial accelerator: Brainy is MIT and complete on its own; Cor is licensed and funds both.

Performance

Use cases

AI agent memory — persistent semantic recall with relationship tracking · Knowledge bases — auto-linking and meaning-aware navigation · Semantic search over codebases, documents, media · Enterprise data — CRM, catalogs, institutional memory · Games & simulations — worlds and characters that remember.

Documentation

Start Core Going deeper
Brainy explained simply API reference Architecture overview
Installation Data model Consistency model
Natural-language queries Query operators Multi-process model
Find system Scaling

Requirements

Bun ≥ 1.1 (recommended) or Node.js ≥ 22. Brainy 8.x is server-only; the 7.x line remains on npm for browser use.

Contributing & license

Contributions welcome — see CONTRIBUTING.md. MIT © Brainy Contributors.