refactor: remove augmentation system and semantic type matching
Remove the entire augmentation pipeline infrastructure (52 files, ~15,000 lines) and the semantic type matching system. These were unused middleware layers adding complexity without value. What was removed: - src/augmentations/ directory (all augmentation implementations) - src/augmentationManager.ts (pipeline orchestrator) - src/types/augmentations.ts, src/types/pipelineTypes.ts - src/shared/default-augmentations.ts - Semantic type suggestion (BrainyTypes.suggestNoun/suggestVerb) - src/utils/typeMatching/ (embedding-based type matcher) What was preserved by relocating: - Import handlers (CSV, PDF, Excel) -> src/importers/handlers/ - NeuralImportAugmentation -> src/cortex/neuralImportAugmentation.ts - Type matching utilities -> heuristic inference in consumers What was simplified: - brainy.ts: operations call storage directly (no execute() wrapper) - IntegrationBase: standalone class (no BaseAugmentation parent) - BrainyTypes: validation-only (nouns, verbs, isValid*, get*) - Pipeline: direct execution (no augmentation interception) - index.ts: removed TypeSuggestion, suggestType exports - package.json: removed stale types/augmentations export Build passes, 1176 tests pass, 0 failures.
This commit is contained in:
parent
ac7a1f772c
commit
d1db3510be
97 changed files with 349 additions and 19705 deletions
|
|
@ -1,105 +0,0 @@
|
|||
/**
|
||||
* API Server Example
|
||||
*
|
||||
* This example shows how to expose Brainy through REST, WebSocket, and MCP APIs
|
||||
* using the APIServerAugmentation.
|
||||
*
|
||||
* Zero-config philosophy: Just create and register the augmentation!
|
||||
*/
|
||||
|
||||
import { Brainy } from '../src/index.js'
|
||||
import { APIServerAugmentation } from '../src/augmentations/apiServerAugmentation.js'
|
||||
|
||||
async function main() {
|
||||
// 1. Create Brainy with zero config
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// 2. Add some sample data
|
||||
await brain.add({ data: "The quick brown fox", type: 'content', metadata: { type: "sentence", category: "animals" } })
|
||||
await brain.add({ data: "Machine learning models", type: 'content', metadata: { type: "tech", category: "AI" } })
|
||||
await brain.add({ data: "Natural language processing", type: 'content', metadata: { type: "tech", category: "NLP" } })
|
||||
|
||||
// 3. Create and register the API Server augmentation
|
||||
const apiServer = new APIServerAugmentation({
|
||||
port: 3000,
|
||||
host: 'localhost'
|
||||
})
|
||||
|
||||
// Register the augmentation with Brainy
|
||||
brain.augmentations.register(apiServer)
|
||||
|
||||
// Initialize augmentations with Brainy context
|
||||
await brain.augmentations.initialize({
|
||||
brain,
|
||||
log: (msg: string, level?: string) => console.log(`[${level || 'info'}] ${msg}`),
|
||||
config: {}
|
||||
})
|
||||
|
||||
console.log('🚀 Brainy API Server is running!')
|
||||
console.log('📡 REST API: http://localhost:3000')
|
||||
console.log('🔌 WebSocket: ws://localhost:3000/ws')
|
||||
console.log('🧠 MCP: http://localhost:3000/api/mcp')
|
||||
console.log('')
|
||||
console.log('Try these endpoints:')
|
||||
console.log(' GET http://localhost:3000/health')
|
||||
console.log(' POST http://localhost:3000/api/search')
|
||||
console.log(' Body: { "query": "fox", "limit": 10 }')
|
||||
console.log(' POST http://localhost:3000/api/add')
|
||||
console.log(' Body: { "content": "New data", "metadata": {} }')
|
||||
console.log('')
|
||||
console.log('Press Ctrl+C to stop the server')
|
||||
}
|
||||
|
||||
// Run the example
|
||||
main().catch(console.error)
|
||||
|
||||
/**
|
||||
* Example REST API calls:
|
||||
*
|
||||
* # Health check
|
||||
* curl http://localhost:3000/health
|
||||
*
|
||||
* # Search
|
||||
* curl -X POST http://localhost:3000/api/search \
|
||||
* -H "Content-Type: application/json" \
|
||||
* -d '{"query": "fox", "limit": 5}'
|
||||
*
|
||||
* # Add data
|
||||
* curl -X POST http://localhost:3000/api/add \
|
||||
* -H "Content-Type: application/json" \
|
||||
* -d '{"content": "The cat sat on the mat", "metadata": {"type": "sentence"}}'
|
||||
*
|
||||
* # Get by ID
|
||||
* curl http://localhost:3000/api/get/[id]
|
||||
*
|
||||
* # Statistics
|
||||
* curl http://localhost:3000/api/stats
|
||||
*/
|
||||
|
||||
/**
|
||||
* Example WebSocket client (browser):
|
||||
*
|
||||
* const ws = new WebSocket('ws://localhost:3000/ws')
|
||||
*
|
||||
* ws.onopen = () => {
|
||||
* // Subscribe to all operations
|
||||
* ws.send(JSON.stringify({
|
||||
* type: 'subscribe',
|
||||
* operations: ['all']
|
||||
* }))
|
||||
*
|
||||
* // Perform a search
|
||||
* ws.send(JSON.stringify({
|
||||
* type: 'search',
|
||||
* query: 'fox',
|
||||
* limit: 5,
|
||||
* requestId: '123'
|
||||
* }))
|
||||
* }
|
||||
*
|
||||
* ws.onmessage = (event) => {
|
||||
* const msg = JSON.parse(event.data)
|
||||
* console.log('Received:', msg)
|
||||
* }
|
||||
*/
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/**
|
||||
* Zero-Config Augmentations Example
|
||||
*
|
||||
* Brainy's philosophy: Everything just works with zero configuration.
|
||||
* Augmentations extend Brainy without any complex setup.
|
||||
*/
|
||||
|
||||
import { Brainy } from '../src/index.js'
|
||||
import { EntityRegistryAugmentation } from '../src/augmentations/entityRegistryAugmentation.js'
|
||||
import { BatchProcessingAugmentation } from '../src/augmentations/batchProcessingAugmentation.js'
|
||||
import { APIServerAugmentation } from '../src/augmentations/apiServerAugmentation.js'
|
||||
|
||||
async function main() {
|
||||
// Create Brainy - zero config!
|
||||
const brain = new Brainy()
|
||||
|
||||
// Register augmentations - they just work!
|
||||
brain.augmentations.register(new EntityRegistryAugmentation()) // Deduplication
|
||||
brain.augmentations.register(new BatchProcessingAugmentation()) // Performance
|
||||
brain.augmentations.register(new APIServerAugmentation()) // API exposure
|
||||
|
||||
// Initialize Brainy (augmentations auto-initialize)
|
||||
await brain.init()
|
||||
|
||||
// Use Brainy normally - augmentations work transparently
|
||||
await brain.add({ data: "Hello world", type: 'content', metadata: { type: "greeting" } })
|
||||
|
||||
// Batch operations automatically optimized
|
||||
await brain.addBatch([
|
||||
{ content: "Item 1", metadata: { id: 1 } },
|
||||
{ content: "Item 2", metadata: { id: 2 } },
|
||||
{ content: "Item 3", metadata: { id: 3 } }
|
||||
])
|
||||
|
||||
// Search works with all augmentations active
|
||||
const results = await brain.search("hello")
|
||||
console.log('Search results:', results)
|
||||
|
||||
// API server is running at http://localhost:3000
|
||||
console.log('✨ Brainy is running with:')
|
||||
console.log(' - Write-ahead logging (durability)')
|
||||
console.log(' - Entity deduplication (performance)')
|
||||
console.log(' - Batch optimization (speed)')
|
||||
console.log(' - REST/WebSocket/MCP APIs (connectivity)')
|
||||
console.log('')
|
||||
console.log('Zero configuration required!')
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
|
|
@ -49,11 +49,8 @@ try {
|
|||
test('Memory storage configured', brain.storage && brain.storage.storageType === 'memory')
|
||||
|
||||
console.log('\n📊 API Architecture Validation:')
|
||||
|
||||
// Test 5: Augmentation system structure
|
||||
test('Augmentations system exists', brain.augmentations !== undefined)
|
||||
|
||||
// Test 6: Core properties exist
|
||||
|
||||
// Test 5: Core properties exist
|
||||
test('Index system exists', brain.index !== undefined)
|
||||
test('Storage system exists', brain.storage !== undefined)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,89 +0,0 @@
|
|||
/**
|
||||
* Test script to verify storage augmentation system works
|
||||
*/
|
||||
|
||||
import { Brainy } from '../../dist/index.js'
|
||||
import {
|
||||
MemoryStorageAugmentation,
|
||||
FileSystemStorageAugmentation
|
||||
} from './dist/augmentations/storageAugmentations.js'
|
||||
|
||||
console.log('🧪 Testing Storage Augmentation System')
|
||||
console.log('=' .repeat(50))
|
||||
|
||||
async function test1_ZeroConfig() {
|
||||
console.log('\n1. Zero-Config Test')
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
await brain.add('test', { content: 'Zero-config test' })
|
||||
const results = await brain.search('test', { limit: 1 })
|
||||
|
||||
console.log('✅ Zero-config works:', results.length > 0)
|
||||
await brain.destroy()
|
||||
}
|
||||
|
||||
async function test2_ConfigBased() {
|
||||
console.log('\n2. Config-Based Storage Test')
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
forceMemoryStorage: true
|
||||
}
|
||||
})
|
||||
await brain.init()
|
||||
|
||||
await brain.add('config test', { content: 'Config-based test' })
|
||||
const results = await brain.search('config', { limit: 1 })
|
||||
|
||||
console.log('✅ Config-based works:', results.length > 0)
|
||||
await brain.destroy()
|
||||
}
|
||||
|
||||
async function test3_AugmentationOverride() {
|
||||
console.log('\n3. Augmentation Override Test')
|
||||
const brain = new Brainy()
|
||||
|
||||
// Register storage augmentation BEFORE init
|
||||
brain.augmentations.register(new MemoryStorageAugmentation('test-memory'))
|
||||
|
||||
await brain.init()
|
||||
|
||||
await brain.add('augmentation test', { content: 'Augmentation override test' })
|
||||
const results = await brain.search('augmentation', { limit: 1 })
|
||||
|
||||
console.log('✅ Augmentation override works:', results.length > 0)
|
||||
await brain.destroy()
|
||||
}
|
||||
|
||||
async function test4_BackwardCompatibility() {
|
||||
console.log('\n4. Backward Compatibility Test')
|
||||
|
||||
// Old style with rootDirectory config
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
rootDirectory: './test-data',
|
||||
forceFileSystemStorage: true
|
||||
}
|
||||
})
|
||||
|
||||
await brain.init()
|
||||
console.log('✅ Backward compatible config works')
|
||||
await brain.destroy()
|
||||
}
|
||||
|
||||
async function runAllTests() {
|
||||
try {
|
||||
await test1_ZeroConfig()
|
||||
await test2_ConfigBased()
|
||||
await test3_AugmentationOverride()
|
||||
await test4_BackwardCompatibility()
|
||||
|
||||
console.log('\n' + '='.repeat(50))
|
||||
console.log('✅ ALL STORAGE AUGMENTATION TESTS PASSED!')
|
||||
} catch (error) {
|
||||
console.error('❌ Test failed:', error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
runAllTests()
|
||||
Loading…
Add table
Add a link
Reference in a new issue