Commit graph

8 commits

Author SHA1 Message Date
38c28ae038 **feat(models): enhance loader reliability and compatibility**
- **Compatibility Enhancements**:
  - Added support to detect and inject missing `"format"` field in `model.json` files for TensorFlow.js compatibility.
  - Modified model loading logic to handle both `tfjs-graph-model` and `tfjs-layers-model` formats.

- **New Features**:
  - Introduced additional fallback paths for locating models to increase reliability in varying environments.
  - Added support for mock implementations of the Universal Sentence Encoder in test environments.

- **Bug Fixes**:
  - Fixed module loading resolution in `FileSystemStorage` with improved initialization and error handling for Node.js environments.
  - Resolved issues with test assertions to improve validation logic in core tests.

**Purpose**: Improve model loading reliability, expand compatibility with TensorFlow.js models, and enhance test environment support.
2025-08-01 18:31:37 -07:00
e2373b798e **feat(scripts): add automated release workflow script**
- 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
2025-07-31 13:40:28 -07:00
86fb1220b6 **feat(core, migration, docs): introduce dimension mismatch resolution tools and migration guide**
- **Core**:
  - Added `check-database.js` to verify database status and validate search functionality.
  - Created `fix-dimension-mismatch.js` to handle re-embedding of existing data to resolve dimension mismatch from 3 to 512.
  - Improved test cases by updating vector operations to support 512 dimensions, replacing previously hardcoded dimensions.

- **Migration**:
  - Developed `DIMENSION_MISMATCH_SUMMARY.md`, detailing the root cause, solution, and preventive strategies for dimension mismatch issues.
  - Added `production-migration-guide.md` for structured production migration with detailed steps on re-embedding strategies, batching, and error handling.

- **Tests**:
  - Enhanced test coverage with 512-dimensional vector validation.
  - Introduced helper functions for consistent vector testing behavior and streamlined search test cases.

- **Documentation**:
  - Updated project documentation to highlight the resolution process for dimension mismatches, emphasizing preventive mechanisms such as auto-migration and version tracking.

**Purpose**: Address critical dimension mismatch issues caused by embedding changes, restore functionality, and provide a roadmap for robust prevention strategies and migration processes.
2025-07-25 13:38:56 -07:00
2322b53a0c feat(core, tests): add standalone getStatistics function and improve storage configuration
- **Core**: Introduced a new `getStatistics` utility function in `statistics.ts` for fetching database statistics at the root level of the library. Enhanced `BrainyData` methods to ensure metadata includes `id` field and refined statistics calculations, excluding verbs from the noun count.
- **Tests**: Added comprehensive test coverage in `statistics.test.ts` for the new utility function, validating proper error handling, statistics accuracy, and consistent results between instance methods and standalone function.
- **Storage Config**: Enabled dynamic support for AWS S3, Cloudflare R2, and Google Cloud Storage in web service configuration, utilizing environment variables for adapter setup. Addressed a race condition in `FileSystemStorage` initialization by deferring path module imports.

**Purpose**: Enhance database analytics by introducing a reusable `getStatistics` function, improve flexibility in storage configuration, and ensure robust testing for reliability and accuracy.
2025-07-23 16:26:59 -07:00
e12ecf8d72 **feat(core): enhance logging, storage options, and testing coverage**
- **Core Improvements**:
  - Refactored logging functions into a unified `logger` method for consistent output across the library.
  - Enabled the `forceMemoryStorage` option in `BrainyData` initialization for improved storage flexibility in tests and specific use cases.

- **TensorFlow.js and Environment Updates**:
  - Clarified the dependency structure in `README.md` to emphasize bundled dependencies and remove legacy peer dependency instructions.
  - Simplified and reformatted environment detection logic for better maintainability and readability.

- **Testing Enhancements**:
  - Added `tests/package-size-limit.test.ts` to monitor and validate npm package size against defined thresholds.
  - Updated `tests/environment.node.test.ts` and core tests to leverage `forceMemoryStorage` for better test setup standardization.
  - Improved test isolation with expanded `globalThis` utility definitions and cleanup logic.

- **Documentation**:
  - Added detailed best practices for debugging and organizing tests in `DEVELOPERS.md`.
  - Removed outdated installation hints from `package.json` and streamlined scripts by including `test:size` for package size validation.

**Purpose**: These changes unify core logging mechanisms, expand configurability of storage options, and improve testing reliability and coverage. Documentation and clarity are enhanced to align with updated functionality and best practices.
2025-07-17 10:00:28 -07:00
ad4af27385 **test(tests): improve isolation and enhance test configuration**
- **Test Enhancements**:
  - Refactored test setup in `core.test.ts` for better isolation and clarity:
    - Added explicit `.clear()` calls to ensure clean state between tests.
    - Replaced old vector addition logic with simplified data insertion methods.
    - Updated search operations to reflect current functionality and debug-friendly output.
  - Introduced the `@vitest-environment jsdom` annotation in `environment.browser.test.ts` for accurate browser environment emulation.

- **Configuration Updates**:
  - Enhanced `vitest.config.ts`:
    - Introduced custom `reporters` for cleaner and focused test result presentation.
    - Expanded console log filtering with additional patterns for reducing noise from TensorFlow.js and setup processes.

- **Purpose**:
  - These updates improve test clarity, consistency, and robustness while streamlining the configuration to minimize distractions in test outputs.
2025-07-16 13:08:41 -07:00
5958502cf3 **test(tests): enhance test clarity, isolation, and robustness**
- **Test Improvements**:
  - Introduced data-clearing steps (`.clear()`) across critical test cases for ensuring better test isolation and preventing state leakage.
  - Extended support for overriding global utilities (`testUtils`) and added fallback behaviors for test vector creation.

- **Configuration Updates**:
  - Added support for `distanceFunction` as an alternative to `metric` in vector operations for consistency.
  - Adjusted and unified asynchronous `timeout` handling across test suites for predictability.

- **Purpose**:
  - These updates improve reliability, maintainability, and clarity in test cases while ensuring compatibility across diverse test environments.
2025-07-16 11:39:53 -07:00
8ffc7115a5 **test(tests): add comprehensive test suite for Brainy functionality**
- **New Tests Added**:
  - Introduced multiple test suites covering core functionalities (`core.test.ts`), vector operations (`vector-operations.test.ts`), Node.js environment (`environment.node.test.ts`), browser setup (`environment.browser.test.ts`), and TensorFlow.js-specific behaviors (`tensorflow-patch.test.ts`).
  - Added performance, scalability, and error-handling tests to ensure robust validation of vector addition, search, and text embedding functionalities.
  - Introduced setup utilities (`tests/setup.ts`) and standardized test utilities for creating predictable test cases.

- **Configuration**:
  - Created `vitest.config.ts` for custom test configurations, including support for modern test environments (`jsdom`, `happy-dom`) and extended timeouts for asynchronous operations.

- **Validation**:
  - Includes compatibility checks for TensorFlow.js imports and ensures proper handling of `TextEncoder`/`TextDecoder` in Node.js environments.

This commit significantly enhances the testing coverage and structure, ensuring Brainy functionality is robust, cross-platform, and aligned with evolving reliability standards.
2025-07-15 11:56:16 -07:00