@soulcraft/brainy 5.6.1 β†’ 5.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [5.6.3](https://github.com/soulcraftlabs/brainy/compare/v5.6.2...v5.6.3) (2025-11-11)
6
+
7
+ - docs: add entity versioning to fork section (3e81fd8)
8
+ - docs: add asOf() time-travel to fork section (5706b71)
9
+
10
+
11
+ ### [5.6.2](https://github.com/soulcraftlabs/brainy/compare/v5.6.1...v5.6.2) (2025-11-11)
12
+
13
+ - fix: update tests for Stage 3 CANONICAL taxonomy (42 nouns, 127 verbs) (c5dcdf6)
14
+ - docs: restructure README for better new user flow (2d3f59e)
15
+
16
+
5
17
  ## [5.6.1](https://github.com/soulcraftlabs/brainy/compare/v5.6.0...v5.6.1) (2025-11-11)
6
18
 
7
19
  ### πŸ› Bug Fixes
package/README.md CHANGED
@@ -32,6 +32,25 @@ await brain.init()
32
32
 
33
33
  ---
34
34
 
35
+ ## πŸ‘‰ Choose Your Path
36
+
37
+ **New to Brainy? Pick your starting point:**
38
+
39
+ ### πŸš€ Path 1: I want to build something NOW
40
+ **β†’ [Complete API Reference](docs/api/README.md)** ⭐ **Most developers start here** ⭐
41
+ - Every method documented with examples
42
+ - Quick start in 60 seconds
43
+ - 1,870 lines of copy-paste ready code
44
+ - **This is your primary resource**
45
+
46
+ ### 🧠 Path 2: I want to understand the big picture first
47
+ **β†’ Keep reading below** for demos, architecture, and use cases
48
+
49
+ ### πŸ“Š Path 3: I'm evaluating database options
50
+ **β†’ Jump to [Why Revolutionary](#why-brainy-is-revolutionary)** or **[Benchmarks](#benchmarks)**
51
+
52
+ ---
53
+
35
54
  ## See It In Action
36
55
 
37
56
  **30 seconds to understand why Brainy is different:**
@@ -72,98 +91,96 @@ const results = await brain.find({
72
91
 
73
92
  ---
74
93
 
75
- ## From Prototype to Planet Scale
94
+ ## Quick Start
76
95
 
77
- **The same API. Zero rewrites. Any scale.**
96
+ ```bash
97
+ npm install @soulcraft/brainy
98
+ ```
78
99
 
79
- ### πŸ‘€ **Individual Developer** β†’ Weekend Prototype
100
+ ### Your First Knowledge Graph (60 seconds)
80
101
 
81
102
  ```javascript
82
- // Zero configuration - starts in memory
103
+ import { Brainy, NounType, VerbType } from '@soulcraft/brainy'
104
+
83
105
  const brain = new Brainy()
84
106
  await brain.init()
85
107
 
86
- // Build your prototype in minutes
87
- // Change nothing when ready to scale
88
- ```
108
+ // Add knowledge
109
+ const jsId = await brain.add({
110
+ data: "JavaScript is a programming language",
111
+ type: NounType.Concept,
112
+ metadata: { category: "language", year: 1995 }
113
+ })
89
114
 
90
- **Perfect for:** Hackathons, side projects, rapid prototyping, learning AI concepts
115
+ const nodeId = await brain.add({
116
+ data: "Node.js runtime environment",
117
+ type: NounType.Concept,
118
+ metadata: { category: "runtime", year: 2009 }
119
+ })
91
120
 
92
- ### πŸ‘₯ **Small Team** β†’ Production MVP (Thousands of Entities)
121
+ // Create relationships
122
+ await brain.relate({ from: nodeId, to: jsId, type: VerbType.Executes })
93
123
 
94
- ```javascript
95
- // Add persistence - one line
96
- const brain = new Brainy({
97
- storage: {
98
- type: 'filesystem',
99
- path: './brainy-data',
100
- compression: true // 60-80% space savings
101
- }
124
+ // Query with Triple Intelligence
125
+ const results = await brain.find({
126
+ query: "JavaScript", // πŸ” Vector
127
+ where: { category: "language" }, // πŸ“Š Document
128
+ connected: { from: nodeId, depth: 1 } // πŸ•ΈοΈ Graph
102
129
  })
103
130
  ```
104
131
 
105
- **Perfect for:** Startups, MVPs, internal tools, team knowledge bases
106
- **Scale:** Thousands to hundreds of thousands of entities
107
- **Performance:** <5ms queries, sub-second imports
132
+ **Done.** No configuration. No complexity. Production-ready from day one.
133
+
134
+ **β†’ Ready to dive deeper? [Complete API Documentation](docs/api/README.md)** has every method with examples.
108
135
 
109
- ### 🏒 **Growing Company** β†’ Multi-Million Entity Scale
136
+ ---
137
+
138
+ ## From Prototype to Planet Scale
139
+
140
+ **The same API. Zero rewrites. Any scale.**
141
+
142
+ ### πŸ‘€ Individual Developer β†’ Weekend Prototype
143
+ ```javascript
144
+ const brain = new Brainy() // Zero config, starts in memory
145
+ await brain.init()
146
+ ```
147
+ **Perfect for:** Hackathons, side projects, prototyping, learning
110
148
 
149
+ ### πŸ‘₯ Small Team β†’ Production MVP
111
150
  ```javascript
112
- // Scale to cloud - same API
113
151
  const brain = new Brainy({
114
- storage: {
115
- type: 's3',
116
- s3Storage: {
117
- bucketName: 'my-knowledge-base',
118
- region: 'us-east-1'
119
- }
120
- },
121
- hnsw: { typeAware: true } // 87% memory reduction
152
+ storage: { type: 'filesystem', path: './data', compression: true }
122
153
  })
123
154
  ```
155
+ **Scale:** Thousands to hundreds of thousands β€’ **Performance:** <5ms queries
124
156
 
125
- **Perfect for:** SaaS products, e-commerce, content platforms, enterprise apps
126
- **Scale:** Millions of entities
127
- **Performance:** <10ms queries, 12GB memory @ 10M entities
128
- **Features:** Auto-scaling, distributed storage, cost optimization (96% savings)
129
-
130
- ### 🌍 **Enterprise / Planet Scale** β†’ Billion+ Entities
131
-
157
+ ### 🏒 Growing Company β†’ Multi-Million Scale
132
158
  ```javascript
133
- // Billion-scale - STILL the same API
134
159
  const brain = new Brainy({
135
- storage: {
136
- type: 'gcs',
137
- gcsStorage: { bucketName: 'global-knowledge' }
138
- },
139
- hnsw: {
140
- typeAware: true,
141
- M: 32,
142
- efConstruction: 400
143
- }
160
+ storage: { type: 's3', s3Storage: { bucketName: 'my-kb', region: 'us-east-1' } },
161
+ hnsw: { typeAware: true } // 87% memory reduction
144
162
  })
163
+ ```
164
+ **Scale:** Millions of entities β€’ **Performance:** <10ms queries, 12GB @ 10M entities
145
165
 
146
- // Enable intelligent archival
147
- await brain.storage.enableAutoclass({
148
- terminalStorageClass: 'ARCHIVE'
166
+ ### 🌍 Enterprise β†’ Billion+ Scale
167
+ ```javascript
168
+ const brain = new Brainy({
169
+ storage: { type: 'gcs', gcsStorage: { bucketName: 'global-kb' } },
170
+ hnsw: { typeAware: true, M: 32, efConstruction: 400 }
149
171
  })
150
172
  ```
151
-
152
- **Perfect for:** Fortune 500, global platforms, research institutions, government
153
- **Scale:** Billions of entities (tested at 1B+)
154
- **Performance:** 18ms queries @ 1B scale, 50GB memory (87% reduction)
173
+ **Scale:** Billions (tested @ 1B+) β€’ **Performance:** 18ms queries, 50GB memory
155
174
  **Cost:** $138k/year β†’ $6k/year with intelligent tiering (96% savings)
156
- **Features:** Sharding, replication, monitoring, enterprise SLAs
157
175
 
158
- ### 🎯 **The Point**
176
+ **β†’ [Capacity Planning Guide](docs/operations/capacity-planning.md)** | **[Cost Optimization](docs/operations/)**
159
177
 
160
- **Start simple. Scale infinitely. Never rewrite.**
178
+ ### 🎯 The Point
161
179
 
162
- Most systems force you to choose:
163
- - Simple but doesn't scale (SQLite, Redis)
164
- - Scales but complex (Kubernetes + 7 databases)
180
+ **Start simple. Scale infinitely. Never rewrite.**
165
181
 
166
- **Brainy gives you both:** Starts simple as SQLite. Scales like Google.
182
+ Most systems make you choose: Simple (SQLite) OR Scalable (Kubernetes + 7 databases).
183
+ **Brainy gives you both.** Starts simple as SQLite. Scales like Google.
167
184
 
168
185
  ---
169
186
 
@@ -219,9 +236,9 @@ Brainy automatically:
219
236
 
220
237
  **You write business logic. Brainy handles infrastructure.**
221
238
 
222
- ### πŸš€ **Instant Forkβ„’** β€” Git for Databases (v5.0.0)
239
+ ### πŸš€ **Git-Style Version Control** β€” Database & Entity Level (v5.0.0+)
223
240
 
224
- **Clone your entire database in <100ms. Merge back when ready. Full Git-style workflow.**
241
+ **Clone your entire database in <100ms. Track every entity change. Full Git-style workflow.**
225
242
 
226
243
  ```javascript
227
244
  // Fork instantly - Snowflake-style copy-on-write
@@ -240,19 +257,44 @@ const result = await brain.merge('test-migration', 'main', {
240
257
  })
241
258
 
242
259
  console.log(result) // { added: 1, modified: 0, conflicts: 0 }
260
+
261
+ // Time-travel: Query database at any past commit (read-only)
262
+ const commits = await brain.getHistory({ limit: 10 })
263
+ const snapshot = await brain.asOf(commits[5].id)
264
+ const pastResults = await snapshot.find({ query: 'historical data' })
265
+ await snapshot.close()
266
+
267
+ // Entity versioning: Track changes to individual entities (v5.3.0+)
268
+ const userId = await brain.add({ type: 'user', data: { name: 'Alice' } })
269
+ await brain.versions.save(userId, { tag: 'v1.0', description: 'Initial profile' })
270
+
271
+ await brain.update(userId, { data: { name: 'Alice Smith', role: 'admin' } })
272
+ await brain.versions.save(userId, { tag: 'v2.0', description: 'Added role' })
273
+
274
+ // Compare versions or restore previous state
275
+ const diff = await brain.versions.compare(userId, 1, 2) // See what changed
276
+ await brain.versions.restore(userId, 1) // Restore v1.0
243
277
  ```
244
278
 
245
- **NEW in v5.0.0:**
279
+ **Database-level version control (v5.0.0):**
246
280
  - βœ… `fork()` - Instant clone in <100ms
247
281
  - βœ… `merge()` - Merge with conflict resolution
248
282
  - βœ… `commit()` - Snapshot state
283
+ - βœ… `asOf()` - Time-travel queries (query at any commit)
249
284
  - βœ… `getHistory()` - View commit history
250
285
  - βœ… `checkout()`, `listBranches()` - Full branch management
251
286
  - βœ… CLI support for all features
252
287
 
288
+ **Entity-level version control (v5.3.0):**
289
+ - βœ… `versions.save()` - Save entity snapshots with tags
290
+ - βœ… `versions.restore()` - Restore previous versions
291
+ - βœ… `versions.compare()` - Diff between versions
292
+ - βœ… `versions.list()` - View version history
293
+ - βœ… Automatic deduplication (content-addressable storage)
294
+
253
295
  **How it works:** Snowflake-style COW shares HNSW index structures, copying only modified nodes (10-20% memory overhead).
254
296
 
255
- **Perfect for:** Safe migrations, A/B testing, feature branches, distributed development
297
+ **Perfect for:** Safe migrations, A/B testing, feature branches, distributed development, time-travel debugging, audit trails, document versioning, compliance tracking
256
298
 
257
299
  [β†’ See Full Documentation](docs/features/instant-fork.md)
258
300
 
@@ -296,48 +338,6 @@ Every asset knows its relationships. Intelligent tagging, similarity-based disco
296
338
 
297
339
  ---
298
340
 
299
- ## Quick Start
300
-
301
- ```bash
302
- npm install @soulcraft/brainy
303
- ```
304
-
305
- ### Your First Knowledge Graph (60 seconds)
306
-
307
- ```javascript
308
- import { Brainy, NounType, VerbType } from '@soulcraft/brainy'
309
-
310
- const brain = new Brainy()
311
- await brain.init()
312
-
313
- // Add knowledge
314
- const jsId = await brain.add({
315
- data: "JavaScript is a programming language",
316
- type: NounType.Concept,
317
- metadata: { category: "language", year: 1995 }
318
- })
319
-
320
- const nodeId = await brain.add({
321
- data: "Node.js runtime environment",
322
- type: NounType.Concept,
323
- metadata: { category: "runtime", year: 2009 }
324
- })
325
-
326
- // Create relationships
327
- await brain.relate({ from: nodeId, to: jsId, type: VerbType.Executes })
328
-
329
- // Query with Triple Intelligence
330
- const results = await brain.find({
331
- query: "JavaScript", // πŸ” Vector
332
- where: { category: "language" }, // πŸ“Š Document
333
- connected: { from: nodeId, depth: 1 } // πŸ•ΈοΈ Graph
334
- })
335
- ```
336
-
337
- **Done.** No configuration. No complexity. Production-ready from day one.
338
-
339
- ---
340
-
341
341
  ## Core Features
342
342
 
343
343
  ### 🧠 **Natural Language Queries**
@@ -355,6 +355,8 @@ await brain.find({
355
355
  })
356
356
  ```
357
357
 
358
+ **β†’ [See all query methods in API Reference](docs/api/README.md#search--query)**
359
+
358
360
  ### 🌐 **Virtual Filesystem** β€” Intelligent File Management
359
361
 
360
362
  Build file explorers and IDEs that never crash:
@@ -566,40 +568,60 @@ brainy search "programming"
566
568
 
567
569
  ---
568
570
 
569
- ## Documentation
571
+ ## πŸ“– Complete Documentation
570
572
 
571
- ### πŸš€ Getting Started
572
- - **[API Reference](docs/api/README.md)** β€” Complete API documentation for all features
573
- - **[v4.0.0 Migration Guide](docs/MIGRATION-V3-TO-V4.md)** β€” Upgrade from v3 (backward compatible)
573
+ **For most developers:** Start with the **[Complete API Reference](docs/api/README.md)** ⭐
574
574
 
575
- ### 🧠 Core Concepts
576
- - **[Triple Intelligence Architecture](docs/architecture/triple-intelligence.md)** β€” How vector + graph + document work together
577
- - **[Natural Language Queries](docs/guides/natural-language.md)** β€” Using find() effectively
578
- - **[API Reference](docs/api/README.md)** β€” Complete API documentation
579
- - **[Noun-Verb Taxonomy](docs/architecture/noun-verb-taxonomy.md)** β€” The universal type system
575
+ This comprehensive guide includes:
576
+ - βœ… Every method with parameters, returns, and examples
577
+ - βœ… Quick start in 60 seconds
578
+ - βœ… Core CRUD β†’ Advanced features (branching, versioning, time-travel)
579
+ - βœ… TypeScript types and patterns
580
+ - βœ… 1,870 lines of copy-paste ready code
581
+
582
+ ---
583
+
584
+ ### 🎯 Essential Reading (Start Here)
585
+
586
+ 1. **[πŸ“– Complete API Reference](docs/api/README.md)** ⭐ **START HERE** ⭐
587
+ - Your primary resource for building with Brainy
588
+ - Every method documented with working examples
580
589
 
581
- ### πŸ—οΈ Architecture & Scaling
590
+ 2. **[Natural Language Queries](docs/guides/natural-language.md)**
591
+ - Master the `find()` method and Triple Intelligence queries
592
+
593
+ 3. **[v4.0.0 Migration Guide](docs/MIGRATION-V3-TO-V4.md)**
594
+ - Upgrading from v3 (100% backward compatible)
595
+
596
+ ### 🧠 Core Concepts & Architecture
597
+
598
+ - **[Triple Intelligence Architecture](docs/architecture/triple-intelligence.md)** β€” How vector + graph + document work together
599
+ - **[Noun-Verb Taxonomy](docs/architecture/noun-verb-taxonomy.md)** β€” The universal type system (42 nouns Γ— 127 verbs)
582
600
  - **[Architecture Overview](docs/architecture/overview.md)** β€” System design and components
583
601
  - **[Data Storage Architecture](docs/architecture/data-storage-architecture.md)** β€” Type-aware indexing and HNSW
584
- - **[Capacity Planning](docs/operations/capacity-planning.md)** β€” Memory, storage, and scaling guidelines
585
602
 
586
603
  ### ☁️ Production & Operations
604
+
587
605
  - **[Cloud Deployment Guide](docs/deployment/CLOUD_DEPLOYMENT_GUIDE.md)** β€” Deploy to AWS, GCS, Azure
588
- - **[AWS Cost Optimization](docs/operations/cost-optimization-aws-s3.md)** | **[GCS](docs/operations/cost-optimization-gcs.md)** | **[Azure](docs/operations/cost-optimization-azure.md)** | **[Cloudflare R2](docs/operations/cost-optimization-cloudflare-r2.md)**
606
+ - **[Capacity Planning](docs/operations/capacity-planning.md)** β€” Memory, storage, and scaling to billions
607
+ - **Cost Optimization:** **[AWS S3](docs/operations/cost-optimization-aws-s3.md)** | **[GCS](docs/operations/cost-optimization-gcs.md)** | **[Azure](docs/operations/cost-optimization-azure.md)** | **[Cloudflare R2](docs/operations/cost-optimization-cloudflare-r2.md)**
589
608
 
590
609
  ### 🌐 Framework Integration
610
+
591
611
  - **[Framework Integration Guide](docs/guides/framework-integration.md)** β€” React, Vue, Angular, Svelte
592
612
  - **[Next.js Integration](docs/guides/nextjs-integration.md)**
593
613
  - **[Vue.js Integration](docs/guides/vue-integration.md)**
594
614
 
595
- ### 🌳 Virtual Filesystem
615
+ ### 🌳 Virtual Filesystem (VFS)
616
+
596
617
  - **[VFS Quick Start](docs/vfs/QUICK_START.md)** β€” Build file explorers that never crash
597
618
  - **[VFS Core Documentation](docs/vfs/VFS_CORE.md)**
598
- - **[Semantic VFS Guide](docs/vfs/SEMANTIC_VFS.md)**
619
+ - **[Semantic VFS Guide](docs/vfs/SEMANTIC_VFS.md)** β€” AI-powered file navigation
599
620
  - **[Neural Extraction API](docs/vfs/NEURAL_EXTRACTION.md)**
600
621
 
601
- ### πŸ“¦ Data Import
602
- - **[Import Anything Guide](docs/guides/import-anything.md)** β€” CSV, Excel, PDF, URLs
622
+ ### πŸ“¦ Data Import & Processing
623
+
624
+ - **[Import Anything Guide](docs/guides/import-anything.md)** β€” CSV, Excel, PDF, URLs with auto-detection
603
625
 
604
626
  ---
605
627
 
@@ -31,6 +31,14 @@ const NOUN_TYPE_DESCRIPTIONS = {
31
31
  [NounType.Organism]: 'organism animal plant bacteria fungi species living biological life creature being microorganism',
32
32
  // Material Types (1) - Stage 3
33
33
  [NounType.Substance]: 'substance material matter chemical element compound liquid gas solid molecule atom material',
34
+ // Property & Quality Types (1) - Stage 3
35
+ [NounType.Quality]: 'quality property attribute characteristic feature aspect trait dimension parameter value',
36
+ // Temporal Types (1) - Stage 3
37
+ [NounType.TimeInterval]: 'timeInterval period duration span range epoch era season quarter interval window',
38
+ // Functional Types (1) - Stage 3
39
+ [NounType.Function]: 'function purpose role capability capacity utility objective goal aim intent',
40
+ // Informational Types (1) - Stage 3
41
+ [NounType.Proposition]: 'proposition statement claim assertion declaration premise conclusion hypothesis theory',
34
42
  // Digital/Content Types
35
43
  [NounType.Document]: 'document file report article paper text pdf word contract agreement record documentation',
36
44
  [NounType.Media]: 'media image photo video audio music podcast multimedia graphic visualization animation',
@@ -59,7 +67,18 @@ const NOUN_TYPE_DESCRIPTIONS = {
59
67
  [NounType.Regulation]: 'regulation law rule policy standard compliance requirement guideline ordinance statute',
60
68
  // Technical Infrastructure Types
61
69
  [NounType.Interface]: 'interface API endpoint protocol specification contract schema definition connection',
62
- [NounType.Resource]: 'resource infrastructure server database storage compute memory bandwidth capacity asset'
70
+ [NounType.Resource]: 'resource infrastructure server database storage compute memory bandwidth capacity asset',
71
+ // Custom/Extensible (1) - Stage 3
72
+ [NounType.Custom]: 'custom special unique particular specific domain-specific specialized tailored bespoke',
73
+ // Social Structures (3) - Stage 3
74
+ [NounType.SocialGroup]: 'socialGroup community tribe clan network circle collective society crowd gathering',
75
+ [NounType.Institution]: 'institution establishment foundation organization system structure framework tradition practice',
76
+ [NounType.Norm]: 'norm convention standard custom tradition protocol etiquette rule practice expectation',
77
+ // Information Theory (2) - Stage 3
78
+ [NounType.InformationContent]: 'informationContent story narrative knowledge data schema pattern model structure',
79
+ [NounType.InformationBearer]: 'informationBearer carrier medium vehicle signal token representation document',
80
+ // Meta-Level (1) - Stage 3
81
+ [NounType.Relationship]: 'relationship connection relation association link bond tie interaction dynamic'
63
82
  };
64
83
  const VERB_TYPE_DESCRIPTIONS = {
65
84
  // Core Relationship Types
@@ -389,6 +408,16 @@ export class BrainyTypes {
389
408
  generateReasoning(obj, selectedType, typeKind) {
390
409
  const descriptions = typeKind === 'noun' ? NOUN_TYPE_DESCRIPTIONS : VERB_TYPE_DESCRIPTIONS;
391
410
  const typeDesc = descriptions[selectedType];
411
+ // Handle missing descriptions gracefully
412
+ if (!typeDesc) {
413
+ if (typeKind === 'noun') {
414
+ const fields = Object.keys(obj).slice(0, 3).join(', ');
415
+ return `Matched to ${selectedType} based on semantic similarity and object fields: ${fields}`;
416
+ }
417
+ else {
418
+ return `Matched to ${selectedType} based on semantic similarity and relationship context`;
419
+ }
420
+ }
392
421
  if (typeKind === 'noun') {
393
422
  const fields = Object.keys(obj).slice(0, 3).join(', ');
394
423
  return `Matched to ${selectedType} based on semantic similarity to "${typeDesc.split(' ').slice(0, 5).join(' ')}..." and object fields: ${fields}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "5.6.1",
3
+ "version": "5.6.3",
4
4
  "description": "Universal Knowledge Protocolβ„’ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. Stage 3 CANONICAL: 42 nouns Γ— 127 verbs covering 96-97% of all human knowledge.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",