chore: recovery checkpoint - v3.0 API successfully recovered

CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB

Recovery Status:
- Successfully recovered brainy.ts from compiled JavaScript
- All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.)
- Neural subsystem intact (562KB embedded patterns, NLP working)
- Augmentation pipeline operational (20+ augmentations)
- HNSW clustering system complete
- Triple Intelligence compiled (needs constructor fix)
- Test suite validates functionality

Changes preserved:
- 898 files with changes from last 3 days
- 144,475 insertions
- All augmentation improvements
- All test coverage enhancements
- Complete v3.0 feature set

This is a LOCAL checkpoint only - contains recovered work after corruption incident.
Created backup in .backups/brainy-full-20250910-151314.tar.gz

Branch: recovery-checkpoint-20250910-151433
Date: Wed Sep 10 03:18:04 PM PDT 2025
This commit is contained in:
David Snelling 2025-09-10 15:18:04 -07:00
parent f65455fb22
commit 8ff382ca3b
895 changed files with 143654 additions and 28268 deletions

View file

@ -0,0 +1,4 @@
/**
* Basic usage example for the Soulcraft Brainy database
*/
export {};

View file

@ -0,0 +1,121 @@
/**
* Basic usage example for the Soulcraft Brainy database
*/
import { Brainy } from '../brainy.js';
// Example data - word embeddings
const wordEmbeddings = {
cat: [0.2, 0.3, 0.4, 0.1],
dog: [0.3, 0.2, 0.4, 0.2],
fish: [0.1, 0.1, 0.8, 0.2],
bird: [0.1, 0.4, 0.2, 0.5],
tiger: [0.3, 0.4, 0.3, 0.1],
lion: [0.4, 0.3, 0.2, 0.1],
shark: [0.2, 0.1, 0.7, 0.3],
eagle: [0.2, 0.5, 0.1, 0.4]
};
// Example metadata
const metadata = {
cat: { type: 'mammal', domesticated: true },
dog: { type: 'mammal', domesticated: true },
fish: { type: 'fish', domesticated: false },
bird: { type: 'bird', domesticated: false },
tiger: { type: 'mammal', domesticated: false },
lion: { type: 'mammal', domesticated: false },
shark: { type: 'fish', domesticated: false },
eagle: { type: 'bird', domesticated: false }
};
/**
* Run the example
*/
async function runExample() {
console.log('Initializing vector database...');
// Create a new vector database
const db = new Brainy();
await db.init();
console.log('Adding vectors to the database...');
// Add vectors to the database
const ids = {};
for (const [word, vector] of Object.entries(wordEmbeddings)) {
// Determine noun type based on the metadata
const meta = metadata[word];
const nounType = meta.type === 'mammal' || meta.type === 'bird' || meta.type === 'fish' ? 'Thing' : 'Content';
ids[word] = await db.addNoun(vector, nounType, meta);
console.log(`Added "${word}" with ID: ${ids[word]}`);
}
console.log('\nDatabase size:', db.size());
// Search for similar vectors
console.log('\nSearching for vectors similar to "cat"...');
const catResults = await db.search(wordEmbeddings['cat'], { limit: 3 });
console.log('Results:');
for (const result of catResults) {
const word = Object.entries(ids).find(([_, id]) => id === result.id)?.[0] || 'unknown';
console.log(`- ${word} (score: ${result.score.toFixed(4)}, metadata:`, result.metadata, ')');
}
// Search for similar vectors
console.log('\nSearching for vectors similar to "fish"...');
const fishResults = await db.search(wordEmbeddings['fish'], { limit: 3 });
console.log('Results:');
for (const result of fishResults) {
const word = Object.entries(ids).find(([_, id]) => id === result.id)?.[0] || 'unknown';
console.log(`- ${word} (score: ${result.score.toFixed(4)}, metadata:`, result.metadata, ')');
}
// Update metadata
console.log('\nUpdating metadata for "bird"...');
await db.updateNounMetadata(ids['bird'], {
...metadata['bird'],
notes: 'Can fly'
});
// Get the updated document
const birdDoc = await db.getNoun(ids['bird']);
console.log('Updated bird document:', birdDoc);
// Delete a vector
console.log('\nDeleting "shark"...');
await db.deleteNoun(ids['shark']);
console.log('Database size after deletion:', db.size());
// Search again to verify shark is gone
console.log('\nSearching for vectors similar to "fish" after deletion...');
const fishResultsAfterDeletion = await db.search(wordEmbeddings['fish'], { limit: 3 });
console.log('Results:');
for (const result of fishResultsAfterDeletion) {
const word = Object.entries(ids).find(([_, id]) => id === result.id)?.[0] || 'unknown';
console.log(`- ${word} (score: ${result.score.toFixed(4)}, metadata:`, result.metadata, ')');
}
console.log('\nExample completed successfully!');
}
// Check if we're in a browser or Node.js environment
if (typeof window !== 'undefined') {
// Browser environment
document.addEventListener('DOMContentLoaded', () => {
const button = document.createElement('button');
button.textContent = 'Run Brainy Example';
button.addEventListener('click', async () => {
const output = document.createElement('pre');
document.body.appendChild(output);
// Redirect console.log to the output element
const originalLog = console.log;
console.log = (...args) => {
originalLog(...args);
output.textContent +=
args
.map((arg) => typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg)
.join(' ') + '\n';
};
try {
await runExample();
}
catch (error) {
console.error('Error running example:', error);
}
// Restore console.log
console.log = originalLog;
});
document.body.appendChild(button);
});
}
else {
// Node.js environment
runExample().catch((error) => {
console.error('Error running example:', error);
});
}
//# sourceMappingURL=basicUsage.js.map

File diff suppressed because one or more lines are too long