@soulcraft/brainy 5.6.0 β 5.6.2
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 +38 -0
- package/README.md +116 -119
- package/dist/augmentations/typeMatching/brainyTypes.js +30 -1
- package/dist/storage/adapters/azureBlobStorage.js +9 -0
- package/dist/storage/adapters/fileSystemStorage.js +17 -0
- package/dist/storage/adapters/gcsStorage.js +11 -0
- package/dist/storage/adapters/opfsStorage.js +22 -0
- package/dist/storage/adapters/r2Storage.js +11 -2
- package/dist/storage/adapters/s3CompatibleStorage.js +13 -0
- package/dist/storage/baseStorage.js +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
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.2](https://github.com/soulcraftlabs/brainy/compare/v5.6.1...v5.6.2) (2025-11-11)
|
|
6
|
+
|
|
7
|
+
- fix: update tests for Stage 3 CANONICAL taxonomy (42 nouns, 127 verbs) (c5dcdf6)
|
|
8
|
+
- docs: restructure README for better new user flow (2d3f59e)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [5.6.1](https://github.com/soulcraftlabs/brainy/compare/v5.6.0...v5.6.1) (2025-11-11)
|
|
12
|
+
|
|
13
|
+
### π Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **storage**: Fix `clear()` not deleting COW version control data ([#workshop-bug-report](https://github.com/soulcraftlabs/brainy/issues))
|
|
16
|
+
- Fixed all storage adapters to properly delete `_cow/` directory on clear()
|
|
17
|
+
- Fixed in-memory entity counters not being reset after clear()
|
|
18
|
+
- Prevents COW reinitialization after clear() by setting `cowEnabled = false`
|
|
19
|
+
- **Impact**: Resolves storage persistence bug (103MB β 0 bytes after clear)
|
|
20
|
+
- **Affected adapters**: FileSystemStorage, OPFSStorage, S3CompatibleStorage (GCSStorage, R2Storage, AzureBlobStorage already correct)
|
|
21
|
+
|
|
22
|
+
### π Technical Details
|
|
23
|
+
|
|
24
|
+
* **Root causes identified**:
|
|
25
|
+
1. `_cow/` directory contents deleted but directory not removed
|
|
26
|
+
2. In-memory counters (`totalNounCount`, `totalVerbCount`) not reset
|
|
27
|
+
3. COW could auto-reinitialize on next operation
|
|
28
|
+
* **Fixes applied**:
|
|
29
|
+
- FileSystemStorage: Use `fs.rm()` to delete entire `_cow/` directory
|
|
30
|
+
- OPFSStorage: Use `removeEntry('_cow', {recursive: true})`
|
|
31
|
+
- Cloud adapters: Already use `deleteObjectsWithPrefix('_cow/')`
|
|
32
|
+
- All adapters: Reset `totalNounCount = 0` and `totalVerbCount = 0`
|
|
33
|
+
- BaseStorage: Added guard in `initializeCOW()` to prevent reinitialization when `cowEnabled === false`
|
|
34
|
+
|
|
35
|
+
## [5.6.0](https://github.com/soulcraftlabs/brainy/compare/v5.5.0...v5.6.0) (2025-11-11)
|
|
36
|
+
|
|
37
|
+
### π Bug Fixes
|
|
38
|
+
|
|
39
|
+
* **relations**: Fix `getRelations()` returning empty array for fresh instances
|
|
40
|
+
- Resolved initialization race condition in relationship loading
|
|
41
|
+
- Fresh Brain instances now correctly load persisted relationships
|
|
42
|
+
|
|
5
43
|
## [5.5.0](https://github.com/soulcraftlabs/brainy/compare/v5.4.0...v5.5.0) (2025-11-06)
|
|
6
44
|
|
|
7
45
|
### π― Stage 3 CANONICAL Taxonomy - Complete Coverage
|
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
|
-
##
|
|
94
|
+
## Quick Start
|
|
76
95
|
|
|
77
|
-
|
|
96
|
+
```bash
|
|
97
|
+
npm install @soulcraft/brainy
|
|
98
|
+
```
|
|
78
99
|
|
|
79
|
-
###
|
|
100
|
+
### Your First Knowledge Graph (60 seconds)
|
|
80
101
|
|
|
81
102
|
```javascript
|
|
82
|
-
|
|
103
|
+
import { Brainy, NounType, VerbType } from '@soulcraft/brainy'
|
|
104
|
+
|
|
83
105
|
const brain = new Brainy()
|
|
84
106
|
await brain.init()
|
|
85
107
|
|
|
86
|
-
//
|
|
87
|
-
|
|
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
|
-
|
|
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
|
-
|
|
121
|
+
// Create relationships
|
|
122
|
+
await brain.relate({ from: nodeId, to: jsId, type: VerbType.Executes })
|
|
93
123
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
**
|
|
106
|
-
|
|
107
|
-
**
|
|
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.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## From Prototype to Planet Scale
|
|
108
139
|
|
|
109
|
-
|
|
140
|
+
**The same API. Zero rewrites. Any scale.**
|
|
110
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
176
|
+
**β [Capacity Planning Guide](docs/operations/capacity-planning.md)** | **[Cost Optimization](docs/operations/)**
|
|
159
177
|
|
|
160
|
-
|
|
178
|
+
### π― The Point
|
|
161
179
|
|
|
162
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -296,48 +313,6 @@ Every asset knows its relationships. Intelligent tagging, similarity-based disco
|
|
|
296
313
|
|
|
297
314
|
---
|
|
298
315
|
|
|
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
316
|
## Core Features
|
|
342
317
|
|
|
343
318
|
### π§ **Natural Language Queries**
|
|
@@ -355,6 +330,8 @@ await brain.find({
|
|
|
355
330
|
})
|
|
356
331
|
```
|
|
357
332
|
|
|
333
|
+
**β [See all query methods in API Reference](docs/api/README.md#search--query)**
|
|
334
|
+
|
|
358
335
|
### π **Virtual Filesystem** β Intelligent File Management
|
|
359
336
|
|
|
360
337
|
Build file explorers and IDEs that never crash:
|
|
@@ -566,40 +543,60 @@ brainy search "programming"
|
|
|
566
543
|
|
|
567
544
|
---
|
|
568
545
|
|
|
569
|
-
## Documentation
|
|
546
|
+
## π Complete Documentation
|
|
570
547
|
|
|
571
|
-
|
|
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)
|
|
548
|
+
**For most developers:** Start with the **[Complete API Reference](docs/api/README.md)** β
|
|
574
549
|
|
|
575
|
-
|
|
576
|
-
-
|
|
577
|
-
-
|
|
578
|
-
-
|
|
579
|
-
-
|
|
550
|
+
This comprehensive guide includes:
|
|
551
|
+
- β
Every method with parameters, returns, and examples
|
|
552
|
+
- β
Quick start in 60 seconds
|
|
553
|
+
- β
Core CRUD β Advanced features (branching, versioning, time-travel)
|
|
554
|
+
- β
TypeScript types and patterns
|
|
555
|
+
- β
1,870 lines of copy-paste ready code
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
### π― Essential Reading (Start Here)
|
|
560
|
+
|
|
561
|
+
1. **[π Complete API Reference](docs/api/README.md)** β **START HERE** β
|
|
562
|
+
- Your primary resource for building with Brainy
|
|
563
|
+
- Every method documented with working examples
|
|
564
|
+
|
|
565
|
+
2. **[Natural Language Queries](docs/guides/natural-language.md)**
|
|
566
|
+
- Master the `find()` method and Triple Intelligence queries
|
|
580
567
|
|
|
581
|
-
|
|
568
|
+
3. **[v4.0.0 Migration Guide](docs/MIGRATION-V3-TO-V4.md)**
|
|
569
|
+
- Upgrading from v3 (100% backward compatible)
|
|
570
|
+
|
|
571
|
+
### π§ Core Concepts & Architecture
|
|
572
|
+
|
|
573
|
+
- **[Triple Intelligence Architecture](docs/architecture/triple-intelligence.md)** β How vector + graph + document work together
|
|
574
|
+
- **[Noun-Verb Taxonomy](docs/architecture/noun-verb-taxonomy.md)** β The universal type system (42 nouns Γ 127 verbs)
|
|
582
575
|
- **[Architecture Overview](docs/architecture/overview.md)** β System design and components
|
|
583
576
|
- **[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
577
|
|
|
586
578
|
### βοΈ Production & Operations
|
|
579
|
+
|
|
587
580
|
- **[Cloud Deployment Guide](docs/deployment/CLOUD_DEPLOYMENT_GUIDE.md)** β Deploy to AWS, GCS, Azure
|
|
588
|
-
- **[
|
|
581
|
+
- **[Capacity Planning](docs/operations/capacity-planning.md)** β Memory, storage, and scaling to billions
|
|
582
|
+
- **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
583
|
|
|
590
584
|
### π Framework Integration
|
|
585
|
+
|
|
591
586
|
- **[Framework Integration Guide](docs/guides/framework-integration.md)** β React, Vue, Angular, Svelte
|
|
592
587
|
- **[Next.js Integration](docs/guides/nextjs-integration.md)**
|
|
593
588
|
- **[Vue.js Integration](docs/guides/vue-integration.md)**
|
|
594
589
|
|
|
595
|
-
### π³ Virtual Filesystem
|
|
590
|
+
### π³ Virtual Filesystem (VFS)
|
|
591
|
+
|
|
596
592
|
- **[VFS Quick Start](docs/vfs/QUICK_START.md)** β Build file explorers that never crash
|
|
597
593
|
- **[VFS Core Documentation](docs/vfs/VFS_CORE.md)**
|
|
598
|
-
- **[Semantic VFS Guide](docs/vfs/SEMANTIC_VFS.md)**
|
|
594
|
+
- **[Semantic VFS Guide](docs/vfs/SEMANTIC_VFS.md)** β AI-powered file navigation
|
|
599
595
|
- **[Neural Extraction API](docs/vfs/NEURAL_EXTRACTION.md)**
|
|
600
596
|
|
|
601
|
-
### π¦ Data Import
|
|
602
|
-
|
|
597
|
+
### π¦ Data Import & Processing
|
|
598
|
+
|
|
599
|
+
- **[Import Anything Guide](docs/guides/import-anything.md)** β CSV, Excel, PDF, URLs with auto-detection
|
|
603
600
|
|
|
604
601
|
---
|
|
605
602
|
|
|
@@ -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}`;
|
|
@@ -851,12 +851,21 @@ export class AzureBlobStorage extends BaseStorage {
|
|
|
851
851
|
try {
|
|
852
852
|
this.logger.info('π§Ή Clearing all data from Azure container...');
|
|
853
853
|
// Delete all blobs in container
|
|
854
|
+
// v5.6.1: listBlobsFlat() returns ALL blobs including _cow/ prefix
|
|
855
|
+
// This correctly deletes COW version control data (commits, trees, blobs, refs)
|
|
854
856
|
for await (const blob of this.containerClient.listBlobsFlat()) {
|
|
855
857
|
if (blob.name) {
|
|
856
858
|
const blockBlobClient = this.containerClient.getBlockBlobClient(blob.name);
|
|
857
859
|
await blockBlobClient.delete();
|
|
858
860
|
}
|
|
859
861
|
}
|
|
862
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
863
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
864
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
865
|
+
this.refManager = undefined;
|
|
866
|
+
this.blobStorage = undefined;
|
|
867
|
+
this.commitLog = undefined;
|
|
868
|
+
this.cowEnabled = false;
|
|
860
869
|
// Clear caches
|
|
861
870
|
this.nounCacheManager.clear();
|
|
862
871
|
this.verbCacheManager.clear();
|
|
@@ -874,9 +874,26 @@ export class FileSystemStorage extends BaseStorage {
|
|
|
874
874
|
if (await this.directoryExists(this.indexDir)) {
|
|
875
875
|
await removeDirectoryContents(this.indexDir);
|
|
876
876
|
}
|
|
877
|
+
// v5.6.1: Remove COW (copy-on-write) version control data
|
|
878
|
+
// This directory stores all git-like versioning data (commits, trees, blobs, refs)
|
|
879
|
+
// Must be deleted to fully clear all data including version history
|
|
880
|
+
const cowDir = path.join(this.rootDir, '_cow');
|
|
881
|
+
if (await this.directoryExists(cowDir)) {
|
|
882
|
+
// Delete the entire _cow/ directory (not just contents)
|
|
883
|
+
await fs.promises.rm(cowDir, { recursive: true, force: true });
|
|
884
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
885
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
886
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
887
|
+
this.refManager = undefined;
|
|
888
|
+
this.blobStorage = undefined;
|
|
889
|
+
this.commitLog = undefined;
|
|
890
|
+
this.cowEnabled = false;
|
|
891
|
+
}
|
|
877
892
|
// Clear the statistics cache
|
|
878
893
|
this.statisticsCache = null;
|
|
879
894
|
this.statisticsModified = false;
|
|
895
|
+
this.totalNounCount = 0;
|
|
896
|
+
this.totalVerbCount = 0;
|
|
880
897
|
}
|
|
881
898
|
/**
|
|
882
899
|
* Enhanced clear operation with safety mechanisms and performance optimizations
|
|
@@ -778,6 +778,17 @@ export class GcsStorage extends BaseStorage {
|
|
|
778
778
|
await deleteObjectsWithPrefix(this.metadataPrefix);
|
|
779
779
|
await deleteObjectsWithPrefix(this.verbMetadataPrefix);
|
|
780
780
|
await deleteObjectsWithPrefix(this.systemPrefix);
|
|
781
|
+
// v5.6.1: Clear COW (copy-on-write) version control data
|
|
782
|
+
// This includes all git-like versioning data (commits, trees, blobs, refs)
|
|
783
|
+
// Must be deleted to fully clear all data including version history
|
|
784
|
+
await deleteObjectsWithPrefix('_cow/');
|
|
785
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
786
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
787
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
788
|
+
this.refManager = undefined;
|
|
789
|
+
this.blobStorage = undefined;
|
|
790
|
+
this.commitLog = undefined;
|
|
791
|
+
this.cowEnabled = false;
|
|
781
792
|
// Clear caches
|
|
782
793
|
this.nounCacheManager.clear();
|
|
783
794
|
this.verbCacheManager.clear();
|
|
@@ -387,9 +387,31 @@ export class OPFSStorage extends BaseStorage {
|
|
|
387
387
|
await removeDirectoryContents(this.verbMetadataDir);
|
|
388
388
|
// Remove all files in the index directory
|
|
389
389
|
await removeDirectoryContents(this.indexDir);
|
|
390
|
+
// v5.6.1: Remove COW (copy-on-write) version control data
|
|
391
|
+
// This directory stores all git-like versioning data (commits, trees, blobs, refs)
|
|
392
|
+
// Must be deleted to fully clear all data including version history
|
|
393
|
+
try {
|
|
394
|
+
// Delete the entire _cow/ directory (not just contents)
|
|
395
|
+
await this.rootDir.removeEntry('_cow', { recursive: true });
|
|
396
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
397
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
398
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
399
|
+
this.refManager = undefined;
|
|
400
|
+
this.blobStorage = undefined;
|
|
401
|
+
this.commitLog = undefined;
|
|
402
|
+
this.cowEnabled = false;
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
// Ignore if _cow directory doesn't exist (not all instances use COW)
|
|
406
|
+
if (error.name !== 'NotFoundError') {
|
|
407
|
+
throw error;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
390
410
|
// Clear the statistics cache
|
|
391
411
|
this.statisticsCache = null;
|
|
392
412
|
this.statisticsModified = false;
|
|
413
|
+
this.totalNounCount = 0;
|
|
414
|
+
this.totalVerbCount = 0;
|
|
393
415
|
}
|
|
394
416
|
catch (error) {
|
|
395
417
|
console.error('Error clearing storage:', error);
|
|
@@ -771,13 +771,22 @@ export class R2Storage extends BaseStorage {
|
|
|
771
771
|
async clear() {
|
|
772
772
|
await this.ensureInitialized();
|
|
773
773
|
prodLog.info('π§Ή R2: Clearing all data from bucket...');
|
|
774
|
-
// Clear all prefixes
|
|
775
|
-
|
|
774
|
+
// Clear all prefixes (v5.6.1: includes _cow/ for version control data)
|
|
775
|
+
// _cow/ stores all git-like versioning data (commits, trees, blobs, refs)
|
|
776
|
+
// Must be deleted to fully clear all data including version history
|
|
777
|
+
for (const prefix of [this.nounPrefix, this.verbPrefix, this.metadataPrefix, this.verbMetadataPrefix, this.systemPrefix, '_cow/']) {
|
|
776
778
|
const objects = await this.listObjectsUnderPath(prefix);
|
|
777
779
|
for (const key of objects) {
|
|
778
780
|
await this.deleteObjectFromPath(key);
|
|
779
781
|
}
|
|
780
782
|
}
|
|
783
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
784
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
785
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
786
|
+
this.refManager = undefined;
|
|
787
|
+
this.blobStorage = undefined;
|
|
788
|
+
this.commitLog = undefined;
|
|
789
|
+
this.cowEnabled = false;
|
|
781
790
|
this.nounCacheManager.clear();
|
|
782
791
|
this.verbCacheManager.clear();
|
|
783
792
|
this.totalNounCount = 0;
|
|
@@ -1621,9 +1621,22 @@ export class S3CompatibleStorage extends BaseStorage {
|
|
|
1621
1621
|
await deleteObjectsWithPrefix(this.verbMetadataPrefix);
|
|
1622
1622
|
// Delete all objects in the index directory
|
|
1623
1623
|
await deleteObjectsWithPrefix(this.indexPrefix);
|
|
1624
|
+
// v5.6.1: Delete COW (copy-on-write) version control data
|
|
1625
|
+
// This includes all git-like versioning data (commits, trees, blobs, refs)
|
|
1626
|
+
// Must be deleted to fully clear all data including version history
|
|
1627
|
+
await deleteObjectsWithPrefix('_cow/');
|
|
1628
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
1629
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
1630
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
1631
|
+
this.refManager = undefined;
|
|
1632
|
+
this.blobStorage = undefined;
|
|
1633
|
+
this.commitLog = undefined;
|
|
1634
|
+
this.cowEnabled = false;
|
|
1624
1635
|
// Clear the statistics cache
|
|
1625
1636
|
this.statisticsCache = null;
|
|
1626
1637
|
this.statisticsModified = false;
|
|
1638
|
+
this.totalNounCount = 0;
|
|
1639
|
+
this.totalVerbCount = 0;
|
|
1627
1640
|
}
|
|
1628
1641
|
catch (error) {
|
|
1629
1642
|
prodLog.error('Failed to clear storage:', error);
|
|
@@ -203,6 +203,11 @@ export class BaseStorage extends BaseStorageAdapter {
|
|
|
203
203
|
* @returns Promise that resolves when COW is initialized
|
|
204
204
|
*/
|
|
205
205
|
async initializeCOW(options) {
|
|
206
|
+
// v5.6.1: If COW was explicitly disabled (e.g., via clear()), don't reinitialize
|
|
207
|
+
// This prevents automatic recreation of COW data after clear() operations
|
|
208
|
+
if (this.cowEnabled === false) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
206
211
|
// Check if RefManager already initialized (full COW setup complete)
|
|
207
212
|
if (this.refManager) {
|
|
208
213
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.2",
|
|
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",
|