brainy/docs/technical/ENVIRONMENT_TESTING.md
David Snelling 1539ba74de **chore(archive): remove outdated documentation and summaries**
- Deleted the following obsolete files:
  - `CHANGES.md`, `changes-summary.md`, `CHANGES_SUMMARY.md`: Contained redundant or outdated change logs and implementation summaries.
  - `COMPATIBILITY.md`: Detailed compatibility behavior no longer relevant after environment detection updates.
  - `fix-documentation.md`: Addressed a resolved issue regarding `process.memoryUsage` errors in testing.
  - `DIMENSION_MISMATCH_SUMMARY.md`: Provided a legacy summary of resolved embedding dimension mismatch issues.
  - `demo.md`: Documented an outdated demo process for testing Brainy features.
  - `CONCURRENCY_IMPLEMENTATION_SUMMARY.md`: Summarized already-documented concurrency features.
  - `IMPLEMENTATION_SUMMARY.md`: Detailed an obsolete implementation of optional model bundling.

- Purpose:
  - Streamline and declutter archive by removing redundant or outdated documentation.
  - Align repository with current feature set and documentation standards.
2025-08-01 16:21:35 -07:00

2.5 KiB

Testing Brainy Across Different Environments

This document provides instructions for testing Brainy's cache detection functionality across different environments.

Testing in Node.js Environment

To test Brainy in a Node.js environment:

  1. Build the project:

    npm run build
    
  2. Run the Node.js test script:

    node test-cache-detection.js
    
  3. Expected output:

    Brainy: Successfully patched TensorFlow.js PlatformNode at module load time
    Applied TensorFlow.js patch via ES modules in setup.ts
    Brainy running in Node.js environment
    Creating BrainyData instance...
    BrainyData instance created successfully!
    Test completed successfully!
    

Testing in Browser Environment

To test Brainy in a browser environment:

  1. Build the project:

    npm run build
    
  2. Start a local web server:

    npx http-server -p 8080
    
  3. Open the browser test page:

    http://localhost:8080/test-browser-cache-detection.html
    
  4. Click the "Run Test" button on the page.

  5. Expected results:

    • The page should display success messages
    • No errors should appear in the browser console
    • You should see "BrainyData instance created successfully!" and "Test completed successfully!"

Testing in Web Worker Environment

To test Brainy in a Web Worker environment:

  1. Build the project:

    npm run build
    
  2. Start a local web server:

    npx http-server -p 8080
    
  3. Open the worker test page:

    http://localhost:8080/test-worker-cache-detection.html
    
  4. Click the "Run Test" button on the page.

  5. Expected results:

    • The page should display success messages from the worker
    • No errors should appear in the browser console
    • You should see "BrainyData instance created successfully!" and "Test completed successfully!"

Compatibility Notes

Brainy's cache detection has been designed to work across all environments:

  1. Node.js Environment:

    • Uses fixed default memory values (8GB total, 4GB free) for cache size calculation
    • This approach ensures compatibility with ES modules
  2. Browser Environment:

    • Uses navigator.deviceMemory API when available
    • Falls back to conservative defaults when the API is not available
  3. Worker Environment:

    • Uses a more conservative approach to cache sizing
    • Automatically detects the worker environment and adjusts accordingly

The cache manager automatically detects the environment and adjusts its behavior to ensure optimal performance in each context.