- Removed `demo-optional-model-bundling.js`:
- Obsolete demonstration of model bundling and offline loading.
- Replaced by comprehensive documentation and tools in `@soulcraft/brainy-models`.
- Added `create-github-release.js`:
- Automates GitHub release creation for `@soulcraft/brainy-models-package`.
- Includes features for generating release notes, tagging, and uploading with GitHub CLI.
- Updated `package-lock.json`:
- Reflects new dependencies and updates for GitHub release automation.
**Purpose**: Streamline repository by removing redundant scripts and introducing automated GitHub release workflows for efficient version management.
- Removed `SOLUTION.md` as it contained an outdated explanation of ES module compatibility fixes for cache detection.
- Updated `rollup.config.js`:
- Added detailed shims for 'url' and 'os' modules to ensure proper functionality in browser environments:
- **OS Shim**: Provided reasonable defaults for `totalmem()`, `freemem()`, `platform()`, and `arch()` to maintain compatibility and consistency.
- **URL Shim**: Added `fileURLToPath` and `pathToFileURL` to handle browser-specific file paths.
- Updated `nodeBuiltins` to include `'node:url'` and `'node:os'` for handling edge cases in module resolution.
**Purpose**: Streamline codebase by removing redundant documentation and enhancing compatibility shims for ES modules, ensuring seamless operation in browser environments.
- Introduced new documentation files under `docs/`:
- `model-bundling-analysis.md`: Provides detailed analysis of current, bundled, hybrid, and dynamic model loading approaches, including pros, cons, and recommendations.
- `model-management.md`: Explains how Brainy manages Universal Sentence Encoder models, including setup, usage, and troubleshooting.
- `optional-model-bundling.md`: Details the `@soulcraft/brainy-models` package for offline reliability with pre-bundled models.
- Added `src/utils/robustModelLoader.ts`:
- Implements enhanced model loading with retry mechanisms, timeout handling, fallback URLs, and optional local model bundling.
- Supports Node.js and browser environments with exponential backoff logic.
- Key Updates:
- **Hybrid Loading Strategy**: Recommended for balancing reliability and flexibility via hybrid online/offline mechanisms.
- **Enhanced Fallback Scenarios**: Robust loader improves network-dependent reliability for embedding workflows.
- **Offline Reliability Support**: Optional model bundling eliminates dependency on external services, supporting air-gapped and edge environments.
**Purpose**: Introduce a hybrid model loading approach with robust options for
- Added new scripts under `brainy-models-package/scripts`:
- **`compress-models.js`**: Implements model compression with float16 and int8 precision to create optimized variants of Universal Sentence Encoder models.
- **`download-full-models.js`**: Downloads the complete Universal Sentence Encoder model for offline usage.
- **`download-model.js`**: Downloads reference files for TensorFlow Hub-based Universal Sentence Encoder.
- Introduced a demonstration script:
- **`demo-optional-model-bundling.js`**: Highlights the solution of bundling models to eliminate network dependency, ensuring reliability and offline capability.
- Key Features:
- **Compression**:
- Reduced model size with float16 (balanced precision and size) and int8 (low-memory environments) options.
- Generated compression summaries for quick insights into model variants and saved space.
- **Offline Reliability**:
- Bundled versions eliminate first-load delays, network dependencies, and failures.
- Ensures rapid initialization in offline and memory-constrained scenarios.
- **Dynamic Optimization**:
- Tailored optimization profiles for various use cases: general, low-memory, and high-performance.
- **Demonstration and Documentation**:
- Comprehensive demo showcasing benefits of bundled models over online loading.
- Examples for usage, testing, and integration with Brainy.
**Purpose**: Introduce essential scripts and tools to enable efficient, offline-ready model usage, streamlining the embedding workflow while ensuring reliability in production and resource-constrained environments.
- Deleted `model.json` from `src/models/universal-sentence-encoder/`.
- File contained redundant `modelTopology` definitions for the Universal Sentence Encoder.
- Configuration no longer needed due to updates in model handling and initialization logic.
**Purpose**: Clean up unused configuration to reduce repository clutter and maintain consistency with updated model integration practices.
- Added `cache-configuration.md` under `docs/guides`:
- Detailed multi-level cache system (hot, warm, cold) overview.
- Explained new adaptive tuning capabilities:
- Memory-based adjustments across Node.js, Browser, and Worker environments.
- Dynamic sizing for read-heavy/write-heavy workloads.
- Environment-specific configurations for optimal caching.
- Included best practices for large datasets, memory-constrained and read-only environments.
- Added monitoring and advanced manual tuning instructions.
- Modified `cacheManager.ts`:
- Introduced `environmentConfig` for tailored per-environment cache settings.
- Enhanced auto-tuning with support for dynamic memory detection and cache hit/miss ratio.
- Added fine-grained tuning for eviction thresholds, TTLs, and batch sizes based on workload characteristics.
- Improved adaptive tuning with async memory detection and detailed cache statistics tracking.
**Purpose**: Provide developers with detailed guidance and dynamic tools for optimizing Brainy's cache system, ensuring better performance across diverse environments and workloads.
- Added `model.json` file for the Universal Sentence Encoder (USE).
- Defined `modelTopology` structure, including TensorFlow node definitions with layer configurations.
- Organized file under `src/models/universal-sentence-encoder/` for consistency with model shards.
**Purpose**: Include necessary model configuration to enable the initialization and usage of the Universal Sentence Encoder, completing the model setup for embedding operations.
- Added model shard files (`group1-shard1of7` to `group1-shard7of7`) to support the Universal Sentence Encoder (USE).
- Organized shard files under `src/models/universal-sentence-encoder/` to ensure structured storage and scalability for embedding operations.
**Purpose**: Include necessary model shards for the Universal Sentence Encoder to enable reliable and efficient embedding generation.
- Added new documentation files:
- `COMPATIBILITY.md` detailing environment-specific compatibility and behavior (Node.js, Browser, Worker).
- `TESTING.md` providing instructions for verifying cache detection across environments.
- Created browser (`test-browser-cache-detection.html`) and worker (`test-worker-cache-detection.html`) test scripts to validate cache mechanisms.
- Removed fallback mechanisms for embedding:
- Updated `embedding.ts` to enforce strict usage of Universal Sentence Encoder (USE).
- Fallback methods (`generateFallbackVector`) and related logic have been removed.
- Errors are thrown when USE initialization or embedding fails, ensuring stricter reliability.
- Improved error handling:
- Standardized error throwing for all USE-related failures across single and batch embeddings.
- Logging updated to reflect critical embedding issues without allowing degraded operations.
**Purpose**: Improve documentation for environment compatibility and testing while enforcing consistent use of Universal Sentence Encoder for deterministic embeddings, removing unreliable fallback mechanisms.
- Created `service-identification.md` in `docs/guides`:
- Detailed guidelines on how services should identify themselves within Brainy.
- Documented two identification methods: default service initialization and operation-specific service naming.
- Included service name conventions and common examples (`github`, `reddit`, `default`).
- Described benefits of proper service identification:
- Enhanced statistics tracking and JSON field discovery by service.
- Provided best practices for consistent and descriptive service naming.
- Explained internal implementation details, such as `getServiceName` usage and statistic tracking.
**Purpose**: Help users properly identify services to enable statistics tracking, field discovery, and improved data management in Brainy.
- Introduced `calculateSimilarity` method in `types.d.ts` for comparing vectors or textual inputs:
- Added support for custom options, including `forceEmbed` and a custom `distanceFunction`.
- Enhanced functionality in `embed` to convert text inputs into vector representations.
- Added new test cases in `vector-operations.test.ts`:
- Validated similarity calculations between identical and different vectors.
- Tested similarity scoring for similar and dissimilar text inputs.
- Updated `README.md`:
- Documented `calculateSimilarity` usage examples, including advanced options.
- Clarified the integration of the similarity function into workflows.
**Purpose**: Enable calculation of similarity scores for vectors and text inputs to facilitate advanced data comparison and retrieval tasks.
- Enhanced `CacheManager` for better handling of large datasets, especially in `S3` or remote storage:
- Added `REMOTE_API` as a supported storage type.
- Improved cache sizing and batch tuning:
- Optimized memory usage based on environment (Browser, Node.js, Worker).
- Increased cache aggressiveness in read-only mode and for large datasets.
- Adjusted cache parameters dynamically for S3 or remote storage.
- Introduced `isReadOnly` and `isRemoteStorage` checks to refine tuning logic.
- Added new `cacheConfig` options:
- `autoTune`, `autoTuneInterval`, and mode-specific settings for read-only optimizations.
- Batch sizes, eviction thresholds, and TTLs tailored for operating modes.
- Enhanced documentation:
- Detailed performance-tuning guides and S3 examples in `README.md`.
- Included new configuration examples for large datasets in cloud storage.
- Improved extensibility:
- Unified cache and batch logic under storage type and mode-aware rules.
- Updated interfaces (`BrainyData`, `StorageFactory`) to include new cache settings.
- Verified enhancements with rigorous testing across multiple configurations.
**Purpose**: Improve caching strategy and query performance in complex cloud and on-premise environments with flexible, dynamic tuning.
- Added support for field-specific and prioritized searches in `brainyData`:
- Introduced `searchField` option to enable targeted field-level searches.
- Implemented `priorityFields` option for weighted vectorization and query relevance.
- Developed utilities in `jsonProcessing.ts` and `fieldNameTracking.ts`:
- `extractTextFromJson` for text extraction with customizable depth and field prioritization.
- `extractFieldFromJson` to target specific fields in JSON documents.
- `prepareJsonForVectorization` for optimized JSON vectorization.
- Enhanced management of field names and mappings:
- Integrated `trackFieldNames` to associate fields with their services.
- Supported cross-service consistency through `standardFieldMappings`.
- Updated documentation:
- Added detailed guides for JSON search enhancements and HNSW limitations.
- Extended usage examples in `README.md` and `json-search-test.js`.
- Verified improvements with comprehensive tests:
- Created unit and integration tests demonstrating search behavior improvements.
- Addressed previous TypeScript errors related to search parameters.
**Purpose**: Improve search accuracy and usability when working with complex JSON documents by enabling field-specific searches and enhancing contextual relevance.
- Added a new `CacheManager` class in `cacheManager.ts` to support three-level caching strategy:
- **Level 1**: Hot cache in RAM for most accessed nodes.
- **Level 2**: Warm cache using OPFS, Filesystem, or S3, depending on the environment.
- **Level 3**: Cold storage for longer-term data storage.
- Integrated features for dynamic tuning:
- Auto-detection of environment (Browser, Node.js, Worker) and memory availability.
- Parameter tuning for cache size, eviction thresholds, and TTL based on usage patterns.
- Enhanced support for:
- LRU-based eviction in hot cache.
- Batch-based operations with configurable batch sizes.
- Comprehensive logging and debug outputs for cache operations.
- Ensured robust fallback handling to manage storage in constrained environments.
- Improved extensibility for storage adapters (warm and cold storage detection and initialization).
**Purpose**: Optimize data access and storage across multiple environments with seamless scalability and dynamic parameter adjustments.
- Introduced `getNounTypes`, `getVerbTypes`, `getNounTypeMap`, and `getVerbTypeMap` utilities for managing noun and verb types at runtime.
- Added comprehensive unit tests (`type-utils.test.ts`) to ensure correctness of type utility functions.
- Created new example files (`type-utils-example.js`, `type-utils-example.ts`) to demonstrate the use of type utilities in JavaScript and TypeScript environments.
- Updated `README.md` with detailed documentation and usage examples for the new type utilities.
- Enhanced `index.ts` to export the new utility functions, making them accessible throughout the library.
**Purpose**: Facilitate easy access, validation, and manipulation of noun and verb types in client applications, providing better runtime type management.
- Updated `storage-adapter-coverage.test` to handle different adapter behaviors:
- Memory adapter: size remains 0 after restoration.
- FileSystem adapter: size matches restored items.
- Enhanced `delete` method in `brainyData.ts`:
- Added handling for content text passed instead of ID.
- Improved logging for better traceability during deletions.
- Modified restoration logic to skip index rebuilding during test scenarios:
- Clears index explicitly in test environments when performing a backup restoration for storage tests.
- Refined logic in `specialized-scenarios.test`:
- Validated database size changes after adding and deleting items.
- Enhanced clarity and debugging
- Introduced `release-workflow.js` to streamline the release process:
- Automates version updates (`patch`, `minor`, `major`).
- Generates changelogs based on commit messages.
- Creates GitHub releases with autogenerated notes.
- Publishes packages to NPM.
- Enhanced documentation in `README.md` with detailed release instructions, both automated and manual.
- Updated related test cases and ensured compatibility.
**Purpose**: Simplify and standardize the release
- Deleted `scripts/update-changelog.js`, as it became obsolete with the adoption of `standard-version` for automated versioning and changelog management.
- Ensured repository alignment with the updated workflow outlined in prior
This change implements standard-version for versioning and changelog management:
- Adds standard-version as a dev dependency
- Updates package.json scripts to use standard-version
- Creates .versionrc.json configuration file
- Updates CHANGELOG.md with instructions for conventional commits
- Removes obsolete manual changelog update script
- Introduced `PaginationOptions`, `NounFilterOptions`, and `VerbFilterOptions` types for improved query flexibility in data retrieval operations.
- Added `getNouns` and `getVerbs` methods with pagination and filtering capabilities, replacing existing methods for broader use cases and scalability.
- Marked legacy methods (`getAllNouns`, `getAllVerbs`, `getVerbsBySource`, `getVerbsByTarget`, `getVerbsByType`) as deprecated, directing users to use new methods.
- Updated `coreTypes`, `memoryStorage`, and related modules to support new functionality, including cursor and offset-based pagination handling.
- Updated fallback logic for storage adapters, ensuring compatibility with non-paginated operations when required.
**Purpose**: Enhance scalability and query precision by implementing paginated and filtered retrieval of nouns and verbs, aligning query methods with modern requirements.
- Introduced new test cases to validate `getChangesSince` and change log handling in `S3CompatibleStorage`.
- Verified correct logging of entity changes and retrieval based on timestamps.
- Ensured cleanup after tests to maintain test environment integrity.
**Purpose**: Strengthen test coverage for `S3CompatibleStorage` by ensuring correctness in change log functionality and timestamp-based filtering.
- Updated error handling in `S3CompatibleStorage` to include checks for `NotFound` errors alongside `NoSuchKey` during lock operations.
- Ensured robustness in determining lock existence and managing exceptions related to missing keys.
**Purpose**: Improve resilience of the S3-compatible storage adapter by addressing additional error scenarios, ensuring accurate lock detection and stable operation.
Remove `@modelcontextprotocol/server-sequential-thinking` and its nested dependencies from `devDependencies` in `package-lock.json` as they are no longer required for the project. This reduces the overall package size and improves maintenance.
- Introduced `writeOnly` mode in `BrainyData` allowing optimized data ingestion by skipping index loading and disabling search operations.
- Enhanced `BrainyDataConfig` to include `writeOnly` support and validate compatibility with `readOnly` mode.
- Implemented error handling for search attempts during `writeOnly` mode.
- Updated the README with detailed usage examples for database modes, including `writeOnly` and `readOnly`.
- Added `examples/write-only-mode.js` to demonstrate practical applications of the `writeOnly` mode.
**Purpose**: Optimize memory usage and startup time for data ingestion scenarios by enabling write-only mode with comprehensive documentation and examples.
- Reformatted export statements across `index.ts` and related modules for consistent style, improving code readability and maintainability.
- Updated graph types in `graphTypes.ts` to include additional standardized noun and verb categories, enhancing the flexibility of the type system for graph modeling.
- Replaced `Place` with `Location` and merged similar types (e.g., `Group` into `Collection`) to eliminate redundancy in entity definitions.
- Expanded verb types in `VerbType` to cover more comprehensive use cases, including social, temporal, and ownership relationships.
**Purpose**: Streamline code structure with consistent export formatting, simplify type definitions, and enhance the type system for broader modeling capabilities.
- Deleted `CHANGES.md`, `CHANGES_SUMMARY.md`, `CONCURRENCY_ANALYSIS.md`, `CONCURRENCY_IMPLEMENTATION_SUMMARY.md`, and related developer documentation files.
- Removed redundant or legacy content no longer aligned with the current codebase and workflows.
- Updated repository to reflect streamlined documentation approach, reducing clutter and improving maintainability.
**Purpose**: Simplify and declutter repository by removing obsolete documentation files, ensuring it remains focused and relevant.
- Added `BrainyError` class to classify and handle errors with types like `TIMEOUT`, `NETWORK`, `STORAGE`, `NOT_FOUND`, and `RETRY_EXHAUSTED`. Includes static helper methods for error creation and retry determination.
- Introduced `operationUtils` with utility functions for timeout, retry logic, and exponential backoff. Implements features like `withTimeout`, `withRetry`, and a combined `withTimeoutAndRetry`.
- Updated `S3CompatibleStorage` to leverage new operation utilities for timeout and retry handling, including `StorageOperationExecutors` for clean operation execution.
- Enhanced `storageFactory` to pass `OperationConfig` for configurable timeout and retry behavior.
- Extended `BrainyData` to include timeout and retry policy configuration at initialization.
**Purpose**: Improve storage reliability by introducing configurable and reusable error-handling and operation utilities, reducing code duplication and enhancing maintainability.
- Modified `storageFactory` to ensure `FileSystemStorage` gracefully degrades to `MemoryStorage` in browser environments, with proper warnings added.
- Enhanced `opfsStorage` adapter to support recursive directory removal with the `recursive` option.
- Removed `test-fix.js` script, as it is no longer relevant with recent storage fixes and updates.
**Purpose**: Streamline and ensure cross-environment compatibility for `FileSystemStorage`, while removing outdated test artifacts for better maintainability.
- Introduced `CONCURRENCY_ANALYSIS.md` to outline identified concurrency issues, including statistics handling, index synchronization, and storage contention.
- Added `CONCURRENCY_IMPLEMENTATION_SUMMARY.md` to summarize concurrency improvements, such as distributed locking and change log mechanisms.
- Created `STORAGE_CONCURRENCY_ANALYSIS.md` to evaluate concurrency risks and applied solutions for different storage adapters (`S3CompatibleStorage`, `FileSystemStorage`, `OPFSStorage`, and `MemoryStorage`).
- Updated codebase with changes related to concurrency, including distributed locking, atomic updates, event-driven synchronization, and change log support.
- Refactored tests to verify behavior of new concurrency mechanisms, including robust error handling and cleanup functions.
**Purpose**: Provides comprehensive documentation and implementation details to ensure robust concurrency handling in multi-instance, high-throughput environments.
- Added patterns for temporary test files (`test*.js`, `test*.ts`, `temp-test*.js`, `temp-test*.ts`, etc.) to `.gitignore`.
- Included directories `/temp/` and `/temp-tests/` to prevent accidental commits of temporary or debug-related files.
**Purpose**: Ensure cleaner version control by excluding unnecessary temporary and debug files created during development.
- Updated test results output path in `vitest.config.ts` to `./tests/results/test-results.json` for better organization.
- Modified `.gitignore` to include `/tests/results/` and its `.json` files to avoid committing test artifacts.
**Purpose**: Improves test results file structure and ensures consistent exclusion of test artifact files from version control.
- Updated `test-results.json` to reflect the latest test outcomes.
- Ensures accuracy of recorded test results after recent changes.
**Purpose**: Keep test result records up-to-date for reliable tracking and reference.